Skip to content

Commit

Permalink
Remove PowerMock (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
offa committed Sep 23, 2021
1 parent a1a4c9b commit 5faac48
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
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

0 comments on commit 5faac48

Please sign in to comment.