From 96444ee8aad1ff0fe01be28ba0d17ecdaa642cde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Thu, 22 Jun 2023 20:28:19 -0600 Subject: [PATCH 1/5] Support ServiceConnection beans in slice tests Currently, in order to use `@ServiceConnection` in beans along with slice test annotations `@ImportAutoConfiguration(ServiceConnectionAutoConfiguration.class)` should be added to make it work. This commit register `ServiceConnectionAutoConfiguration` in specific slice test annotations. See gh-35252 --- .../build.gradle | 2 +- ...ersServiceConnectionAutoConfiguration.java | 44 +++++++++ ...ssandra.AutoConfigureDataCassandra.imports | 1 + ...uchbase.AutoConfigureDataCouchbase.imports | 2 +- ...rch.AutoConfigureDataElasticsearch.imports | 1 + ...re.data.jdbc.AutoConfigureDataJdbc.imports | 1 + ....data.mongo.AutoConfigureDataMongo.imports | 1 + ....data.neo4j.AutoConfigureDataNeo4j.imports | 1 + ....data.r2dbc.AutoConfigureDataR2dbc.imports | 1 + ....data.redis.AutoConfigureDataRedis.imports | 1 + ...toconfigure.jdbc.AutoConfigureJdbc.imports | 1 + ...ure.jdbc.AutoConfigureTestDatabase.imports | 1 + ...toconfigure.jooq.AutoConfigureJooq.imports | 1 + ...igure.orm.jpa.AutoConfigureDataJpa.imports | 1 + ...ServiceConnectionBeanIntegrationTests.java | 90 +++++++++++++++++++ ...ServiceConnectionBeanIntegrationTests.java | 83 +++++++++++++++++ ...ServiceConnectionBeanIntegrationTests.java | 83 +++++++++++++++++ ...ServiceConnectionBeanIntegrationTests.java | 74 +++++++++++++++ ...ServiceConnectionBeanIntegrationTests.java | 79 ++++++++++++++++ ...ServiceConnectionBeanIntegrationTests.java | 80 +++++++++++++++++ 20 files changed, 546 insertions(+), 2 deletions(-) create mode 100644 spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/service/connection/TestcontainersServiceConnectionAutoConfiguration.java create mode 100644 spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTestWithServiceConnectionBeanIntegrationTests.java create mode 100644 spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestWithServiceConnectionBeanIntegrationTests.java create mode 100644 spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestWithServiceConnectionBeanIntegrationTests.java create mode 100644 spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestWithServiceConnectionBeanIntegrationTests.java create mode 100644 spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestWithServiceConnectionBeanIntegrationTests.java create mode 100644 spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestWithServiceConnectionBeanIntegrationTests.java diff --git a/spring-boot-project/spring-boot-test-autoconfigure/build.gradle b/spring-boot-project/spring-boot-test-autoconfigure/build.gradle index 623831519c1c..617054b75b6f 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/build.gradle +++ b/spring-boot-project/spring-boot-test-autoconfigure/build.gradle @@ -35,6 +35,7 @@ dependencies { optional("org.springframework:spring-web") optional("org.springframework:spring-webmvc") optional("org.springframework:spring-webflux") + optional(project(":spring-boot-project:spring-boot-testcontainers")) optional("org.springframework.data:spring-data-cassandra") { exclude group: "org.slf4j", module: "jcl-over-slf4j" } @@ -63,7 +64,6 @@ dependencies { testImplementation(project(":spring-boot-project:spring-boot-actuator")) testImplementation(project(":spring-boot-project:spring-boot-actuator-autoconfigure")) testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support")) - testImplementation(project(":spring-boot-project:spring-boot-testcontainers")) testImplementation("ch.qos.logback:logback-classic") testImplementation("com.fasterxml.jackson.module:jackson-module-parameter-names") testImplementation("com.h2database:h2") diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/service/connection/TestcontainersServiceConnectionAutoConfiguration.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/service/connection/TestcontainersServiceConnectionAutoConfiguration.java new file mode 100644 index 000000000000..69801e422337 --- /dev/null +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/service/connection/TestcontainersServiceConnectionAutoConfiguration.java @@ -0,0 +1,44 @@ +/* + * Copyright 2012-2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.test.autoconfigure.service.connection; + +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureOrder; +import org.springframework.boot.autoconfigure.ImportAutoConfiguration; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.Ordered; + +/** + * Auto-configuration for ServiceConnection. + * + * @author Eddú Meléndez + * @since 3.1.2 + */ +@AutoConfiguration +@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE) +@ConditionalOnClass(ServiceConnectionAutoConfiguration.class) +public class TestcontainersServiceConnectionAutoConfiguration { + + @Configuration(proxyBeanMethods = false) + @ImportAutoConfiguration(ServiceConnectionAutoConfiguration.class) + static class ImportAutoConfigurationTest { + + } + +} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.cassandra.AutoConfigureDataCassandra.imports b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.cassandra.AutoConfigureDataCassandra.imports index 890af9413d96..609ee282095b 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.cassandra.AutoConfigureDataCassandra.imports +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.cassandra.AutoConfigureDataCassandra.imports @@ -1,4 +1,5 @@ # AutoConfigureDataCassandra auto-configuration imports +org.springframework.boot.test.autoconfigure.service.connection.TestcontainersServiceConnectionAutoConfiguration org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration org.springframework.boot.autoconfigure.data.cassandra.CassandraReactiveDataAutoConfiguration diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.couchbase.AutoConfigureDataCouchbase.imports b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.couchbase.AutoConfigureDataCouchbase.imports index aaae4207e95c..0196301a42ae 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.couchbase.AutoConfigureDataCouchbase.imports +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.couchbase.AutoConfigureDataCouchbase.imports @@ -1,5 +1,5 @@ # AutoConfigureDataCouchbase auto-configuration imports - +org.springframework.boot.test.autoconfigure.service.connection.TestcontainersServiceConnectionAutoConfiguration org.springframework.boot.autoconfigure.couchbase.CouchbaseAutoConfiguration org.springframework.boot.autoconfigure.data.couchbase.CouchbaseDataAutoConfiguration org.springframework.boot.autoconfigure.data.couchbase.CouchbaseReactiveDataAutoConfiguration diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.elasticsearch.AutoConfigureDataElasticsearch.imports b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.elasticsearch.AutoConfigureDataElasticsearch.imports index 9e23ddfa3279..cba09ee8aaa8 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.elasticsearch.AutoConfigureDataElasticsearch.imports +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.elasticsearch.AutoConfigureDataElasticsearch.imports @@ -1,4 +1,5 @@ # AutoConfigureDataElasticsearch auto-configuration imports +org.springframework.boot.test.autoconfigure.service.connection.TestcontainersServiceConnectionAutoConfiguration org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchRepositoriesAutoConfiguration org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration org.springframework.boot.autoconfigure.data.elasticsearch.ReactiveElasticsearchRepositoriesAutoConfiguration diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.jdbc.AutoConfigureDataJdbc.imports b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.jdbc.AutoConfigureDataJdbc.imports index e276c6de14f6..706966d39916 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.jdbc.AutoConfigureDataJdbc.imports +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.jdbc.AutoConfigureDataJdbc.imports @@ -1,4 +1,5 @@ # AutoConfigureDataJdbc auto-configuration imports +org.springframework.boot.test.autoconfigure.service.connection.TestcontainersServiceConnectionAutoConfiguration org.springframework.boot.autoconfigure.data.jdbc.JdbcRepositoriesAutoConfiguration org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.mongo.AutoConfigureDataMongo.imports b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.mongo.AutoConfigureDataMongo.imports index d16785df6837..2beab16e3bf3 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.mongo.AutoConfigureDataMongo.imports +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.mongo.AutoConfigureDataMongo.imports @@ -1,4 +1,5 @@ # AutoConfigureDataMongo auto-configuration imports +org.springframework.boot.test.autoconfigure.service.connection.TestcontainersServiceConnectionAutoConfiguration org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration org.springframework.boot.autoconfigure.data.mongo.MongoReactiveDataAutoConfiguration org.springframework.boot.autoconfigure.data.mongo.MongoReactiveRepositoriesAutoConfiguration diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.neo4j.AutoConfigureDataNeo4j.imports b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.neo4j.AutoConfigureDataNeo4j.imports index 5d25aa7db0f8..9b709b913832 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.neo4j.AutoConfigureDataNeo4j.imports +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.neo4j.AutoConfigureDataNeo4j.imports @@ -1,4 +1,5 @@ # AutoConfigureDataNeo4j auto-configuration imports +org.springframework.boot.test.autoconfigure.service.connection.TestcontainersServiceConnectionAutoConfiguration org.springframework.boot.autoconfigure.neo4j.Neo4jAutoConfiguration org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration org.springframework.boot.autoconfigure.data.neo4j.Neo4jReactiveDataAutoConfiguration diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.r2dbc.AutoConfigureDataR2dbc.imports b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.r2dbc.AutoConfigureDataR2dbc.imports index ed0f4bec9234..56f361dc4015 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.r2dbc.AutoConfigureDataR2dbc.imports +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.r2dbc.AutoConfigureDataR2dbc.imports @@ -1,4 +1,5 @@ # AutoConfigureDataR2dbc auto-configuration imports +org.springframework.boot.test.autoconfigure.service.connection.TestcontainersServiceConnectionAutoConfiguration org.springframework.boot.autoconfigure.data.r2dbc.R2dbcRepositoriesAutoConfiguration org.springframework.boot.autoconfigure.data.r2dbc.R2dbcDataAutoConfiguration org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.redis.AutoConfigureDataRedis.imports b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.redis.AutoConfigureDataRedis.imports index c871e47207e9..89abc00e9aeb 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.redis.AutoConfigureDataRedis.imports +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.redis.AutoConfigureDataRedis.imports @@ -1,4 +1,5 @@ # AutoConfigureDataRedis auto-configuration imports +org.springframework.boot.test.autoconfigure.service.connection.TestcontainersServiceConnectionAutoConfiguration org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration org.springframework.boot.autoconfigure.data.redis.RedisReactiveAutoConfiguration org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration \ No newline at end of file diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureJdbc.imports b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureJdbc.imports index b3700d9cc94b..8589e6a32674 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureJdbc.imports +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureJdbc.imports @@ -1,4 +1,5 @@ # AutoConfigureJdbc auto-configuration imports +org.springframework.boot.test.autoconfigure.service.connection.TestcontainersServiceConnectionAutoConfiguration org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.imports b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.imports index 11ab8a552a5e..ddcaaa45d11f 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.imports +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.imports @@ -1,3 +1,4 @@ # AutoConfigureTestDatabase auto-configuration imports +org.springframework.boot.test.autoconfigure.service.connection.TestcontainersServiceConnectionAutoConfiguration org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration \ No newline at end of file diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jooq.AutoConfigureJooq.imports b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jooq.AutoConfigureJooq.imports index c35cbedeefc7..0f6eb21732ea 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jooq.AutoConfigureJooq.imports +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jooq.AutoConfigureJooq.imports @@ -1,4 +1,5 @@ # AutoConfigureJooq auto-configuration imports +org.springframework.boot.test.autoconfigure.service.connection.TestcontainersServiceConnectionAutoConfiguration org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureDataJpa.imports b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureDataJpa.imports index 22c50b61e7e9..84dd305c96fc 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureDataJpa.imports +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureDataJpa.imports @@ -1,4 +1,5 @@ # AutoConfigureDataJpa auto-configuration imports +org.springframework.boot.test.autoconfigure.service.connection.TestcontainersServiceConnectionAutoConfiguration org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTestWithServiceConnectionBeanIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTestWithServiceConnectionBeanIntegrationTests.java new file mode 100644 index 000000000000..95cc0b47c3f6 --- /dev/null +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTestWithServiceConnectionBeanIntegrationTests.java @@ -0,0 +1,90 @@ +/* + * Copyright 2012-2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.test.autoconfigure.data.cassandra; + +import java.util.UUID; + +import com.datastax.oss.driver.api.core.CqlSession; +import com.datastax.oss.driver.api.core.CqlSessionBuilder; +import org.junit.jupiter.api.Test; +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.ServiceConnection; +import org.springframework.boot.testsupport.testcontainers.CassandraContainer; +import org.springframework.context.annotation.Bean; +import org.springframework.data.cassandra.core.CassandraTemplate; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Integration test for {@link DataCassandraTest @DataCassandraTest}. + * + * @author Artsiom Yudovin + * @author Moritz Halbritter + * @author Andy Wilkinson + * @author Phillip Webb + * @author Eddú Meléndez + */ +@DataCassandraTest(properties = { "spring.cassandra.schema-action=create-if-not-exists", + "spring.cassandra.connection.connect-timeout=60s", "spring.cassandra.connection.init-query-timeout=60s", + "spring.cassandra.request.timeout=60s" }) +@Testcontainers(disabledWithoutDocker = true) +class DataCassandraTestWithServiceConnectionBeanIntegrationTests { + + @Autowired + private CassandraTemplate cassandraTemplate; + + @Autowired + private ExampleRepository exampleRepository; + + @Test + void testRepository() { + ExampleEntity entity = new ExampleEntity(); + entity.setDescription("Look, new @DataCassandraTest!"); + String id = UUID.randomUUID().toString(); + entity.setId(id); + ExampleEntity savedEntity = this.exampleRepository.save(entity); + ExampleEntity getEntity = this.cassandraTemplate.selectOneById(id, ExampleEntity.class); + assertThat(getEntity).isNotNull(); + assertThat(getEntity.getId()).isNotNull(); + assertThat(getEntity.getId()).isEqualTo(savedEntity.getId()); + this.exampleRepository.deleteAll(); + } + + @TestConfiguration(proxyBeanMethods = false) + static class KeyspaceTestConfiguration { + + @Bean + @ServiceConnection + CassandraContainer cassandra() { + return new CassandraContainer(); + } + + @Bean + CqlSession cqlSession(CqlSessionBuilder cqlSessionBuilder) { + try (CqlSession session = cqlSessionBuilder.build()) { + session.execute("CREATE KEYSPACE IF NOT EXISTS boot_test" + + " WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };"); + } + return cqlSessionBuilder.withKeyspace("boot_test").build(); + } + + } + +} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestWithServiceConnectionBeanIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestWithServiceConnectionBeanIntegrationTests.java new file mode 100644 index 000000000000..843dd1cc239d --- /dev/null +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestWithServiceConnectionBeanIntegrationTests.java @@ -0,0 +1,83 @@ +/* + * Copyright 2012-2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.test.autoconfigure.data.couchbase; + +import java.time.Duration; + +import org.junit.jupiter.api.Test; +import org.testcontainers.couchbase.BucketDefinition; +import org.testcontainers.couchbase.CouchbaseContainer; +import org.testcontainers.junit.jupiter.Testcontainers; + +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.ServiceConnection; +import org.springframework.boot.testsupport.testcontainers.DockerImageNames; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.data.couchbase.core.CouchbaseTemplate; +import org.springframework.test.annotation.DirtiesContext; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; + +/** + * Integration test for {@link DataCouchbaseTest @DataCouchbaseTest}. + * + * @author Eddú Meléndez + * @author Moritz Halbritter + * @author Andy Wilkinson + * @author Phillip Webb + */ +@DataCouchbaseTest( + properties = { "spring.couchbase.env.timeouts.connect=2m", "spring.data.couchbase.bucket-name=cbbucket" }) +@Testcontainers(disabledWithoutDocker = true) +class DataCouchbaseTestWithServiceConnectionBeanIntegrationTests { + + private static final String BUCKET_NAME = "cbbucket"; + + @Autowired + private CouchbaseTemplate couchbaseTemplate; + + @Autowired + private ExampleRepository exampleRepository; + + @Test + void testRepository() { + ExampleDocument document = new ExampleDocument(); + document.setText("Look, new @DataCouchbaseTest!"); + document = this.exampleRepository.save(document); + assertThat(document.getId()).isNotNull(); + assertThat(this.couchbaseTemplate.getBucketName()).isEqualTo(BUCKET_NAME); + this.exampleRepository.deleteAll(); + } + + @TestConfiguration(proxyBeanMethods = false) + static class ContainerConfig { + + @Bean + @ServiceConnection + CouchbaseContainer couchbase() { + return new CouchbaseContainer(DockerImageNames.couchbase()).withStartupAttempts(5) + .withStartupTimeout(Duration.ofMinutes(10)) + .withBucket(new BucketDefinition(BUCKET_NAME)); + } + + } + +} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestWithServiceConnectionBeanIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestWithServiceConnectionBeanIntegrationTests.java new file mode 100644 index 000000000000..ccb2f77af3f7 --- /dev/null +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestWithServiceConnectionBeanIntegrationTests.java @@ -0,0 +1,83 @@ +/* + * Copyright 2012-2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.test.autoconfigure.data.elasticsearch; + +import java.time.Duration; +import java.util.UUID; + +import org.junit.jupiter.api.Test; +import org.testcontainers.elasticsearch.ElasticsearchContainer; +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.ServiceConnection; +import org.springframework.boot.testsupport.testcontainers.DockerImageNames; +import org.springframework.context.annotation.Bean; +import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Sample test for {@link DataElasticsearchTest @DataElasticsearchTest} + * + * @author Eddú Meléndez + * @author Moritz Halbritter + * @author Andy Wilkinson + * @author Phillip Webb + */ +@DataElasticsearchTest +@Testcontainers(disabledWithoutDocker = true) +class DataElasticsearchTestWithServiceConnectionBeanIntegrationTests { + + ; + + @Autowired + private ElasticsearchTemplate elasticsearchTemplate; + + @Autowired + private ExampleRepository exampleRepository; + + @Test + void testRepository() { + ExampleDocument document = new ExampleDocument(); + document.setText("Look, new @DataElasticsearchTest!"); + String id = UUID.randomUUID().toString(); + document.setId(id); + ExampleDocument savedDocument = this.exampleRepository.save(document); + ExampleDocument getDocument = this.elasticsearchTemplate.get(id, ExampleDocument.class); + assertThat(getDocument).isNotNull(); + assertThat(getDocument.getId()).isNotNull(); + assertThat(getDocument.getId()).isEqualTo(savedDocument.getId()); + this.exampleRepository.deleteAll(); + } + + @TestConfiguration(proxyBeanMethods = false) + static class ContainerConfig { + + @Bean + @ServiceConnection + ElasticsearchContainer elasticsearch() { + return new ElasticsearchContainer(DockerImageNames.elasticsearch()) + .withEnv("ES_JAVA_OPTS", "-Xms32m -Xmx512m") + .withStartupAttempts(5) + .withStartupTimeout(Duration.ofMinutes(10)); + } + + } + +} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestWithServiceConnectionBeanIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestWithServiceConnectionBeanIntegrationTests.java new file mode 100644 index 000000000000..3b19ac253a9b --- /dev/null +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestWithServiceConnectionBeanIntegrationTests.java @@ -0,0 +1,74 @@ +/* + * Copyright 2012-2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.test.autoconfigure.data.mongo; + +import java.time.Duration; + +import org.junit.jupiter.api.Test; +import org.testcontainers.containers.MongoDBContainer; +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.ServiceConnection; +import org.springframework.boot.testsupport.testcontainers.DockerImageNames; +import org.springframework.context.annotation.Bean; +import org.springframework.data.mongodb.core.MongoTemplate; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Sample test for {@link DataMongoTest @DataMongoTest} + * + * @author Michael Simons + * @author Moritz Halbritter + * @author Andy Wilkinson + * @author Phillip Webb + * @author Eddú Meléndez + */ +@DataMongoTest +@Testcontainers(disabledWithoutDocker = true) +class DataMongoTestWithServiceConnectionBeanIntegrationTests { + + @Autowired + private MongoTemplate mongoTemplate; + + @Autowired + private ExampleRepository exampleRepository; + + @Test + void testRepository() { + ExampleDocument exampleDocument = new ExampleDocument(); + exampleDocument.setText("Look, new @DataMongoTest!"); + exampleDocument = this.exampleRepository.save(exampleDocument); + assertThat(exampleDocument.getId()).isNotNull(); + assertThat(this.mongoTemplate.collectionExists("exampleDocuments")).isTrue(); + } + + @TestConfiguration(proxyBeanMethods = false) + static class ContainerConfig { + + @Bean + @ServiceConnection + MongoDBContainer mongoDB() { + return new MongoDBContainer(DockerImageNames.mongo()).withStartupAttempts(5) + .withStartupTimeout(Duration.ofMinutes(5)); + } + + } + +} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestWithServiceConnectionBeanIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestWithServiceConnectionBeanIntegrationTests.java new file mode 100644 index 000000000000..ba194037582c --- /dev/null +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestWithServiceConnectionBeanIntegrationTests.java @@ -0,0 +1,79 @@ +/* + * Copyright 2012-2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.test.autoconfigure.data.neo4j; + +import java.time.Duration; + +import org.junit.jupiter.api.Test; +import org.testcontainers.containers.Neo4jContainer; +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.ServiceConnection; +import org.springframework.boot.testsupport.testcontainers.DockerImageNames; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.data.neo4j.core.Neo4jTemplate; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Integration test for {@link DataNeo4jTest @DataNeo4jTest}. + * + * @author Eddú Meléndez + * @author Stephane Nicoll + * @author Michael Simons + * @author Moritz Halbritter + * @author Andy Wilkinson + * @author Phillip Webb + */ +@DataNeo4jTest +@Testcontainers(disabledWithoutDocker = true) +class DataNeo4jTestWithServiceConnectionBeanIntegrationTests { + + @Autowired + private Neo4jTemplate neo4jTemplate; + + @Autowired + private ExampleRepository exampleRepository; + + @Autowired + private ApplicationContext applicationContext; + + @Test + void testRepository() { + ExampleGraph exampleGraph = new ExampleGraph("Look, new @DataNeo4jTest!"); + assertThat(exampleGraph.getId()).isNull(); + ExampleGraph savedGraph = this.exampleRepository.save(exampleGraph); + assertThat(savedGraph.getId()).isNotNull(); + assertThat(this.neo4jTemplate.count(ExampleGraph.class)).isOne(); + } + + @TestConfiguration + static class ContainerConfig { + + @Bean + @ServiceConnection + Neo4jContainer neo4j() { + return new Neo4jContainer<>(DockerImageNames.neo4j()).withStartupAttempts(5) + .withStartupTimeout(Duration.ofMinutes(10)); + } + + } + +} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestWithServiceConnectionBeanIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestWithServiceConnectionBeanIntegrationTests.java new file mode 100644 index 000000000000..3efada383aeb --- /dev/null +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestWithServiceConnectionBeanIntegrationTests.java @@ -0,0 +1,80 @@ +/* + * Copyright 2012-2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.test.autoconfigure.data.redis; + +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; + +import org.junit.jupiter.api.Test; +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.ServiceConnection; +import org.springframework.boot.testsupport.testcontainers.RedisContainer; +import org.springframework.context.annotation.Bean; +import org.springframework.data.redis.core.RedisOperations; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Integration test for {@link DataRedisTest @DataRedisTest}. + * + * @author Jayaram Pradhan + * @author Moritz Halbritter + * @author Andy Wilkinson + * @author Phillip Webb + * @author Eddú Meléndez + */ +@Testcontainers(disabledWithoutDocker = true) +@DataRedisTest +class DataRedisTestWithServiceConnectionBeanIntegrationTests { + + private static final Charset CHARSET = StandardCharsets.UTF_8; + + @Autowired + private RedisOperations operations; + + @Autowired + private ExampleRepository exampleRepository; + + @Test + void testRepository() { + PersonHash personHash = new PersonHash(); + personHash.setDescription("Look, new @DataRedisTest!"); + assertThat(personHash.getId()).isNull(); + PersonHash savedEntity = this.exampleRepository.save(personHash); + assertThat(savedEntity.getId()).isNotNull(); + assertThat(this.operations + .execute((org.springframework.data.redis.connection.RedisConnection connection) -> connection.keyCommands() + .exists(("persons:" + savedEntity.getId()).getBytes(CHARSET)))) + .isTrue(); + this.exampleRepository.deleteAll(); + } + + @TestConfiguration(proxyBeanMethods = false) + static class ContainerConfig { + + @Bean + @ServiceConnection + RedisContainer redis() { + return new RedisContainer(); + } + + } + +} From 455954794c44ba4b06260bb317c939541cd5b9cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Thu, 22 Jun 2023 20:51:08 -0600 Subject: [PATCH 2/5] Move import files to spring-boot-testcontainers --- .../build.gradle | 2 +- ...ersServiceConnectionAutoConfiguration.java | 44 ------------------- ...ssandra.AutoConfigureDataCassandra.imports | 1 - ...uchbase.AutoConfigureDataCouchbase.imports | 1 - ...rch.AutoConfigureDataElasticsearch.imports | 1 - ...re.data.jdbc.AutoConfigureDataJdbc.imports | 1 - ....data.mongo.AutoConfigureDataMongo.imports | 1 - ....data.neo4j.AutoConfigureDataNeo4j.imports | 1 - ....data.r2dbc.AutoConfigureDataR2dbc.imports | 1 - ....data.redis.AutoConfigureDataRedis.imports | 1 - ...toconfigure.jdbc.AutoConfigureJdbc.imports | 1 - ...ure.jdbc.AutoConfigureTestDatabase.imports | 1 - ...toconfigure.jooq.AutoConfigureJooq.imports | 1 - ...igure.orm.jpa.AutoConfigureDataJpa.imports | 1 - ...ServiceConnectionBeanIntegrationTests.java | 4 -- ...ssandra.AutoConfigureDataCassandra.imports | 2 + ...uchbase.AutoConfigureDataCouchbase.imports | 2 + ...rch.AutoConfigureDataElasticsearch.imports | 2 + ...re.data.jdbc.AutoConfigureDataJdbc.imports | 2 + ....data.mongo.AutoConfigureDataMongo.imports | 2 + ....data.neo4j.AutoConfigureDataNeo4j.imports | 2 + ....data.r2dbc.AutoConfigureDataR2dbc.imports | 2 + ....data.redis.AutoConfigureDataRedis.imports | 2 + ...toconfigure.jdbc.AutoConfigureJdbc.imports | 2 + ...ure.jdbc.AutoConfigureTestDatabase.imports | 2 + ...toconfigure.jooq.AutoConfigureJooq.imports | 2 + ...igure.orm.jpa.AutoConfigureDataJpa.imports | 2 + 27 files changed, 25 insertions(+), 61 deletions(-) delete mode 100644 spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/service/connection/TestcontainersServiceConnectionAutoConfiguration.java create mode 100644 spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.cassandra.AutoConfigureDataCassandra.imports create mode 100644 spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.couchbase.AutoConfigureDataCouchbase.imports create mode 100644 spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.elasticsearch.AutoConfigureDataElasticsearch.imports create mode 100644 spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.jdbc.AutoConfigureDataJdbc.imports create mode 100644 spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.mongo.AutoConfigureDataMongo.imports create mode 100644 spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.neo4j.AutoConfigureDataNeo4j.imports create mode 100644 spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.r2dbc.AutoConfigureDataR2dbc.imports create mode 100644 spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.redis.AutoConfigureDataRedis.imports create mode 100644 spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureJdbc.imports create mode 100644 spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.imports create mode 100644 spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jooq.AutoConfigureJooq.imports create mode 100644 spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureDataJpa.imports diff --git a/spring-boot-project/spring-boot-test-autoconfigure/build.gradle b/spring-boot-project/spring-boot-test-autoconfigure/build.gradle index 617054b75b6f..623831519c1c 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/build.gradle +++ b/spring-boot-project/spring-boot-test-autoconfigure/build.gradle @@ -35,7 +35,6 @@ dependencies { optional("org.springframework:spring-web") optional("org.springframework:spring-webmvc") optional("org.springframework:spring-webflux") - optional(project(":spring-boot-project:spring-boot-testcontainers")) optional("org.springframework.data:spring-data-cassandra") { exclude group: "org.slf4j", module: "jcl-over-slf4j" } @@ -64,6 +63,7 @@ dependencies { testImplementation(project(":spring-boot-project:spring-boot-actuator")) testImplementation(project(":spring-boot-project:spring-boot-actuator-autoconfigure")) testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support")) + testImplementation(project(":spring-boot-project:spring-boot-testcontainers")) testImplementation("ch.qos.logback:logback-classic") testImplementation("com.fasterxml.jackson.module:jackson-module-parameter-names") testImplementation("com.h2database:h2") diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/service/connection/TestcontainersServiceConnectionAutoConfiguration.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/service/connection/TestcontainersServiceConnectionAutoConfiguration.java deleted file mode 100644 index 69801e422337..000000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/service/connection/TestcontainersServiceConnectionAutoConfiguration.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2012-2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.test.autoconfigure.service.connection; - -import org.springframework.boot.autoconfigure.AutoConfiguration; -import org.springframework.boot.autoconfigure.AutoConfigureOrder; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.Ordered; - -/** - * Auto-configuration for ServiceConnection. - * - * @author Eddú Meléndez - * @since 3.1.2 - */ -@AutoConfiguration -@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE) -@ConditionalOnClass(ServiceConnectionAutoConfiguration.class) -public class TestcontainersServiceConnectionAutoConfiguration { - - @Configuration(proxyBeanMethods = false) - @ImportAutoConfiguration(ServiceConnectionAutoConfiguration.class) - static class ImportAutoConfigurationTest { - - } - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.cassandra.AutoConfigureDataCassandra.imports b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.cassandra.AutoConfigureDataCassandra.imports index 609ee282095b..890af9413d96 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.cassandra.AutoConfigureDataCassandra.imports +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.cassandra.AutoConfigureDataCassandra.imports @@ -1,5 +1,4 @@ # AutoConfigureDataCassandra auto-configuration imports -org.springframework.boot.test.autoconfigure.service.connection.TestcontainersServiceConnectionAutoConfiguration org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration org.springframework.boot.autoconfigure.data.cassandra.CassandraReactiveDataAutoConfiguration diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.couchbase.AutoConfigureDataCouchbase.imports b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.couchbase.AutoConfigureDataCouchbase.imports index 0196301a42ae..ac06617018e6 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.couchbase.AutoConfigureDataCouchbase.imports +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.couchbase.AutoConfigureDataCouchbase.imports @@ -1,5 +1,4 @@ # AutoConfigureDataCouchbase auto-configuration imports -org.springframework.boot.test.autoconfigure.service.connection.TestcontainersServiceConnectionAutoConfiguration org.springframework.boot.autoconfigure.couchbase.CouchbaseAutoConfiguration org.springframework.boot.autoconfigure.data.couchbase.CouchbaseDataAutoConfiguration org.springframework.boot.autoconfigure.data.couchbase.CouchbaseReactiveDataAutoConfiguration diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.elasticsearch.AutoConfigureDataElasticsearch.imports b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.elasticsearch.AutoConfigureDataElasticsearch.imports index cba09ee8aaa8..9e23ddfa3279 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.elasticsearch.AutoConfigureDataElasticsearch.imports +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.elasticsearch.AutoConfigureDataElasticsearch.imports @@ -1,5 +1,4 @@ # AutoConfigureDataElasticsearch auto-configuration imports -org.springframework.boot.test.autoconfigure.service.connection.TestcontainersServiceConnectionAutoConfiguration org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchRepositoriesAutoConfiguration org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration org.springframework.boot.autoconfigure.data.elasticsearch.ReactiveElasticsearchRepositoriesAutoConfiguration diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.jdbc.AutoConfigureDataJdbc.imports b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.jdbc.AutoConfigureDataJdbc.imports index 706966d39916..e276c6de14f6 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.jdbc.AutoConfigureDataJdbc.imports +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.jdbc.AutoConfigureDataJdbc.imports @@ -1,5 +1,4 @@ # AutoConfigureDataJdbc auto-configuration imports -org.springframework.boot.test.autoconfigure.service.connection.TestcontainersServiceConnectionAutoConfiguration org.springframework.boot.autoconfigure.data.jdbc.JdbcRepositoriesAutoConfiguration org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.mongo.AutoConfigureDataMongo.imports b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.mongo.AutoConfigureDataMongo.imports index 2beab16e3bf3..d16785df6837 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.mongo.AutoConfigureDataMongo.imports +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.mongo.AutoConfigureDataMongo.imports @@ -1,5 +1,4 @@ # AutoConfigureDataMongo auto-configuration imports -org.springframework.boot.test.autoconfigure.service.connection.TestcontainersServiceConnectionAutoConfiguration org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration org.springframework.boot.autoconfigure.data.mongo.MongoReactiveDataAutoConfiguration org.springframework.boot.autoconfigure.data.mongo.MongoReactiveRepositoriesAutoConfiguration diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.neo4j.AutoConfigureDataNeo4j.imports b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.neo4j.AutoConfigureDataNeo4j.imports index 9b709b913832..5d25aa7db0f8 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.neo4j.AutoConfigureDataNeo4j.imports +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.neo4j.AutoConfigureDataNeo4j.imports @@ -1,5 +1,4 @@ # AutoConfigureDataNeo4j auto-configuration imports -org.springframework.boot.test.autoconfigure.service.connection.TestcontainersServiceConnectionAutoConfiguration org.springframework.boot.autoconfigure.neo4j.Neo4jAutoConfiguration org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration org.springframework.boot.autoconfigure.data.neo4j.Neo4jReactiveDataAutoConfiguration diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.r2dbc.AutoConfigureDataR2dbc.imports b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.r2dbc.AutoConfigureDataR2dbc.imports index 56f361dc4015..ed0f4bec9234 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.r2dbc.AutoConfigureDataR2dbc.imports +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.r2dbc.AutoConfigureDataR2dbc.imports @@ -1,5 +1,4 @@ # AutoConfigureDataR2dbc auto-configuration imports -org.springframework.boot.test.autoconfigure.service.connection.TestcontainersServiceConnectionAutoConfiguration org.springframework.boot.autoconfigure.data.r2dbc.R2dbcRepositoriesAutoConfiguration org.springframework.boot.autoconfigure.data.r2dbc.R2dbcDataAutoConfiguration org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.redis.AutoConfigureDataRedis.imports b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.redis.AutoConfigureDataRedis.imports index 89abc00e9aeb..c871e47207e9 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.redis.AutoConfigureDataRedis.imports +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.redis.AutoConfigureDataRedis.imports @@ -1,5 +1,4 @@ # AutoConfigureDataRedis auto-configuration imports -org.springframework.boot.test.autoconfigure.service.connection.TestcontainersServiceConnectionAutoConfiguration org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration org.springframework.boot.autoconfigure.data.redis.RedisReactiveAutoConfiguration org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration \ No newline at end of file diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureJdbc.imports b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureJdbc.imports index 8589e6a32674..b3700d9cc94b 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureJdbc.imports +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureJdbc.imports @@ -1,5 +1,4 @@ # AutoConfigureJdbc auto-configuration imports -org.springframework.boot.test.autoconfigure.service.connection.TestcontainersServiceConnectionAutoConfiguration org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.imports b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.imports index ddcaaa45d11f..11ab8a552a5e 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.imports +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.imports @@ -1,4 +1,3 @@ # AutoConfigureTestDatabase auto-configuration imports -org.springframework.boot.test.autoconfigure.service.connection.TestcontainersServiceConnectionAutoConfiguration org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration \ No newline at end of file diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jooq.AutoConfigureJooq.imports b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jooq.AutoConfigureJooq.imports index 0f6eb21732ea..c35cbedeefc7 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jooq.AutoConfigureJooq.imports +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jooq.AutoConfigureJooq.imports @@ -1,5 +1,4 @@ # AutoConfigureJooq auto-configuration imports -org.springframework.boot.test.autoconfigure.service.connection.TestcontainersServiceConnectionAutoConfiguration org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureDataJpa.imports b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureDataJpa.imports index 84dd305c96fc..22c50b61e7e9 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureDataJpa.imports +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureDataJpa.imports @@ -1,5 +1,4 @@ # AutoConfigureDataJpa auto-configuration imports -org.springframework.boot.test.autoconfigure.service.connection.TestcontainersServiceConnectionAutoConfiguration org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestWithServiceConnectionBeanIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestWithServiceConnectionBeanIntegrationTests.java index 843dd1cc239d..94139ac45302 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestWithServiceConnectionBeanIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestWithServiceConnectionBeanIntegrationTests.java @@ -23,18 +23,14 @@ import org.testcontainers.couchbase.CouchbaseContainer; import org.testcontainers.junit.jupiter.Testcontainers; -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.ServiceConnection; import org.springframework.boot.testsupport.testcontainers.DockerImageNames; -import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.data.couchbase.core.CouchbaseTemplate; -import org.springframework.test.annotation.DirtiesContext; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; /** * Integration test for {@link DataCouchbaseTest @DataCouchbaseTest}. diff --git a/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.cassandra.AutoConfigureDataCassandra.imports b/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.cassandra.AutoConfigureDataCassandra.imports new file mode 100644 index 000000000000..c69a4ef992e9 --- /dev/null +++ b/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.cassandra.AutoConfigureDataCassandra.imports @@ -0,0 +1,2 @@ +# AutoConfigureDataCassandra auto-configuration imports +org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration diff --git a/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.couchbase.AutoConfigureDataCouchbase.imports b/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.couchbase.AutoConfigureDataCouchbase.imports new file mode 100644 index 000000000000..cd54f01baaa4 --- /dev/null +++ b/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.couchbase.AutoConfigureDataCouchbase.imports @@ -0,0 +1,2 @@ +# AutoConfigureDataCouchbase auto-configuration imports +org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration diff --git a/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.elasticsearch.AutoConfigureDataElasticsearch.imports b/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.elasticsearch.AutoConfigureDataElasticsearch.imports new file mode 100644 index 000000000000..3ac366cc6f06 --- /dev/null +++ b/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.elasticsearch.AutoConfigureDataElasticsearch.imports @@ -0,0 +1,2 @@ +# AutoConfigureDataElasticsearch auto-configuration imports +org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration diff --git a/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.jdbc.AutoConfigureDataJdbc.imports b/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.jdbc.AutoConfigureDataJdbc.imports new file mode 100644 index 000000000000..db9bad5b3078 --- /dev/null +++ b/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.jdbc.AutoConfigureDataJdbc.imports @@ -0,0 +1,2 @@ +# AutoConfigureDataJdbc auto-configuration imports +org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration diff --git a/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.mongo.AutoConfigureDataMongo.imports b/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.mongo.AutoConfigureDataMongo.imports new file mode 100644 index 000000000000..c8652834587b --- /dev/null +++ b/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.mongo.AutoConfigureDataMongo.imports @@ -0,0 +1,2 @@ +# AutoConfigureDataMongo auto-configuration imports +org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration diff --git a/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.neo4j.AutoConfigureDataNeo4j.imports b/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.neo4j.AutoConfigureDataNeo4j.imports new file mode 100644 index 000000000000..e09426c62300 --- /dev/null +++ b/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.neo4j.AutoConfigureDataNeo4j.imports @@ -0,0 +1,2 @@ +# AutoConfigureDataNeo4j auto-configuration imports +org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration \ No newline at end of file diff --git a/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.r2dbc.AutoConfigureDataR2dbc.imports b/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.r2dbc.AutoConfigureDataR2dbc.imports new file mode 100644 index 000000000000..fe6633b44fee --- /dev/null +++ b/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.r2dbc.AutoConfigureDataR2dbc.imports @@ -0,0 +1,2 @@ +# AutoConfigureDataR2dbc auto-configuration imports +org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration \ No newline at end of file diff --git a/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.redis.AutoConfigureDataRedis.imports b/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.redis.AutoConfigureDataRedis.imports new file mode 100644 index 000000000000..b86166da8820 --- /dev/null +++ b/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.redis.AutoConfigureDataRedis.imports @@ -0,0 +1,2 @@ +# AutoConfigureDataRedis auto-configuration imports +org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration \ No newline at end of file diff --git a/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureJdbc.imports b/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureJdbc.imports new file mode 100644 index 000000000000..3a4619215ccc --- /dev/null +++ b/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureJdbc.imports @@ -0,0 +1,2 @@ +# AutoConfigureJdbc auto-configuration imports +org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration \ No newline at end of file diff --git a/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.imports b/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.imports new file mode 100644 index 000000000000..ad021386df49 --- /dev/null +++ b/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.imports @@ -0,0 +1,2 @@ +# AutoConfigureTestDatabase auto-configuration imports +org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration \ No newline at end of file diff --git a/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jooq.AutoConfigureJooq.imports b/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jooq.AutoConfigureJooq.imports new file mode 100644 index 000000000000..574484f893b3 --- /dev/null +++ b/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jooq.AutoConfigureJooq.imports @@ -0,0 +1,2 @@ +# AutoConfigureJooq auto-configuration imports +org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration \ No newline at end of file diff --git a/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureDataJpa.imports b/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureDataJpa.imports new file mode 100644 index 000000000000..1a3c071f5757 --- /dev/null +++ b/spring-boot-project/spring-boot-testcontainers/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureDataJpa.imports @@ -0,0 +1,2 @@ +# AutoConfigureDataJpa auto-configuration imports +org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration \ No newline at end of file From 08c7cb231f5ddc9563c0680b7444aae52890654a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Thu, 22 Jun 2023 20:52:15 -0600 Subject: [PATCH 3/5] restore file --- ...toconfigure.data.couchbase.AutoConfigureDataCouchbase.imports | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.couchbase.AutoConfigureDataCouchbase.imports b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.couchbase.AutoConfigureDataCouchbase.imports index ac06617018e6..aaae4207e95c 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.couchbase.AutoConfigureDataCouchbase.imports +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.couchbase.AutoConfigureDataCouchbase.imports @@ -1,4 +1,5 @@ # AutoConfigureDataCouchbase auto-configuration imports + org.springframework.boot.autoconfigure.couchbase.CouchbaseAutoConfiguration org.springframework.boot.autoconfigure.data.couchbase.CouchbaseDataAutoConfiguration org.springframework.boot.autoconfigure.data.couchbase.CouchbaseReactiveDataAutoConfiguration From 268574e6b44634e2b0f9f43df1d29127ea13bc72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Fri, 23 Jun 2023 11:04:52 -0600 Subject: [PATCH 4/5] Remove semicolon --- ...sticsearchTestWithServiceConnectionBeanIntegrationTests.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestWithServiceConnectionBeanIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestWithServiceConnectionBeanIntegrationTests.java index ccb2f77af3f7..0d36a9a07626 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestWithServiceConnectionBeanIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestWithServiceConnectionBeanIntegrationTests.java @@ -44,8 +44,6 @@ @Testcontainers(disabledWithoutDocker = true) class DataElasticsearchTestWithServiceConnectionBeanIntegrationTests { - ; - @Autowired private ElasticsearchTemplate elasticsearchTemplate; From 7f4425bbbae9d7c67212f0aab02d7e16ad2345b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Fri, 23 Jun 2023 20:31:25 -0600 Subject: [PATCH 5/5] Fix redis test --- .../DataRedisTestWithServiceConnectionBeanIntegrationTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestWithServiceConnectionBeanIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestWithServiceConnectionBeanIntegrationTests.java index 3efada383aeb..9bce650387e4 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestWithServiceConnectionBeanIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestWithServiceConnectionBeanIntegrationTests.java @@ -70,7 +70,7 @@ void testRepository() { static class ContainerConfig { @Bean - @ServiceConnection + @ServiceConnection(name = "redis") RedisContainer redis() { return new RedisContainer(); }