|
2 | 2 |
|
3 | 3 | import static org.hamcrest.MatcherAssert.assertThat; |
4 | 4 | import static org.hamcrest.Matchers.hasItem; |
5 | | -import static org.junit.Assert.assertEquals; |
6 | | -import static org.junit.Assert.assertFalse; |
7 | | -import static org.junit.Assert.assertNotNull; |
8 | | -import static org.junit.Assert.assertTrue; |
| 5 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 6 | +import static org.junit.jupiter.api.Assertions.assertFalse; |
| 7 | +import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 8 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
9 | 9 |
|
10 | 10 | import hudson.model.Node; |
11 | 11 | import hudson.model.Queue; |
12 | 12 | import hudson.util.RunList; |
| 13 | +import java.io.File; |
13 | 14 | import java.util.ArrayList; |
14 | 15 | import java.util.Arrays; |
15 | 16 | import java.util.Collections; |
16 | 17 | import java.util.List; |
17 | 18 | import java.util.Set; |
18 | | -import java.util.stream.Collectors; |
19 | 19 | import org.jenkinsci.plugins.workflow.job.WorkflowJob; |
20 | 20 | import org.jenkinsci.plugins.workflow.job.WorkflowRun; |
21 | 21 | import org.jenkinsci.plugins.workflow.test.steps.SemaphoreStep; |
22 | | -import org.junit.ClassRule; |
23 | | -import org.junit.Rule; |
24 | | -import org.junit.Test; |
25 | | -import org.junit.rules.TemporaryFolder; |
26 | | -import org.jvnet.hudson.test.BuildWatcher; |
27 | | -import org.jvnet.hudson.test.JenkinsSessionRule; |
| 22 | +import org.junit.jupiter.api.Test; |
| 23 | +import org.junit.jupiter.api.extension.RegisterExtension; |
| 24 | +import org.junit.jupiter.api.io.TempDir; |
| 25 | +import org.jvnet.hudson.test.junit.jupiter.BuildWatcherExtension; |
| 26 | +import org.jvnet.hudson.test.junit.jupiter.JenkinsSessionExtension; |
28 | 27 |
|
29 | | -public class ThrottleJobPropertyPipelineRestartTest { |
| 28 | +class ThrottleJobPropertyPipelineRestartTest { |
30 | 29 |
|
31 | | - @Rule |
32 | | - public JenkinsSessionRule sessions = new JenkinsSessionRule(); |
| 30 | + @RegisterExtension |
| 31 | + private final JenkinsSessionExtension sessions = new JenkinsSessionExtension(); |
33 | 32 |
|
34 | | - @ClassRule |
35 | | - public static BuildWatcher buildWatcher = new BuildWatcher(); |
| 33 | + @RegisterExtension |
| 34 | + private static final BuildWatcherExtension buildWatcher = new BuildWatcherExtension(); |
36 | 35 |
|
37 | | - @Rule |
38 | | - public TemporaryFolder firstAgentTmp = new TemporaryFolder(); |
| 36 | + @TempDir |
| 37 | + private File firstAgentTmp; |
39 | 38 |
|
40 | | - @Rule |
41 | | - public TemporaryFolder secondAgentTmp = new TemporaryFolder(); |
| 39 | + @TempDir |
| 40 | + private File secondAgentTmp; |
42 | 41 |
|
43 | 42 | @Test |
44 | | - public void twoTotalWithRestart() throws Throwable { |
| 43 | + void twoTotalWithRestart() throws Throwable { |
45 | 44 | String[] jobNames = new String[2]; |
46 | 45 | String[] agentNames = new String[2]; |
47 | 46 | sessions.then(j -> { |
48 | 47 | List<Node> agents = new ArrayList<>(); |
49 | | - Node firstAgent = TestUtil.setupAgent(j, firstAgentTmp.getRoot(), agents, null, 4, "on-agent"); |
50 | | - Node secondAgent = TestUtil.setupAgent(j, secondAgentTmp.getRoot(), agents, null, 4, "on-agent"); |
| 48 | + Node firstAgent = TestUtil.setupAgent(j, firstAgentTmp, agents, null, 4, "on-agent"); |
| 49 | + Node secondAgent = TestUtil.setupAgent(j, secondAgentTmp, agents, null, 4, "on-agent"); |
51 | 50 | agentNames[0] = firstAgent.getNodeName(); |
52 | 51 | agentNames[1] = secondAgent.getNodeName(); |
53 | 52 | TestUtil.setupCategories(TestUtil.TWO_TOTAL); |
@@ -106,7 +105,7 @@ public void twoTotalWithRestart() throws Throwable { |
106 | 105 | j.jenkins.getQueue().maintain(); |
107 | 106 | assertFalse(j.jenkins.getQueue().isEmpty()); |
108 | 107 | List<Queue.Item> queuedItemList = |
109 | | - Arrays.stream(j.jenkins.getQueue().getItems()).collect(Collectors.toList()); |
| 108 | + Arrays.stream(j.jenkins.getQueue().getItems()).toList(); |
110 | 109 | assertEquals(1, queuedItemList.size()); |
111 | 110 | Queue.Item queuedItem = queuedItemList.get(0); |
112 | 111 | Set<String> blockageReasons = TestUtil.getBlockageReasons(queuedItem.getCauseOfBlockage()); |
@@ -141,7 +140,7 @@ public void twoTotalWithRestart() throws Throwable { |
141 | 140 |
|
142 | 141 | assertFalse(j.jenkins.getQueue().isEmpty()); |
143 | 142 | List<Queue.Item> queuedItemList = |
144 | | - Arrays.stream(j.jenkins.getQueue().getItems()).collect(Collectors.toList()); |
| 143 | + Arrays.stream(j.jenkins.getQueue().getItems()).toList(); |
145 | 144 | assertEquals(1, queuedItemList.size()); |
146 | 145 | Queue.Item queuedItem = queuedItemList.get(0); |
147 | 146 | Set<String> blockageReasons = TestUtil.getBlockageReasons(queuedItem.getCauseOfBlockage()); |
|
0 commit comments