Skip to content

Commit d697dae

Browse files
authored
Move Redpanda tests to JUnit Jupiter (#10762)
1 parent 8822b91 commit d697dae

File tree

3 files changed

+31
-31
lines changed

3 files changed

+31
-31
lines changed

modules/redpanda/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,16 @@ dependencies {
44
api project(':testcontainers')
55
shaded 'org.freemarker:freemarker:2.3.34'
66

7+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.0'
8+
9+
testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4'
10+
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.13.4'
711
testImplementation 'org.apache.kafka:kafka-clients:4.0.0'
812
testImplementation 'org.assertj:assertj-core:3.27.4'
913
testImplementation 'io.rest-assured:rest-assured:5.5.6'
1014
testImplementation 'org.awaitility:awaitility:4.3.0'
1115
}
16+
17+
test {
18+
useJUnitPlatform()
19+
}

modules/redpanda/src/test/java/org/testcontainers/redpanda/CompatibleImageTest.java

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,18 @@
11
package org.testcontainers.redpanda;
22

3-
import org.junit.Test;
4-
import org.junit.runner.RunWith;
5-
import org.junit.runners.Parameterized;
3+
import org.junit.jupiter.params.ParameterizedTest;
4+
import org.junit.jupiter.params.provider.MethodSource;
65

7-
@RunWith(Parameterized.class)
8-
public class CompatibleImageTest extends AbstractRedpanda {
6+
class CompatibleImageTest extends AbstractRedpanda {
97

10-
private final String image;
11-
12-
public CompatibleImageTest(String image) {
13-
this.image = image;
14-
}
15-
16-
@Parameterized.Parameters(name = "{0}")
178
public static String[] image() {
189
return new String[] { "docker.redpanda.com/redpandadata/redpanda:v22.2.1", "redpandadata/redpanda:v22.2.1" };
1910
}
2011

21-
@Test
22-
public void shouldProduceAndConsumeMessage() throws Exception {
23-
try (RedpandaContainer container = new RedpandaContainer(this.image)) {
12+
@ParameterizedTest
13+
@MethodSource("image")
14+
void shouldProduceAndConsumeMessage(String image) throws Exception {
15+
try (RedpandaContainer container = new RedpandaContainer(image)) {
2416
container.start();
2517
testKafkaFunctionality(container.getBootstrapServers());
2618
}

modules/redpanda/src/test/java/org/testcontainers/redpanda/RedpandaContainerTest.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import org.apache.kafka.common.errors.SaslAuthenticationException;
1313
import org.apache.kafka.common.errors.TopicAuthorizationException;
1414
import org.awaitility.Awaitility;
15-
import org.junit.Test;
15+
import org.junit.jupiter.api.Test;
1616
import org.testcontainers.containers.GenericContainer;
1717
import org.testcontainers.containers.Network;
1818
import org.testcontainers.containers.SocatContainer;
@@ -30,22 +30,22 @@
3030
import static org.assertj.core.api.Assertions.assertThat;
3131
import static org.assertj.core.api.Assertions.assertThatThrownBy;
3232

33-
public class RedpandaContainerTest extends AbstractRedpanda {
33+
class RedpandaContainerTest extends AbstractRedpanda {
3434

3535
private static final String REDPANDA_IMAGE = "docker.redpanda.com/redpandadata/redpanda:v22.2.1";
3636

3737
private static final DockerImageName REDPANDA_DOCKER_IMAGE = DockerImageName.parse(REDPANDA_IMAGE);
3838

3939
@Test
40-
public void testUsage() throws Exception {
40+
void testUsage() throws Exception {
4141
try (RedpandaContainer container = new RedpandaContainer(REDPANDA_DOCKER_IMAGE)) {
4242
container.start();
4343
testKafkaFunctionality(container.getBootstrapServers());
4444
}
4545
}
4646

4747
@Test
48-
public void testUsageWithStringImage() throws Exception {
48+
void testUsageWithStringImage() throws Exception {
4949
try (
5050
// constructorWithVersion {
5151
RedpandaContainer container = new RedpandaContainer("docker.redpanda.com/redpandadata/redpanda:v23.1.2")
@@ -61,21 +61,21 @@ public void testUsageWithStringImage() throws Exception {
6161
}
6262

6363
@Test
64-
public void testNotCompatibleVersion() {
64+
void testNotCompatibleVersion() {
6565
assertThatThrownBy(() -> new RedpandaContainer("docker.redpanda.com/redpandadata/redpanda:v21.11.19"))
6666
.isInstanceOf(IllegalArgumentException.class)
6767
.hasMessageContaining("Redpanda version must be >= v22.2.1");
6868
}
6969

7070
@Test
71-
public void redpandadataRedpandaImageVersion2221ShouldNotBeCompatible() {
71+
void redpandadataRedpandaImageVersion2221ShouldNotBeCompatible() {
7272
assertThatThrownBy(() -> new RedpandaContainer("redpandadata/redpanda:v21.11.19"))
7373
.isInstanceOf(IllegalArgumentException.class)
7474
.hasMessageContaining("Redpanda version must be >= v22.2.1");
7575
}
7676

7777
@Test
78-
public void testSchemaRegistry() {
78+
void testSchemaRegistry() {
7979
try (RedpandaContainer container = new RedpandaContainer(REDPANDA_DOCKER_IMAGE)) {
8080
container.start();
8181

@@ -105,7 +105,7 @@ public void testSchemaRegistry() {
105105
}
106106

107107
@Test
108-
public void testUsageWithListener() throws Exception {
108+
void testUsageWithListener() throws Exception {
109109
try (
110110
Network network = Network.newNetwork();
111111
RedpandaContainer redpanda = new RedpandaContainer("docker.redpanda.com/redpandadata/redpanda:v23.1.7")
@@ -132,7 +132,7 @@ public void testUsageWithListener() throws Exception {
132132
}
133133

134134
@Test
135-
public void testUsageWithListenerInTheSameNetwork() throws Exception {
135+
void testUsageWithListenerInTheSameNetwork() throws Exception {
136136
try (
137137
Network network = Network.newNetwork();
138138
// registerListener {
@@ -165,7 +165,7 @@ public void testUsageWithListenerInTheSameNetwork() throws Exception {
165165
}
166166

167167
@Test
168-
public void testUsageWithListenerFromProxy() throws Exception {
168+
void testUsageWithListenerFromProxy() throws Exception {
169169
try (
170170
Network network = Network.newNetwork();
171171
// createProxy {
@@ -187,7 +187,7 @@ public void testUsageWithListenerFromProxy() throws Exception {
187187
}
188188

189189
@Test
190-
public void testUsageWithListenerAndSasl() throws Exception {
190+
void testUsageWithListenerAndSasl() throws Exception {
191191
final String username = "panda";
192192
final String password = "pandapass";
193193
final String algorithm = "SCRAM-SHA-256";
@@ -266,7 +266,7 @@ public void testUsageWithListenerAndSasl() throws Exception {
266266

267267
@SneakyThrows
268268
@Test
269-
public void enableSaslWithSuccessfulTopicCreation() {
269+
void enableSaslWithSuccessfulTopicCreation() {
270270
try (
271271
// security {
272272
RedpandaContainer redpanda = new RedpandaContainer("docker.redpanda.com/redpandadata/redpanda:v23.1.7")
@@ -289,7 +289,7 @@ public void enableSaslWithSuccessfulTopicCreation() {
289289
}
290290

291291
@Test
292-
public void enableSaslWithUnsuccessfulTopicCreation() {
292+
void enableSaslWithUnsuccessfulTopicCreation() {
293293
try (
294294
RedpandaContainer redpanda = new RedpandaContainer("docker.redpanda.com/redpandadata/redpanda:v23.1.7")
295295
.enableAuthorization()
@@ -313,7 +313,7 @@ public void enableSaslWithUnsuccessfulTopicCreation() {
313313
}
314314

315315
@Test
316-
public void enableSaslAndWithAuthenticationError() {
316+
void enableSaslAndWithAuthenticationError() {
317317
try (
318318
RedpandaContainer redpanda = new RedpandaContainer("docker.redpanda.com/redpandadata/redpanda:v23.1.7")
319319
.enableAuthorization()
@@ -335,7 +335,7 @@ public void enableSaslAndWithAuthenticationError() {
335335
}
336336

337337
@Test
338-
public void schemaRegistryWithHttpBasic() {
338+
void schemaRegistryWithHttpBasic() {
339339
try (
340340
RedpandaContainer redpanda = new RedpandaContainer("docker.redpanda.com/redpandadata/redpanda:v23.1.7")
341341
.enableSchemaRegistryHttpBasicAuth()
@@ -362,7 +362,7 @@ public void schemaRegistryWithHttpBasic() {
362362

363363
@SneakyThrows
364364
@Test
365-
public void testRestProxy() {
365+
void testRestProxy() {
366366
try (RedpandaContainer redpanda = new RedpandaContainer("docker.redpanda.com/redpandadata/redpanda:v23.1.7")) {
367367
redpanda.start();
368368

0 commit comments

Comments
 (0)