Skip to content

Commit 86d102f

Browse files
committed
Move PostgreSQL tests to JUnit Jupiter
1 parent 1f3ac9d commit 86d102f

File tree

12 files changed

+47
-56
lines changed

12 files changed

+47
-56
lines changed

modules/postgresql/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ dependencies {
66
compileOnly project(':testcontainers-r2dbc')
77
compileOnly 'io.r2dbc:r2dbc-postgresql:0.8.13.RELEASE'
88

9+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.0'
10+
11+
testImplementation 'org.junit.jupiter:junit-jupiter:5.13.4'
912
testImplementation project(':testcontainers-jdbc-test')
1013
testRuntimeOnly 'org.postgresql:postgresql:42.7.7'
1114

@@ -20,3 +23,7 @@ tasks.japicmp {
2023
"org.testcontainers.containers.PostgreSQLContainer"
2124
]
2225
}
26+
27+
test {
28+
useJUnitPlatform()
29+
}

modules/postgresql/src/test/java/org/testcontainers/containers/CompatibleImageTest.java

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

3-
import org.junit.Test;
3+
import org.junit.jupiter.api.Test;
44
import org.testcontainers.db.AbstractContainerDatabaseTest;
55
import org.testcontainers.utility.DockerImageName;
66

@@ -9,10 +9,10 @@
99

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

12-
public class CompatibleImageTest extends AbstractContainerDatabaseTest {
12+
class CompatibleImageTest extends AbstractContainerDatabaseTest {
1313

1414
@Test
15-
public void pgvector() throws SQLException {
15+
void pgvector() throws SQLException {
1616
try (
1717
// pgvectorContainer {
1818
PostgreSQLContainer<?> pgvector = new PostgreSQLContainer<>("pgvector/pgvector:pg16")
@@ -27,7 +27,7 @@ public void pgvector() throws SQLException {
2727
}
2828

2929
@Test
30-
public void postgis() throws SQLException {
30+
void postgis() throws SQLException {
3131
try (
3232
// postgisContainer {
3333
PostgreSQLContainer<?> postgis = new PostgreSQLContainer<>(
@@ -44,7 +44,7 @@ public void postgis() throws SQLException {
4444
}
4545

4646
@Test
47-
public void timescaledb() throws SQLException {
47+
void timescaledb() throws SQLException {
4848
try (
4949
// timescaledbContainer {
5050
PostgreSQLContainer<?> timescaledb = new PostgreSQLContainer<>(

modules/postgresql/src/test/java/org/testcontainers/containers/PostgreSQLConnectionURLTest.java

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

3-
import org.junit.Test;
3+
import org.junit.jupiter.api.Test;
44
import org.testcontainers.PostgreSQLTestImages;
55

66
import static org.assertj.core.api.Assertions.assertThat;
77
import static org.assertj.core.api.Assertions.catchThrowable;
88

9-
public class PostgreSQLConnectionURLTest {
9+
class PostgreSQLConnectionURLTest {
1010

1111
@Test
12-
public void shouldCorrectlyAppendQueryString() {
12+
void shouldCorrectlyAppendQueryString() {
1313
PostgreSQLContainer<?> postgres = new FixedJdbcUrlPostgreSQLContainer();
1414
String connectionUrl = postgres.constructUrlForConnection("?stringtype=unspecified&stringtype=unspecified");
1515
String queryString = connectionUrl.substring(connectionUrl.indexOf('?'));
@@ -22,7 +22,7 @@ public void shouldCorrectlyAppendQueryString() {
2222
}
2323

2424
@Test
25-
public void shouldCorrectlyAppendQueryStringWhenNoBaseParams() {
25+
void shouldCorrectlyAppendQueryStringWhenNoBaseParams() {
2626
PostgreSQLContainer<?> postgres = new NoParamsUrlPostgreSQLContainer();
2727
String connectionUrl = postgres.constructUrlForConnection("?stringtype=unspecified&stringtype=unspecified");
2828
String queryString = connectionUrl.substring(connectionUrl.indexOf('?'));
@@ -35,15 +35,15 @@ public void shouldCorrectlyAppendQueryStringWhenNoBaseParams() {
3535
}
3636

3737
@Test
38-
public void shouldReturnOriginalURLWhenEmptyQueryString() {
38+
void shouldReturnOriginalURLWhenEmptyQueryString() {
3939
PostgreSQLContainer<?> postgres = new FixedJdbcUrlPostgreSQLContainer();
4040
String connectionUrl = postgres.constructUrlForConnection("");
4141

4242
assertThat(postgres.getJdbcUrl()).as("Query String remains unchanged").isEqualTo(connectionUrl);
4343
}
4444

4545
@Test
46-
public void shouldRejectInvalidQueryString() {
46+
void shouldRejectInvalidQueryString() {
4747
assertThat(
4848
catchThrowable(() -> {
4949
new NoParamsUrlPostgreSQLContainer().constructUrlForConnection("stringtype=unspecified");

modules/postgresql/src/test/java/org/testcontainers/containers/TimescaleDBContainerTest.java

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

3-
import org.junit.Test;
3+
import org.junit.jupiter.api.Test;
44
import org.testcontainers.db.AbstractContainerDatabaseTest;
55

66
import java.sql.ResultSet;
77
import java.sql.SQLException;
88

99
import static org.assertj.core.api.Assertions.assertThat;
1010

11-
public class TimescaleDBContainerTest extends AbstractContainerDatabaseTest {
11+
class TimescaleDBContainerTest extends AbstractContainerDatabaseTest {
1212

1313
@Test
14-
public void testSimple() throws SQLException {
14+
void testSimple() throws SQLException {
1515
try (JdbcDatabaseContainer<?> postgres = new TimescaleDBContainerProvider().newInstance()) {
1616
postgres.start();
1717

@@ -22,7 +22,7 @@ public void testSimple() throws SQLException {
2222
}
2323

2424
@Test
25-
public void testCommandOverride() throws SQLException {
25+
void testCommandOverride() throws SQLException {
2626
try (
2727
GenericContainer<?> postgres = new TimescaleDBContainerProvider()
2828
.newInstance()
@@ -40,7 +40,7 @@ public void testCommandOverride() throws SQLException {
4040
}
4141

4242
@Test
43-
public void testUnsetCommand() throws SQLException {
43+
void testUnsetCommand() throws SQLException {
4444
try (
4545
GenericContainer<?> postgres = new TimescaleDBContainerProvider()
4646
.newInstance()
@@ -59,7 +59,7 @@ public void testUnsetCommand() throws SQLException {
5959
}
6060

6161
@Test
62-
public void testExplicitInitScript() throws SQLException {
62+
void testExplicitInitScript() throws SQLException {
6363
try (
6464
JdbcDatabaseContainer<?> postgres = new TimescaleDBContainerProvider()
6565
.newInstance()

modules/postgresql/src/test/java/org/testcontainers/jdbc/DatabaseDriverShutdownTest.java

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

3-
import org.junit.AfterClass;
4-
import org.junit.Test;
3+
import org.junit.jupiter.api.BeforeAll;
4+
import org.junit.jupiter.api.Test;
55
import org.testcontainers.containers.JdbcDatabaseContainer;
66

77
import java.sql.Connection;
@@ -16,15 +16,15 @@
1616
* the mysql module, to avoid circular dependencies.
1717
* 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.
1818
*/
19-
public class DatabaseDriverShutdownTest {
19+
class DatabaseDriverShutdownTest {
2020

21-
@AfterClass
21+
@BeforeAll
2222
public static void testCleanup() {
2323
ContainerDatabaseDriver.killContainers();
2424
}
2525

2626
@Test
27-
public void shouldStopContainerWhenAllConnectionsClosed() throws SQLException {
27+
void shouldStopContainerWhenAllConnectionsClosed() throws SQLException {
2828
final String jdbcUrl = "jdbc:tc:postgresql:9.6.8://hostname/databasename";
2929

3030
getConnectionAndClose(jdbcUrl);
@@ -34,7 +34,7 @@ public void shouldStopContainerWhenAllConnectionsClosed() throws SQLException {
3434
}
3535

3636
@Test
37-
public void shouldNotStopDaemonContainerWhenAllConnectionsClosed() throws SQLException {
37+
void shouldNotStopDaemonContainerWhenAllConnectionsClosed() throws SQLException {
3838
final String jdbcUrl = "jdbc:tc:postgresql:9.6.8://hostname/databasename?TC_DAEMON=true";
3939

4040
getConnectionAndClose(jdbcUrl);

modules/postgresql/src/test/java/org/testcontainers/jdbc/DatabaseDriverTmpfsTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.testcontainers.jdbc;
22

3-
import org.junit.Test;
3+
import org.junit.jupiter.api.Test;
44
import org.testcontainers.containers.Container;
55
import org.testcontainers.containers.JdbcDatabaseContainer;
66

@@ -15,10 +15,10 @@
1515
* the mysql module, to avoid circular dependencies.
1616
* 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.
1717
*/
18-
public class DatabaseDriverTmpfsTest {
18+
class DatabaseDriverTmpfsTest {
1919

2020
@Test
21-
public void testDatabaseHasTmpFsViaConnectionString() throws Exception {
21+
void testDatabaseHasTmpFsViaConnectionString() throws Exception {
2222
final String jdbcUrl = "jdbc:tc:postgresql:9.6.8://hostname/databasename?TC_TMPFS=/testtmpfs:rw";
2323
try (Connection ignored = DriverManager.getConnection(jdbcUrl)) {
2424
JdbcDatabaseContainer<?> container = ContainerDatabaseDriver.getContainer(jdbcUrl);

modules/postgresql/src/test/java/org/testcontainers/jdbc/pgvector/PgVectorJDBCDriverTest.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
package org.testcontainers.jdbc.pgvector;
22

3-
import org.junit.runner.RunWith;
4-
import org.junit.runners.Parameterized;
53
import org.testcontainers.jdbc.AbstractJDBCDriverTest;
64

75
import java.util.Arrays;
86
import java.util.EnumSet;
97

10-
@RunWith(Parameterized.class)
11-
public class PgVectorJDBCDriverTest extends AbstractJDBCDriverTest {
8+
class PgVectorJDBCDriverTest extends AbstractJDBCDriverTest {
129

13-
@Parameterized.Parameters(name = "{index} - {0}")
1410
public static Iterable<Object[]> data() {
1511
return Arrays.asList(
1612
new Object[][] {

modules/postgresql/src/test/java/org/testcontainers/jdbc/postgis/PostgisJDBCDriverTest.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
package org.testcontainers.jdbc.postgis;
22

3-
import org.junit.runner.RunWith;
4-
import org.junit.runners.Parameterized;
53
import org.testcontainers.jdbc.AbstractJDBCDriverTest;
64

75
import java.util.Arrays;
86
import java.util.EnumSet;
97

10-
@RunWith(Parameterized.class)
11-
public class PostgisJDBCDriverTest extends AbstractJDBCDriverTest {
8+
class PostgisJDBCDriverTest extends AbstractJDBCDriverTest {
129

13-
@Parameterized.Parameters(name = "{index} - {0}")
1410
public static Iterable<Object[]> data() {
1511
return Arrays.asList(
1612
new Object[][] {

modules/postgresql/src/test/java/org/testcontainers/jdbc/postgresql/PostgreSQLJDBCDriverTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
package org.testcontainers.jdbc.postgresql;
22

3-
import org.junit.runner.RunWith;
4-
import org.junit.runners.Parameterized;
53
import org.testcontainers.jdbc.AbstractJDBCDriverTest;
64

75
import java.util.Arrays;
86
import java.util.EnumSet;
97

10-
@RunWith(Parameterized.class)
118
public class PostgreSQLJDBCDriverTest extends AbstractJDBCDriverTest {
129

13-
@Parameterized.Parameters(name = "{index} - {0}")
1410
public static Iterable<Object[]> data() {
1511
return Arrays.asList(
1612
new Object[][] {

modules/postgresql/src/test/java/org/testcontainers/jdbc/timescaledb/TimescaleDBJDBCDriverTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
package org.testcontainers.jdbc.timescaledb;
22

3-
import org.junit.runner.RunWith;
4-
import org.junit.runners.Parameterized;
53
import org.testcontainers.jdbc.AbstractJDBCDriverTest;
64

75
import java.util.Arrays;
86
import java.util.EnumSet;
97

10-
@RunWith(Parameterized.class)
118
public class TimescaleDBJDBCDriverTest extends AbstractJDBCDriverTest {
129

13-
@Parameterized.Parameters(name = "{index} - {0}")
1410
public static Iterable<Object[]> data() {
1511
return Arrays.asList(
1612
new Object[][] {

0 commit comments

Comments
 (0)