Skip to content

Commit 9d6e0e0

Browse files
Migrate to JUnit Jupiter
Signed-off-by: Adrian Cole <[email protected]>
1 parent 2ea85da commit 9d6e0e0

File tree

131 files changed

+1716
-1708
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+1716
-1708
lines changed

e2e/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
</dependency>
2727

2828
<dependency>
29-
<groupId>junit</groupId>
30-
<artifactId>junit</artifactId>
29+
<groupId>org.junit.jupiter</groupId>
30+
<artifactId>junit-jupiter</artifactId>
3131
<scope>test</scope>
3232
</dependency>
3333
<dependency>

e2e/src/test/java/io/kubernetes/client/e2e/basic/CoreV1ApiTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
import io.kubernetes.client.openapi.models.V1ObjectMeta;
2222
import io.kubernetes.client.openapi.models.V1Status;
2323
import io.kubernetes.client.util.ClientBuilder;
24-
import org.junit.Test;
24+
import org.junit.jupiter.api.Test;
2525

26-
public class CoreV1ApiTest {
26+
class CoreV1ApiTest {
2727

2828
@Test
29-
public void testCreateAndDeleteNamespace() throws Exception {
29+
void createAndDeleteNamespace() throws Exception {
3030
ApiClient client = ClientBuilder.defaultClient();
3131
CoreV1Api coreV1Api = new CoreV1Api(client);
3232
V1Namespace namespaceFoo = new V1Namespace()

e2e/src/test/java/io/kubernetes/client/e2e/csr/CSRTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
import java.security.KeyPair;
2626
import java.security.KeyPairGenerator;
2727
import java.security.SecureRandom;
28-
import org.junit.Test;
28+
import org.junit.jupiter.api.Test;
2929

30-
public class CSRTest {
30+
class CSRTest {
3131

3232
@Test
33-
public void testBuildClientWithCSR() throws Exception {
33+
void buildClientWithCSR() throws Exception {
3434
// initialize test environment
3535
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
3636
keyGen.initialize(2048, new SecureRandom());

e2e/src/test/java/io/kubernetes/client/e2e/dynamic/DynamicApiTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
import io.kubernetes.client.util.generic.dynamic.DynamicKubernetesApi;
2323
import io.kubernetes.client.util.generic.dynamic.DynamicKubernetesObject;
2424
import io.kubernetes.client.util.generic.dynamic.Dynamics;
25-
import org.junit.Test;
25+
import org.junit.jupiter.api.Test;
2626

27-
public class DynamicApiTest {
27+
class DynamicApiTest {
2828

2929
@Test
30-
public void testDynamicApiCreateAndDeleteNamespace() throws Exception {
30+
void dynamicApiCreateAndDeleteNamespace() throws Exception {
3131
ApiClient client = ClientBuilder.defaultClient();
3232
DynamicKubernetesApi dynamicApi =
3333
new DynamicKubernetesApi("", "v1", "namespaces", client);

e2e/src/test/java/io/kubernetes/client/e2e/extended/leaderelection/LeaderElectorTest.java

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@
3434
import java.util.concurrent.BrokenBarrierException;
3535
import java.util.concurrent.CountDownLatch;
3636
import java.util.concurrent.CyclicBarrier;
37+
import java.util.concurrent.TimeUnit;
3738
import java.util.concurrent.atomic.AtomicInteger;
3839
import java.util.concurrent.atomic.AtomicReference;
39-
import org.junit.Before;
40-
import org.junit.Test;
41-
import org.junit.runner.RunWith;
42-
import org.junit.runners.Parameterized;
40+
import org.junit.jupiter.api.BeforeEach;
41+
import org.junit.jupiter.api.Timeout;
42+
import org.junit.jupiter.params.ParameterizedTest;
43+
import org.junit.jupiter.params.provider.MethodSource;
4344
import org.slf4j.Logger;
4445
import org.slf4j.LoggerFactory;
4546

46-
@RunWith(Parameterized.class)
47-
public class LeaderElectorTest {
47+
class LeaderElectorTest {
4848

4949
private static final Logger LOGGER = LoggerFactory.getLogger(LeaderElectorTest.class);
5050

@@ -57,7 +57,6 @@ private enum LockType {
5757
Lease
5858
}
5959

60-
@Parameterized.Parameters(name = "{0}")
6160
public static Collection<Object[]> constructorFeeder() {
6261
final List<Object[]> args = new ArrayList<>();
6362

@@ -68,10 +67,10 @@ public static Collection<Object[]> constructorFeeder() {
6867
return args;
6968
}
7069

71-
private final ApiClient apiClient;
72-
private final LockType lockType;
70+
private ApiClient apiClient;
71+
private LockType lockType;
7372

74-
public LeaderElectorTest(LockType lockType) {
73+
public void initLeaderElectorTest(LockType lockType) {
7574
try {
7675
apiClient = ClientBuilder.defaultClient();
7776
} catch (IOException ex) {
@@ -80,8 +79,8 @@ public LeaderElectorTest(LockType lockType) {
8079
this.lockType = lockType;
8180
}
8281

83-
@Before
84-
public void setup() throws Exception {
82+
@BeforeEach
83+
void setup() throws Exception {
8584
// delete the lock resource if it exists, or else first leader candidate might need to wait for
8685
// a whole leaseDuration configured
8786
switch (lockType) {
@@ -99,8 +98,11 @@ public void setup() throws Exception {
9998
}
10099
}
101100

102-
@Test(timeout = 30000L)
103-
public void testSingleCandidateLeaderElection() throws Exception {
101+
@MethodSource("constructorFeeder")
102+
@ParameterizedTest(name = "{0}")
103+
@Timeout(value = 30000L, unit = TimeUnit.MILLISECONDS)
104+
void singleCandidateLeaderElection(LockType lockType) throws Exception {
105+
initLeaderElectorTest(lockType);
104106
CountDownLatch startLeadershipLatch = new CountDownLatch(1);
105107
CountDownLatch stopLeadershipLatch = new CountDownLatch(1);
106108

@@ -119,8 +121,11 @@ public void testSingleCandidateLeaderElection() throws Exception {
119121
stopLeadershipLatch.await();
120122
}
121123

122-
@Test(timeout = 30000L)
123-
public void testMultiCandidateLeaderElection() throws Exception {
124+
@MethodSource("constructorFeeder")
125+
@ParameterizedTest(name = "{0}")
126+
@Timeout(value = 30000L, unit = TimeUnit.MILLISECONDS)
127+
void multiCandidateLeaderElection(LockType lockType) throws Exception {
128+
initLeaderElectorTest(lockType);
124129
CyclicBarrier startBarrier = new CyclicBarrier(2);
125130

126131
CountDownLatch startBeingLeader = new CountDownLatch(1);
@@ -186,8 +191,11 @@ public void testMultiCandidateLeaderElection() throws Exception {
186191
assertThat(stopBeingLeaderCount).hasValue(1);
187192
}
188193

189-
@Test(timeout = 45000L)
190-
public void testLeaderGracefulShutdown() throws Exception {
194+
@MethodSource("constructorFeeder")
195+
@ParameterizedTest(name = "{0}")
196+
@Timeout(value = 45000L, unit = TimeUnit.MILLISECONDS)
197+
void leaderGracefulShutdown(LockType lockType) throws Exception {
198+
initLeaderElectorTest(lockType);
191199
CountDownLatch startBeingLeader1 = new CountDownLatch(1);
192200
CountDownLatch stopBeingLeader1 = new CountDownLatch(1);
193201

e2e/src/test/java/io/kubernetes/client/e2e/informer/NamespaceInformerTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
import io.kubernetes.client.openapi.models.V1NamespaceList;
2424
import io.kubernetes.client.util.ClientBuilder;
2525
import io.kubernetes.client.util.generic.GenericKubernetesApi;
26-
import org.junit.Test;
26+
import org.junit.jupiter.api.Test;
2727

28-
public class NamespaceInformerTest {
28+
class NamespaceInformerTest {
2929
@Test
30-
public void testListWatchingNamespaces() throws Exception {
30+
void listWatchingNamespaces() throws Exception {
3131
ApiClient client = ClientBuilder.defaultClient();
3232
SharedInformerFactory informerFactory = new SharedInformerFactory(client);
3333

e2e/src/test/java/io/kubernetes/client/e2e/kubectl/KubectlDrainTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
import io.kubernetes.client.openapi.models.V1PodSpec;
2626
import io.kubernetes.client.util.ClientBuilder;
2727
import java.util.List;
28-
import org.junit.Test;
28+
import org.junit.jupiter.api.Test;
2929

30-
public class KubectlDrainTest {
30+
class KubectlDrainTest {
3131
@Test
32-
public void testPodInvisibleAfterDrain() throws Exception {
32+
void podInvisibleAfterDrain() throws Exception {
3333
Configuration.setDefaultApiClient(ClientBuilder.defaultClient());
3434

3535
V1Node testNode = new V1Node().metadata(new V1ObjectMeta().name("foo"));

e2e/src/test/java/io/kubernetes/client/e2e/kubectl/KubectlNamespaceTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
import io.kubernetes.client.openapi.models.V1Namespace;
1818
import io.kubernetes.client.openapi.models.V1ObjectMeta;
1919
import io.kubernetes.client.util.ClientBuilder;
20-
import org.junit.Test;
20+
import org.junit.jupiter.api.Test;
2121

2222
import static org.assertj.core.api.Assertions.assertThat;
2323

24-
public class KubectlNamespaceTest {
24+
class KubectlNamespaceTest {
2525

2626
@Test
27-
public void testCreateApplyDelete() throws Exception {
27+
void createApplyDelete() throws Exception {
2828
ApiClient client = ClientBuilder.standard().build();
2929

3030
// Create a namespace

e2e/src/test/java/io/kubernetes/client/e2e/kubectl/KubectlRolloutTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,27 @@
2828
import java.io.IOException;
2929
import java.io.InputStreamReader;
3030
import java.io.Reader;
31-
import org.junit.Before;
32-
import org.junit.Test;
31+
import org.junit.jupiter.api.BeforeEach;
32+
import org.junit.jupiter.api.Test;
3333

34-
public class KubectlRolloutTest {
35-
@Before
36-
public void setup() throws Exception {
34+
class KubectlRolloutTest {
35+
@BeforeEach
36+
void setup() throws Exception {
3737
Configuration.setDefaultApiClient(ClientBuilder.defaultClient());
3838
}
3939

4040
@Test
41-
public void testRolloutDaemonSet() throws Exception {
41+
void rolloutDaemonSet() throws Exception {
4242
testRollout(V1DaemonSet.class, "/test-daemonset.yaml", "/test-daemonset-updated.yaml");
4343
}
4444

4545
@Test
46-
public void testRolloutDeployment() throws Exception {
46+
void rolloutDeployment() throws Exception {
4747
testRollout(V1Deployment.class, "/test-deployment.yaml", "/test-deployment-updated.yaml");
4848
}
4949

5050
@Test
51-
public void testRolloutStatefulSet() throws Exception {
51+
void rolloutStatefulSet() throws Exception {
5252
testRollout(V1StatefulSet.class, "/test-statefulset.yaml", "/test-statefulset-updated.yaml");
5353
}
5454

e2e/src/test/java/io/kubernetes/client/e2e/util/ModelMapperTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
import io.kubernetes.client.openapi.models.V1Pod;
2323
import io.kubernetes.client.util.ClientBuilder;
2424
import io.kubernetes.client.util.ModelMapper;
25-
import org.junit.Test;
25+
import org.junit.jupiter.api.Test;
2626

27-
public class ModelMapperTest {
27+
class ModelMapperTest {
2828

2929
@Test
30-
public void apiDiscoveryShouldWork() throws Exception {
30+
void apiDiscoveryShouldWork() throws Exception {
3131
Discovery discovery = new Discovery(ClientBuilder.defaultClient());
3232
ModelMapper.refresh(discovery);
3333

0 commit comments

Comments
 (0)