diff --git a/modules/pulsar/build.gradle b/modules/pulsar/build.gradle index 957b210ec86..c9309daa24a 100644 --- a/modules/pulsar/build.gradle +++ b/modules/pulsar/build.gradle @@ -3,6 +3,10 @@ description = "Testcontainers :: Pulsar" dependencies { api project(':testcontainers') + testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.0' + + testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4' + testImplementation 'org.junit.jupiter:junit-jupiter-params:5.13.4' testImplementation platform("org.apache.pulsar:pulsar-bom:4.0.5") testImplementation 'org.apache.pulsar:pulsar-client' testImplementation 'org.apache.pulsar:pulsar-client-admin' @@ -14,3 +18,7 @@ tasks.japicmp { "org.testcontainers.containers.PulsarContainer" ] } + +test { + useJUnitPlatform() +} diff --git a/modules/pulsar/src/test/java/org/testcontainers/containers/CompatibleApachePulsarImageTest.java b/modules/pulsar/src/test/java/org/testcontainers/containers/CompatibleApachePulsarImageTest.java index b7a9cd3ff4c..702a7223151 100644 --- a/modules/pulsar/src/test/java/org/testcontainers/containers/CompatibleApachePulsarImageTest.java +++ b/modules/pulsar/src/test/java/org/testcontainers/containers/CompatibleApachePulsarImageTest.java @@ -1,25 +1,20 @@ package org.testcontainers.containers; import org.apache.pulsar.client.admin.PulsarAdmin; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.testcontainers.utility.DockerImageName; -@RunWith(Parameterized.class) -public class CompatibleApachePulsarImageTest extends AbstractPulsar { +class CompatibleApachePulsarImageTest extends AbstractPulsar { - @Parameterized.Parameters(name = "{0}") public static String[] params() { return new String[] { "apachepulsar/pulsar:3.0.0", "apachepulsar/pulsar-all:3.0.0" }; } - @Parameterized.Parameter - public String imageName; - - @Test - public void testUsage() throws Exception { - try (PulsarContainer pulsar = new PulsarContainer(DockerImageName.parse(this.imageName));) { + @ParameterizedTest + @MethodSource("params") + void testUsage(String imageName) throws Exception { + try (PulsarContainer pulsar = new PulsarContainer(DockerImageName.parse(imageName));) { pulsar.start(); final String pulsarBrokerUrl = pulsar.getPulsarBrokerUrl(); @@ -27,9 +22,10 @@ public void testUsage() throws Exception { } } - @Test - public void testTransactions() throws Exception { - try (PulsarContainer pulsar = new PulsarContainer(DockerImageName.parse(this.imageName)).withTransactions();) { + @ParameterizedTest + @MethodSource("params") + void testTransactions(String imageName) throws Exception { + try (PulsarContainer pulsar = new PulsarContainer(DockerImageName.parse(imageName)).withTransactions();) { pulsar.start(); try (PulsarAdmin pulsarAdmin = PulsarAdmin.builder().serviceHttpUrl(pulsar.getHttpServiceUrl()).build()) { diff --git a/modules/pulsar/src/test/java/org/testcontainers/containers/PulsarContainerTest.java b/modules/pulsar/src/test/java/org/testcontainers/containers/PulsarContainerTest.java index 779a3a6114a..93e9410ada8 100644 --- a/modules/pulsar/src/test/java/org/testcontainers/containers/PulsarContainerTest.java +++ b/modules/pulsar/src/test/java/org/testcontainers/containers/PulsarContainerTest.java @@ -2,7 +2,7 @@ import org.apache.pulsar.client.admin.PulsarAdmin; import org.apache.pulsar.client.admin.PulsarAdminException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.testcontainers.utility.DockerImageName; import java.time.Duration; @@ -10,12 +10,12 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -public class PulsarContainerTest extends AbstractPulsar { +class PulsarContainerTest extends AbstractPulsar { private static final DockerImageName PULSAR_IMAGE = DockerImageName.parse("apachepulsar/pulsar:3.0.0"); @Test - public void testUsage() throws Exception { + void testUsage() throws Exception { try ( // do not use PULSAR_IMAGE to make the doc looks easier // constructorWithVersion { @@ -32,7 +32,7 @@ public void testUsage() throws Exception { } @Test - public void envVarsUsage() throws Exception { + void envVarsUsage() throws Exception { try ( // constructorWithEnv { PulsarContainer pulsar = new PulsarContainer(PULSAR_IMAGE) @@ -45,7 +45,7 @@ public void envVarsUsage() throws Exception { } @Test - public void customClusterName() throws Exception { + void customClusterName() throws Exception { try ( PulsarContainer pulsar = new PulsarContainer(PULSAR_IMAGE) .withEnv("PULSAR_PREFIX_clusterName", "tc-cluster"); @@ -56,7 +56,7 @@ public void customClusterName() throws Exception { } @Test - public void shouldNotEnableFunctionsWorkerByDefault() throws Exception { + void shouldNotEnableFunctionsWorkerByDefault() throws Exception { try (PulsarContainer pulsar = new PulsarContainer(PULSAR_IMAGE)) { pulsar.start(); @@ -68,7 +68,7 @@ public void shouldNotEnableFunctionsWorkerByDefault() throws Exception { } @Test - public void shouldWaitForFunctionsWorkerStarted() throws Exception { + void shouldWaitForFunctionsWorkerStarted() throws Exception { try ( // constructorWithFunctionsWorker { PulsarContainer pulsar = new PulsarContainer(DockerImageName.parse("apachepulsar/pulsar:3.0.0")) @@ -84,7 +84,7 @@ public void shouldWaitForFunctionsWorkerStarted() throws Exception { } @Test - public void testTransactions() throws Exception { + void testTransactions() throws Exception { try ( // constructorWithTransactions { PulsarContainer pulsar = new PulsarContainer(PULSAR_IMAGE).withTransactions(); @@ -100,7 +100,7 @@ public void testTransactions() throws Exception { } @Test - public void testTransactionsAndFunctionsWorker() throws Exception { + void testTransactionsAndFunctionsWorker() throws Exception { try (PulsarContainer pulsar = new PulsarContainer(PULSAR_IMAGE).withTransactions().withFunctionsWorker()) { pulsar.start(); @@ -113,7 +113,7 @@ public void testTransactionsAndFunctionsWorker() throws Exception { } @Test - public void testClusterFullyInitialized() throws Exception { + void testClusterFullyInitialized() throws Exception { try (PulsarContainer pulsar = new PulsarContainer(PULSAR_IMAGE)) { pulsar.start(); @@ -124,7 +124,7 @@ public void testClusterFullyInitialized() throws Exception { } @Test - public void testStartupTimeoutIsHonored() { + void testStartupTimeoutIsHonored() { try (PulsarContainer pulsar = new PulsarContainer(PULSAR_IMAGE).withStartupTimeout(Duration.ZERO)) { assertThatThrownBy(pulsar::start) .hasRootCauseMessage("Precondition failed: timeout must be greater than zero");