Refactor testcontainers service connections
Update restcontainers service connections support so that technology specific `@ServiceConnector` annotations are not longer required. A single `@ServiceConnector` annotation can now be used to create all `ConnectionDetail` beans. Closes gh-35017
This commit is contained in:
@@ -28,7 +28,7 @@ import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.data.redis.ExampleService;
|
||||
import org.springframework.boot.test.context.TestConfiguration;
|
||||
import org.springframework.boot.testcontainers.service.connection.cassandra.CassandraServiceConnection;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
import org.springframework.boot.testsupport.testcontainers.CassandraContainer;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -52,7 +52,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
class DataCassandraTestIntegrationTests {
|
||||
|
||||
@Container
|
||||
@CassandraServiceConnection
|
||||
@ServiceConnection
|
||||
static final CassandraContainer cassandra = new CassandraContainer();
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.TestConfiguration;
|
||||
import org.springframework.boot.testcontainers.service.connection.cassandra.CassandraServiceConnection;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
import org.springframework.boot.testsupport.testcontainers.CassandraContainer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan.Filter;
|
||||
@@ -51,7 +51,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class DataCassandraTestWithIncludeFilterIntegrationTests {
|
||||
|
||||
@Container
|
||||
@CassandraServiceConnection
|
||||
@ServiceConnection
|
||||
static final CassandraContainer cassandra = new CassandraContainer();
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.testcontainers.service.connection.couchbase.CouchbaseServiceConnection;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.data.couchbase.core.CouchbaseTemplate;
|
||||
@@ -50,7 +50,7 @@ class DataCouchbaseTestIntegrationTests {
|
||||
private static final String BUCKET_NAME = "cbbucket";
|
||||
|
||||
@Container
|
||||
@CouchbaseServiceConnection
|
||||
@ServiceConnection
|
||||
static final CouchbaseContainer couchbase = new CouchbaseContainer(DockerImageNames.couchbase())
|
||||
.withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(10))
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.testcontainers.service.connection.couchbase.CouchbaseServiceConnection;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.data.couchbase.core.ReactiveCouchbaseTemplate;
|
||||
|
||||
@@ -47,7 +47,7 @@ class DataCouchbaseTestReactiveIntegrationTests {
|
||||
private static final String BUCKET_NAME = "cbbucket";
|
||||
|
||||
@Container
|
||||
@CouchbaseServiceConnection
|
||||
@ServiceConnection
|
||||
static final CouchbaseContainer couchbase = new CouchbaseContainer(DockerImageNames.couchbase())
|
||||
.withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(10))
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.testcontainers.service.connection.couchbase.CouchbaseServiceConnection;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.context.annotation.ComponentScan.Filter;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -48,7 +48,7 @@ class DataCouchbaseTestWithIncludeFilterIntegrationTests {
|
||||
private static final String BUCKET_NAME = "cbbucket";
|
||||
|
||||
@Container
|
||||
@CouchbaseServiceConnection
|
||||
@ServiceConnection
|
||||
static final CouchbaseContainer couchbase = new CouchbaseContainer(DockerImageNames.couchbase())
|
||||
.withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(10))
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.testcontainers.service.connection.elasticsearch.ElasticsearchServiceConnection;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate;
|
||||
@@ -47,7 +47,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
class DataElasticsearchTestIntegrationTests {
|
||||
|
||||
@Container
|
||||
@ElasticsearchServiceConnection
|
||||
@ServiceConnection
|
||||
static final ElasticsearchContainer elasticsearch = new ElasticsearchContainer(DockerImageNames.elasticsearch())
|
||||
.withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(10));
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.testcontainers.service.connection.elasticsearch.ElasticsearchServiceConnection;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
@@ -45,7 +45,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class DataElasticsearchTestPropertiesIntegrationTests {
|
||||
|
||||
@Container
|
||||
@ElasticsearchServiceConnection
|
||||
@ServiceConnection
|
||||
static final ElasticsearchContainer elasticsearch = new ElasticsearchContainer(DockerImageNames.elasticsearch())
|
||||
.withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(10));
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.testcontainers.service.connection.elasticsearch.ElasticsearchServiceConnection;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchTemplate;
|
||||
|
||||
@@ -44,7 +44,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class DataElasticsearchTestReactiveIntegrationTests {
|
||||
|
||||
@Container
|
||||
@ElasticsearchServiceConnection
|
||||
@ServiceConnection
|
||||
static final ElasticsearchContainer elasticsearch = new ElasticsearchContainer(DockerImageNames.elasticsearch())
|
||||
.withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(10));
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.testcontainers.service.connection.elasticsearch.ElasticsearchServiceConnection;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.context.annotation.ComponentScan.Filter;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -46,7 +46,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class DataElasticsearchTestWithIncludeFilterIntegrationTests {
|
||||
|
||||
@Container
|
||||
@ElasticsearchServiceConnection
|
||||
@ServiceConnection
|
||||
static final ElasticsearchContainer elasticsearch = new ElasticsearchContainer(DockerImageNames.elasticsearch())
|
||||
.withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(10));
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.testcontainers.service.connection.mongo.MongoServiceConnection;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
@@ -46,7 +46,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
class DataMongoTestIntegrationTests {
|
||||
|
||||
@Container
|
||||
@MongoServiceConnection
|
||||
@ServiceConnection
|
||||
static final MongoDBContainer mongoDB = new MongoDBContainer(DockerImageNames.mongo()).withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(5));
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.testcontainers.service.connection.mongo.MongoServiceConnection;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.data.mongodb.core.ReactiveMongoTemplate;
|
||||
|
||||
@@ -43,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class DataMongoTestReactiveIntegrationTests {
|
||||
|
||||
@Container
|
||||
@MongoServiceConnection
|
||||
@ServiceConnection
|
||||
static final MongoDBContainer mongoDB = new MongoDBContainer(DockerImageNames.mongo()).withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(5));
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.testcontainers.service.connection.mongo.MongoServiceConnection;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.context.annotation.ComponentScan.Filter;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -44,7 +44,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class DataMongoTestWithIncludeFilterIntegrationTests {
|
||||
|
||||
@Container
|
||||
@MongoServiceConnection
|
||||
@ServiceConnection
|
||||
static final MongoDBContainer mongoDB = new MongoDBContainer(DockerImageNames.mongo()).withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(5));
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.TestConfiguration;
|
||||
import org.springframework.boot.testcontainers.service.connection.mongo.MongoServiceConnection;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
||||
@@ -49,7 +49,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class TransactionalDataMongoTestIntegrationTests {
|
||||
|
||||
@Container
|
||||
@MongoServiceConnection
|
||||
@ServiceConnection
|
||||
static final MongoDBContainer mongoDB = new MongoDBContainer(DockerImageNames.mongo()).withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(5));
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.testcontainers.service.connection.neo4j.Neo4jServiceConnection;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.data.neo4j.core.Neo4jTemplate;
|
||||
@@ -48,7 +48,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
class DataNeo4jTestIntegrationTests {
|
||||
|
||||
@Container
|
||||
@Neo4jServiceConnection
|
||||
@ServiceConnection
|
||||
static final Neo4jContainer<?> neo4j = new Neo4jContainer<>(DockerImageNames.neo4j()).withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(10));
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.testcontainers.service.connection.neo4j.Neo4jServiceConnection;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
@@ -45,7 +45,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class DataNeo4jTestPropertiesIntegrationTests {
|
||||
|
||||
@Container
|
||||
@Neo4jServiceConnection
|
||||
@ServiceConnection
|
||||
static final Neo4jContainer<?> neo4j = new Neo4jContainer<>(DockerImageNames.neo4j()).withoutAuthentication()
|
||||
.withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(10));
|
||||
|
||||
@@ -29,7 +29,7 @@ import reactor.test.StepVerifier;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.TestConfiguration;
|
||||
import org.springframework.boot.testcontainers.service.connection.neo4j.Neo4jServiceConnection;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -56,7 +56,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
class DataNeo4jTestReactiveIntegrationTests {
|
||||
|
||||
@Container
|
||||
@Neo4jServiceConnection
|
||||
@ServiceConnection
|
||||
static final Neo4jContainer<?> neo4j = new Neo4jContainer<>(DockerImageNames.neo4j()).withoutAuthentication()
|
||||
.withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(10));
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.testcontainers.service.connection.neo4j.Neo4jServiceConnection;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.context.annotation.ComponentScan.Filter;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -45,7 +45,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class DataNeo4jTestWithIncludeFilterIntegrationTests {
|
||||
|
||||
@Container
|
||||
@Neo4jServiceConnection
|
||||
@ServiceConnection
|
||||
static final Neo4jContainer<?> neo4j = new Neo4jContainer<>(DockerImageNames.neo4j()).withoutAuthentication()
|
||||
.withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(10));
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.testcontainers.service.connection.redis.RedisServiceConnection;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
import org.springframework.boot.testsupport.testcontainers.RedisContainer;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.data.redis.core.RedisOperations;
|
||||
@@ -48,7 +48,7 @@ class DataRedisTestIntegrationTests {
|
||||
private static final Charset CHARSET = StandardCharsets.UTF_8;
|
||||
|
||||
@Container
|
||||
@RedisServiceConnection
|
||||
@ServiceConnection
|
||||
static RedisContainer redis = new RedisContainer();
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.testcontainers.service.connection.redis.RedisServiceConnection;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
import org.springframework.boot.testsupport.testcontainers.RedisContainer;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
@@ -42,7 +42,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class DataRedisTestPropertiesIntegrationTests {
|
||||
|
||||
@Container
|
||||
@RedisServiceConnection
|
||||
@ServiceConnection
|
||||
static final RedisContainer redis = new RedisContainer();
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -25,7 +25,7 @@ import reactor.test.StepVerifier;
|
||||
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.testcontainers.service.connection.redis.RedisServiceConnection;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
import org.springframework.boot.testsupport.testcontainers.RedisContainer;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.data.redis.core.ReactiveRedisOperations;
|
||||
@@ -45,7 +45,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
class DataRedisTestReactiveIntegrationTests {
|
||||
|
||||
@Container
|
||||
@RedisServiceConnection
|
||||
@ServiceConnection
|
||||
static RedisContainer redis = new RedisContainer();
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.testcontainers.service.connection.redis.RedisServiceConnection;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
import org.springframework.boot.testsupport.testcontainers.RedisContainer;
|
||||
import org.springframework.context.annotation.ComponentScan.Filter;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class DataRedisTestWithIncludeFilterIntegrationTests {
|
||||
|
||||
@Container
|
||||
@RedisServiceConnection
|
||||
@ServiceConnection
|
||||
static final RedisContainer redis = new RedisContainer();
|
||||
|
||||
@Autowired
|
||||
|
||||
Reference in New Issue
Block a user