Skip to content

Commit 9e7aa3c

Browse files
authored
Move Pulsar tests to JUnit Jupiter (#10759)
1 parent d8c9f9f commit 9e7aa3c

File tree

3 files changed

+30
-26
lines changed

3 files changed

+30
-26
lines changed

modules/pulsar/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ description = "Testcontainers :: Pulsar"
33
dependencies {
44
api project(':testcontainers')
55

6+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.0'
7+
8+
testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4'
9+
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.13.4'
610
testImplementation platform("org.apache.pulsar:pulsar-bom:4.0.5")
711
testImplementation 'org.apache.pulsar:pulsar-client'
812
testImplementation 'org.apache.pulsar:pulsar-client-admin'
@@ -14,3 +18,7 @@ tasks.japicmp {
1418
"org.testcontainers.containers.PulsarContainer"
1519
]
1620
}
21+
22+
test {
23+
useJUnitPlatform()
24+
}

modules/pulsar/src/test/java/org/testcontainers/containers/CompatibleApachePulsarImageTest.java

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,31 @@
11
package org.testcontainers.containers;
22

33
import org.apache.pulsar.client.admin.PulsarAdmin;
4-
import org.junit.Test;
5-
import org.junit.runner.RunWith;
6-
import org.junit.runners.Parameterized;
4+
import org.junit.jupiter.params.ParameterizedTest;
5+
import org.junit.jupiter.params.provider.MethodSource;
76
import org.testcontainers.utility.DockerImageName;
87

9-
@RunWith(Parameterized.class)
10-
public class CompatibleApachePulsarImageTest extends AbstractPulsar {
8+
class CompatibleApachePulsarImageTest extends AbstractPulsar {
119

12-
@Parameterized.Parameters(name = "{0}")
1310
public static String[] params() {
1411
return new String[] { "apachepulsar/pulsar:3.0.0", "apachepulsar/pulsar-all:3.0.0" };
1512
}
1613

17-
@Parameterized.Parameter
18-
public String imageName;
19-
20-
@Test
21-
public void testUsage() throws Exception {
22-
try (PulsarContainer pulsar = new PulsarContainer(DockerImageName.parse(this.imageName));) {
14+
@ParameterizedTest
15+
@MethodSource("params")
16+
void testUsage(String imageName) throws Exception {
17+
try (PulsarContainer pulsar = new PulsarContainer(DockerImageName.parse(imageName));) {
2318
pulsar.start();
2419
final String pulsarBrokerUrl = pulsar.getPulsarBrokerUrl();
2520

2621
testPulsarFunctionality(pulsarBrokerUrl);
2722
}
2823
}
2924

30-
@Test
31-
public void testTransactions() throws Exception {
32-
try (PulsarContainer pulsar = new PulsarContainer(DockerImageName.parse(this.imageName)).withTransactions();) {
25+
@ParameterizedTest
26+
@MethodSource("params")
27+
void testTransactions(String imageName) throws Exception {
28+
try (PulsarContainer pulsar = new PulsarContainer(DockerImageName.parse(imageName)).withTransactions();) {
3329
pulsar.start();
3430

3531
try (PulsarAdmin pulsarAdmin = PulsarAdmin.builder().serviceHttpUrl(pulsar.getHttpServiceUrl()).build()) {

modules/pulsar/src/test/java/org/testcontainers/containers/PulsarContainerTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22

33
import org.apache.pulsar.client.admin.PulsarAdmin;
44
import org.apache.pulsar.client.admin.PulsarAdminException;
5-
import org.junit.Test;
5+
import org.junit.jupiter.api.Test;
66
import org.testcontainers.utility.DockerImageName;
77

88
import java.time.Duration;
99

1010
import static org.assertj.core.api.Assertions.assertThat;
1111
import static org.assertj.core.api.Assertions.assertThatThrownBy;
1212

13-
public class PulsarContainerTest extends AbstractPulsar {
13+
class PulsarContainerTest extends AbstractPulsar {
1414

1515
private static final DockerImageName PULSAR_IMAGE = DockerImageName.parse("apachepulsar/pulsar:3.0.0");
1616

1717
@Test
18-
public void testUsage() throws Exception {
18+
void testUsage() throws Exception {
1919
try (
2020
// do not use PULSAR_IMAGE to make the doc looks easier
2121
// constructorWithVersion {
@@ -32,7 +32,7 @@ public void testUsage() throws Exception {
3232
}
3333

3434
@Test
35-
public void envVarsUsage() throws Exception {
35+
void envVarsUsage() throws Exception {
3636
try (
3737
// constructorWithEnv {
3838
PulsarContainer pulsar = new PulsarContainer(PULSAR_IMAGE)
@@ -45,7 +45,7 @@ public void envVarsUsage() throws Exception {
4545
}
4646

4747
@Test
48-
public void customClusterName() throws Exception {
48+
void customClusterName() throws Exception {
4949
try (
5050
PulsarContainer pulsar = new PulsarContainer(PULSAR_IMAGE)
5151
.withEnv("PULSAR_PREFIX_clusterName", "tc-cluster");
@@ -56,7 +56,7 @@ public void customClusterName() throws Exception {
5656
}
5757

5858
@Test
59-
public void shouldNotEnableFunctionsWorkerByDefault() throws Exception {
59+
void shouldNotEnableFunctionsWorkerByDefault() throws Exception {
6060
try (PulsarContainer pulsar = new PulsarContainer(PULSAR_IMAGE)) {
6161
pulsar.start();
6262

@@ -68,7 +68,7 @@ public void shouldNotEnableFunctionsWorkerByDefault() throws Exception {
6868
}
6969

7070
@Test
71-
public void shouldWaitForFunctionsWorkerStarted() throws Exception {
71+
void shouldWaitForFunctionsWorkerStarted() throws Exception {
7272
try (
7373
// constructorWithFunctionsWorker {
7474
PulsarContainer pulsar = new PulsarContainer(DockerImageName.parse("apachepulsar/pulsar:3.0.0"))
@@ -84,7 +84,7 @@ public void shouldWaitForFunctionsWorkerStarted() throws Exception {
8484
}
8585

8686
@Test
87-
public void testTransactions() throws Exception {
87+
void testTransactions() throws Exception {
8888
try (
8989
// constructorWithTransactions {
9090
PulsarContainer pulsar = new PulsarContainer(PULSAR_IMAGE).withTransactions();
@@ -100,7 +100,7 @@ public void testTransactions() throws Exception {
100100
}
101101

102102
@Test
103-
public void testTransactionsAndFunctionsWorker() throws Exception {
103+
void testTransactionsAndFunctionsWorker() throws Exception {
104104
try (PulsarContainer pulsar = new PulsarContainer(PULSAR_IMAGE).withTransactions().withFunctionsWorker()) {
105105
pulsar.start();
106106

@@ -113,7 +113,7 @@ public void testTransactionsAndFunctionsWorker() throws Exception {
113113
}
114114

115115
@Test
116-
public void testClusterFullyInitialized() throws Exception {
116+
void testClusterFullyInitialized() throws Exception {
117117
try (PulsarContainer pulsar = new PulsarContainer(PULSAR_IMAGE)) {
118118
pulsar.start();
119119

@@ -124,7 +124,7 @@ public void testClusterFullyInitialized() throws Exception {
124124
}
125125

126126
@Test
127-
public void testStartupTimeoutIsHonored() {
127+
void testStartupTimeoutIsHonored() {
128128
try (PulsarContainer pulsar = new PulsarContainer(PULSAR_IMAGE).withStartupTimeout(Duration.ZERO)) {
129129
assertThatThrownBy(pulsar::start)
130130
.hasRootCauseMessage("Precondition failed: timeout must be greater than zero");

0 commit comments

Comments
 (0)