Skip to content

Commit b32a46b

Browse files
committed
Upgrade to Testcontainers 2.0.
See spring-projects/spring-data-build#2688
1 parent fc0ec73 commit b32a46b

File tree

11 files changed

+31
-50
lines changed

11 files changed

+31
-50
lines changed

spring-data-jdbc/pom.xml

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,6 @@
2323
<project.root>${basedir}/..</project.root>
2424
</properties>
2525

26-
<dependencyManagement>
27-
<dependencies>
28-
<dependency>
29-
<groupId>org.testcontainers</groupId>
30-
<artifactId>testcontainers-bom</artifactId>
31-
<version>${testcontainers}</version>
32-
<type>pom</type>
33-
<scope>import</scope>
34-
</dependency>
35-
</dependencies>
36-
</dependencyManagement>
37-
3826
<dependencies>
3927

4028
<dependency>
@@ -250,7 +238,7 @@
250238

251239
<dependency>
252240
<groupId>org.testcontainers</groupId>
253-
<artifactId>mysql</artifactId>
241+
<artifactId>testcontainers-mysql</artifactId>
254242
<scope>test</scope>
255243
<exclusions>
256244
<exclusion>
@@ -262,31 +250,31 @@
262250

263251
<dependency>
264252
<groupId>org.testcontainers</groupId>
265-
<artifactId>postgresql</artifactId>
253+
<artifactId>testcontainers-postgresql</artifactId>
266254
<scope>test</scope>
267255
</dependency>
268256

269257
<dependency>
270258
<groupId>org.testcontainers</groupId>
271-
<artifactId>mariadb</artifactId>
259+
<artifactId>testcontainers-mariadb</artifactId>
272260
<scope>test</scope>
273261
</dependency>
274262

275263
<dependency>
276264
<groupId>org.testcontainers</groupId>
277-
<artifactId>mssqlserver</artifactId>
265+
<artifactId>testcontainers-mssqlserver</artifactId>
278266
<scope>test</scope>
279267
</dependency>
280268

281269
<dependency>
282270
<groupId>org.testcontainers</groupId>
283-
<artifactId>db2</artifactId>
271+
<artifactId>testcontainers-db2</artifactId>
284272
<scope>test</scope>
285273
</dependency>
286274

287275
<dependency>
288276
<groupId>org.testcontainers</groupId>
289-
<artifactId>oracle-free</artifactId>
277+
<artifactId>testcontainers-oracle-free</artifactId>
290278
<scope>test</scope>
291279
</dependency>
292280

spring-data-jdbc/src/test/java/org/springframework/data/jdbc/testing/Db2DataSourceConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.springframework.core.env.Environment;
2424
import org.springframework.jdbc.datasource.DriverManagerDataSource;
2525
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
26-
import org.testcontainers.containers.Db2Container;
26+
import org.testcontainers.db2.Db2Container;
2727

2828
/**
2929
* {@link DataSource} setup for DB2.

spring-data-jdbc/src/test/java/org/springframework/data/jdbc/testing/MariaDBDataSourceConfiguration.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.springframework.core.env.Environment;
2727
import org.springframework.core.io.ByteArrayResource;
2828
import org.springframework.jdbc.datasource.init.ScriptUtils;
29-
import org.testcontainers.containers.MariaDBContainer;
29+
import org.testcontainers.mariadb.MariaDBContainer;
3030

3131
/**
3232
* {@link DataSource} setup for MariaDB. Starts a Docker-container with a MariaDB database, and sets up database "test".
@@ -39,7 +39,7 @@
3939
@ConditionalOnDatabase(DatabaseType.MARIADB)
4040
class MariaDBDataSourceConfiguration extends DataSourceConfiguration implements InitializingBean {
4141

42-
private static MariaDBContainer<?> MARIADB_CONTAINER;
42+
private static MariaDBContainer MARIADB_CONTAINER;
4343

4444
public MariaDBDataSourceConfiguration(TestClass testClass, Environment environment) {
4545
super(testClass, environment);
@@ -50,7 +50,7 @@ protected DataSource createDataSource() {
5050

5151
if (MARIADB_CONTAINER == null) {
5252

53-
MariaDBContainer<?> container = new MariaDBContainer<>("mariadb:10.8.3").withUsername("root").withPassword("")
53+
MariaDBContainer container = new MariaDBContainer("mariadb:10.8.3").withUsername("root").withPassword("")
5454
.withConfigurationOverride("");
5555
container.start();
5656

spring-data-jdbc/src/test/java/org/springframework/data/jdbc/testing/MsSqlDataSourceConfiguration.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import org.springframework.context.annotation.Configuration;
2121
import org.springframework.core.env.Environment;
2222
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
23-
import org.testcontainers.containers.MSSQLServerContainer;
23+
import org.testcontainers.mssqlserver.MSSQLServerContainer;
2424

2525
import com.microsoft.sqlserver.jdbc.SQLServerDataSource;
2626

@@ -39,7 +39,7 @@
3939
public class MsSqlDataSourceConfiguration extends DataSourceConfiguration {
4040

4141
public static final String MS_SQL_SERVER_VERSION = "mcr.microsoft.com/mssql/server:2022-latest";
42-
private static MSSQLServerContainer<?> MSSQL_CONTAINER;
42+
private static MSSQLServerContainer MSSQL_CONTAINER;
4343

4444
public MsSqlDataSourceConfiguration(TestClass testClass, Environment environment) {
4545
super(testClass, environment);
@@ -50,7 +50,7 @@ protected DataSource createDataSource() {
5050

5151
if (MSSQL_CONTAINER == null) {
5252

53-
MSSQLServerContainer<?> container = new MSSQLServerContainer<>(MS_SQL_SERVER_VERSION) //
53+
MSSQLServerContainer container = new MSSQLServerContainer(MS_SQL_SERVER_VERSION) //
5454
.withReuse(true);
5555
container.start();
5656

spring-data-jdbc/src/test/java/org/springframework/data/jdbc/testing/MySqlDataSourceConfiguration.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import org.springframework.core.env.Environment;
2525
import org.springframework.core.io.ByteArrayResource;
2626
import org.springframework.jdbc.datasource.init.ScriptUtils;
27-
import org.testcontainers.containers.MySQLContainer;
27+
import org.testcontainers.mysql.MySQLContainer;
2828

2929
import com.mysql.cj.jdbc.MysqlDataSource;
3030

@@ -41,7 +41,7 @@
4141
@ConditionalOnDatabase(DatabaseType.MYSQL)
4242
class MySqlDataSourceConfiguration extends DataSourceConfiguration implements InitializingBean {
4343

44-
private static MySQLContainer<?> MYSQL_CONTAINER;
44+
private static MySQLContainer MYSQL_CONTAINER;
4545

4646
public MySqlDataSourceConfiguration(TestClass testClass, Environment environment) {
4747
super(testClass, environment);
@@ -52,7 +52,7 @@ protected DataSource createDataSource() {
5252

5353
if (MYSQL_CONTAINER == null) {
5454

55-
MySQLContainer<?> container = new MySQLContainer<>("mysql:8.0.29").withUsername("test").withPassword("test")
55+
MySQLContainer container = new MySQLContainer("mysql:8.0.29").withUsername("test").withPassword("test")
5656
.withConfigurationOverride("");
5757

5858
container.start();

spring-data-jdbc/src/test/java/org/springframework/data/jdbc/testing/PostgresDataSourceConfiguration.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import org.springframework.context.annotation.Configuration;
2222
import org.springframework.core.env.Environment;
2323
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
24-
import org.testcontainers.containers.PostgreSQLContainer;
24+
import org.testcontainers.postgresql.PostgreSQLContainer;
2525

2626
/**
2727
* {@link DataSource} setup for PostgreSQL. Starts a docker container with a Postgres database.
@@ -35,7 +35,7 @@
3535
@ConditionalOnDatabase(DatabaseType.POSTGRES)
3636
public class PostgresDataSourceConfiguration extends DataSourceConfiguration {
3737

38-
private static PostgreSQLContainer<?> POSTGRESQL_CONTAINER;
38+
private static PostgreSQLContainer POSTGRESQL_CONTAINER;
3939

4040
public PostgresDataSourceConfiguration(TestClass testClass, Environment environment) {
4141
super(testClass, environment);
@@ -46,7 +46,7 @@ protected DataSource createDataSource() {
4646

4747
if (POSTGRESQL_CONTAINER == null) {
4848

49-
PostgreSQLContainer<?> container = new PostgreSQLContainer<>("postgres:14.3");
49+
PostgreSQLContainer container = new PostgreSQLContainer("postgres:14.3");
5050
container.start();
5151

5252
POSTGRESQL_CONTAINER = container;

spring-data-r2dbc/pom.xml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,6 @@
3535

3636
<dependencyManagement>
3737
<dependencies>
38-
<dependency>
39-
<groupId>org.testcontainers</groupId>
40-
<artifactId>testcontainers-bom</artifactId>
41-
<version>${testcontainers}</version>
42-
<type>pom</type>
43-
<scope>import</scope>
44-
</dependency>
4538
<dependency>
4639
<groupId>io.netty</groupId>
4740
<artifactId>netty-bom</artifactId>
@@ -249,7 +242,7 @@
249242

250243
<dependency>
251244
<groupId>org.testcontainers</groupId>
252-
<artifactId>mysql</artifactId>
245+
<artifactId>testcontainers-mysql</artifactId>
253246
<scope>test</scope>
254247
<exclusions>
255248
<exclusion>
@@ -261,7 +254,7 @@
261254

262255
<dependency>
263256
<groupId>org.testcontainers</groupId>
264-
<artifactId>mariadb</artifactId>
257+
<artifactId>testcontainers-mariadb</artifactId>
265258
<scope>test</scope>
266259
<exclusions>
267260
<exclusion>
@@ -273,7 +266,7 @@
273266

274267
<dependency>
275268
<groupId>org.testcontainers</groupId>
276-
<artifactId>mssqlserver</artifactId>
269+
<artifactId>testcontainers-mssqlserver</artifactId>
277270
<scope>test</scope>
278271
<exclusions>
279272
<exclusion>
@@ -285,13 +278,13 @@
285278

286279
<dependency>
287280
<groupId>org.testcontainers</groupId>
288-
<artifactId>oracle-free</artifactId>
281+
<artifactId>testcontainers-oracle-free</artifactId>
289282
<scope>test</scope>
290283
</dependency>
291284

292285
<dependency>
293286
<groupId>org.testcontainers</groupId>
294-
<artifactId>postgresql</artifactId>
287+
<artifactId>testcontainers-postgresql</artifactId>
295288
<scope>test</scope>
296289
</dependency>
297290

spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/testing/MariaDbTestSupport.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import org.mariadb.jdbc.MariaDbDataSource;
2828
import org.mariadb.r2dbc.MariadbConnectionFactoryProvider;
2929
import org.springframework.data.r2dbc.testing.ExternalDatabase.ProvidedDatabase;
30-
import org.testcontainers.containers.MariaDBContainer;
30+
import org.testcontainers.mariadb.MariaDBContainer;
3131
import org.testcontainers.utility.DockerImageName;
3232

3333
/**
@@ -123,7 +123,7 @@ private static ExternalDatabase testContainer() {
123123
.asCompatibleSubstituteFor("mariadb");
124124

125125
DockerImageName mariadb = DockerImageName.parse("mariadb").withTag("10.3.6");
126-
var container = new MariaDBContainer<>("aarch64".equals(osArch) ? armImageName : mariadb);
126+
var container = new MariaDBContainer("aarch64".equals(osArch) ? armImageName : mariadb);
127127

128128
container.start();
129129

spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/testing/MySqlDbTestSupport.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import javax.sql.DataSource;
2626

2727
import org.springframework.data.r2dbc.testing.ExternalDatabase.ProvidedDatabase;
28-
import org.testcontainers.containers.MySQLContainer;
28+
import org.testcontainers.mysql.MySQLContainer;
2929

3030
import com.mysql.cj.jdbc.MysqlDataSource;
3131

@@ -116,7 +116,7 @@ private static ExternalDatabase testContainer() {
116116

117117
try {
118118

119-
var container = new MySQLContainer<>("mysql:8.0.32").withUsername("test").withPassword("test")
119+
var container = new MySQLContainer("mysql:8.0.32").withUsername("test").withPassword("test")
120120
.withConfigurationOverride("");
121121

122122
container.start();

spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/testing/PostgresTestSupport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
import org.postgresql.ds.PGSimpleDataSource;
2626
import org.springframework.data.r2dbc.testing.ExternalDatabase.ProvidedDatabase;
27-
import org.testcontainers.containers.PostgreSQLContainer;
27+
import org.testcontainers.postgresql.PostgreSQLContainer;
2828

2929
/**
3030
* Utility class for testing against Postgres.

0 commit comments

Comments
 (0)