Skip to content

Commit 888378b

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

File tree

11 files changed

+49
-51
lines changed

11 files changed

+49
-51
lines changed

spring-data-jdbc/pom.xml

Lines changed: 13 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>
@@ -248,9 +236,16 @@
248236

249237
<!-- Testcontainers -->
250238

239+
<dependency>
240+
<groupId>org.apache.commons</groupId>
241+
<artifactId>commons-lang3</artifactId>
242+
<version>3.19.0</version>
243+
<scope>test</scope>
244+
</dependency>
245+
251246
<dependency>
252247
<groupId>org.testcontainers</groupId>
253-
<artifactId>mysql</artifactId>
248+
<artifactId>testcontainers-mysql</artifactId>
254249
<scope>test</scope>
255250
<exclusions>
256251
<exclusion>
@@ -262,31 +257,31 @@
262257

263258
<dependency>
264259
<groupId>org.testcontainers</groupId>
265-
<artifactId>postgresql</artifactId>
260+
<artifactId>testcontainers-postgresql</artifactId>
266261
<scope>test</scope>
267262
</dependency>
268263

269264
<dependency>
270265
<groupId>org.testcontainers</groupId>
271-
<artifactId>mariadb</artifactId>
266+
<artifactId>testcontainers-mariadb</artifactId>
272267
<scope>test</scope>
273268
</dependency>
274269

275270
<dependency>
276271
<groupId>org.testcontainers</groupId>
277-
<artifactId>mssqlserver</artifactId>
272+
<artifactId>testcontainers-mssqlserver</artifactId>
278273
<scope>test</scope>
279274
</dependency>
280275

281276
<dependency>
282277
<groupId>org.testcontainers</groupId>
283-
<artifactId>db2</artifactId>
278+
<artifactId>testcontainers-db2</artifactId>
284279
<scope>test</scope>
285280
</dependency>
286281

287282
<dependency>
288283
<groupId>org.testcontainers</groupId>
289-
<artifactId>oracle-free</artifactId>
284+
<artifactId>testcontainers-oracle-free</artifactId>
290285
<scope>test</scope>
291286
</dependency>
292287

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
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;
27+
import org.testcontainers.utility.DockerImageName;
2728

2829
/**
2930
* {@link DataSource} setup for DB2.
@@ -50,7 +51,9 @@ protected DataSource createDataSource() {
5051
if (DB_2_CONTAINER == null) {
5152

5253
LOG.info("DB2 starting...");
53-
Db2Container container = new Db2Container(DOCKER_IMAGE_NAME).withReuse(true);
54+
Db2Container container = new Db2Container(
55+
DockerImageName.parse(DOCKER_IMAGE_NAME).asCompatibleSubstituteFor("icr.io/db2_community/db2"))
56+
.withReuse(true);
5457
container.start();
5558
LOG.info("DB2 started");
5659

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: 12 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>
@@ -247,9 +240,16 @@
247240

248241
<!-- Testcontainers -->
249242

243+
<dependency>
244+
<groupId>org.apache.commons</groupId>
245+
<artifactId>commons-lang3</artifactId>
246+
<version>3.19.0</version>
247+
<scope>test</scope>
248+
</dependency>
249+
250250
<dependency>
251251
<groupId>org.testcontainers</groupId>
252-
<artifactId>mysql</artifactId>
252+
<artifactId>testcontainers-mysql</artifactId>
253253
<scope>test</scope>
254254
<exclusions>
255255
<exclusion>
@@ -261,7 +261,7 @@
261261

262262
<dependency>
263263
<groupId>org.testcontainers</groupId>
264-
<artifactId>mariadb</artifactId>
264+
<artifactId>testcontainers-mariadb</artifactId>
265265
<scope>test</scope>
266266
<exclusions>
267267
<exclusion>
@@ -273,7 +273,7 @@
273273

274274
<dependency>
275275
<groupId>org.testcontainers</groupId>
276-
<artifactId>mssqlserver</artifactId>
276+
<artifactId>testcontainers-mssqlserver</artifactId>
277277
<scope>test</scope>
278278
<exclusions>
279279
<exclusion>
@@ -285,13 +285,13 @@
285285

286286
<dependency>
287287
<groupId>org.testcontainers</groupId>
288-
<artifactId>oracle-free</artifactId>
288+
<artifactId>testcontainers-oracle-free</artifactId>
289289
<scope>test</scope>
290290
</dependency>
291291

292292
<dependency>
293293
<groupId>org.testcontainers</groupId>
294-
<artifactId>postgresql</artifactId>
294+
<artifactId>testcontainers-postgresql</artifactId>
295295
<scope>test</scope>
296296
</dependency>
297297

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)