Merge branch '3.1.x'

Closes gh-36486
pull/36565/head
Scott Frederick 1 year ago
commit 2452958f7b

@ -29,6 +29,7 @@ dependencies {
testImplementation("org.mockito:mockito-core") testImplementation("org.mockito:mockito-core")
testImplementation("org.springframework:spring-core-test") testImplementation("org.springframework:spring-core-test")
testImplementation("org.springframework:spring-test") testImplementation("org.springframework:spring-test")
testImplementation("org.testcontainers:testcontainers")
testRuntimeOnly("com.microsoft.sqlserver:mssql-jdbc") testRuntimeOnly("com.microsoft.sqlserver:mssql-jdbc")
testRuntimeOnly("com.oracle.database.r2dbc:oracle-r2dbc") testRuntimeOnly("com.oracle.database.r2dbc:oracle-r2dbc")

@ -20,6 +20,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.jms.activemq.ActiveMQConnectionDetails; import org.springframework.boot.autoconfigure.jms.activemq.ActiveMQConnectionDetails;
import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests; import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests;
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -31,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class ActiveMQDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests { class ActiveMQDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests {
ActiveMQDockerComposeConnectionDetailsFactoryIntegrationTests() { ActiveMQDockerComposeConnectionDetailsFactoryIntegrationTests() {
super("activemq-compose.yaml"); super("activemq-compose.yaml", DockerImageNames.activeMq());
} }
@Test @Test

@ -23,6 +23,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.cassandra.CassandraConnectionDetails; import org.springframework.boot.autoconfigure.cassandra.CassandraConnectionDetails;
import org.springframework.boot.autoconfigure.cassandra.CassandraConnectionDetails.Node; import org.springframework.boot.autoconfigure.cassandra.CassandraConnectionDetails.Node;
import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests; import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests;
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -34,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class CassandraDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests { class CassandraDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests {
CassandraDockerComposeConnectionDetailsFactoryIntegrationTests() { CassandraDockerComposeConnectionDetailsFactoryIntegrationTests() {
super("cassandra-compose.yaml"); super("cassandra-compose.yaml", DockerImageNames.cassandra());
} }
@Test @Test

@ -22,6 +22,7 @@ import org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchConnect
import org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchConnectionDetails.Node; import org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchConnectionDetails.Node;
import org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchConnectionDetails.Node.Protocol; import org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchConnectionDetails.Node.Protocol;
import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests; import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests;
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -35,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class ElasticsearchDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests { class ElasticsearchDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests {
ElasticsearchDockerComposeConnectionDetailsFactoryIntegrationTests() { ElasticsearchDockerComposeConnectionDetailsFactoryIntegrationTests() {
super("elasticsearch-compose.yaml"); super("elasticsearch-compose.yaml", DockerImageNames.elasticsearch8());
} }
@Test @Test

@ -20,6 +20,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.flyway.FlywayConnectionDetails; import org.springframework.boot.autoconfigure.flyway.FlywayConnectionDetails;
import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests; import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests;
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -31,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class JdbcAdaptingFlywayConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests { class JdbcAdaptingFlywayConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests {
JdbcAdaptingFlywayConnectionDetailsFactoryIntegrationTests() { JdbcAdaptingFlywayConnectionDetailsFactoryIntegrationTests() {
super("flyway-compose.yaml"); super("flyway-compose.yaml", DockerImageNames.postgresql());
} }
@Test @Test

@ -20,6 +20,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.liquibase.LiquibaseConnectionDetails; import org.springframework.boot.autoconfigure.liquibase.LiquibaseConnectionDetails;
import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests; import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests;
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -31,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class JdbcAdaptingLiquibaseConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests { class JdbcAdaptingLiquibaseConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests {
JdbcAdaptingLiquibaseConnectionDetailsFactoryIntegrationTests() { JdbcAdaptingLiquibaseConnectionDetailsFactoryIntegrationTests() {
super("liquibase-compose.yaml"); super("liquibase-compose.yaml", DockerImageNames.postgresql());
} }
@Test @Test

@ -20,6 +20,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.jdbc.JdbcConnectionDetails; import org.springframework.boot.autoconfigure.jdbc.JdbcConnectionDetails;
import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests; import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests;
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -33,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class MariaDbJdbcDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests { class MariaDbJdbcDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests {
MariaDbJdbcDockerComposeConnectionDetailsFactoryIntegrationTests() { MariaDbJdbcDockerComposeConnectionDetailsFactoryIntegrationTests() {
super("mariadb-compose.yaml"); super("mariadb-compose.yaml", DockerImageNames.mariadb());
} }
@Test @Test

@ -21,6 +21,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.r2dbc.R2dbcConnectionDetails; import org.springframework.boot.autoconfigure.r2dbc.R2dbcConnectionDetails;
import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests; import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests;
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -34,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class MariaDbR2dbcDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests { class MariaDbR2dbcDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests {
MariaDbR2dbcDockerComposeConnectionDetailsFactoryIntegrationTests() { MariaDbR2dbcDockerComposeConnectionDetailsFactoryIntegrationTests() {
super("mariadb-compose.yaml"); super("mariadb-compose.yaml", DockerImageNames.mariadb());
} }
@Test @Test

@ -21,6 +21,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.mongo.MongoConnectionDetails; import org.springframework.boot.autoconfigure.mongo.MongoConnectionDetails;
import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests; import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests;
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -35,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class MongoDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests { class MongoDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests {
MongoDockerComposeConnectionDetailsFactoryIntegrationTests() { MongoDockerComposeConnectionDetailsFactoryIntegrationTests() {
super("mongo-compose.yaml"); super("mongo-compose.yaml", DockerImageNames.mongo());
} }
@Test @Test

@ -20,6 +20,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.jdbc.JdbcConnectionDetails; import org.springframework.boot.autoconfigure.jdbc.JdbcConnectionDetails;
import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests; import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests;
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -33,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class MySqlJdbcDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests { class MySqlJdbcDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests {
MySqlJdbcDockerComposeConnectionDetailsFactoryIntegrationTests() { MySqlJdbcDockerComposeConnectionDetailsFactoryIntegrationTests() {
super("mysql-compose.yaml"); super("mysql-compose.yaml", DockerImageNames.mysql());
} }
@Test @Test

@ -21,6 +21,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.r2dbc.R2dbcConnectionDetails; import org.springframework.boot.autoconfigure.r2dbc.R2dbcConnectionDetails;
import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests; import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests;
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -34,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class MySqlR2dbcDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests { class MySqlR2dbcDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests {
MySqlR2dbcDockerComposeConnectionDetailsFactoryIntegrationTests() { MySqlR2dbcDockerComposeConnectionDetailsFactoryIntegrationTests() {
super("mysql-compose.yaml"); super("mysql-compose.yaml", DockerImageNames.mysql());
} }
@Test @Test

@ -27,6 +27,7 @@ import org.springframework.boot.autoconfigure.jdbc.JdbcConnectionDetails;
import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests; import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests;
import org.springframework.boot.jdbc.DatabaseDriver; import org.springframework.boot.jdbc.DatabaseDriver;
import org.springframework.boot.testsupport.junit.DisabledOnOs; import org.springframework.boot.testsupport.junit.DisabledOnOs;
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.SimpleDriverDataSource; import org.springframework.jdbc.datasource.SimpleDriverDataSource;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
@ -43,7 +44,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class OracleJdbcDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests { class OracleJdbcDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests {
OracleJdbcDockerComposeConnectionDetailsFactoryIntegrationTests() { OracleJdbcDockerComposeConnectionDetailsFactoryIntegrationTests() {
super("oracle-compose.yaml"); super("oracle-compose.yaml", DockerImageNames.oracleXe());
} }
@Test @Test

@ -28,6 +28,7 @@ import org.springframework.boot.autoconfigure.r2dbc.R2dbcConnectionDetails;
import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests; import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests;
import org.springframework.boot.jdbc.DatabaseDriver; import org.springframework.boot.jdbc.DatabaseDriver;
import org.springframework.boot.testsupport.junit.DisabledOnOs; import org.springframework.boot.testsupport.junit.DisabledOnOs;
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
import org.springframework.r2dbc.core.DatabaseClient; import org.springframework.r2dbc.core.DatabaseClient;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -42,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class OracleR2dbcDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests { class OracleR2dbcDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests {
OracleR2dbcDockerComposeConnectionDetailsFactoryIntegrationTests() { OracleR2dbcDockerComposeConnectionDetailsFactoryIntegrationTests() {
super("oracle-compose.yaml"); super("oracle-compose.yaml", DockerImageNames.oracleXe());
} }
@Test @Test

@ -20,6 +20,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.jdbc.JdbcConnectionDetails; import org.springframework.boot.autoconfigure.jdbc.JdbcConnectionDetails;
import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests; import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests;
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -33,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class PostgresJdbcDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests { class PostgresJdbcDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests {
PostgresJdbcDockerComposeConnectionDetailsFactoryIntegrationTests() { PostgresJdbcDockerComposeConnectionDetailsFactoryIntegrationTests() {
super("postgres-compose.yaml"); super("postgres-compose.yaml", DockerImageNames.postgresql());
} }
@Test @Test

@ -21,6 +21,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.r2dbc.R2dbcConnectionDetails; import org.springframework.boot.autoconfigure.r2dbc.R2dbcConnectionDetails;
import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests; import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests;
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -34,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class PostgresR2dbcDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests { class PostgresR2dbcDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests {
PostgresR2dbcDockerComposeConnectionDetailsFactoryIntegrationTests() { PostgresR2dbcDockerComposeConnectionDetailsFactoryIntegrationTests() {
super("postgres-compose.yaml"); super("postgres-compose.yaml", DockerImageNames.postgresql());
} }
@Test @Test

@ -21,6 +21,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.amqp.RabbitConnectionDetails; import org.springframework.boot.autoconfigure.amqp.RabbitConnectionDetails;
import org.springframework.boot.autoconfigure.amqp.RabbitConnectionDetails.Address; import org.springframework.boot.autoconfigure.amqp.RabbitConnectionDetails.Address;
import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests; import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests;
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -34,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class RabbitDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests { class RabbitDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests {
RabbitDockerComposeConnectionDetailsFactoryIntegrationTests() { RabbitDockerComposeConnectionDetailsFactoryIntegrationTests() {
super("rabbit-compose.yaml"); super("rabbit-compose.yaml", DockerImageNames.rabbit());
} }
@Test @Test

@ -21,6 +21,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.data.redis.RedisConnectionDetails; import org.springframework.boot.autoconfigure.data.redis.RedisConnectionDetails;
import org.springframework.boot.autoconfigure.data.redis.RedisConnectionDetails.Standalone; import org.springframework.boot.autoconfigure.data.redis.RedisConnectionDetails.Standalone;
import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests; import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests;
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -34,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class RedisDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests { class RedisDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests {
RedisDockerComposeConnectionDetailsFactoryIntegrationTests() { RedisDockerComposeConnectionDetailsFactoryIntegrationTests() {
super("redis-compose.yaml"); super("redis-compose.yaml", DockerImageNames.redis());
} }
@Test @Test

@ -25,6 +25,7 @@ import org.springframework.boot.autoconfigure.jdbc.JdbcConnectionDetails;
import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests; import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests;
import org.springframework.boot.jdbc.DatabaseDriver; import org.springframework.boot.jdbc.DatabaseDriver;
import org.springframework.boot.testsupport.junit.DisabledOnOs; import org.springframework.boot.testsupport.junit.DisabledOnOs;
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.SimpleDriverDataSource; import org.springframework.jdbc.datasource.SimpleDriverDataSource;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
@ -41,7 +42,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class SqlServerJdbcDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests { class SqlServerJdbcDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests {
SqlServerJdbcDockerComposeConnectionDetailsFactoryIntegrationTests() { SqlServerJdbcDockerComposeConnectionDetailsFactoryIntegrationTests() {
super("mssqlserver-compose.yaml"); super("mssqlserver-compose.yaml", DockerImageNames.sqlserver());
} }
@Test @Test

@ -27,6 +27,7 @@ import org.springframework.boot.autoconfigure.r2dbc.R2dbcConnectionDetails;
import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests; import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests;
import org.springframework.boot.jdbc.DatabaseDriver; import org.springframework.boot.jdbc.DatabaseDriver;
import org.springframework.boot.testsupport.junit.DisabledOnOs; import org.springframework.boot.testsupport.junit.DisabledOnOs;
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
import org.springframework.r2dbc.core.DatabaseClient; import org.springframework.r2dbc.core.DatabaseClient;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -42,7 +43,7 @@ class SqlServerR2dbcDockerComposeConnectionDetailsFactoryIntegrationTests
extends AbstractDockerComposeIntegrationTests { extends AbstractDockerComposeIntegrationTests {
SqlServerR2dbcDockerComposeConnectionDetailsFactoryIntegrationTests() { SqlServerR2dbcDockerComposeConnectionDetailsFactoryIntegrationTests() {
super("mssqlserver-compose.yaml"); super("mssqlserver-compose.yaml", DockerImageNames.sqlserver());
} }
@Test @Test

@ -16,10 +16,17 @@
package org.springframework.boot.docker.compose.service.connection.test; package org.springframework.boot.docker.compose.service.connection.test;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Path;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.io.TempDir;
import org.testcontainers.utility.DockerImageName;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringApplicationShutdownHandlers; import org.springframework.boot.SpringApplicationShutdownHandlers;
@ -28,28 +35,38 @@ import org.springframework.boot.testsupport.process.DisabledIfProcessUnavailable
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.util.FileCopyUtils;
import org.springframework.util.function.ThrowingSupplier; import org.springframework.util.function.ThrowingSupplier;
import static org.junit.Assert.fail;
/** /**
* Abstract base class for integration tests. * Abstract base class for integration tests.
* *
* @author Moritz Halbritter * @author Moritz Halbritter
* @author Andy Wilkinson * @author Andy Wilkinson
* @author Scott Frederick
*/ */
@DisabledIfProcessUnavailable({ "docker", "version" }) @DisabledIfProcessUnavailable({ "docker", "version" })
@DisabledIfProcessUnavailable({ "docker", "compose" }) @DisabledIfProcessUnavailable({ "docker", "compose" })
public abstract class AbstractDockerComposeIntegrationTests { public abstract class AbstractDockerComposeIntegrationTests {
@TempDir
private static Path tempDir;
private final Resource composeResource; private final Resource composeResource;
private final DockerImageName dockerImageName;
@AfterAll @AfterAll
static void shutDown() { static void shutDown() {
SpringApplicationShutdownHandlers shutdownHandlers = SpringApplication.getShutdownHandlers(); SpringApplicationShutdownHandlers shutdownHandlers = SpringApplication.getShutdownHandlers();
((Runnable) shutdownHandlers).run(); ((Runnable) shutdownHandlers).run();
} }
protected AbstractDockerComposeIntegrationTests(String composeResource) { protected AbstractDockerComposeIntegrationTests(String composeResource, DockerImageName dockerImageName) {
this.composeResource = new ClassPathResource(composeResource, getClass()); this.composeResource = new ClassPathResource(composeResource, getClass());
this.dockerImageName = dockerImageName;
} }
protected final <T extends ConnectionDetails> T run(Class<T> type) { protected final <T extends ConnectionDetails> T run(Class<T> type) {
@ -57,12 +74,26 @@ public abstract class AbstractDockerComposeIntegrationTests {
Map<String, Object> properties = new LinkedHashMap<>(); Map<String, Object> properties = new LinkedHashMap<>();
properties.put("spring.docker.compose.skip.in-tests", "false"); properties.put("spring.docker.compose.skip.in-tests", "false");
properties.put("spring.docker.compose.file", properties.put("spring.docker.compose.file",
ThrowingSupplier.of(this.composeResource::getFile).get().getAbsolutePath()); transformedComposeFile(ThrowingSupplier.of(this.composeResource::getFile).get(), this.dockerImageName));
properties.put("spring.docker.compose.stop.command", "down"); properties.put("spring.docker.compose.stop.command", "down");
application.setDefaultProperties(properties); application.setDefaultProperties(properties);
return application.run().getBean(type); return application.run().getBean(type);
} }
private File transformedComposeFile(File composeFile, DockerImageName imageName) {
File tempComposeFile = Path.of(tempDir.toString(), composeFile.getName()).toFile();
try {
String composeFileContent = FileCopyUtils.copyToString(new FileReader(composeFile));
composeFileContent = composeFileContent.replace("{imageName}", imageName.asCanonicalNameString());
FileCopyUtils.copy(composeFileContent, new FileWriter(tempComposeFile));
}
catch (IOException ex) {
fail("Error transforming Docker compose file '" + composeFile + "' to '" + tempComposeFile + "': "
+ ex.getMessage());
}
return tempComposeFile;
}
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
static class Config { static class Config {

@ -20,6 +20,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.autoconfigure.tracing.zipkin.ZipkinConnectionDetails; import org.springframework.boot.actuate.autoconfigure.tracing.zipkin.ZipkinConnectionDetails;
import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests; import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests;
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -33,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class ZipkinDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests { class ZipkinDockerComposeConnectionDetailsFactoryIntegrationTests extends AbstractDockerComposeIntegrationTests {
ZipkinDockerComposeConnectionDetailsFactoryIntegrationTests() { ZipkinDockerComposeConnectionDetailsFactoryIntegrationTests() {
super("zipkin-compose.yaml"); super("zipkin-compose.yaml", DockerImageNames.zipkin());
} }
@Test @Test

@ -1,6 +1,6 @@
services: services:
activemq: activemq:
image: 'symptoma/activemq:5.18.0' image: '{imageName}'
ports: ports:
- '61616' - '61616'
environment: environment:

@ -1,6 +1,6 @@
services: services:
cassandra: cassandra:
image: 'cassandra:3.11.10' image: '{imageName}'
ports: ports:
- '9042' - '9042'
environment: environment:

@ -1,6 +1,6 @@
services: services:
elasticsearch: elasticsearch:
image: 'elasticsearch:8.6.1' image: '{imageName}'
environment: environment:
- 'ELASTIC_PASSWORD=secret' - 'ELASTIC_PASSWORD=secret'
- 'ES_JAVA_OPTS=-Xmx512m' - 'ES_JAVA_OPTS=-Xmx512m'

@ -1,6 +1,6 @@
services: services:
database: database:
image: 'postgres:15.2' image: '{imageName}'
ports: ports:
- '5432' - '5432'
environment: environment:

@ -1,6 +1,6 @@
services: services:
database: database:
image: 'postgres:15.2' image: '{imageName}'
ports: ports:
- '5432' - '5432'
environment: environment:

@ -1,6 +1,6 @@
services: services:
database: database:
image: 'mariadb:10.10' image: '{imageName}'
ports: ports:
- '3306' - '3306'
environment: environment:

@ -1,6 +1,6 @@
services: services:
mongo: mongo:
image: 'mongo:6.0' image: '{imageName}'
ports: ports:
- '27017' - '27017'
environment: environment:

@ -1,6 +1,6 @@
services: services:
database: database:
image: 'mysql:8.0' image: '{imageName}'
ports: ports:
- '3306' - '3306'
environment: environment:

@ -1,6 +1,6 @@
services: services:
database: database:
image: 'gvenzl/oracle-xe:18.4.0-slim' image: '{imageName}'
ports: ports:
- '1521' - '1521'
environment: environment:

@ -1,6 +1,6 @@
services: services:
database: database:
image: 'postgres:15.2' image: '{imageName}'
ports: ports:
- '5432' - '5432'
environment: environment:

@ -1,6 +1,6 @@
services: services:
rabbitmq: rabbitmq:
image: 'rabbitmq:3.11' image: '{imageName}'
environment: environment:
- 'RABBITMQ_DEFAULT_USER=myuser' - 'RABBITMQ_DEFAULT_USER=myuser'
- 'RABBITMQ_DEFAULT_PASS=secret' - 'RABBITMQ_DEFAULT_PASS=secret'

@ -1,5 +1,5 @@
services: services:
redis: redis:
image: 'redis:7.0' image: '{imageName}'
ports: ports:
- '6379' - '6379'

@ -1,6 +1,6 @@
services: services:
database: database:
image: 'mcr.microsoft.com/mssql/server' image: '{imageName}'
ports: ports:
- '1433' - '1433'
environment: environment:

@ -1,5 +1,5 @@
services: services:
zipkin: zipkin:
image: 'openzipkin/zipkin:2.24' image: '{imageName}'
ports: ports:
- '9411' - '9411'

@ -36,10 +36,16 @@ public final class DockerImageNames {
private static final String ELASTICSEARCH_VERSION = "7.17.5"; private static final String ELASTICSEARCH_VERSION = "7.17.5";
private static final String ELASTICSEARCH_8_VERSION = "8.6.1";
private static final String KAFKA_VERSION = "7.4.0"; private static final String KAFKA_VERSION = "7.4.0";
private static final String MARIADB_VERSION = "10.10";
private static final String MONGO_VERSION = "5.0.17"; private static final String MONGO_VERSION = "5.0.17";
private static final String MYSQL_VERSION = "8.0";
private static final String NEO4J_VERSION = "4.4.11"; private static final String NEO4J_VERSION = "4.4.11";
private static final String ORACLE_XE_VERSION = "18.4.0-slim"; private static final String ORACLE_XE_VERSION = "18.4.0-slim";
@ -84,13 +90,21 @@ public final class DockerImageNames {
} }
/** /**
* Return a {@link DockerImageName} suitable for running Elasticsearch. * Return a {@link DockerImageName} suitable for running Elasticsearch 7.
* @return a docker image name for running elasticsearch * @return a docker image name for running elasticsearch
*/ */
public static DockerImageName elasticsearch() { public static DockerImageName elasticsearch() {
return DockerImageName.parse("docker.elastic.co/elasticsearch/elasticsearch").withTag(ELASTICSEARCH_VERSION); return DockerImageName.parse("docker.elastic.co/elasticsearch/elasticsearch").withTag(ELASTICSEARCH_VERSION);
} }
/**
* Return a {@link DockerImageName} suitable for running Elasticsearch 8.
* @return a docker image name for running elasticsearch
*/
public static DockerImageName elasticsearch8() {
return DockerImageName.parse("elasticsearch").withTag(ELASTICSEARCH_8_VERSION);
}
/** /**
* Return a {@link DockerImageName} suitable for running Kafka. * Return a {@link DockerImageName} suitable for running Kafka.
* @return a docker image name for running Kafka * @return a docker image name for running Kafka
@ -99,6 +113,14 @@ public final class DockerImageNames {
return DockerImageName.parse("confluentinc/cp-kafka").withTag(KAFKA_VERSION); return DockerImageName.parse("confluentinc/cp-kafka").withTag(KAFKA_VERSION);
} }
/**
* Return a {@link DockerImageName} suitable for running MariaDB.
* @return a docker image name for running Mariadb
*/
public static DockerImageName mariadb() {
return DockerImageName.parse("mariadb").withTag(MARIADB_VERSION);
}
/** /**
* Return a {@link DockerImageName} suitable for running Mongo. * Return a {@link DockerImageName} suitable for running Mongo.
* @return a docker image name for running mongo * @return a docker image name for running mongo
@ -107,6 +129,14 @@ public final class DockerImageNames {
return DockerImageName.parse("mongo").withTag(MONGO_VERSION); return DockerImageName.parse("mongo").withTag(MONGO_VERSION);
} }
/**
* Return a {@link DockerImageName} suitable for running MySQL.
* @return a docker image name for running MySQL
*/
public static DockerImageName mysql() {
return DockerImageName.parse("mysql").withTag(MYSQL_VERSION);
}
/** /**
* Return a {@link DockerImageName} suitable for running Neo4j. * Return a {@link DockerImageName} suitable for running Neo4j.
* @return a docker image name for running neo4j * @return a docker image name for running neo4j
@ -157,6 +187,14 @@ public final class DockerImageNames {
.asCompatibleSubstituteFor("docker.redpanda.com/redpandadata/redpanda"); .asCompatibleSubstituteFor("docker.redpanda.com/redpandadata/redpanda");
} }
/**
* Return a {@link DockerImageName} suitable for running Microsoft SQLServer.
* @return a docker image name for running SQLServer
*/
public static DockerImageName sqlserver() {
return DockerImageName.parse("mcr.microsoft.com/mssql/server");
}
/** /**
* Return a {@link DockerImageName} suitable for running a Docker registry. * Return a {@link DockerImageName} suitable for running a Docker registry.
* @return a docker image name for running a registry * @return a docker image name for running a registry

Loading…
Cancel
Save