From e78c5e2fdb91f34642810e31eda43cd30c41f17f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Thu, 11 Sep 2025 10:24:07 -0600 Subject: [PATCH 01/20] Move jdbc-test tests to JUnit Jupiter --- modules/jdbc-test/build.gradle | 1 + .../jdbc/AbstractJDBCDriverTest.java | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/modules/jdbc-test/build.gradle b/modules/jdbc-test/build.gradle index f4f762ae43a..1136c2b44b0 100644 --- a/modules/jdbc-test/build.gradle +++ b/modules/jdbc-test/build.gradle @@ -11,4 +11,5 @@ dependencies { api 'org.apache.tomcat:tomcat-jdbc:11.0.10' api 'org.vibur:vibur-dbcp:26.0' api 'mysql:mysql-connector-java:8.0.33' + api 'org.junit.jupiter:junit-jupiter:5.13.4' } diff --git a/modules/jdbc-test/src/main/java/org/testcontainers/jdbc/AbstractJDBCDriverTest.java b/modules/jdbc-test/src/main/java/org/testcontainers/jdbc/AbstractJDBCDriverTest.java index 5a22e37ecfc..ff844b8988b 100644 --- a/modules/jdbc-test/src/main/java/org/testcontainers/jdbc/AbstractJDBCDriverTest.java +++ b/modules/jdbc-test/src/main/java/org/testcontainers/jdbc/AbstractJDBCDriverTest.java @@ -4,9 +4,11 @@ import com.zaxxer.hikari.HikariDataSource; import org.apache.commons.dbutils.QueryRunner; import org.apache.commons.lang3.SystemUtils; -import org.junit.AfterClass; -import org.junit.Test; -import org.junit.runners.Parameterized.Parameter; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import java.sql.Connection; import java.sql.ResultSet; @@ -17,6 +19,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assume.assumeFalse; +@ParameterizedClass +@MethodSource("data") public class AbstractJDBCDriverTest { protected enum Options { @@ -27,7 +31,7 @@ protected enum Options { PmdKnownBroken, } - @Parameter + @Parameter(0) public String jdbcUrl; @Parameter(1) @@ -39,13 +43,13 @@ public static void sampleInitFunction(Connection connection) throws SQLException connection.createStatement().execute("CREATE TABLE my_counter (\n" + " n INT\n" + ");"); } - @AfterClass + @AfterAll public static void testCleanup() { ContainerDatabaseDriver.killContainers(); } @Test - public void test() throws SQLException { + void test() throws SQLException { try (HikariDataSource dataSource = getDataSource(jdbcUrl, 1)) { performSimpleTest(dataSource); From 625335a526da5f9ecab0acfb04ae351398d83706 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Thu, 11 Sep 2025 10:24:59 -0600 Subject: [PATCH 02/20] Move r2dbc tests to JUnit Jupiter --- modules/r2dbc/build.gradle | 1 + .../r2dbc/AbstractR2DBCDatabaseContainerTest.java | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/r2dbc/build.gradle b/modules/r2dbc/build.gradle index 143deb8828e..87c0e927048 100644 --- a/modules/r2dbc/build.gradle +++ b/modules/r2dbc/build.gradle @@ -17,6 +17,7 @@ dependencies { testFixturesImplementation 'io.projectreactor:reactor-core:3.7.9' testFixturesImplementation 'org.assertj:assertj-core:3.27.4' + testFixturesImplementation 'org.junit.jupiter:junit-jupiter:5.13.4' } test { diff --git a/modules/r2dbc/src/testFixtures/java/org/testcontainers/r2dbc/AbstractR2DBCDatabaseContainerTest.java b/modules/r2dbc/src/testFixtures/java/org/testcontainers/r2dbc/AbstractR2DBCDatabaseContainerTest.java index ca06e22d631..ed0a7fba70f 100644 --- a/modules/r2dbc/src/testFixtures/java/org/testcontainers/r2dbc/AbstractR2DBCDatabaseContainerTest.java +++ b/modules/r2dbc/src/testFixtures/java/org/testcontainers/r2dbc/AbstractR2DBCDatabaseContainerTest.java @@ -6,7 +6,7 @@ import io.r2dbc.spi.ConnectionFactory; import io.r2dbc.spi.ConnectionFactoryMetadata; import io.r2dbc.spi.ConnectionFactoryOptions; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.testcontainers.containers.GenericContainer; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -28,7 +28,7 @@ protected String createTestQuery(int result) { } @Test - public final void testGetOptions() { + void testGetOptions() { try (T container = createContainer()) { container.start(); @@ -38,13 +38,13 @@ public final void testGetOptions() { } @Test - public final void testUrlSupport() { + void testUrlSupport() { ConnectionFactory connectionFactory = ConnectionFactories.get(createR2DBCUrl()); runTestQuery(connectionFactory); } @Test - public final void testGetMetadata() { + void testGetMetadata() { ConnectionFactory connectionFactory = ConnectionFactories.get(createR2DBCUrl()); ConnectionFactoryMetadata metadata = connectionFactory.getMetadata(); assertThat(metadata).isNotNull(); From 6e5e6e833e00d701af759418fa8ecca1695794ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Thu, 11 Sep 2025 10:25:12 -0600 Subject: [PATCH 03/20] Move ClickHouse tests to JUnit Jupiter --- modules/clickhouse/build.gradle | 7 ++++++ .../clickhouse/ClickHouseContainerTest.java | 12 +++++----- .../clickhouse/ClickhouseJDBCDriverTest.java | 6 +---- .../clickhouse/SimpleClickhouseTest.java | 23 +++---------------- 4 files changed, 17 insertions(+), 31 deletions(-) diff --git a/modules/clickhouse/build.gradle b/modules/clickhouse/build.gradle index b840e70763b..3fc372b2891 100644 --- a/modules/clickhouse/build.gradle +++ b/modules/clickhouse/build.gradle @@ -10,8 +10,15 @@ dependencies { testImplementation project(':testcontainers-jdbc-test') testRuntimeOnly(group: 'com.clickhouse', name: 'clickhouse-jdbc', version: '0.9.1', classifier: 'all') + testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.0' + + testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4' testImplementation 'org.assertj:assertj-core:3.27.4' testImplementation 'com.clickhouse:client-v2:0.9.1' testImplementation testFixtures(project(':testcontainers-r2dbc')) testRuntimeOnly(group: 'com.clickhouse', name: 'clickhouse-r2dbc', version: '0.9.1', classifier: 'http') } + +test { + useJUnitPlatform() +} diff --git a/modules/clickhouse/src/test/java/org/testcontainers/clickhouse/ClickHouseContainerTest.java b/modules/clickhouse/src/test/java/org/testcontainers/clickhouse/ClickHouseContainerTest.java index ff20917e009..0f9eb3ef6a3 100644 --- a/modules/clickhouse/src/test/java/org/testcontainers/clickhouse/ClickHouseContainerTest.java +++ b/modules/clickhouse/src/test/java/org/testcontainers/clickhouse/ClickHouseContainerTest.java @@ -3,7 +3,7 @@ import com.clickhouse.client.api.Client; import com.clickhouse.client.api.data_formats.ClickHouseBinaryFormatReader; import com.clickhouse.client.api.query.QueryResponse; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.testcontainers.ClickhouseTestImages; import org.testcontainers.db.AbstractContainerDatabaseTest; @@ -16,10 +16,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -public class ClickHouseContainerTest extends AbstractContainerDatabaseTest { +class ClickHouseContainerTest extends AbstractContainerDatabaseTest { @Test - public void testSimple() throws SQLException { + void testSimple() throws SQLException { try ( // container { ClickHouseContainer clickhouse = new ClickHouseContainer("clickhouse/clickhouse-server:21.11-alpine") // } @@ -34,7 +34,7 @@ public void testSimple() throws SQLException { } @Test - public void customCredentialsWithUrlParams() throws SQLException { + void customCredentialsWithUrlParams() throws SQLException { try ( ClickHouseContainer clickhouse = new ClickHouseContainer("clickhouse/clickhouse-server:21.11.2-alpine") .withUsername("default") @@ -56,7 +56,7 @@ public void customCredentialsWithUrlParams() throws SQLException { } @Test - public void testNewAuth() throws SQLException { + void testNewAuth() throws SQLException { try (ClickHouseContainer clickhouse = new ClickHouseContainer(ClickhouseTestImages.CLICKHOUSE_24_12_IMAGE)) { clickhouse.start(); @@ -68,7 +68,7 @@ public void testNewAuth() throws SQLException { } @Test - public void testGetHttpMethodWithHttpClient() { + void testGetHttpMethodWithHttpClient() { ClickHouseContainer clickhouse = new ClickHouseContainer(ClickhouseTestImages.CLICKHOUSE_24_12_IMAGE); clickhouse.start(); Client client = new Client.Builder() diff --git a/modules/clickhouse/src/test/java/org/testcontainers/jdbc/clickhouse/ClickhouseJDBCDriverTest.java b/modules/clickhouse/src/test/java/org/testcontainers/jdbc/clickhouse/ClickhouseJDBCDriverTest.java index 056aace7772..0a85a26899a 100644 --- a/modules/clickhouse/src/test/java/org/testcontainers/jdbc/clickhouse/ClickhouseJDBCDriverTest.java +++ b/modules/clickhouse/src/test/java/org/testcontainers/jdbc/clickhouse/ClickhouseJDBCDriverTest.java @@ -1,16 +1,12 @@ package org.testcontainers.jdbc.clickhouse; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.testcontainers.jdbc.AbstractJDBCDriverTest; import java.util.Arrays; import java.util.EnumSet; -@RunWith(Parameterized.class) -public class ClickhouseJDBCDriverTest extends AbstractJDBCDriverTest { +class ClickhouseJDBCDriverTest extends AbstractJDBCDriverTest { - @Parameterized.Parameters(name = "{index} - {0}") public static Iterable data() { return Arrays.asList( new Object[][] { // diff --git a/modules/clickhouse/src/test/java/org/testcontainers/junit/clickhouse/SimpleClickhouseTest.java b/modules/clickhouse/src/test/java/org/testcontainers/junit/clickhouse/SimpleClickhouseTest.java index eb33274ce6b..c9bd9e917f5 100644 --- a/modules/clickhouse/src/test/java/org/testcontainers/junit/clickhouse/SimpleClickhouseTest.java +++ b/modules/clickhouse/src/test/java/org/testcontainers/junit/clickhouse/SimpleClickhouseTest.java @@ -1,37 +1,20 @@ package org.testcontainers.junit.clickhouse; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Test; import org.testcontainers.ClickhouseTestImages; import org.testcontainers.containers.ClickHouseContainer; import org.testcontainers.db.AbstractContainerDatabaseTest; -import org.testcontainers.utility.DockerImageName; import java.sql.ResultSet; import java.sql.SQLException; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) -public class SimpleClickhouseTest extends AbstractContainerDatabaseTest { - - private final DockerImageName imageName; - - public SimpleClickhouseTest(DockerImageName imageName) { - this.imageName = imageName; - } - - @Parameterized.Parameters(name = "{0}") - public static Object[][] data() { - return new Object[][] { // - { ClickhouseTestImages.CLICKHOUSE_IMAGE }, - }; - } +class SimpleClickhouseTest extends AbstractContainerDatabaseTest { @Test public void testSimple() throws SQLException { - try (ClickHouseContainer clickhouse = new ClickHouseContainer(this.imageName)) { + try (ClickHouseContainer clickhouse = new ClickHouseContainer(ClickhouseTestImages.CLICKHOUSE_IMAGE)) { clickhouse.start(); ResultSet resultSet = performQuery(clickhouse, "SELECT 1"); From e3bcdb365214576474ca5eccd533b858176e9d73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Thu, 11 Sep 2025 10:25:30 -0600 Subject: [PATCH 04/20] Move CockroachDB tests to JUnit Jupiter --- modules/cockroachdb/build.gradle | 9 ++++++++- .../cockroachdb/CockroachDBJDBCDriverTest.java | 6 +----- .../junit/cockroachdb/SimpleCockroachDBTest.java | 16 ++++++++-------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/modules/cockroachdb/build.gradle b/modules/cockroachdb/build.gradle index 264c22eff9e..8107fc92f6a 100644 --- a/modules/cockroachdb/build.gradle +++ b/modules/cockroachdb/build.gradle @@ -3,8 +3,11 @@ description = "Testcontainers :: JDBC :: CockroachDB" dependencies { api project(':testcontainers-jdbc') - testImplementation project(':testcontainers-jdbc-test') testRuntimeOnly 'org.postgresql:postgresql:42.7.7' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.0' + + testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4' + testImplementation project(':testcontainers-jdbc-test') testImplementation 'org.assertj:assertj-core:3.27.4' } @@ -13,3 +16,7 @@ tasks.japicmp { "org.testcontainers.containers.CockroachContainer" ] } + +test { + useJUnitPlatform() +} diff --git a/modules/cockroachdb/src/test/java/org/testcontainers/jdbc/cockroachdb/CockroachDBJDBCDriverTest.java b/modules/cockroachdb/src/test/java/org/testcontainers/jdbc/cockroachdb/CockroachDBJDBCDriverTest.java index b5e147ce553..dc4915aac3e 100644 --- a/modules/cockroachdb/src/test/java/org/testcontainers/jdbc/cockroachdb/CockroachDBJDBCDriverTest.java +++ b/modules/cockroachdb/src/test/java/org/testcontainers/jdbc/cockroachdb/CockroachDBJDBCDriverTest.java @@ -1,16 +1,12 @@ package org.testcontainers.jdbc.cockroachdb; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.testcontainers.jdbc.AbstractJDBCDriverTest; import java.util.Arrays; import java.util.EnumSet; -@RunWith(Parameterized.class) -public class CockroachDBJDBCDriverTest extends AbstractJDBCDriverTest { +class CockroachDBJDBCDriverTest extends AbstractJDBCDriverTest { - @Parameterized.Parameters(name = "{index} - {0}") public static Iterable data() { return Arrays.asList( new Object[][] { // diff --git a/modules/cockroachdb/src/test/java/org/testcontainers/junit/cockroachdb/SimpleCockroachDBTest.java b/modules/cockroachdb/src/test/java/org/testcontainers/junit/cockroachdb/SimpleCockroachDBTest.java index 12c25738e45..5846c22a5db 100644 --- a/modules/cockroachdb/src/test/java/org/testcontainers/junit/cockroachdb/SimpleCockroachDBTest.java +++ b/modules/cockroachdb/src/test/java/org/testcontainers/junit/cockroachdb/SimpleCockroachDBTest.java @@ -1,6 +1,6 @@ package org.testcontainers.junit.cockroachdb; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.testcontainers.CockroachDBTestImages; import org.testcontainers.containers.CockroachContainer; import org.testcontainers.db.AbstractContainerDatabaseTest; @@ -14,14 +14,14 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -public class SimpleCockroachDBTest extends AbstractContainerDatabaseTest { +class SimpleCockroachDBTest extends AbstractContainerDatabaseTest { static { // Postgres JDBC driver uses JUL; disable it to avoid annoying, irrelevant, stderr logs during connection testing LogManager.getLogManager().getLogger("").setLevel(Level.OFF); } @Test - public void testSimple() throws SQLException { + void testSimple() throws SQLException { try ( // container { CockroachContainer cockroach = new CockroachContainer("cockroachdb/cockroach:v22.2.3") // } @@ -36,7 +36,7 @@ public void testSimple() throws SQLException { } @Test - public void testExplicitInitScript() throws SQLException { + void testExplicitInitScript() throws SQLException { try ( CockroachContainer cockroach = new CockroachContainer(CockroachDBTestImages.COCKROACHDB_IMAGE) .withInitScript("somepath/init_postgresql.sql") @@ -51,7 +51,7 @@ public void testExplicitInitScript() throws SQLException { } @Test - public void testWithAdditionalUrlParamInJdbcUrl() { + void testWithAdditionalUrlParamInJdbcUrl() { CockroachContainer cockroach = new CockroachContainer(CockroachDBTestImages.COCKROACHDB_IMAGE) .withUrlParam("sslmode", "disable") .withUrlParam("application_name", "cockroach"); @@ -70,7 +70,7 @@ public void testWithAdditionalUrlParamInJdbcUrl() { } @Test - public void testWithUsernamePasswordDatabase() throws SQLException { + void testWithUsernamePasswordDatabase() throws SQLException { try ( CockroachContainer cockroach = new CockroachContainer( CockroachDBTestImages.FIRST_COCKROACHDB_IMAGE_WITH_ENV_VARS_SUPPORT @@ -92,7 +92,7 @@ public void testWithUsernamePasswordDatabase() throws SQLException { } @Test - public void testAnExceptionIsThrownWhenImageDoesNotSupportEnvVars() { + void testAnExceptionIsThrownWhenImageDoesNotSupportEnvVars() { CockroachContainer cockroachContainer = new CockroachContainer( CockroachDBTestImages.COCKROACHDB_IMAGE_WITH_ENV_VARS_UNSUPPORTED ); @@ -111,7 +111,7 @@ public void testAnExceptionIsThrownWhenImageDoesNotSupportEnvVars() { } @Test - public void testInitializationScript() throws SQLException { + void testInitializationScript() throws SQLException { String sql = "USE postgres; \n" + "CREATE TABLE bar (foo VARCHAR(255)); \n" + From e73cc7fab89d47c930bf24997165ab6cfab57698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Thu, 11 Sep 2025 10:25:42 -0600 Subject: [PATCH 05/20] Move CrateDB tests to JUnit Jupiter --- modules/cratedb/build.gradle | 9 ++++++++- .../jdbc/cratedb/CrateDBJDBCDriverTest.java | 6 +----- .../junit/cratedb/SimpleCrateDBTest.java | 10 +++++----- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/modules/cratedb/build.gradle b/modules/cratedb/build.gradle index b74d9c5f949..f7bc059ced3 100644 --- a/modules/cratedb/build.gradle +++ b/modules/cratedb/build.gradle @@ -3,8 +3,15 @@ description = "Testcontainers :: JDBC :: CrateDB" dependencies { api project(':testcontainers-jdbc') - testImplementation project(':testcontainers-jdbc-test') testRuntimeOnly 'org.postgresql:postgresql:42.7.7' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.0' + + testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4' + testImplementation project(':testcontainers-jdbc-test') compileOnly 'org.jetbrains:annotations:26.0.2' } + +test { + useJUnitPlatform() +} diff --git a/modules/cratedb/src/test/java/org/testcontainers/jdbc/cratedb/CrateDBJDBCDriverTest.java b/modules/cratedb/src/test/java/org/testcontainers/jdbc/cratedb/CrateDBJDBCDriverTest.java index 54ef9704ac5..2c20afe6680 100644 --- a/modules/cratedb/src/test/java/org/testcontainers/jdbc/cratedb/CrateDBJDBCDriverTest.java +++ b/modules/cratedb/src/test/java/org/testcontainers/jdbc/cratedb/CrateDBJDBCDriverTest.java @@ -1,16 +1,12 @@ package org.testcontainers.jdbc.cratedb; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.testcontainers.jdbc.AbstractJDBCDriverTest; import java.util.Arrays; import java.util.EnumSet; -@RunWith(Parameterized.class) -public class CrateDBJDBCDriverTest extends AbstractJDBCDriverTest { +class CrateDBJDBCDriverTest extends AbstractJDBCDriverTest { - @Parameterized.Parameters(name = "{index} - {0}") public static Iterable data() { return Arrays.asList( new Object[][] { diff --git a/modules/cratedb/src/test/java/org/testcontainers/junit/cratedb/SimpleCrateDBTest.java b/modules/cratedb/src/test/java/org/testcontainers/junit/cratedb/SimpleCrateDBTest.java index 40f2c667711..803b9173218 100644 --- a/modules/cratedb/src/test/java/org/testcontainers/junit/cratedb/SimpleCrateDBTest.java +++ b/modules/cratedb/src/test/java/org/testcontainers/junit/cratedb/SimpleCrateDBTest.java @@ -1,6 +1,6 @@ package org.testcontainers.junit.cratedb; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.testcontainers.CrateDBTestImages; import org.testcontainers.cratedb.CrateDBContainer; import org.testcontainers.db.AbstractContainerDatabaseTest; @@ -12,14 +12,14 @@ import static org.assertj.core.api.Assertions.assertThat; -public class SimpleCrateDBTest extends AbstractContainerDatabaseTest { +class SimpleCrateDBTest extends AbstractContainerDatabaseTest { static { // Postgres JDBC driver uses JUL; disable it to avoid annoying, irrelevant, stderr logs during connection testing LogManager.getLogManager().getLogger("").setLevel(Level.OFF); } @Test - public void testSimple() throws SQLException { + void testSimple() throws SQLException { try ( // container { CrateDBContainer cratedb = new CrateDBContainer("crate:5.2.5") // } @@ -34,7 +34,7 @@ public void testSimple() throws SQLException { } @Test - public void testCommandOverride() throws SQLException { + void testCommandOverride() throws SQLException { try ( CrateDBContainer cratedb = new CrateDBContainer(CrateDBTestImages.CRATEDB_TEST_IMAGE) .withCommand("crate -C discovery.type=single-node -C cluster.name=testcontainers") @@ -48,7 +48,7 @@ public void testCommandOverride() throws SQLException { } @Test - public void testExplicitInitScript() throws SQLException { + void testExplicitInitScript() throws SQLException { try ( CrateDBContainer cratedb = new CrateDBContainer(CrateDBTestImages.CRATEDB_TEST_IMAGE) .withInitScript("somepath/init_cratedb.sql") From 2eee1beb03cd55c8854ad2a21639382f6f2c4f6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Thu, 11 Sep 2025 10:26:02 -0600 Subject: [PATCH 06/20] Move Databend tests to JUnit Jupiter --- modules/databend/build.gradle | 7 +++++++ .../testcontainers/databend/DatabendContainerTest.java | 8 ++++---- .../testcontainers/databend/DatabendJDBCDriverTest.java | 6 +----- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/modules/databend/build.gradle b/modules/databend/build.gradle index 6e57f4bd198..1535441e925 100644 --- a/modules/databend/build.gradle +++ b/modules/databend/build.gradle @@ -5,5 +5,12 @@ dependencies { testImplementation project(':testcontainers-jdbc-test') testRuntimeOnly 'com.databend:databend-jdbc:0.4.0' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.0' + + testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4' testImplementation 'org.assertj:assertj-core:3.27.4' } + +test { + useJUnitPlatform() +} diff --git a/modules/databend/src/test/java/org/testcontainers/databend/DatabendContainerTest.java b/modules/databend/src/test/java/org/testcontainers/databend/DatabendContainerTest.java index 66f3504e725..984f42979c4 100644 --- a/modules/databend/src/test/java/org/testcontainers/databend/DatabendContainerTest.java +++ b/modules/databend/src/test/java/org/testcontainers/databend/DatabendContainerTest.java @@ -1,6 +1,6 @@ package org.testcontainers.databend; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.testcontainers.db.AbstractContainerDatabaseTest; import java.sql.ResultSet; @@ -8,10 +8,10 @@ import static org.assertj.core.api.Assertions.assertThat; -public class DatabendContainerTest extends AbstractContainerDatabaseTest { +class DatabendContainerTest extends AbstractContainerDatabaseTest { @Test - public void testSimple() throws SQLException { + void testSimple() throws SQLException { try ( // container { DatabendContainer databend = new DatabendContainer("datafuselabs/databend:v1.2.615") // } @@ -26,7 +26,7 @@ public void testSimple() throws SQLException { } @Test - public void customCredentialsWithUrlParams() throws SQLException { + void customCredentialsWithUrlParams() throws SQLException { try ( DatabendContainer databend = new DatabendContainer("datafuselabs/databend:v1.2.615") .withUsername("test") diff --git a/modules/databend/src/test/java/org/testcontainers/databend/DatabendJDBCDriverTest.java b/modules/databend/src/test/java/org/testcontainers/databend/DatabendJDBCDriverTest.java index a36039dc8d1..2f3a030919f 100644 --- a/modules/databend/src/test/java/org/testcontainers/databend/DatabendJDBCDriverTest.java +++ b/modules/databend/src/test/java/org/testcontainers/databend/DatabendJDBCDriverTest.java @@ -1,16 +1,12 @@ package org.testcontainers.databend; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.testcontainers.jdbc.AbstractJDBCDriverTest; import java.util.Arrays; import java.util.EnumSet; -@RunWith(Parameterized.class) -public class DatabendJDBCDriverTest extends AbstractJDBCDriverTest { +class DatabendJDBCDriverTest extends AbstractJDBCDriverTest { - @Parameterized.Parameters(name = "{index} - {0}") public static Iterable data() { return Arrays.asList( new Object[][] { // From 8e07d8c319e264273dcd989aad2b7d9bdd4cc964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Thu, 11 Sep 2025 10:26:11 -0600 Subject: [PATCH 07/20] Move DB2 tests to JUnit Jupiter --- modules/db2/build.gradle | 7 +++++++ .../org/testcontainers/jdbc/db2/DB2JDBCDriverTest.java | 6 +----- .../org/testcontainers/junit/db2/SimpleDb2Test.java | 10 +++++----- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/modules/db2/build.gradle b/modules/db2/build.gradle index b50291c201d..49fb4c72e28 100644 --- a/modules/db2/build.gradle +++ b/modules/db2/build.gradle @@ -3,6 +3,9 @@ description = "Testcontainers :: JDBC :: DB2" dependencies { api project(':testcontainers-jdbc') + testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.0' + + testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4' testImplementation project(':testcontainers-jdbc-test') testRuntimeOnly 'com.ibm.db2:jcc:12.1.2.0' testImplementation 'org.assertj:assertj-core:3.27.4' @@ -13,3 +16,7 @@ tasks.japicmp { "org.testcontainers.containers.Db2Container" ] } + +test { + useJUnitPlatform() +} diff --git a/modules/db2/src/test/java/org/testcontainers/jdbc/db2/DB2JDBCDriverTest.java b/modules/db2/src/test/java/org/testcontainers/jdbc/db2/DB2JDBCDriverTest.java index 4a03f824a28..cfa74c8017a 100644 --- a/modules/db2/src/test/java/org/testcontainers/jdbc/db2/DB2JDBCDriverTest.java +++ b/modules/db2/src/test/java/org/testcontainers/jdbc/db2/DB2JDBCDriverTest.java @@ -1,16 +1,12 @@ package org.testcontainers.jdbc.db2; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.testcontainers.jdbc.AbstractJDBCDriverTest; import java.util.Arrays; import java.util.EnumSet; -@RunWith(Parameterized.class) -public class DB2JDBCDriverTest extends AbstractJDBCDriverTest { +class DB2JDBCDriverTest extends AbstractJDBCDriverTest { - @Parameterized.Parameters(name = "{index} - {0}") public static Iterable data() { return Arrays.asList( new Object[][] { // diff --git a/modules/db2/src/test/java/org/testcontainers/junit/db2/SimpleDb2Test.java b/modules/db2/src/test/java/org/testcontainers/junit/db2/SimpleDb2Test.java index 5f8763b1e19..95222330e09 100644 --- a/modules/db2/src/test/java/org/testcontainers/junit/db2/SimpleDb2Test.java +++ b/modules/db2/src/test/java/org/testcontainers/junit/db2/SimpleDb2Test.java @@ -1,6 +1,6 @@ package org.testcontainers.junit.db2; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.testcontainers.Db2TestImages; import org.testcontainers.containers.Db2Container; import org.testcontainers.db.AbstractContainerDatabaseTest; @@ -10,10 +10,10 @@ import static org.assertj.core.api.Assertions.assertThat; -public class SimpleDb2Test extends AbstractContainerDatabaseTest { +class SimpleDb2Test extends AbstractContainerDatabaseTest { @Test - public void testSimple() throws SQLException { + void testSimple() throws SQLException { try ( // container { Db2Container db2 = new Db2Container("ibmcom/db2:11.5.0.0a").acceptLicense() // } @@ -29,7 +29,7 @@ public void testSimple() throws SQLException { } @Test - public void testSimpleWithNewImage() throws SQLException { + void testSimpleWithNewImage() throws SQLException { try (Db2Container db2 = new Db2Container("icr.io/db2_community/db2:11.5.8.0").acceptLicense()) { db2.start(); @@ -42,7 +42,7 @@ public void testSimpleWithNewImage() throws SQLException { } @Test - public void testWithAdditionalUrlParamInJdbcUrl() { + void testWithAdditionalUrlParamInJdbcUrl() { try ( Db2Container db2 = new Db2Container(Db2TestImages.DB2_IMAGE) .withUrlParam("sslConnection", "false") From 2f61104fe7383bc8356d403a164357dbf26cede7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Thu, 11 Sep 2025 10:26:27 -0600 Subject: [PATCH 08/20] Move MariaDB tests to JUnit Jupiter --- modules/mariadb/build.gradle | 7 +++++++ .../jdbc/mariadb/MariaDBJDBCDriverTest.java | 6 +----- .../junit/mariadb/SimpleMariaDBTest.java | 18 +++++++++--------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/modules/mariadb/build.gradle b/modules/mariadb/build.gradle index d68f122f4dc..2bb703099aa 100644 --- a/modules/mariadb/build.gradle +++ b/modules/mariadb/build.gradle @@ -6,6 +6,9 @@ dependencies { compileOnly project(':testcontainers-r2dbc') compileOnly 'org.mariadb:r2dbc-mariadb:1.0.3' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.0' + + testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4' testImplementation project(':testcontainers-jdbc-test') testImplementation 'org.mariadb.jdbc:mariadb-java-client:3.5.5' @@ -18,3 +21,7 @@ tasks.japicmp { "org.testcontainers.containers.MariaDBContainer" ] } + +test { + useJUnitPlatform() +} diff --git a/modules/mariadb/src/test/java/org/testcontainers/jdbc/mariadb/MariaDBJDBCDriverTest.java b/modules/mariadb/src/test/java/org/testcontainers/jdbc/mariadb/MariaDBJDBCDriverTest.java index 9d903ab3965..5d3b799f0ff 100644 --- a/modules/mariadb/src/test/java/org/testcontainers/jdbc/mariadb/MariaDBJDBCDriverTest.java +++ b/modules/mariadb/src/test/java/org/testcontainers/jdbc/mariadb/MariaDBJDBCDriverTest.java @@ -1,16 +1,12 @@ package org.testcontainers.jdbc.mariadb; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.testcontainers.jdbc.AbstractJDBCDriverTest; import java.util.Arrays; import java.util.EnumSet; -@RunWith(Parameterized.class) -public class MariaDBJDBCDriverTest extends AbstractJDBCDriverTest { +class MariaDBJDBCDriverTest extends AbstractJDBCDriverTest { - @Parameterized.Parameters(name = "{index} - {0}") public static Iterable data() { return Arrays.asList( new Object[][] { diff --git a/modules/mariadb/src/test/java/org/testcontainers/junit/mariadb/SimpleMariaDBTest.java b/modules/mariadb/src/test/java/org/testcontainers/junit/mariadb/SimpleMariaDBTest.java index 2651615928c..9b7fab4daaf 100644 --- a/modules/mariadb/src/test/java/org/testcontainers/junit/mariadb/SimpleMariaDBTest.java +++ b/modules/mariadb/src/test/java/org/testcontainers/junit/mariadb/SimpleMariaDBTest.java @@ -1,7 +1,7 @@ package org.testcontainers.junit.mariadb; import org.apache.commons.lang3.SystemUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.testcontainers.MariaDBTestImages; import org.testcontainers.containers.MariaDBContainer; import org.testcontainers.db.AbstractContainerDatabaseTest; @@ -21,10 +21,10 @@ import static org.assertj.core.api.Assumptions.assumeThat; import static org.junit.Assume.assumeFalse; -public class SimpleMariaDBTest extends AbstractContainerDatabaseTest { +class SimpleMariaDBTest extends AbstractContainerDatabaseTest { @Test - public void testSimple() throws SQLException { + void testSimple() throws SQLException { try ( // container { MariaDBContainer mariadb = new MariaDBContainer<>("mariadb:10.3.39") // } @@ -39,7 +39,7 @@ public void testSimple() throws SQLException { } @Test - public void testSpecificVersion() throws SQLException { + void testSpecificVersion() throws SQLException { try ( MariaDBContainer mariadbOldVersion = new MariaDBContainer<>( MariaDBTestImages.MARIADB_IMAGE.withTag("10.3.39") @@ -57,7 +57,7 @@ public void testSpecificVersion() throws SQLException { } @Test - public void testMariaDBWithCustomIniFile() throws SQLException { + void testMariaDBWithCustomIniFile() throws SQLException { assumeFalse(SystemUtils.IS_OS_WINDOWS); try ( @@ -73,7 +73,7 @@ public void testMariaDBWithCustomIniFile() throws SQLException { } @Test - public void testMariaDBWithCommandOverride() throws SQLException { + void testMariaDBWithCommandOverride() throws SQLException { try ( MariaDBContainer mariadbCustomConfig = new MariaDBContainer<>(MariaDBTestImages.MARIADB_IMAGE) .withCommand("mysqld --auto_increment_increment=10") @@ -87,7 +87,7 @@ public void testMariaDBWithCommandOverride() throws SQLException { } @Test - public void testWithAdditionalUrlParamInJdbcUrl() { + void testWithAdditionalUrlParamInJdbcUrl() { MariaDBContainer mariaDBContainer = new MariaDBContainer<>(MariaDBTestImages.MARIADB_IMAGE) .withUrlParam("connectTimeout", "40000") .withUrlParam("rewriteBatchedStatements", "true"); @@ -105,7 +105,7 @@ public void testWithAdditionalUrlParamInJdbcUrl() { } @Test - public void testWithOnlyUserReadableCustomIniFile() throws Exception { + void testWithOnlyUserReadableCustomIniFile() throws Exception { assumeThat(FileSystems.getDefault().supportedFileAttributeViews().contains("posix")).isTrue(); try ( @@ -136,7 +136,7 @@ public void testWithOnlyUserReadableCustomIniFile() throws Exception { } @Test - public void testEmptyPasswordWithRootUser() throws SQLException { + void testEmptyPasswordWithRootUser() throws SQLException { try (MariaDBContainer mysql = new MariaDBContainer<>("mariadb:11.2.4").withUsername("root")) { mysql.start(); From a107b395422e5f267fab6b74ea0508c23878068f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Thu, 11 Sep 2025 10:26:46 -0600 Subject: [PATCH 09/20] Move MSSQL Server tests to JUnit Jupiter --- modules/mssqlserver/build.gradle | 7 ++ .../MSSQLServerJDBCDriverTest.java | 6 +- .../CustomPasswordMSSQLServerTest.java | 73 ++++++++----------- .../CustomizableMSSQLServerTest.java | 6 +- .../mssqlserver/SimpleMSSQLServerTest.java | 10 +-- 5 files changed, 46 insertions(+), 56 deletions(-) diff --git a/modules/mssqlserver/build.gradle b/modules/mssqlserver/build.gradle index 3ba79559b58..da8318ffa84 100644 --- a/modules/mssqlserver/build.gradle +++ b/modules/mssqlserver/build.gradle @@ -6,6 +6,9 @@ dependencies { compileOnly project(':testcontainers-r2dbc') compileOnly 'io.r2dbc:r2dbc-mssql:1.0.2.RELEASE' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.0' + + testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4' testImplementation project(':testcontainers-jdbc-test') testImplementation 'com.microsoft.sqlserver:mssql-jdbc:13.2.0.jre8' @@ -21,3 +24,7 @@ tasks.japicmp { "org.testcontainers.containers.MSSQLServerContainer" ] } + +test { + useJUnitPlatform() +} diff --git a/modules/mssqlserver/src/test/java/org/testcontainers/jdbc/mssqlserver/MSSQLServerJDBCDriverTest.java b/modules/mssqlserver/src/test/java/org/testcontainers/jdbc/mssqlserver/MSSQLServerJDBCDriverTest.java index 4ed4db9e8ab..9f616ab10f8 100644 --- a/modules/mssqlserver/src/test/java/org/testcontainers/jdbc/mssqlserver/MSSQLServerJDBCDriverTest.java +++ b/modules/mssqlserver/src/test/java/org/testcontainers/jdbc/mssqlserver/MSSQLServerJDBCDriverTest.java @@ -1,16 +1,12 @@ package org.testcontainers.jdbc.mssqlserver; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.testcontainers.jdbc.AbstractJDBCDriverTest; import java.util.Arrays; import java.util.EnumSet; -@RunWith(Parameterized.class) -public class MSSQLServerJDBCDriverTest extends AbstractJDBCDriverTest { +class MSSQLServerJDBCDriverTest extends AbstractJDBCDriverTest { - @Parameterized.Parameters(name = "{index} - {0}") public static Iterable data() { return Arrays.asList( new Object[][] { diff --git a/modules/mssqlserver/src/test/java/org/testcontainers/junit/mssqlserver/CustomPasswordMSSQLServerTest.java b/modules/mssqlserver/src/test/java/org/testcontainers/junit/mssqlserver/CustomPasswordMSSQLServerTest.java index 27075d6a3fe..06aa1dc4a61 100644 --- a/modules/mssqlserver/src/test/java/org/testcontainers/junit/mssqlserver/CustomPasswordMSSQLServerTest.java +++ b/modules/mssqlserver/src/test/java/org/testcontainers/junit/mssqlserver/CustomPasswordMSSQLServerTest.java @@ -1,14 +1,13 @@ package org.testcontainers.junit.mssqlserver; import org.apache.commons.lang3.RandomStringUtils; -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.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.testcontainers.MSSQLServerTestImages; import org.testcontainers.containers.MSSQLServerContainer; -import java.util.Arrays; -import java.util.Collection; +import java.util.stream.Stream; import static org.assertj.core.api.Assertions.fail; @@ -16,7 +15,6 @@ * Tests if the password passed to the container satisfied the password policy described at * https://docs.microsoft.com/en-us/sql/relational-databases/security/password-policy?view=sql-server-2017 */ -@RunWith(Parameterized.class) public class CustomPasswordMSSQLServerTest { private static String UPPER_CASE_LETTERS = "ABCDE"; @@ -27,51 +25,40 @@ public class CustomPasswordMSSQLServerTest { private static String SPECIAL_CHARS = "_(!)_"; - private String password; - - private Boolean valid; - - public CustomPasswordMSSQLServerTest(String password, Boolean valid) { - this.password = password; - this.valid = valid; - } - - @Parameterized.Parameters - public static Collection data() { - return Arrays.asList( - new Object[][] { - new Object[] { null, false }, - // too short - { "abc123", false }, - // too long - { RandomStringUtils.randomAlphabetic(129), false }, - // only 2 categories - { UPPER_CASE_LETTERS + NUMBERS, false }, - { UPPER_CASE_LETTERS + SPECIAL_CHARS, false }, - { LOWER_CASE_LETTERS + NUMBERS, false }, - { LOWER_CASE_LETTERS + SPECIAL_CHARS, false }, - { NUMBERS + SPECIAL_CHARS, false }, - // 3 categories - { UPPER_CASE_LETTERS + LOWER_CASE_LETTERS + NUMBERS, true }, - { UPPER_CASE_LETTERS + LOWER_CASE_LETTERS + SPECIAL_CHARS, true }, - { UPPER_CASE_LETTERS + NUMBERS + SPECIAL_CHARS, true }, - { LOWER_CASE_LETTERS + NUMBERS + SPECIAL_CHARS, true }, - // 4 categories - { UPPER_CASE_LETTERS + LOWER_CASE_LETTERS + NUMBERS + SPECIAL_CHARS, true }, - } + public static Stream data() { + return Stream.of( + Arguments.arguments(null, false), + // too short + Arguments.arguments("abc123", false), + // too long + Arguments.arguments(RandomStringUtils.randomAlphabetic(129), false), + // only 2 categories + Arguments.arguments(UPPER_CASE_LETTERS + NUMBERS, false), + Arguments.arguments(UPPER_CASE_LETTERS + SPECIAL_CHARS, false), + Arguments.arguments(LOWER_CASE_LETTERS + NUMBERS, false), + Arguments.arguments(LOWER_CASE_LETTERS + SPECIAL_CHARS, false), + Arguments.arguments(NUMBERS + SPECIAL_CHARS, false), + // 3 categories + Arguments.arguments(UPPER_CASE_LETTERS + LOWER_CASE_LETTERS + NUMBERS, true), + Arguments.arguments(UPPER_CASE_LETTERS + LOWER_CASE_LETTERS + SPECIAL_CHARS, true), + Arguments.arguments(UPPER_CASE_LETTERS + NUMBERS + SPECIAL_CHARS, true), + Arguments.arguments(LOWER_CASE_LETTERS + NUMBERS + SPECIAL_CHARS, true), + // 4 categories + Arguments.arguments(UPPER_CASE_LETTERS + LOWER_CASE_LETTERS + NUMBERS + SPECIAL_CHARS, true) ); } - @Test - public void runPasswordTests() { + @ParameterizedTest + @MethodSource("data") + public void runPasswordTests(String password, boolean valid) { try { - new MSSQLServerContainer<>(MSSQLServerTestImages.MSSQL_SERVER_IMAGE).withPassword(this.password); + new MSSQLServerContainer<>(MSSQLServerTestImages.MSSQL_SERVER_IMAGE).withPassword(password); if (!valid) { - fail("Password " + this.password + " is not valid. Expected exception"); + fail("Password " + password + " is not valid. Expected exception"); } } catch (IllegalArgumentException e) { if (valid) { - fail("Password " + this.password + " should have been validated"); + fail("Password " + password + " should have been validated"); } } } diff --git a/modules/mssqlserver/src/test/java/org/testcontainers/junit/mssqlserver/CustomizableMSSQLServerTest.java b/modules/mssqlserver/src/test/java/org/testcontainers/junit/mssqlserver/CustomizableMSSQLServerTest.java index 03e0affa00c..630b6c5356c 100644 --- a/modules/mssqlserver/src/test/java/org/testcontainers/junit/mssqlserver/CustomizableMSSQLServerTest.java +++ b/modules/mssqlserver/src/test/java/org/testcontainers/junit/mssqlserver/CustomizableMSSQLServerTest.java @@ -1,6 +1,6 @@ package org.testcontainers.junit.mssqlserver; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.testcontainers.containers.MSSQLServerContainer; import org.testcontainers.db.AbstractContainerDatabaseTest; import org.testcontainers.utility.DockerImageName; @@ -10,12 +10,12 @@ import static org.assertj.core.api.Assertions.assertThat; -public class CustomizableMSSQLServerTest extends AbstractContainerDatabaseTest { +class CustomizableMSSQLServerTest extends AbstractContainerDatabaseTest { private static final String STRONG_PASSWORD = "myStrong(!)Password"; @Test - public void testSqlServerConnection() throws SQLException { + void testSqlServerConnection() throws SQLException { try ( MSSQLServerContainer mssqlServerContainer = new MSSQLServerContainer<>( DockerImageName.parse("mcr.microsoft.com/mssql/server:2022-CU14-ubuntu-22.04") diff --git a/modules/mssqlserver/src/test/java/org/testcontainers/junit/mssqlserver/SimpleMSSQLServerTest.java b/modules/mssqlserver/src/test/java/org/testcontainers/junit/mssqlserver/SimpleMSSQLServerTest.java index 943eff30a53..0d995911893 100644 --- a/modules/mssqlserver/src/test/java/org/testcontainers/junit/mssqlserver/SimpleMSSQLServerTest.java +++ b/modules/mssqlserver/src/test/java/org/testcontainers/junit/mssqlserver/SimpleMSSQLServerTest.java @@ -1,6 +1,6 @@ package org.testcontainers.junit.mssqlserver; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.testcontainers.MSSQLServerTestImages; import org.testcontainers.containers.MSSQLServerContainer; import org.testcontainers.db.AbstractContainerDatabaseTest; @@ -13,10 +13,10 @@ import static org.assertj.core.api.Assertions.assertThat; -public class SimpleMSSQLServerTest extends AbstractContainerDatabaseTest { +class SimpleMSSQLServerTest extends AbstractContainerDatabaseTest { @Test - public void testSimple() throws SQLException { + void testSimple() throws SQLException { try ( // container { MSSQLServerContainer mssqlServer = new MSSQLServerContainer<>( "mcr.microsoft.com/mssql/server:2022-CU20-ubuntu-22.04" @@ -34,7 +34,7 @@ public void testSimple() throws SQLException { } @Test - public void testWithAdditionalUrlParamInJdbcUrl() { + void testWithAdditionalUrlParamInJdbcUrl() { try ( MSSQLServerContainer mssqlServer = new MSSQLServerContainer<>(MSSQLServerTestImages.MSSQL_SERVER_IMAGE) .withUrlParam("integratedSecurity", "false") @@ -48,7 +48,7 @@ public void testWithAdditionalUrlParamInJdbcUrl() { } @Test - public void testSetupDatabase() throws SQLException { + void testSetupDatabase() throws SQLException { try ( MSSQLServerContainer mssqlServer = new MSSQLServerContainer<>(MSSQLServerTestImages.MSSQL_SERVER_IMAGE) ) { From e5acbeb3f9d75e84067e5be3078c7ef087bfdfae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Thu, 11 Sep 2025 10:27:01 -0600 Subject: [PATCH 10/20] Move MySQL tests to JUnit Jupiter --- modules/mysql/build.gradle | 7 ++++ .../containers/MySQLRootAccountTest.java | 27 +++++++------- .../jdbc/mysql/JDBCDriverWithPoolTest.java | 18 +++++----- .../MySQLDatabaseContainerDriverTest.java | 6 ++-- .../jdbc/mysql/MySQLJDBCDriverTest.java | 6 +--- .../junit/mysql/CustomizableMysqlTest.java | 6 ++-- .../junit/mysql/MultiVersionMySQLTest.java | 17 ++++----- .../junit/mysql/SimpleMySQLTest.java | 35 ++++++++++--------- 8 files changed, 59 insertions(+), 63 deletions(-) diff --git a/modules/mysql/build.gradle b/modules/mysql/build.gradle index ddacc0fdc50..32573799f70 100644 --- a/modules/mysql/build.gradle +++ b/modules/mysql/build.gradle @@ -6,6 +6,9 @@ dependencies { compileOnly project(':testcontainers-r2dbc') compileOnly 'io.asyncer:r2dbc-mysql:1.4.1' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.0' + + testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4' testImplementation project(':testcontainers-jdbc-test') testRuntimeOnly 'mysql:mysql-connector-java:8.0.33' @@ -20,3 +23,7 @@ tasks.japicmp { "org.testcontainers.containers.MySQLContainer" ] } + +test { + useJUnitPlatform() +} diff --git a/modules/mysql/src/test/java/org/testcontainers/containers/MySQLRootAccountTest.java b/modules/mysql/src/test/java/org/testcontainers/containers/MySQLRootAccountTest.java index e9a3c862143..a8737c4c74f 100644 --- a/modules/mysql/src/test/java/org/testcontainers/containers/MySQLRootAccountTest.java +++ b/modules/mysql/src/test/java/org/testcontainers/containers/MySQLRootAccountTest.java @@ -1,9 +1,8 @@ package org.testcontainers.containers; import lombok.extern.slf4j.Slf4j; -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.MySQLTestImages; import org.testcontainers.containers.output.Slf4jLogConsumer; import org.testcontainers.utility.DockerImageName; @@ -13,10 +12,8 @@ import java.sql.SQLException; @Slf4j -@RunWith(Parameterized.class) -public class MySQLRootAccountTest { +class MySQLRootAccountTest { - @Parameterized.Parameters(name = "{0}") public static DockerImageName[] params() { return new DockerImageName[] { MySQLTestImages.MYSQL_57_IMAGE, @@ -26,21 +23,21 @@ public static DockerImageName[] params() { }; } - @Parameterized.Parameter - public DockerImageName image; - - @Test - public void testRootAccountUsageWithDefaultPassword() throws SQLException { + @ParameterizedTest + @MethodSource("params") + void testRootAccountUsageWithDefaultPassword(DockerImageName image) throws SQLException { testWithDB(new MySQLContainer<>(image).withUsername("root")); } - @Test - public void testRootAccountUsageWithEmptyPassword() throws SQLException { + @ParameterizedTest + @MethodSource("params") + void testRootAccountUsageWithEmptyPassword(DockerImageName image) throws SQLException { testWithDB(new MySQLContainer<>(image).withUsername("root").withPassword("")); } - @Test - public void testRootAccountUsageWithCustomPassword() throws SQLException { + @ParameterizedTest + @MethodSource("params") + void testRootAccountUsageWithCustomPassword(DockerImageName image) throws SQLException { testWithDB(new MySQLContainer<>(image).withUsername("root").withPassword("not-default")); } diff --git a/modules/mysql/src/test/java/org/testcontainers/jdbc/mysql/JDBCDriverWithPoolTest.java b/modules/mysql/src/test/java/org/testcontainers/jdbc/mysql/JDBCDriverWithPoolTest.java index be48f623183..0075b2ebf7f 100644 --- a/modules/mysql/src/test/java/org/testcontainers/jdbc/mysql/JDBCDriverWithPoolTest.java +++ b/modules/mysql/src/test/java/org/testcontainers/jdbc/mysql/JDBCDriverWithPoolTest.java @@ -5,19 +5,19 @@ import org.apache.commons.dbutils.QueryRunner; import org.apache.commons.dbutils.ResultSetHandler; import org.apache.tomcat.jdbc.pool.PoolProperties; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.testcontainers.jdbc.ContainerDatabaseDriver; import org.vibur.dbcp.ViburDBCPDataSource; import java.sql.Connection; import java.sql.SQLException; -import java.util.Arrays; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.function.Supplier; +import java.util.stream.Stream; import javax.sql.DataSource; @@ -29,7 +29,8 @@ * the mysql module, to avoid circular dependencies. * TODO: Move to the jdbc module and either (a) implement a barebones {@link org.testcontainers.containers.JdbcDatabaseContainerProvider} for testing, or (b) refactor into a unit test. */ -@RunWith(Parameterized.class) +@ParameterizedClass +@MethodSource("dataSourceSuppliers") public class JDBCDriverWithPoolTest { public static final String URL = @@ -37,9 +38,8 @@ public class JDBCDriverWithPoolTest { private final DataSource dataSource; - @Parameterized.Parameters - public static Iterable> dataSourceSuppliers() { - return Arrays.asList( + public static Stream> dataSourceSuppliers() { + return Stream.of( JDBCDriverWithPoolTest::getTomcatDataSourceWithDriverClassName, JDBCDriverWithPoolTest::getTomcatDataSource, JDBCDriverWithPoolTest::getHikariDataSourceWithDriverClassName, @@ -56,7 +56,7 @@ public JDBCDriverWithPoolTest(Supplier dataSourceSupplier) { private ExecutorService executorService = Executors.newFixedThreadPool(5); @Test - public void testMySQLWithConnectionPoolUsingSameContainer() throws SQLException, InterruptedException { + void testMySQLWithConnectionPoolUsingSameContainer() throws SQLException, InterruptedException { // Populate the database with some data in multiple threads, so that multiple connections from the pool will be used for (int i = 0; i < 100; i++) { executorService.submit(() -> { diff --git a/modules/mysql/src/test/java/org/testcontainers/jdbc/mysql/MySQLDatabaseContainerDriverTest.java b/modules/mysql/src/test/java/org/testcontainers/jdbc/mysql/MySQLDatabaseContainerDriverTest.java index 7f5cf5eae1d..da73f21ae2e 100644 --- a/modules/mysql/src/test/java/org/testcontainers/jdbc/mysql/MySQLDatabaseContainerDriverTest.java +++ b/modules/mysql/src/test/java/org/testcontainers/jdbc/mysql/MySQLDatabaseContainerDriverTest.java @@ -1,6 +1,6 @@ package org.testcontainers.jdbc.mysql; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.testcontainers.jdbc.ContainerDatabaseDriver; import java.sql.Connection; @@ -11,10 +11,10 @@ import static org.assertj.core.api.Assertions.assertThat; -public class MySQLDatabaseContainerDriverTest { +class MySQLDatabaseContainerDriverTest { @Test - public void shouldRespectBothUrlPropertiesAndParameterProperties() throws SQLException { + void shouldRespectBothUrlPropertiesAndParameterProperties() throws SQLException { ContainerDatabaseDriver driver = new ContainerDatabaseDriver(); String url = "jdbc:tc:mysql:8.0.36://hostname/databasename?padCharsWithSpace=true"; Properties properties = new Properties(); diff --git a/modules/mysql/src/test/java/org/testcontainers/jdbc/mysql/MySQLJDBCDriverTest.java b/modules/mysql/src/test/java/org/testcontainers/jdbc/mysql/MySQLJDBCDriverTest.java index 526c2ab522c..b069e5fd0c8 100644 --- a/modules/mysql/src/test/java/org/testcontainers/jdbc/mysql/MySQLJDBCDriverTest.java +++ b/modules/mysql/src/test/java/org/testcontainers/jdbc/mysql/MySQLJDBCDriverTest.java @@ -1,16 +1,12 @@ package org.testcontainers.jdbc.mysql; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.testcontainers.jdbc.AbstractJDBCDriverTest; import java.util.Arrays; import java.util.EnumSet; -@RunWith(Parameterized.class) -public class MySQLJDBCDriverTest extends AbstractJDBCDriverTest { +class MySQLJDBCDriverTest extends AbstractJDBCDriverTest { - @Parameterized.Parameters(name = "{index} - {0}") public static Iterable data() { return Arrays.asList( new Object[][] { diff --git a/modules/mysql/src/test/java/org/testcontainers/junit/mysql/CustomizableMysqlTest.java b/modules/mysql/src/test/java/org/testcontainers/junit/mysql/CustomizableMysqlTest.java index e756631d8e1..9e9d97dc54e 100644 --- a/modules/mysql/src/test/java/org/testcontainers/junit/mysql/CustomizableMysqlTest.java +++ b/modules/mysql/src/test/java/org/testcontainers/junit/mysql/CustomizableMysqlTest.java @@ -1,6 +1,6 @@ package org.testcontainers.junit.mysql; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.testcontainers.MySQLTestImages; import org.testcontainers.containers.MySQLContainer; import org.testcontainers.db.AbstractContainerDatabaseTest; @@ -10,7 +10,7 @@ import static org.assertj.core.api.Assertions.assertThat; -public class CustomizableMysqlTest extends AbstractContainerDatabaseTest { +class CustomizableMysqlTest extends AbstractContainerDatabaseTest { private static final String DB_NAME = "foo"; @@ -19,7 +19,7 @@ public class CustomizableMysqlTest extends AbstractContainerDatabaseTest { private static final String PWD = "baz"; @Test - public void testSimple() throws SQLException { + void testSimple() throws SQLException { // Add MYSQL_ROOT_HOST environment so that we can root login from anywhere for testing purposes try ( MySQLContainer mysql = new MySQLContainer<>(MySQLTestImages.MYSQL_80_IMAGE) diff --git a/modules/mysql/src/test/java/org/testcontainers/junit/mysql/MultiVersionMySQLTest.java b/modules/mysql/src/test/java/org/testcontainers/junit/mysql/MultiVersionMySQLTest.java index 25085289ba7..d8e8b52dc56 100644 --- a/modules/mysql/src/test/java/org/testcontainers/junit/mysql/MultiVersionMySQLTest.java +++ b/modules/mysql/src/test/java/org/testcontainers/junit/mysql/MultiVersionMySQLTest.java @@ -1,8 +1,7 @@ package org.testcontainers.junit.mysql; -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.MySQLTestImages; import org.testcontainers.containers.MySQLContainer; import org.testcontainers.db.AbstractContainerDatabaseTest; @@ -13,10 +12,8 @@ import static org.assertj.core.api.Assertions.assertThat; -@RunWith(Parameterized.class) -public class MultiVersionMySQLTest extends AbstractContainerDatabaseTest { +class MultiVersionMySQLTest extends AbstractContainerDatabaseTest { - @Parameterized.Parameters(name = "{0}") public static DockerImageName[] params() { return new DockerImageName[] { MySQLTestImages.MYSQL_57_IMAGE, @@ -26,11 +23,9 @@ public static DockerImageName[] params() { }; } - @Parameterized.Parameter - public DockerImageName dockerImageName; - - @Test - public void versionCheckTest() throws SQLException { + @ParameterizedTest + @MethodSource("params") + void versionCheckTest(DockerImageName dockerImageName) throws SQLException { try (MySQLContainer mysql = new MySQLContainer<>(dockerImageName)) { mysql.start(); final ResultSet resultSet = performQuery(mysql, "SELECT VERSION()"); diff --git a/modules/mysql/src/test/java/org/testcontainers/junit/mysql/SimpleMySQLTest.java b/modules/mysql/src/test/java/org/testcontainers/junit/mysql/SimpleMySQLTest.java index 085fdf074cb..b3eac503c57 100644 --- a/modules/mysql/src/test/java/org/testcontainers/junit/mysql/SimpleMySQLTest.java +++ b/modules/mysql/src/test/java/org/testcontainers/junit/mysql/SimpleMySQLTest.java @@ -1,6 +1,6 @@ package org.testcontainers.junit.mysql; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testcontainers.MySQLTestImages; @@ -27,15 +27,15 @@ import java.util.Set; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assumptions.assumeThat; -public class SimpleMySQLTest extends AbstractContainerDatabaseTest { +class SimpleMySQLTest extends AbstractContainerDatabaseTest { private static final Logger logger = LoggerFactory.getLogger(SimpleMySQLTest.class); @Test - public void testSimple() throws SQLException { + void testSimple() throws SQLException { try ( // container { MySQLContainer mysql = new MySQLContainer<>("mysql:8.0.36") // } @@ -51,7 +51,7 @@ public void testSimple() throws SQLException { } @Test - public void testSpecificVersion() throws SQLException { + void testSpecificVersion() throws SQLException { try ( MySQLContainer mysqlOldVersion = new MySQLContainer<>(MySQLTestImages.MYSQL_80_IMAGE) .withConfigurationOverride("somepath/mysql_conf_override") @@ -69,7 +69,7 @@ public void testSpecificVersion() throws SQLException { } @Test - public void testMySQLWithCustomIniFile() throws SQLException { + void testMySQLWithCustomIniFile() throws SQLException { try ( MySQLContainer mysqlCustomConfig = new MySQLContainer<>(MySQLTestImages.MYSQL_80_IMAGE) .withConfigurationOverride("somepath/mysql_conf_override") @@ -81,7 +81,7 @@ public void testMySQLWithCustomIniFile() throws SQLException { } @Test - public void testCommandOverride() throws SQLException { + void testCommandOverride() throws SQLException { try ( MySQLContainer mysqlCustomConfig = new MySQLContainer<>(MySQLTestImages.MYSQL_80_IMAGE) .withCommand("mysqld --auto_increment_increment=42") @@ -96,7 +96,7 @@ public void testCommandOverride() throws SQLException { } @Test - public void testExplicitInitScript() throws SQLException { + void testExplicitInitScript() throws SQLException { try ( MySQLContainer container = new MySQLContainer<>(MySQLTestImages.MYSQL_80_IMAGE) .withInitScript("somepath/init_mysql.sql") @@ -111,8 +111,8 @@ public void testExplicitInitScript() throws SQLException { } } - @Test(expected = ContainerLaunchException.class) - public void testEmptyPasswordWithNonRootUser() { + @Test + void testEmptyPasswordWithNonRootUser() { try ( MySQLContainer container = new MySQLContainer<>(MySQLTestImages.MYSQL_80_IMAGE) .withDatabaseName("TEST") @@ -120,13 +120,14 @@ public void testEmptyPasswordWithNonRootUser() { .withPassword("") .withEnv("MYSQL_ROOT_HOST", "%") ) { - container.start(); - fail("ContainerLaunchException expected to be thrown"); + assertThatThrownBy(container::start) + .isInstanceOf(ContainerLaunchException.class) + .hasMessageStartingWith("Container startup failed for image mysql"); } } @Test - public void testEmptyPasswordWithRootUser() throws SQLException { + void testEmptyPasswordWithRootUser() throws SQLException { // Add MYSQL_ROOT_HOST environment so that we can root login from anywhere for testing purposes try ( MySQLContainer mysql = new MySQLContainer<>(MySQLTestImages.MYSQL_80_IMAGE) @@ -145,7 +146,7 @@ public void testEmptyPasswordWithRootUser() throws SQLException { } @Test - public void testWithAdditionalUrlParamTimeZone() throws SQLException { + void testWithAdditionalUrlParamTimeZone() throws SQLException { MySQLContainer mysql = new MySQLContainer<>(MySQLTestImages.MYSQL_80_IMAGE) .withUrlParam("serverTimezone", "Europe/Zurich") .withEnv("TZ", "Europe/Zurich") @@ -180,7 +181,7 @@ public void testWithAdditionalUrlParamTimeZone() throws SQLException { } @Test - public void testWithAdditionalUrlParamMultiQueries() throws SQLException { + void testWithAdditionalUrlParamMultiQueries() throws SQLException { MySQLContainer mysql = new MySQLContainer<>(MySQLTestImages.MYSQL_80_IMAGE) .withUrlParam("allowMultiQueries", "true") .withLogConsumer(new Slf4jLogConsumer(logger)); @@ -205,7 +206,7 @@ public void testWithAdditionalUrlParamMultiQueries() throws SQLException { } @Test - public void testWithAdditionalUrlParamInJdbcUrl() { + void testWithAdditionalUrlParamInJdbcUrl() { MySQLContainer mysql = new MySQLContainer<>(MySQLTestImages.MYSQL_80_IMAGE) .withUrlParam("allowMultiQueries", "true") .withUrlParam("rewriteBatchedStatements", "true") @@ -224,7 +225,7 @@ public void testWithAdditionalUrlParamInJdbcUrl() { } @Test - public void testWithOnlyUserReadableCustomIniFile() throws Exception { + void testWithOnlyUserReadableCustomIniFile() throws Exception { assumeThat(FileSystems.getDefault().supportedFileAttributeViews().contains("posix")).isTrue(); try ( MySQLContainer mysql = new MySQLContainer<>(MySQLTestImages.MYSQL_80_IMAGE) From 7351b678c4899dcc96040be040540ef9ae803034 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Thu, 11 Sep 2025 10:27:35 -0600 Subject: [PATCH 11/20] Move OceanBase tests to JUnit Jupiter --- modules/oceanbase/build.gradle | 7 +++++++ .../oceanbase/OceanBaseJdbcDriverTest.java | 6 +----- .../oceanbase/SimpleOceanBaseCETest.java | 10 +++++----- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/modules/oceanbase/build.gradle b/modules/oceanbase/build.gradle index d4278ddc0bc..c577c65b260 100644 --- a/modules/oceanbase/build.gradle +++ b/modules/oceanbase/build.gradle @@ -3,6 +3,13 @@ description = "Testcontainers :: JDBC :: OceanBase" dependencies { api project(':testcontainers-jdbc') + testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.0' + + testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4' testImplementation project(':testcontainers-jdbc-test') testRuntimeOnly 'mysql:mysql-connector-java:8.0.33' } + +test { + useJUnitPlatform() +} diff --git a/modules/oceanbase/src/test/java/org/testcontainers/oceanbase/OceanBaseJdbcDriverTest.java b/modules/oceanbase/src/test/java/org/testcontainers/oceanbase/OceanBaseJdbcDriverTest.java index a4f63b1eb90..b701d953e9a 100644 --- a/modules/oceanbase/src/test/java/org/testcontainers/oceanbase/OceanBaseJdbcDriverTest.java +++ b/modules/oceanbase/src/test/java/org/testcontainers/oceanbase/OceanBaseJdbcDriverTest.java @@ -1,16 +1,12 @@ package org.testcontainers.oceanbase; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.testcontainers.jdbc.AbstractJDBCDriverTest; import java.util.Arrays; import java.util.EnumSet; -@RunWith(Parameterized.class) -public class OceanBaseJdbcDriverTest extends AbstractJDBCDriverTest { +class OceanBaseJdbcDriverTest extends AbstractJDBCDriverTest { - @Parameterized.Parameters(name = "{index} - {0}") public static Iterable data() { return Arrays.asList( new Object[][] { { "jdbc:tc:oceanbasece://hostname/databasename", EnumSet.noneOf(Options.class) } } diff --git a/modules/oceanbase/src/test/java/org/testcontainers/oceanbase/SimpleOceanBaseCETest.java b/modules/oceanbase/src/test/java/org/testcontainers/oceanbase/SimpleOceanBaseCETest.java index 46619f328be..ee2d8196718 100644 --- a/modules/oceanbase/src/test/java/org/testcontainers/oceanbase/SimpleOceanBaseCETest.java +++ b/modules/oceanbase/src/test/java/org/testcontainers/oceanbase/SimpleOceanBaseCETest.java @@ -1,6 +1,6 @@ package org.testcontainers.oceanbase; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.testcontainers.db.AbstractContainerDatabaseTest; import java.sql.ResultSet; @@ -8,12 +8,12 @@ import static org.assertj.core.api.Assertions.assertThat; -public class SimpleOceanBaseCETest extends AbstractContainerDatabaseTest { +class SimpleOceanBaseCETest extends AbstractContainerDatabaseTest { private static final String IMAGE = "oceanbase/oceanbase-ce:4.2.1.8-108000022024072217"; @Test - public void testSimple() throws SQLException { + void testSimple() throws SQLException { try ( // container { OceanBaseCEContainer oceanbase = new OceanBaseCEContainer( "oceanbase/oceanbase-ce:4.2.1.8-108000022024072217" @@ -30,7 +30,7 @@ public void testSimple() throws SQLException { } @Test - public void testExplicitInitScript() throws SQLException { + void testExplicitInitScript() throws SQLException { try (OceanBaseCEContainer oceanbase = new OceanBaseCEContainer(IMAGE).withInitScript("init.sql")) { oceanbase.start(); @@ -41,7 +41,7 @@ public void testExplicitInitScript() throws SQLException { } @Test - public void testWithAdditionalUrlParamInJdbcUrl() { + void testWithAdditionalUrlParamInJdbcUrl() { try (OceanBaseCEContainer oceanbase = new OceanBaseCEContainer(IMAGE).withUrlParam("useSSL", "false")) { oceanbase.start(); From a5cd4e96cf3d25ae1e5ea2a1141a53a6ab8c12d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Thu, 11 Sep 2025 10:27:50 -0600 Subject: [PATCH 12/20] Move Oracle Free tests to JUnit Jupiter --- modules/oracle-free/build.gradle | 7 +++++++ .../junit/oracle/SimpleOracleTest.java | 18 +++++++++--------- .../oracle/jdbc/OracleJDBCDriverTest.java | 6 +++--- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/modules/oracle-free/build.gradle b/modules/oracle-free/build.gradle index a55c9f26518..3f85086074f 100644 --- a/modules/oracle-free/build.gradle +++ b/modules/oracle-free/build.gradle @@ -6,6 +6,9 @@ dependencies { compileOnly project(':testcontainers-r2dbc') compileOnly 'com.oracle.database.r2dbc:oracle-r2dbc:1.3.0' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.0' + + testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4' testImplementation project(':testcontainers-jdbc-test') testImplementation 'com.oracle.database.jdbc:ojdbc11:23.9.0.25.07' @@ -14,3 +17,7 @@ dependencies { testImplementation testFixtures(project(':testcontainers-r2dbc')) testRuntimeOnly 'com.oracle.database.r2dbc:oracle-r2dbc:1.3.0' } + +test { + useJUnitPlatform() +} diff --git a/modules/oracle-free/src/test/java/org/testcontainers/junit/oracle/SimpleOracleTest.java b/modules/oracle-free/src/test/java/org/testcontainers/junit/oracle/SimpleOracleTest.java index a9c3bce593a..f46539bac89 100644 --- a/modules/oracle-free/src/test/java/org/testcontainers/junit/oracle/SimpleOracleTest.java +++ b/modules/oracle-free/src/test/java/org/testcontainers/junit/oracle/SimpleOracleTest.java @@ -1,6 +1,6 @@ package org.testcontainers.junit.oracle; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.testcontainers.db.AbstractContainerDatabaseTest; import org.testcontainers.oracle.OracleContainer; import org.testcontainers.utility.DockerImageName; @@ -11,7 +11,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -public class SimpleOracleTest extends AbstractContainerDatabaseTest { +class SimpleOracleTest extends AbstractContainerDatabaseTest { private static final DockerImageName ORACLE_DOCKER_IMAGE_NAME = DockerImageName.parse( "gvenzl/oracle-free:slim-faststart" @@ -32,7 +32,7 @@ private void runTest(OracleContainer container, String databaseName, String user } @Test - public void testDefaultSettings() throws SQLException { + void testDefaultSettings() throws SQLException { try ( // container { OracleContainer oracle = new OracleContainer("gvenzl/oracle-free:slim-faststart") // } @@ -46,14 +46,14 @@ public void testDefaultSettings() throws SQLException { } @Test - public void testPluggableDatabase() throws SQLException { + void testPluggableDatabase() throws SQLException { try (OracleContainer oracle = new OracleContainer(ORACLE_DOCKER_IMAGE_NAME).withDatabaseName("testDB")) { runTest(oracle, "testDB", "test", "test"); } } @Test - public void testPluggableDatabaseAndCustomUser() throws SQLException { + void testPluggableDatabaseAndCustomUser() throws SQLException { try ( OracleContainer oracle = new OracleContainer("gvenzl/oracle-free:slim-faststart") .withDatabaseName("testDB") @@ -65,7 +65,7 @@ public void testPluggableDatabaseAndCustomUser() throws SQLException { } @Test - public void testCustomUser() throws SQLException { + void testCustomUser() throws SQLException { try ( OracleContainer oracle = new OracleContainer(ORACLE_DOCKER_IMAGE_NAME) .withUsername("testUser") @@ -76,7 +76,7 @@ public void testCustomUser() throws SQLException { } @Test - public void testSID() throws SQLException { + void testSID() throws SQLException { try (OracleContainer oracle = new OracleContainer(ORACLE_DOCKER_IMAGE_NAME).usingSid()) { runTest(oracle, "freepdb1", "system", "test"); @@ -87,7 +87,7 @@ public void testSID() throws SQLException { } @Test - public void testSIDAndCustomPassword() throws SQLException { + void testSIDAndCustomPassword() throws SQLException { try ( OracleContainer oracle = new OracleContainer(ORACLE_DOCKER_IMAGE_NAME) .usingSid() @@ -98,7 +98,7 @@ public void testSIDAndCustomPassword() throws SQLException { } @Test - public void testErrorPaths() throws SQLException { + void testErrorPaths() throws SQLException { try (OracleContainer oracle = new OracleContainer(ORACLE_DOCKER_IMAGE_NAME)) { try { oracle.withDatabaseName("FREEPDB1"); diff --git a/modules/oracle-free/src/test/java/org/testcontainers/oracle/jdbc/OracleJDBCDriverTest.java b/modules/oracle-free/src/test/java/org/testcontainers/oracle/jdbc/OracleJDBCDriverTest.java index 6f6157c61c8..a4982e966c1 100644 --- a/modules/oracle-free/src/test/java/org/testcontainers/oracle/jdbc/OracleJDBCDriverTest.java +++ b/modules/oracle-free/src/test/java/org/testcontainers/oracle/jdbc/OracleJDBCDriverTest.java @@ -4,17 +4,17 @@ import com.zaxxer.hikari.HikariDataSource; import org.apache.commons.dbutils.QueryRunner; import org.apache.commons.dbutils.ResultSetHandler; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.sql.ResultSet; import java.sql.SQLException; import static org.assertj.core.api.Assertions.assertThat; -public class OracleJDBCDriverTest { +class OracleJDBCDriverTest { @Test - public void testOracleWithNoSpecifiedVersion() throws SQLException { + void testOracleWithNoSpecifiedVersion() throws SQLException { performSimpleTest("jdbc:tc:oracle://hostname/databasename"); } From 1f3ac9da7fde45f1204e9ed1ae9efa38609ac066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Thu, 11 Sep 2025 10:28:00 -0600 Subject: [PATCH 13/20] Move Oracle XE tests to JUnit Jupiter --- modules/oracle-xe/build.gradle | 7 +++++++ .../containers/jdbc/OracleJDBCDriverTest.java | 6 +++--- .../junit/oracle/SimpleOracleTest.java | 18 +++++++++--------- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/modules/oracle-xe/build.gradle b/modules/oracle-xe/build.gradle index a384fcb7221..edc86cef19c 100644 --- a/modules/oracle-xe/build.gradle +++ b/modules/oracle-xe/build.gradle @@ -6,6 +6,9 @@ dependencies { compileOnly project(':testcontainers-r2dbc') compileOnly 'com.oracle.database.r2dbc:oracle-r2dbc:1.3.0' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.0' + + testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4' testImplementation project(':testcontainers-jdbc-test') testImplementation 'com.oracle.database.jdbc:ojdbc11:23.9.0.25.07' @@ -20,3 +23,7 @@ tasks.japicmp { "org.testcontainers.containers.OracleContainer" ] } + +test { + useJUnitPlatform() +} diff --git a/modules/oracle-xe/src/test/java/org/testcontainers/containers/jdbc/OracleJDBCDriverTest.java b/modules/oracle-xe/src/test/java/org/testcontainers/containers/jdbc/OracleJDBCDriverTest.java index 5e44f0d368c..4b672827fe6 100644 --- a/modules/oracle-xe/src/test/java/org/testcontainers/containers/jdbc/OracleJDBCDriverTest.java +++ b/modules/oracle-xe/src/test/java/org/testcontainers/containers/jdbc/OracleJDBCDriverTest.java @@ -4,17 +4,17 @@ import com.zaxxer.hikari.HikariDataSource; import org.apache.commons.dbutils.QueryRunner; import org.apache.commons.dbutils.ResultSetHandler; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.sql.ResultSet; import java.sql.SQLException; import static org.assertj.core.api.Assertions.assertThat; -public class OracleJDBCDriverTest { +class OracleJDBCDriverTest { @Test - public void testOracleWithNoSpecifiedVersion() throws SQLException { + void testOracleWithNoSpecifiedVersion() throws SQLException { performSimpleTest("jdbc:tc:oracle://hostname/databasename"); } diff --git a/modules/oracle-xe/src/test/java/org/testcontainers/junit/oracle/SimpleOracleTest.java b/modules/oracle-xe/src/test/java/org/testcontainers/junit/oracle/SimpleOracleTest.java index eb63442c06e..17ee85944a7 100644 --- a/modules/oracle-xe/src/test/java/org/testcontainers/junit/oracle/SimpleOracleTest.java +++ b/modules/oracle-xe/src/test/java/org/testcontainers/junit/oracle/SimpleOracleTest.java @@ -1,6 +1,6 @@ package org.testcontainers.junit.oracle; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.testcontainers.containers.OracleContainer; import org.testcontainers.db.AbstractContainerDatabaseTest; import org.testcontainers.utility.DockerImageName; @@ -11,7 +11,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -public class SimpleOracleTest extends AbstractContainerDatabaseTest { +class SimpleOracleTest extends AbstractContainerDatabaseTest { public static final DockerImageName ORACLE_DOCKER_IMAGE_NAME = DockerImageName.parse( "gvenzl/oracle-xe:21-slim-faststart" @@ -32,7 +32,7 @@ private void runTest(OracleContainer container, String databaseName, String user } @Test - public void testDefaultSettings() throws SQLException { + void testDefaultSettings() throws SQLException { try ( // container { OracleContainer oracle = new OracleContainer("gvenzl/oracle-xe:21-slim-faststart") // } @@ -46,14 +46,14 @@ public void testDefaultSettings() throws SQLException { } @Test - public void testPluggableDatabase() throws SQLException { + void testPluggableDatabase() throws SQLException { try (OracleContainer oracle = new OracleContainer(ORACLE_DOCKER_IMAGE_NAME).withDatabaseName("testDB")) { runTest(oracle, "testDB", "test", "test"); } } @Test - public void testPluggableDatabaseAndCustomUser() throws SQLException { + void testPluggableDatabaseAndCustomUser() throws SQLException { try ( OracleContainer oracle = new OracleContainer("gvenzl/oracle-xe:21-slim-faststart") .withDatabaseName("testDB") @@ -65,7 +65,7 @@ public void testPluggableDatabaseAndCustomUser() throws SQLException { } @Test - public void testCustomUser() throws SQLException { + void testCustomUser() throws SQLException { try ( OracleContainer oracle = new OracleContainer(ORACLE_DOCKER_IMAGE_NAME) .withUsername("testUser") @@ -76,7 +76,7 @@ public void testCustomUser() throws SQLException { } @Test - public void testSID() throws SQLException { + void testSID() throws SQLException { try (OracleContainer oracle = new OracleContainer(ORACLE_DOCKER_IMAGE_NAME).usingSid();) { runTest(oracle, "xepdb1", "system", "test"); @@ -87,7 +87,7 @@ public void testSID() throws SQLException { } @Test - public void testSIDAndCustomPassword() throws SQLException { + void testSIDAndCustomPassword() throws SQLException { try ( OracleContainer oracle = new OracleContainer(ORACLE_DOCKER_IMAGE_NAME) .usingSid() @@ -98,7 +98,7 @@ public void testSIDAndCustomPassword() throws SQLException { } @Test - public void testErrorPaths() throws SQLException { + void testErrorPaths() throws SQLException { try (OracleContainer oracle = new OracleContainer(ORACLE_DOCKER_IMAGE_NAME)) { try { oracle.withDatabaseName("XEPDB1"); From 86d102f81df2e6deae7aa2a42897618769bfc2c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Thu, 11 Sep 2025 10:28:19 -0600 Subject: [PATCH 14/20] Move PostgreSQL tests to JUnit Jupiter --- modules/postgresql/build.gradle | 7 +++++++ .../containers/CompatibleImageTest.java | 10 +++++----- .../PostgreSQLConnectionURLTest.java | 12 ++++++------ .../containers/TimescaleDBContainerTest.java | 12 ++++++------ .../jdbc/DatabaseDriverShutdownTest.java | 12 ++++++------ .../jdbc/DatabaseDriverTmpfsTest.java | 6 +++--- .../jdbc/pgvector/PgVectorJDBCDriverTest.java | 6 +----- .../jdbc/postgis/PostgisJDBCDriverTest.java | 6 +----- .../postgresql/PostgreSQLJDBCDriverTest.java | 4 ---- .../timescaledb/TimescaleDBJDBCDriverTest.java | 4 ---- .../postgresql/CustomizablePostgreSQLTest.java | 6 +++--- .../junit/postgresql/SimplePostgreSQLTest.java | 18 +++++++++--------- 12 files changed, 47 insertions(+), 56 deletions(-) diff --git a/modules/postgresql/build.gradle b/modules/postgresql/build.gradle index 8af61c5f3e2..dd5e441477a 100644 --- a/modules/postgresql/build.gradle +++ b/modules/postgresql/build.gradle @@ -6,6 +6,9 @@ dependencies { compileOnly project(':testcontainers-r2dbc') compileOnly 'io.r2dbc:r2dbc-postgresql:0.8.13.RELEASE' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.0' + + testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4' testImplementation project(':testcontainers-jdbc-test') testRuntimeOnly 'org.postgresql:postgresql:42.7.7' @@ -20,3 +23,7 @@ tasks.japicmp { "org.testcontainers.containers.PostgreSQLContainer" ] } + +test { + useJUnitPlatform() +} diff --git a/modules/postgresql/src/test/java/org/testcontainers/containers/CompatibleImageTest.java b/modules/postgresql/src/test/java/org/testcontainers/containers/CompatibleImageTest.java index 76b4a8c1bda..7101f4a9fb1 100644 --- a/modules/postgresql/src/test/java/org/testcontainers/containers/CompatibleImageTest.java +++ b/modules/postgresql/src/test/java/org/testcontainers/containers/CompatibleImageTest.java @@ -1,6 +1,6 @@ package org.testcontainers.containers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.testcontainers.db.AbstractContainerDatabaseTest; import org.testcontainers.utility.DockerImageName; @@ -9,10 +9,10 @@ import static org.assertj.core.api.Assertions.assertThat; -public class CompatibleImageTest extends AbstractContainerDatabaseTest { +class CompatibleImageTest extends AbstractContainerDatabaseTest { @Test - public void pgvector() throws SQLException { + void pgvector() throws SQLException { try ( // pgvectorContainer { PostgreSQLContainer pgvector = new PostgreSQLContainer<>("pgvector/pgvector:pg16") @@ -27,7 +27,7 @@ public void pgvector() throws SQLException { } @Test - public void postgis() throws SQLException { + void postgis() throws SQLException { try ( // postgisContainer { PostgreSQLContainer postgis = new PostgreSQLContainer<>( @@ -44,7 +44,7 @@ public void postgis() throws SQLException { } @Test - public void timescaledb() throws SQLException { + void timescaledb() throws SQLException { try ( // timescaledbContainer { PostgreSQLContainer timescaledb = new PostgreSQLContainer<>( diff --git a/modules/postgresql/src/test/java/org/testcontainers/containers/PostgreSQLConnectionURLTest.java b/modules/postgresql/src/test/java/org/testcontainers/containers/PostgreSQLConnectionURLTest.java index 275517250b6..3ed0b7030b1 100644 --- a/modules/postgresql/src/test/java/org/testcontainers/containers/PostgreSQLConnectionURLTest.java +++ b/modules/postgresql/src/test/java/org/testcontainers/containers/PostgreSQLConnectionURLTest.java @@ -1,15 +1,15 @@ package org.testcontainers.containers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.testcontainers.PostgreSQLTestImages; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.catchThrowable; -public class PostgreSQLConnectionURLTest { +class PostgreSQLConnectionURLTest { @Test - public void shouldCorrectlyAppendQueryString() { + void shouldCorrectlyAppendQueryString() { PostgreSQLContainer postgres = new FixedJdbcUrlPostgreSQLContainer(); String connectionUrl = postgres.constructUrlForConnection("?stringtype=unspecified&stringtype=unspecified"); String queryString = connectionUrl.substring(connectionUrl.indexOf('?')); @@ -22,7 +22,7 @@ public void shouldCorrectlyAppendQueryString() { } @Test - public void shouldCorrectlyAppendQueryStringWhenNoBaseParams() { + void shouldCorrectlyAppendQueryStringWhenNoBaseParams() { PostgreSQLContainer postgres = new NoParamsUrlPostgreSQLContainer(); String connectionUrl = postgres.constructUrlForConnection("?stringtype=unspecified&stringtype=unspecified"); String queryString = connectionUrl.substring(connectionUrl.indexOf('?')); @@ -35,7 +35,7 @@ public void shouldCorrectlyAppendQueryStringWhenNoBaseParams() { } @Test - public void shouldReturnOriginalURLWhenEmptyQueryString() { + void shouldReturnOriginalURLWhenEmptyQueryString() { PostgreSQLContainer postgres = new FixedJdbcUrlPostgreSQLContainer(); String connectionUrl = postgres.constructUrlForConnection(""); @@ -43,7 +43,7 @@ public void shouldReturnOriginalURLWhenEmptyQueryString() { } @Test - public void shouldRejectInvalidQueryString() { + void shouldRejectInvalidQueryString() { assertThat( catchThrowable(() -> { new NoParamsUrlPostgreSQLContainer().constructUrlForConnection("stringtype=unspecified"); diff --git a/modules/postgresql/src/test/java/org/testcontainers/containers/TimescaleDBContainerTest.java b/modules/postgresql/src/test/java/org/testcontainers/containers/TimescaleDBContainerTest.java index 90f3113c7c0..3991f4c2b1c 100644 --- a/modules/postgresql/src/test/java/org/testcontainers/containers/TimescaleDBContainerTest.java +++ b/modules/postgresql/src/test/java/org/testcontainers/containers/TimescaleDBContainerTest.java @@ -1,6 +1,6 @@ package org.testcontainers.containers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.testcontainers.db.AbstractContainerDatabaseTest; import java.sql.ResultSet; @@ -8,10 +8,10 @@ import static org.assertj.core.api.Assertions.assertThat; -public class TimescaleDBContainerTest extends AbstractContainerDatabaseTest { +class TimescaleDBContainerTest extends AbstractContainerDatabaseTest { @Test - public void testSimple() throws SQLException { + void testSimple() throws SQLException { try (JdbcDatabaseContainer postgres = new TimescaleDBContainerProvider().newInstance()) { postgres.start(); @@ -22,7 +22,7 @@ public void testSimple() throws SQLException { } @Test - public void testCommandOverride() throws SQLException { + void testCommandOverride() throws SQLException { try ( GenericContainer postgres = new TimescaleDBContainerProvider() .newInstance() @@ -40,7 +40,7 @@ public void testCommandOverride() throws SQLException { } @Test - public void testUnsetCommand() throws SQLException { + void testUnsetCommand() throws SQLException { try ( GenericContainer postgres = new TimescaleDBContainerProvider() .newInstance() @@ -59,7 +59,7 @@ public void testUnsetCommand() throws SQLException { } @Test - public void testExplicitInitScript() throws SQLException { + void testExplicitInitScript() throws SQLException { try ( JdbcDatabaseContainer postgres = new TimescaleDBContainerProvider() .newInstance() diff --git a/modules/postgresql/src/test/java/org/testcontainers/jdbc/DatabaseDriverShutdownTest.java b/modules/postgresql/src/test/java/org/testcontainers/jdbc/DatabaseDriverShutdownTest.java index ed519ed2e4b..ab4d6f03d2e 100644 --- a/modules/postgresql/src/test/java/org/testcontainers/jdbc/DatabaseDriverShutdownTest.java +++ b/modules/postgresql/src/test/java/org/testcontainers/jdbc/DatabaseDriverShutdownTest.java @@ -1,7 +1,7 @@ package org.testcontainers.jdbc; -import org.junit.AfterClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.testcontainers.containers.JdbcDatabaseContainer; import java.sql.Connection; @@ -16,15 +16,15 @@ * the mysql module, to avoid circular dependencies. * TODO: Move to the jdbc module and either (a) implement a barebones {@link org.testcontainers.containers.JdbcDatabaseContainerProvider} for testing, or (b) refactor into a unit test. */ -public class DatabaseDriverShutdownTest { +class DatabaseDriverShutdownTest { - @AfterClass + @BeforeAll public static void testCleanup() { ContainerDatabaseDriver.killContainers(); } @Test - public void shouldStopContainerWhenAllConnectionsClosed() throws SQLException { + void shouldStopContainerWhenAllConnectionsClosed() throws SQLException { final String jdbcUrl = "jdbc:tc:postgresql:9.6.8://hostname/databasename"; getConnectionAndClose(jdbcUrl); @@ -34,7 +34,7 @@ public void shouldStopContainerWhenAllConnectionsClosed() throws SQLException { } @Test - public void shouldNotStopDaemonContainerWhenAllConnectionsClosed() throws SQLException { + void shouldNotStopDaemonContainerWhenAllConnectionsClosed() throws SQLException { final String jdbcUrl = "jdbc:tc:postgresql:9.6.8://hostname/databasename?TC_DAEMON=true"; getConnectionAndClose(jdbcUrl); diff --git a/modules/postgresql/src/test/java/org/testcontainers/jdbc/DatabaseDriverTmpfsTest.java b/modules/postgresql/src/test/java/org/testcontainers/jdbc/DatabaseDriverTmpfsTest.java index 463981d2d59..12a6f2216cf 100644 --- a/modules/postgresql/src/test/java/org/testcontainers/jdbc/DatabaseDriverTmpfsTest.java +++ b/modules/postgresql/src/test/java/org/testcontainers/jdbc/DatabaseDriverTmpfsTest.java @@ -1,6 +1,6 @@ package org.testcontainers.jdbc; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.testcontainers.containers.Container; import org.testcontainers.containers.JdbcDatabaseContainer; @@ -15,10 +15,10 @@ * the mysql module, to avoid circular dependencies. * TODO: Move to the jdbc module and either (a) implement a barebones {@link org.testcontainers.containers.JdbcDatabaseContainerProvider} for testing, or (b) refactor into a unit test. */ -public class DatabaseDriverTmpfsTest { +class DatabaseDriverTmpfsTest { @Test - public void testDatabaseHasTmpFsViaConnectionString() throws Exception { + void testDatabaseHasTmpFsViaConnectionString() throws Exception { final String jdbcUrl = "jdbc:tc:postgresql:9.6.8://hostname/databasename?TC_TMPFS=/testtmpfs:rw"; try (Connection ignored = DriverManager.getConnection(jdbcUrl)) { JdbcDatabaseContainer container = ContainerDatabaseDriver.getContainer(jdbcUrl); diff --git a/modules/postgresql/src/test/java/org/testcontainers/jdbc/pgvector/PgVectorJDBCDriverTest.java b/modules/postgresql/src/test/java/org/testcontainers/jdbc/pgvector/PgVectorJDBCDriverTest.java index 2d7e67f4923..e94986e7875 100644 --- a/modules/postgresql/src/test/java/org/testcontainers/jdbc/pgvector/PgVectorJDBCDriverTest.java +++ b/modules/postgresql/src/test/java/org/testcontainers/jdbc/pgvector/PgVectorJDBCDriverTest.java @@ -1,16 +1,12 @@ package org.testcontainers.jdbc.pgvector; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.testcontainers.jdbc.AbstractJDBCDriverTest; import java.util.Arrays; import java.util.EnumSet; -@RunWith(Parameterized.class) -public class PgVectorJDBCDriverTest extends AbstractJDBCDriverTest { +class PgVectorJDBCDriverTest extends AbstractJDBCDriverTest { - @Parameterized.Parameters(name = "{index} - {0}") public static Iterable data() { return Arrays.asList( new Object[][] { diff --git a/modules/postgresql/src/test/java/org/testcontainers/jdbc/postgis/PostgisJDBCDriverTest.java b/modules/postgresql/src/test/java/org/testcontainers/jdbc/postgis/PostgisJDBCDriverTest.java index abc0a3b76bc..d6a0047a23c 100644 --- a/modules/postgresql/src/test/java/org/testcontainers/jdbc/postgis/PostgisJDBCDriverTest.java +++ b/modules/postgresql/src/test/java/org/testcontainers/jdbc/postgis/PostgisJDBCDriverTest.java @@ -1,16 +1,12 @@ package org.testcontainers.jdbc.postgis; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.testcontainers.jdbc.AbstractJDBCDriverTest; import java.util.Arrays; import java.util.EnumSet; -@RunWith(Parameterized.class) -public class PostgisJDBCDriverTest extends AbstractJDBCDriverTest { +class PostgisJDBCDriverTest extends AbstractJDBCDriverTest { - @Parameterized.Parameters(name = "{index} - {0}") public static Iterable data() { return Arrays.asList( new Object[][] { diff --git a/modules/postgresql/src/test/java/org/testcontainers/jdbc/postgresql/PostgreSQLJDBCDriverTest.java b/modules/postgresql/src/test/java/org/testcontainers/jdbc/postgresql/PostgreSQLJDBCDriverTest.java index d42f17f3ec2..b47af39f54b 100644 --- a/modules/postgresql/src/test/java/org/testcontainers/jdbc/postgresql/PostgreSQLJDBCDriverTest.java +++ b/modules/postgresql/src/test/java/org/testcontainers/jdbc/postgresql/PostgreSQLJDBCDriverTest.java @@ -1,16 +1,12 @@ package org.testcontainers.jdbc.postgresql; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.testcontainers.jdbc.AbstractJDBCDriverTest; import java.util.Arrays; import java.util.EnumSet; -@RunWith(Parameterized.class) public class PostgreSQLJDBCDriverTest extends AbstractJDBCDriverTest { - @Parameterized.Parameters(name = "{index} - {0}") public static Iterable data() { return Arrays.asList( new Object[][] { diff --git a/modules/postgresql/src/test/java/org/testcontainers/jdbc/timescaledb/TimescaleDBJDBCDriverTest.java b/modules/postgresql/src/test/java/org/testcontainers/jdbc/timescaledb/TimescaleDBJDBCDriverTest.java index 2a50b46c901..8befb01bfb1 100644 --- a/modules/postgresql/src/test/java/org/testcontainers/jdbc/timescaledb/TimescaleDBJDBCDriverTest.java +++ b/modules/postgresql/src/test/java/org/testcontainers/jdbc/timescaledb/TimescaleDBJDBCDriverTest.java @@ -1,16 +1,12 @@ package org.testcontainers.jdbc.timescaledb; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.testcontainers.jdbc.AbstractJDBCDriverTest; import java.util.Arrays; import java.util.EnumSet; -@RunWith(Parameterized.class) public class TimescaleDBJDBCDriverTest extends AbstractJDBCDriverTest { - @Parameterized.Parameters(name = "{index} - {0}") public static Iterable data() { return Arrays.asList( new Object[][] { diff --git a/modules/postgresql/src/test/java/org/testcontainers/junit/postgresql/CustomizablePostgreSQLTest.java b/modules/postgresql/src/test/java/org/testcontainers/junit/postgresql/CustomizablePostgreSQLTest.java index 0e9904a5f61..fb09530913b 100644 --- a/modules/postgresql/src/test/java/org/testcontainers/junit/postgresql/CustomizablePostgreSQLTest.java +++ b/modules/postgresql/src/test/java/org/testcontainers/junit/postgresql/CustomizablePostgreSQLTest.java @@ -1,6 +1,6 @@ package org.testcontainers.junit.postgresql; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.testcontainers.PostgreSQLTestImages; import org.testcontainers.containers.PostgreSQLContainer; import org.testcontainers.db.AbstractContainerDatabaseTest; @@ -10,7 +10,7 @@ import static org.assertj.core.api.Assertions.assertThat; -public class CustomizablePostgreSQLTest extends AbstractContainerDatabaseTest { +class CustomizablePostgreSQLTest extends AbstractContainerDatabaseTest { private static final String DB_NAME = "foo"; @@ -19,7 +19,7 @@ public class CustomizablePostgreSQLTest extends AbstractContainerDatabaseTest { private static final String PWD = "baz"; @Test - public void testSimple() throws SQLException { + void testSimple() throws SQLException { try ( PostgreSQLContainer postgres = new PostgreSQLContainer<>(PostgreSQLTestImages.POSTGRES_TEST_IMAGE) .withDatabaseName(DB_NAME) diff --git a/modules/postgresql/src/test/java/org/testcontainers/junit/postgresql/SimplePostgreSQLTest.java b/modules/postgresql/src/test/java/org/testcontainers/junit/postgresql/SimplePostgreSQLTest.java index 53585fec327..7227f3bdd60 100644 --- a/modules/postgresql/src/test/java/org/testcontainers/junit/postgresql/SimplePostgreSQLTest.java +++ b/modules/postgresql/src/test/java/org/testcontainers/junit/postgresql/SimplePostgreSQLTest.java @@ -1,6 +1,6 @@ package org.testcontainers.junit.postgresql; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.testcontainers.PostgreSQLTestImages; import org.testcontainers.containers.PostgreSQLContainer; import org.testcontainers.db.AbstractContainerDatabaseTest; @@ -13,14 +13,14 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatNoException; -public class SimplePostgreSQLTest extends AbstractContainerDatabaseTest { +class SimplePostgreSQLTest extends AbstractContainerDatabaseTest { static { // Postgres JDBC driver uses JUL; disable it to avoid annoying, irrelevant, stderr logs during connection testing LogManager.getLogManager().getLogger("").setLevel(Level.OFF); } @Test - public void testSimple() throws SQLException { + void testSimple() throws SQLException { try ( // container { PostgreSQLContainer postgres = new PostgreSQLContainer<>("postgres:9.6.12") // } @@ -35,7 +35,7 @@ public void testSimple() throws SQLException { } @Test - public void testCommandOverride() throws SQLException { + void testCommandOverride() throws SQLException { try ( PostgreSQLContainer postgres = new PostgreSQLContainer<>(PostgreSQLTestImages.POSTGRES_TEST_IMAGE) .withCommand("postgres -c max_connections=42") @@ -49,7 +49,7 @@ public void testCommandOverride() throws SQLException { } @Test - public void testUnsetCommand() throws SQLException { + void testUnsetCommand() throws SQLException { try ( PostgreSQLContainer postgres = new PostgreSQLContainer<>(PostgreSQLTestImages.POSTGRES_TEST_IMAGE) .withCommand("postgres -c max_connections=42") @@ -64,7 +64,7 @@ public void testUnsetCommand() throws SQLException { } @Test - public void testMissingInitScript() { + void testMissingInitScript() { try ( PostgreSQLContainer postgres = new PostgreSQLContainer<>(PostgreSQLTestImages.POSTGRES_TEST_IMAGE) .withInitScript(null) @@ -74,7 +74,7 @@ public void testMissingInitScript() { } @Test - public void testExplicitInitScript() throws SQLException { + void testExplicitInitScript() throws SQLException { try ( PostgreSQLContainer postgres = new PostgreSQLContainer<>(PostgreSQLTestImages.POSTGRES_TEST_IMAGE) .withInitScript("somepath/init_postgresql.sql") @@ -89,7 +89,7 @@ public void testExplicitInitScript() throws SQLException { } @Test - public void testExplicitInitScripts() throws SQLException { + void testExplicitInitScripts() throws SQLException { try ( PostgreSQLContainer postgres = new PostgreSQLContainer<>(PostgreSQLTestImages.POSTGRES_TEST_IMAGE) .withInitScripts("somepath/init_postgresql.sql", "somepath/init_postgresql_2.sql") @@ -110,7 +110,7 @@ public void testExplicitInitScripts() throws SQLException { } @Test - public void testWithAdditionalUrlParamInJdbcUrl() { + void testWithAdditionalUrlParamInJdbcUrl() { try ( PostgreSQLContainer postgres = new PostgreSQLContainer<>(PostgreSQLTestImages.POSTGRES_TEST_IMAGE) .withUrlParam("charSet", "UNICODE") From b570f26432c1c22f55521138192e15c9eb83904e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Thu, 11 Sep 2025 10:28:34 -0600 Subject: [PATCH 15/20] Move Presto tests to JUnit Jupiter --- modules/presto/build.gradle | 7 +++++++ .../containers/PrestoContainerTest.java | 14 +++++++------- .../jdbc/presto/PrestoJDBCDriverTest.java | 6 +----- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/modules/presto/build.gradle b/modules/presto/build.gradle index 194b413c10f..452e8cc271d 100644 --- a/modules/presto/build.gradle +++ b/modules/presto/build.gradle @@ -3,7 +3,14 @@ description = "Testcontainers :: JDBC :: Presto" dependencies { api project(':testcontainers-jdbc') + testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.0' + + testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4' testImplementation project(':testcontainers-jdbc-test') testRuntimeOnly 'io.prestosql:presto-jdbc:350' compileOnly 'org.jetbrains:annotations:26.0.2' } + +test { + useJUnitPlatform() +} diff --git a/modules/presto/src/test/java/org/testcontainers/containers/PrestoContainerTest.java b/modules/presto/src/test/java/org/testcontainers/containers/PrestoContainerTest.java index 8f2aa15f21c..9a46309f9e9 100644 --- a/modules/presto/src/test/java/org/testcontainers/containers/PrestoContainerTest.java +++ b/modules/presto/src/test/java/org/testcontainers/containers/PrestoContainerTest.java @@ -1,6 +1,6 @@ package org.testcontainers.containers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.testcontainers.PrestoTestImages; import java.sql.Connection; @@ -14,10 +14,10 @@ import static org.assertj.core.api.Assertions.assertThat; -public class PrestoContainerTest { +class PrestoContainerTest { @Test - public void testSimple() throws Exception { + void testSimple() throws Exception { try (PrestoContainer prestoSql = new PrestoContainer<>(PrestoTestImages.PRESTO_TEST_IMAGE)) { prestoSql.start(); try ( @@ -35,7 +35,7 @@ public void testSimple() throws Exception { } @Test - public void testSpecificVersion() throws Exception { + void testSpecificVersion() throws Exception { try ( PrestoContainer prestoSql = new PrestoContainer<>(PrestoTestImages.PRESTO_PREVIOUS_VERSION_TEST_IMAGE) ) { @@ -54,7 +54,7 @@ public void testSpecificVersion() throws Exception { } @Test - public void testQueryMemoryAndTpch() throws SQLException { + void testQueryMemoryAndTpch() throws SQLException { try (PrestoContainer prestoSql = new PrestoContainer<>(PrestoTestImages.PRESTO_TEST_IMAGE)) { prestoSql.start(); try ( @@ -88,7 +88,7 @@ public void testQueryMemoryAndTpch() throws SQLException { } @Test - public void testInitScript() throws Exception { + void testInitScript() throws Exception { try (PrestoContainer prestoSql = new PrestoContainer<>(PrestoTestImages.PRESTO_TEST_IMAGE)) { prestoSql.withInitScript("initial.sql"); prestoSql.start(); @@ -105,7 +105,7 @@ public void testInitScript() throws Exception { } @Test - public void testTcJdbcUri() throws Exception { + void testTcJdbcUri() throws Exception { try ( Connection connection = DriverManager.getConnection( String.format("jdbc:tc:presto:%s://hostname/", PrestoContainer.DEFAULT_TAG) diff --git a/modules/presto/src/test/java/org/testcontainers/jdbc/presto/PrestoJDBCDriverTest.java b/modules/presto/src/test/java/org/testcontainers/jdbc/presto/PrestoJDBCDriverTest.java index 9c5dd712104..02e5b2a0485 100644 --- a/modules/presto/src/test/java/org/testcontainers/jdbc/presto/PrestoJDBCDriverTest.java +++ b/modules/presto/src/test/java/org/testcontainers/jdbc/presto/PrestoJDBCDriverTest.java @@ -1,16 +1,12 @@ package org.testcontainers.jdbc.presto; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.testcontainers.jdbc.AbstractJDBCDriverTest; import java.util.Arrays; import java.util.EnumSet; -@RunWith(Parameterized.class) -public class PrestoJDBCDriverTest extends AbstractJDBCDriverTest { +class PrestoJDBCDriverTest extends AbstractJDBCDriverTest { - @Parameterized.Parameters(name = "{index} - {0}") public static Iterable data() { return Arrays.asList( new Object[][] { // From 9672e7a63fedc8eee8b4d9d95b5daaded9193d2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Thu, 11 Sep 2025 10:28:49 -0600 Subject: [PATCH 16/20] Move QuestDB tests to JUnit Jupiter --- modules/questdb/build.gradle | 7 +++++++ .../jdbc/questdb/QuestDBJDBCDriverTest.java | 6 +----- .../testcontainers/junit/questdb/SimpleQuestDBTest.java | 8 ++++---- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/modules/questdb/build.gradle b/modules/questdb/build.gradle index 665b2473b0a..f2b69777ab2 100644 --- a/modules/questdb/build.gradle +++ b/modules/questdb/build.gradle @@ -5,9 +5,16 @@ dependencies { api project(':testcontainers-jdbc') testRuntimeOnly 'org.postgresql:postgresql:42.7.7' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.0' + + testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4' testImplementation project(':testcontainers-jdbc-test') testImplementation 'org.assertj:assertj-core:3.27.4' testImplementation 'org.questdb:questdb:9.0.2' testImplementation 'org.awaitility:awaitility:4.3.0' testImplementation 'org.apache.httpcomponents:httpclient:4.5.14' } + +test { + useJUnitPlatform() +} diff --git a/modules/questdb/src/test/java/org/testcontainers/jdbc/questdb/QuestDBJDBCDriverTest.java b/modules/questdb/src/test/java/org/testcontainers/jdbc/questdb/QuestDBJDBCDriverTest.java index 3144f8bfad3..40612f05680 100644 --- a/modules/questdb/src/test/java/org/testcontainers/jdbc/questdb/QuestDBJDBCDriverTest.java +++ b/modules/questdb/src/test/java/org/testcontainers/jdbc/questdb/QuestDBJDBCDriverTest.java @@ -1,16 +1,12 @@ package org.testcontainers.jdbc.questdb; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.testcontainers.jdbc.AbstractJDBCDriverTest; import java.util.Arrays; import java.util.EnumSet; -@RunWith(Parameterized.class) -public class QuestDBJDBCDriverTest extends AbstractJDBCDriverTest { +class QuestDBJDBCDriverTest extends AbstractJDBCDriverTest { - @Parameterized.Parameters(name = "{index} - {0}") public static Iterable data() { return Arrays.asList( new Object[][] { diff --git a/modules/questdb/src/test/java/org/testcontainers/junit/questdb/SimpleQuestDBTest.java b/modules/questdb/src/test/java/org/testcontainers/junit/questdb/SimpleQuestDBTest.java index f91f17f14b4..aad4df70c2c 100644 --- a/modules/questdb/src/test/java/org/testcontainers/junit/questdb/SimpleQuestDBTest.java +++ b/modules/questdb/src/test/java/org/testcontainers/junit/questdb/SimpleQuestDBTest.java @@ -6,7 +6,7 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.util.EntityUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.testcontainers.QuestDBTestImages; import org.testcontainers.containers.QuestDBContainer; import org.testcontainers.db.AbstractContainerDatabaseTest; @@ -20,12 +20,12 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; -public class SimpleQuestDBTest extends AbstractContainerDatabaseTest { +class SimpleQuestDBTest extends AbstractContainerDatabaseTest { private static final String TABLE_NAME = "mytable"; @Test - public void testSimple() throws SQLException { + void testSimple() throws SQLException { try ( // container { QuestDBContainer questDB = new QuestDBContainer("questdb/questdb:6.5.3") // } @@ -40,7 +40,7 @@ public void testSimple() throws SQLException { } @Test - public void testRest() throws IOException { + void testRest() throws IOException { try (QuestDBContainer questdb = new QuestDBContainer(QuestDBTestImages.QUESTDB_IMAGE)) { questdb.start(); populateByInfluxLineProtocol(questdb, 1_000); From 922c6e3fd6dfbaeccb74ebe7e7b872dd77d83974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Thu, 11 Sep 2025 10:29:04 -0600 Subject: [PATCH 17/20] Move TiDB tests to JUnit Jupiter --- modules/tidb/build.gradle | 7 +++++++ .../testcontainers/jdbc/tidb/TiDBJDBCDriverTest.java | 4 ---- .../org/testcontainers/junit/tidb/SimpleTiDBTest.java | 10 +++++----- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/modules/tidb/build.gradle b/modules/tidb/build.gradle index 47dd9d01027..61d21063af0 100644 --- a/modules/tidb/build.gradle +++ b/modules/tidb/build.gradle @@ -3,8 +3,15 @@ description = "Testcontainers :: JDBC :: TiDB" dependencies { api project(':testcontainers-jdbc') + testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.0' + + testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4' testImplementation project(':testcontainers-jdbc-test') testRuntimeOnly 'mysql:mysql-connector-java:8.0.33' compileOnly 'org.jetbrains:annotations:26.0.2' } + +test { + useJUnitPlatform() +} diff --git a/modules/tidb/src/test/java/org/testcontainers/jdbc/tidb/TiDBJDBCDriverTest.java b/modules/tidb/src/test/java/org/testcontainers/jdbc/tidb/TiDBJDBCDriverTest.java index 566850fa629..4b3d60a013c 100644 --- a/modules/tidb/src/test/java/org/testcontainers/jdbc/tidb/TiDBJDBCDriverTest.java +++ b/modules/tidb/src/test/java/org/testcontainers/jdbc/tidb/TiDBJDBCDriverTest.java @@ -1,16 +1,12 @@ package org.testcontainers.jdbc.tidb; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.testcontainers.jdbc.AbstractJDBCDriverTest; import java.util.Arrays; import java.util.EnumSet; -@RunWith(Parameterized.class) public class TiDBJDBCDriverTest extends AbstractJDBCDriverTest { - @Parameterized.Parameters(name = "{index} - {0}") public static Iterable data() { return Arrays.asList( new Object[][] { { "jdbc:tc:tidb://hostname/databasename", EnumSet.noneOf(Options.class) } } diff --git a/modules/tidb/src/test/java/org/testcontainers/junit/tidb/SimpleTiDBTest.java b/modules/tidb/src/test/java/org/testcontainers/junit/tidb/SimpleTiDBTest.java index c010e4298fe..9323e7d21ac 100644 --- a/modules/tidb/src/test/java/org/testcontainers/junit/tidb/SimpleTiDBTest.java +++ b/modules/tidb/src/test/java/org/testcontainers/junit/tidb/SimpleTiDBTest.java @@ -1,6 +1,6 @@ package org.testcontainers.junit.tidb; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.testcontainers.TiDBTestImages; import org.testcontainers.db.AbstractContainerDatabaseTest; import org.testcontainers.tidb.TiDBContainer; @@ -10,10 +10,10 @@ import static org.assertj.core.api.Assertions.assertThat; -public class SimpleTiDBTest extends AbstractContainerDatabaseTest { +class SimpleTiDBTest extends AbstractContainerDatabaseTest { @Test - public void testSimple() throws SQLException { + void testSimple() throws SQLException { try ( // container { TiDBContainer tidb = new TiDBContainer("pingcap/tidb:v6.1.0") // } @@ -29,7 +29,7 @@ public void testSimple() throws SQLException { } @Test - public void testExplicitInitScript() throws SQLException { + void testExplicitInitScript() throws SQLException { try ( TiDBContainer tidb = new TiDBContainer(TiDBTestImages.TIDB_IMAGE).withInitScript("somepath/init_tidb.sql") ) { // TiDB is expected to be compatible with MySQL @@ -43,7 +43,7 @@ public void testExplicitInitScript() throws SQLException { } @Test - public void testWithAdditionalUrlParamInJdbcUrl() { + void testWithAdditionalUrlParamInJdbcUrl() { TiDBContainer tidb = new TiDBContainer(TiDBTestImages.TIDB_IMAGE).withUrlParam("sslmode", "disable"); try { From 7783939acbc6abdd9d9caf8cd9103f3e6deb3c15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Thu, 11 Sep 2025 10:29:18 -0600 Subject: [PATCH 18/20] Move Timeplus tests to JUnit Jupiter --- modules/timeplus/build.gradle | 7 +++++++ .../junit/timeplus/TimeplusJDBCDriverTest.java | 6 +----- .../testcontainers/timeplus/TimeplusContainerTest.java | 8 ++++---- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/modules/timeplus/build.gradle b/modules/timeplus/build.gradle index 5816772e300..681efb5cf7a 100644 --- a/modules/timeplus/build.gradle +++ b/modules/timeplus/build.gradle @@ -4,7 +4,14 @@ dependencies { api project(':testcontainers') api project(':testcontainers-jdbc') + testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.0' + + testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4' testImplementation project(':testcontainers-jdbc-test') testRuntimeOnly 'com.timeplus:timeplus-native-jdbc:2.0.10' testImplementation 'org.assertj:assertj-core:3.27.4' } + +test { + useJUnitPlatform() +} diff --git a/modules/timeplus/src/test/java/org/testcontainers/junit/timeplus/TimeplusJDBCDriverTest.java b/modules/timeplus/src/test/java/org/testcontainers/junit/timeplus/TimeplusJDBCDriverTest.java index 3f3a7ac8136..1427f33e5a4 100644 --- a/modules/timeplus/src/test/java/org/testcontainers/junit/timeplus/TimeplusJDBCDriverTest.java +++ b/modules/timeplus/src/test/java/org/testcontainers/junit/timeplus/TimeplusJDBCDriverTest.java @@ -1,16 +1,12 @@ package org.testcontainers.junit.timeplus; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.testcontainers.jdbc.AbstractJDBCDriverTest; import java.util.Arrays; import java.util.EnumSet; -@RunWith(Parameterized.class) -public class TimeplusJDBCDriverTest extends AbstractJDBCDriverTest { +class TimeplusJDBCDriverTest extends AbstractJDBCDriverTest { - @Parameterized.Parameters(name = "{index} - {0}") public static Iterable data() { return Arrays.asList( new Object[][] { { "jdbc:tc:timeplus:2.3.21://hostname", EnumSet.noneOf(Options.class) } } diff --git a/modules/timeplus/src/test/java/org/testcontainers/timeplus/TimeplusContainerTest.java b/modules/timeplus/src/test/java/org/testcontainers/timeplus/TimeplusContainerTest.java index 5e00f945555..7ab38c03f87 100644 --- a/modules/timeplus/src/test/java/org/testcontainers/timeplus/TimeplusContainerTest.java +++ b/modules/timeplus/src/test/java/org/testcontainers/timeplus/TimeplusContainerTest.java @@ -1,6 +1,6 @@ package org.testcontainers.timeplus; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.testcontainers.TimeplusImages; import org.testcontainers.db.AbstractContainerDatabaseTest; @@ -9,10 +9,10 @@ import static org.assertj.core.api.Assertions.assertThat; -public class TimeplusContainerTest extends AbstractContainerDatabaseTest { +class TimeplusContainerTest extends AbstractContainerDatabaseTest { @Test - public void testSimple() throws SQLException { + void testSimple() throws SQLException { try ( // container { TimeplusContainer timeplus = new TimeplusContainer("timeplus/timeplusd:2.3.21") // } @@ -27,7 +27,7 @@ public void testSimple() throws SQLException { } @Test - public void customCredentialsWithUrlParams() throws SQLException { + void customCredentialsWithUrlParams() throws SQLException { try ( TimeplusContainer timeplus = new TimeplusContainer(TimeplusImages.TIMEPLUS_IMAGE) .withUsername("system") From db2ab6485043037bc6c2d3d793c575dcb1154afa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Thu, 11 Sep 2025 10:29:31 -0600 Subject: [PATCH 19/20] Move Trino tests to JUnit Jupiter --- modules/trino/build.gradle | 7 +++++++ .../testcontainers/containers/TrinoContainerTest.java | 10 +++++----- .../testcontainers/jdbc/trino/TrinoJDBCDriverTest.java | 6 +----- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/modules/trino/build.gradle b/modules/trino/build.gradle index 08e3c0c2982..04c5ffb73b7 100644 --- a/modules/trino/build.gradle +++ b/modules/trino/build.gradle @@ -3,7 +3,14 @@ description = "Testcontainers :: JDBC :: Trino" dependencies { api project(':testcontainers-jdbc') + testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.0' + + testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4' testImplementation project(':testcontainers-jdbc-test') testRuntimeOnly 'io.trino:trino-jdbc:476' compileOnly 'org.jetbrains:annotations:26.0.2' } + +test { + useJUnitPlatform() +} diff --git a/modules/trino/src/test/java/org/testcontainers/containers/TrinoContainerTest.java b/modules/trino/src/test/java/org/testcontainers/containers/TrinoContainerTest.java index ea25f39dbef..a12df1bcda7 100644 --- a/modules/trino/src/test/java/org/testcontainers/containers/TrinoContainerTest.java +++ b/modules/trino/src/test/java/org/testcontainers/containers/TrinoContainerTest.java @@ -1,6 +1,6 @@ package org.testcontainers.containers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.testcontainers.TrinoTestImages; import java.sql.Connection; @@ -9,10 +9,10 @@ import static org.assertj.core.api.Assertions.assertThat; -public class TrinoContainerTest { +class TrinoContainerTest { @Test - public void testSimple() throws Exception { + void testSimple() throws Exception { try ( // container { TrinoContainer trino = new TrinoContainer("trinodb/trino:352") // } @@ -33,7 +33,7 @@ public void testSimple() throws Exception { } @Test - public void testSpecificVersion() throws Exception { + void testSpecificVersion() throws Exception { try (TrinoContainer trino = new TrinoContainer(TrinoTestImages.TRINO_PREVIOUS_VERSION_TEST_IMAGE)) { trino.start(); try ( @@ -50,7 +50,7 @@ public void testSpecificVersion() throws Exception { } @Test - public void testInitScript() throws Exception { + void testInitScript() throws Exception { try (TrinoContainer trino = new TrinoContainer(TrinoTestImages.TRINO_TEST_IMAGE)) { trino.withInitScript("initial.sql"); trino.start(); diff --git a/modules/trino/src/test/java/org/testcontainers/jdbc/trino/TrinoJDBCDriverTest.java b/modules/trino/src/test/java/org/testcontainers/jdbc/trino/TrinoJDBCDriverTest.java index 9ec98c2e6d7..7674d1bc459 100644 --- a/modules/trino/src/test/java/org/testcontainers/jdbc/trino/TrinoJDBCDriverTest.java +++ b/modules/trino/src/test/java/org/testcontainers/jdbc/trino/TrinoJDBCDriverTest.java @@ -1,16 +1,12 @@ package org.testcontainers.jdbc.trino; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.testcontainers.jdbc.AbstractJDBCDriverTest; import java.util.Arrays; import java.util.EnumSet; -@RunWith(Parameterized.class) -public class TrinoJDBCDriverTest extends AbstractJDBCDriverTest { +class TrinoJDBCDriverTest extends AbstractJDBCDriverTest { - @Parameterized.Parameters(name = "{index} - {0}") public static Iterable data() { return Arrays.asList( new Object[][] { // From a086b6f6a22b6d8d125af9e27aaa4aba0aa12d83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Thu, 11 Sep 2025 10:29:47 -0600 Subject: [PATCH 20/20] Move YugabyteDB tests to JUnit Jupiter --- modules/yugabytedb/build.gradle | 8 ++++++++ .../yugabytedb/YugabyteDBYSQLJDBCDriverTest.java | 6 +----- .../junit/yugabytedb/YugabyteDBYCQLTest.java | 16 ++++++++-------- .../junit/yugabytedb/YugabyteDBYSQLTest.java | 16 ++++++++-------- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/modules/yugabytedb/build.gradle b/modules/yugabytedb/build.gradle index d81dd3e0648..b867b42a603 100644 --- a/modules/yugabytedb/build.gradle +++ b/modules/yugabytedb/build.gradle @@ -2,9 +2,17 @@ description = "Testcontainers :: JDBC :: YugabyteDB" dependencies { api project(':testcontainers-jdbc') + + testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.0' + + testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4' testImplementation project(':testcontainers-jdbc-test') // YCQL driver testImplementation 'com.yugabyte:java-driver-core:4.19.0-yb-1' // YSQL driver testRuntimeOnly 'com.yugabyte:jdbc-yugabytedb:42.7.3-yb-4' } + +test { + useJUnitPlatform() +} diff --git a/modules/yugabytedb/src/test/java/org/testcontainers/jdbc/yugabytedb/YugabyteDBYSQLJDBCDriverTest.java b/modules/yugabytedb/src/test/java/org/testcontainers/jdbc/yugabytedb/YugabyteDBYSQLJDBCDriverTest.java index a7ecab34aba..37129e8f899 100644 --- a/modules/yugabytedb/src/test/java/org/testcontainers/jdbc/yugabytedb/YugabyteDBYSQLJDBCDriverTest.java +++ b/modules/yugabytedb/src/test/java/org/testcontainers/jdbc/yugabytedb/YugabyteDBYSQLJDBCDriverTest.java @@ -1,7 +1,5 @@ package org.testcontainers.jdbc.yugabytedb; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.testcontainers.jdbc.AbstractJDBCDriverTest; import java.util.Arrays; @@ -10,10 +8,8 @@ /** * YugabyteDB YSQL API JDBC connectivity driver test class */ -@RunWith(Parameterized.class) -public class YugabyteDBYSQLJDBCDriverTest extends AbstractJDBCDriverTest { +class YugabyteDBYSQLJDBCDriverTest extends AbstractJDBCDriverTest { - @Parameterized.Parameters(name = "{index} - {0}") public static Iterable data() { return Arrays.asList( new Object[][] { diff --git a/modules/yugabytedb/src/test/java/org/testcontainers/junit/yugabytedb/YugabyteDBYCQLTest.java b/modules/yugabytedb/src/test/java/org/testcontainers/junit/yugabytedb/YugabyteDBYCQLTest.java index bf8ec2be1ea..24e6b2c24dd 100644 --- a/modules/yugabytedb/src/test/java/org/testcontainers/junit/yugabytedb/YugabyteDBYCQLTest.java +++ b/modules/yugabytedb/src/test/java/org/testcontainers/junit/yugabytedb/YugabyteDBYCQLTest.java @@ -2,7 +2,7 @@ import com.datastax.oss.driver.api.core.CqlSession; import com.datastax.oss.driver.api.core.cql.ResultSet; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.testcontainers.containers.YugabyteDBYCQLContainer; import org.testcontainers.utility.DockerImageName; @@ -11,7 +11,7 @@ /** * YugabyteDB YCQL API unit test class */ -public class YugabyteDBYCQLTest { +class YugabyteDBYCQLTest { private static final String IMAGE_NAME = "yugabytedb/yugabyte:2.14.4.0-b26"; @@ -20,7 +20,7 @@ public class YugabyteDBYCQLTest { private static final DockerImageName YBDB_TEST_IMAGE = DockerImageName.parse(IMAGE_NAME); @Test - public void testSmoke() { + void testSmoke() { try ( // creatingYCQLContainer { final YugabyteDBYCQLContainer ycqlContainer = new YugabyteDBYCQLContainer( @@ -38,7 +38,7 @@ public void testSmoke() { } @Test - public void testCustomKeyspace() { + void testCustomKeyspace() { String key = "random"; try ( final YugabyteDBYCQLContainer ycqlContainer = new YugabyteDBYCQLContainer(YBDB_TEST_IMAGE) @@ -61,7 +61,7 @@ public void testCustomKeyspace() { } @Test - public void testAuthenticationEnabled() { + void testAuthenticationEnabled() { String role = "random"; try ( final YugabyteDBYCQLContainer ycqlContainer = new YugabyteDBYCQLContainer(YBDB_TEST_IMAGE) @@ -80,7 +80,7 @@ public void testAuthenticationEnabled() { } @Test - public void testAuthenticationDisabled() { + void testAuthenticationDisabled() { try ( final YugabyteDBYCQLContainer ycqlContainer = new YugabyteDBYCQLContainer(YBDB_TEST_IMAGE) .withPassword("cassandra") @@ -94,7 +94,7 @@ public void testAuthenticationDisabled() { } @Test - public void testInitScript() { + void testInitScript() { String key = "random"; try ( final YugabyteDBYCQLContainer ycqlContainer = new YugabyteDBYCQLContainer(YBDB_TEST_IMAGE) @@ -111,7 +111,7 @@ public void testInitScript() { } @Test - public void shouldStartWhenContainerIpIsUsedInWaitStrategy() { + void shouldStartWhenContainerIpIsUsedInWaitStrategy() { try ( final YugabyteDBYCQLContainer ycqlContainer = new YugabyteDBYCQLContainer(IMAGE_NAME_2_18) .withUsername("cassandra") diff --git a/modules/yugabytedb/src/test/java/org/testcontainers/junit/yugabytedb/YugabyteDBYSQLTest.java b/modules/yugabytedb/src/test/java/org/testcontainers/junit/yugabytedb/YugabyteDBYSQLTest.java index 47a36f4f784..04d1448cfba 100644 --- a/modules/yugabytedb/src/test/java/org/testcontainers/junit/yugabytedb/YugabyteDBYSQLTest.java +++ b/modules/yugabytedb/src/test/java/org/testcontainers/junit/yugabytedb/YugabyteDBYSQLTest.java @@ -1,6 +1,6 @@ package org.testcontainers.junit.yugabytedb; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.testcontainers.containers.YugabyteDBYSQLContainer; import org.testcontainers.db.AbstractContainerDatabaseTest; import org.testcontainers.utility.DockerImageName; @@ -12,14 +12,14 @@ /** * YugabyteDB YSQL API unit test class */ -public class YugabyteDBYSQLTest extends AbstractContainerDatabaseTest { +class YugabyteDBYSQLTest extends AbstractContainerDatabaseTest { private static final String IMAGE_NAME = "yugabytedb/yugabyte:2.14.4.0-b26"; private static final DockerImageName YBDB_TEST_IMAGE = DockerImageName.parse(IMAGE_NAME); @Test - public void testSmoke() throws SQLException { + void testSmoke() throws SQLException { try ( // creatingYSQLContainer { final YugabyteDBYSQLContainer ysqlContainer = new YugabyteDBYSQLContainer( @@ -35,7 +35,7 @@ public void testSmoke() throws SQLException { } @Test - public void testCustomDatabase() throws SQLException { + void testCustomDatabase() throws SQLException { String key = "random"; try ( final YugabyteDBYSQLContainer ysqlContainer = new YugabyteDBYSQLContainer(YBDB_TEST_IMAGE) @@ -49,7 +49,7 @@ public void testCustomDatabase() throws SQLException { } @Test - public void testInitScript() throws SQLException { + void testInitScript() throws SQLException { try ( final YugabyteDBYSQLContainer ysqlContainer = new YugabyteDBYSQLContainer(YBDB_TEST_IMAGE) .withInitScript("init/init_yql.sql") @@ -62,7 +62,7 @@ public void testInitScript() throws SQLException { } @Test - public void testWithAdditionalUrlParamInJdbcUrl() { + void testWithAdditionalUrlParamInJdbcUrl() { try ( final YugabyteDBYSQLContainer ysqlContainer = new YugabyteDBYSQLContainer(YBDB_TEST_IMAGE) .withUrlParam("sslmode", "disable") @@ -80,7 +80,7 @@ public void testWithAdditionalUrlParamInJdbcUrl() { } @Test - public void testWithCustomRole() throws SQLException { + void testWithCustomRole() throws SQLException { try ( final YugabyteDBYSQLContainer ysqlContainer = new YugabyteDBYSQLContainer(YBDB_TEST_IMAGE) .withDatabaseName("yugabyte") @@ -95,7 +95,7 @@ public void testWithCustomRole() throws SQLException { } @Test - public void testWaitStrategy() throws SQLException { + void testWaitStrategy() throws SQLException { try (final YugabyteDBYSQLContainer ysqlContainer = new YugabyteDBYSQLContainer(YBDB_TEST_IMAGE)) { ysqlContainer.start(); assertThat(performQuery(ysqlContainer, "SELECT 1").getInt(1))