diff --git a/modules/redpanda/build.gradle b/modules/redpanda/build.gradle index ec254add76f..d930155291e 100644 --- a/modules/redpanda/build.gradle +++ b/modules/redpanda/build.gradle @@ -4,8 +4,16 @@ dependencies { api project(':testcontainers') shaded 'org.freemarker:freemarker:2.3.34' + 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 'org.apache.kafka:kafka-clients:4.0.0' testImplementation 'org.assertj:assertj-core:3.27.4' testImplementation 'io.rest-assured:rest-assured:5.5.6' testImplementation 'org.awaitility:awaitility:4.3.0' } + +test { + useJUnitPlatform() +} diff --git a/modules/redpanda/src/test/java/org/testcontainers/redpanda/CompatibleImageTest.java b/modules/redpanda/src/test/java/org/testcontainers/redpanda/CompatibleImageTest.java index 478d6e7efbc..1167642615f 100644 --- a/modules/redpanda/src/test/java/org/testcontainers/redpanda/CompatibleImageTest.java +++ b/modules/redpanda/src/test/java/org/testcontainers/redpanda/CompatibleImageTest.java @@ -1,26 +1,18 @@ package org.testcontainers.redpanda; -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; -@RunWith(Parameterized.class) -public class CompatibleImageTest extends AbstractRedpanda { +class CompatibleImageTest extends AbstractRedpanda { - private final String image; - - public CompatibleImageTest(String image) { - this.image = image; - } - - @Parameterized.Parameters(name = "{0}") public static String[] image() { return new String[] { "docker.redpanda.com/redpandadata/redpanda:v22.2.1", "redpandadata/redpanda:v22.2.1" }; } - @Test - public void shouldProduceAndConsumeMessage() throws Exception { - try (RedpandaContainer container = new RedpandaContainer(this.image)) { + @ParameterizedTest + @MethodSource("image") + void shouldProduceAndConsumeMessage(String image) throws Exception { + try (RedpandaContainer container = new RedpandaContainer(image)) { container.start(); testKafkaFunctionality(container.getBootstrapServers()); } diff --git a/modules/redpanda/src/test/java/org/testcontainers/redpanda/RedpandaContainerTest.java b/modules/redpanda/src/test/java/org/testcontainers/redpanda/RedpandaContainerTest.java index d07f33d8b00..6d1f35da0f2 100644 --- a/modules/redpanda/src/test/java/org/testcontainers/redpanda/RedpandaContainerTest.java +++ b/modules/redpanda/src/test/java/org/testcontainers/redpanda/RedpandaContainerTest.java @@ -12,7 +12,7 @@ import org.apache.kafka.common.errors.SaslAuthenticationException; import org.apache.kafka.common.errors.TopicAuthorizationException; import org.awaitility.Awaitility; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.Network; import org.testcontainers.containers.SocatContainer; @@ -30,14 +30,14 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -public class RedpandaContainerTest extends AbstractRedpanda { +class RedpandaContainerTest extends AbstractRedpanda { private static final String REDPANDA_IMAGE = "docker.redpanda.com/redpandadata/redpanda:v22.2.1"; private static final DockerImageName REDPANDA_DOCKER_IMAGE = DockerImageName.parse(REDPANDA_IMAGE); @Test - public void testUsage() throws Exception { + void testUsage() throws Exception { try (RedpandaContainer container = new RedpandaContainer(REDPANDA_DOCKER_IMAGE)) { container.start(); testKafkaFunctionality(container.getBootstrapServers()); @@ -45,7 +45,7 @@ public void testUsage() throws Exception { } @Test - public void testUsageWithStringImage() throws Exception { + void testUsageWithStringImage() throws Exception { try ( // constructorWithVersion { RedpandaContainer container = new RedpandaContainer("docker.redpanda.com/redpandadata/redpanda:v23.1.2") @@ -61,21 +61,21 @@ public void testUsageWithStringImage() throws Exception { } @Test - public void testNotCompatibleVersion() { + void testNotCompatibleVersion() { assertThatThrownBy(() -> new RedpandaContainer("docker.redpanda.com/redpandadata/redpanda:v21.11.19")) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("Redpanda version must be >= v22.2.1"); } @Test - public void redpandadataRedpandaImageVersion2221ShouldNotBeCompatible() { + void redpandadataRedpandaImageVersion2221ShouldNotBeCompatible() { assertThatThrownBy(() -> new RedpandaContainer("redpandadata/redpanda:v21.11.19")) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("Redpanda version must be >= v22.2.1"); } @Test - public void testSchemaRegistry() { + void testSchemaRegistry() { try (RedpandaContainer container = new RedpandaContainer(REDPANDA_DOCKER_IMAGE)) { container.start(); @@ -105,7 +105,7 @@ public void testSchemaRegistry() { } @Test - public void testUsageWithListener() throws Exception { + void testUsageWithListener() throws Exception { try ( Network network = Network.newNetwork(); RedpandaContainer redpanda = new RedpandaContainer("docker.redpanda.com/redpandadata/redpanda:v23.1.7") @@ -132,7 +132,7 @@ public void testUsageWithListener() throws Exception { } @Test - public void testUsageWithListenerInTheSameNetwork() throws Exception { + void testUsageWithListenerInTheSameNetwork() throws Exception { try ( Network network = Network.newNetwork(); // registerListener { @@ -165,7 +165,7 @@ public void testUsageWithListenerInTheSameNetwork() throws Exception { } @Test - public void testUsageWithListenerFromProxy() throws Exception { + void testUsageWithListenerFromProxy() throws Exception { try ( Network network = Network.newNetwork(); // createProxy { @@ -187,7 +187,7 @@ public void testUsageWithListenerFromProxy() throws Exception { } @Test - public void testUsageWithListenerAndSasl() throws Exception { + void testUsageWithListenerAndSasl() throws Exception { final String username = "panda"; final String password = "pandapass"; final String algorithm = "SCRAM-SHA-256"; @@ -266,7 +266,7 @@ public void testUsageWithListenerAndSasl() throws Exception { @SneakyThrows @Test - public void enableSaslWithSuccessfulTopicCreation() { + void enableSaslWithSuccessfulTopicCreation() { try ( // security { RedpandaContainer redpanda = new RedpandaContainer("docker.redpanda.com/redpandadata/redpanda:v23.1.7") @@ -289,7 +289,7 @@ public void enableSaslWithSuccessfulTopicCreation() { } @Test - public void enableSaslWithUnsuccessfulTopicCreation() { + void enableSaslWithUnsuccessfulTopicCreation() { try ( RedpandaContainer redpanda = new RedpandaContainer("docker.redpanda.com/redpandadata/redpanda:v23.1.7") .enableAuthorization() @@ -313,7 +313,7 @@ public void enableSaslWithUnsuccessfulTopicCreation() { } @Test - public void enableSaslAndWithAuthenticationError() { + void enableSaslAndWithAuthenticationError() { try ( RedpandaContainer redpanda = new RedpandaContainer("docker.redpanda.com/redpandadata/redpanda:v23.1.7") .enableAuthorization() @@ -335,7 +335,7 @@ public void enableSaslAndWithAuthenticationError() { } @Test - public void schemaRegistryWithHttpBasic() { + void schemaRegistryWithHttpBasic() { try ( RedpandaContainer redpanda = new RedpandaContainer("docker.redpanda.com/redpandadata/redpanda:v23.1.7") .enableSchemaRegistryHttpBasicAuth() @@ -362,7 +362,7 @@ public void schemaRegistryWithHttpBasic() { @SneakyThrows @Test - public void testRestProxy() { + void testRestProxy() { try (RedpandaContainer redpanda = new RedpandaContainer("docker.redpanda.com/redpandadata/redpanda:v23.1.7")) { redpanda.start();