Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove powermock #37

Merged
merged 2 commits into from
Sep 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.25</version>
<version>4.26</version>
<relativePath />
</parent>

Expand Down Expand Up @@ -60,11 +60,6 @@
<artifactId>hamcrest-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<repositories>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.MockAuthorizationStrategy;
import org.powermock.reflect.Whitebox;

import java.io.IOException;
import java.lang.reflect.Field;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -188,7 +188,7 @@ public void showProblems() throws Exception {
HtmlPage manage = wc.goTo("manage");
assertThat(manage.asText(), not(containsString("There are resources Jenkins was not able to dispose automatically")));

Whitebox.setInternalState(disposer.getBacklog().iterator().next(), "registered", new Date(0)); // Make it decades old
setInternalState(disposer.getBacklog().iterator().next(), "registered", new Date(0)); // Make it decades old

assertTrue(disposer.isActivated());
manage = wc.goTo("manage");
Expand Down Expand Up @@ -367,6 +367,12 @@ public void preventLivelockWithManyStalledInstances() throws Throwable {
assertThat(disposer.getBacklog(), iterableWithSize(MPS));
}

private void setInternalState(Object obj, String fieldName, Object newValue) throws NoSuchFieldException, IllegalAccessException {
Field field = obj.getClass().getDeclaredField(fieldName);
field.setAccessible(true);
field.set(obj, newValue);
}

private static final class OccupyingDisposable implements Disposable {
private static final long serialVersionUID = 4648005477636912909L;

Expand Down