diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTestContextBootstrapper.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTestContextBootstrapper.java index 4238e64b5d6..56fb006508b 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTestContextBootstrapper.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTestContextBootstrapper.java @@ -17,8 +17,7 @@ package org.springframework.boot.test.autoconfigure.data.cassandra; import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; -import org.springframework.core.annotation.MergedAnnotations; -import org.springframework.core.annotation.MergedAnnotations.SearchStrategy; +import org.springframework.test.context.TestContextAnnotationUtils; import org.springframework.test.context.TestContextBootstrapper; /** @@ -31,10 +30,9 @@ class DataCassandraTestContextBootstrapper extends SpringBootTestContextBootstra @Override protected String[] getProperties(Class testClass) { - return MergedAnnotations.from(testClass, SearchStrategy.INHERITED_ANNOTATIONS) - .get(DataCassandraTest.class) - .getValue("properties", String[].class) - .orElse(null); + DataCassandraTest dataCassandraTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, + DataCassandraTest.class); + return (dataCassandraTest != null) ? dataCassandraTest.properties() : null; } } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestContextBootstrapper.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestContextBootstrapper.java index 86fb4c2dc6a..e921b751a31 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestContextBootstrapper.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestContextBootstrapper.java @@ -17,8 +17,7 @@ package org.springframework.boot.test.autoconfigure.data.couchbase; import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; -import org.springframework.core.annotation.MergedAnnotations; -import org.springframework.core.annotation.MergedAnnotations.SearchStrategy; +import org.springframework.test.context.TestContextAnnotationUtils; import org.springframework.test.context.TestContextBootstrapper; /** @@ -31,10 +30,9 @@ class DataCouchbaseTestContextBootstrapper extends SpringBootTestContextBootstra @Override protected String[] getProperties(Class testClass) { - return MergedAnnotations.from(testClass, SearchStrategy.INHERITED_ANNOTATIONS) - .get(DataCouchbaseTest.class) - .getValue("properties", String[].class) - .orElse(null); + DataCouchbaseTest dataCouchbaseTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, + DataCouchbaseTest.class); + return (dataCouchbaseTest != null) ? dataCouchbaseTest.properties() : null; } } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestContextBootstrapper.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestContextBootstrapper.java index e23e629505f..4d80cadae3a 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestContextBootstrapper.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestContextBootstrapper.java @@ -17,8 +17,7 @@ package org.springframework.boot.test.autoconfigure.data.elasticsearch; import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; -import org.springframework.core.annotation.MergedAnnotations; -import org.springframework.core.annotation.MergedAnnotations.SearchStrategy; +import org.springframework.test.context.TestContextAnnotationUtils; import org.springframework.test.context.TestContextBootstrapper; /** @@ -31,10 +30,9 @@ class DataElasticsearchTestContextBootstrapper extends SpringBootTestContextBoot @Override protected String[] getProperties(Class testClass) { - return MergedAnnotations.from(testClass, SearchStrategy.INHERITED_ANNOTATIONS) - .get(DataElasticsearchTest.class) - .getValue("properties", String[].class) - .orElse(null); + DataElasticsearchTest dataElasticsearchTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, + DataElasticsearchTest.class); + return (dataElasticsearchTest != null) ? dataElasticsearchTest.properties() : null; } } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTestContextBootstrapper.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTestContextBootstrapper.java index 9c99f9b2968..f633edd55f4 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTestContextBootstrapper.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTestContextBootstrapper.java @@ -17,8 +17,7 @@ package org.springframework.boot.test.autoconfigure.data.jdbc; import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; -import org.springframework.core.annotation.MergedAnnotations; -import org.springframework.core.annotation.MergedAnnotations.SearchStrategy; +import org.springframework.test.context.TestContextAnnotationUtils; import org.springframework.test.context.TestContextBootstrapper; /** @@ -30,10 +29,8 @@ class DataJdbcTestContextBootstrapper extends SpringBootTestContextBootstrapper @Override protected String[] getProperties(Class testClass) { - return MergedAnnotations.from(testClass, SearchStrategy.INHERITED_ANNOTATIONS) - .get(DataJdbcTest.class) - .getValue("properties", String[].class) - .orElse(null); + DataJdbcTest dataJdbcTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, DataJdbcTest.class); + return (dataJdbcTest != null) ? dataJdbcTest.properties() : null; } } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTestContextBootstrapper.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTestContextBootstrapper.java index 827c313c20e..8268a2e7b84 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTestContextBootstrapper.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTestContextBootstrapper.java @@ -17,8 +17,7 @@ package org.springframework.boot.test.autoconfigure.data.ldap; import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; -import org.springframework.core.annotation.MergedAnnotations; -import org.springframework.core.annotation.MergedAnnotations.SearchStrategy; +import org.springframework.test.context.TestContextAnnotationUtils; import org.springframework.test.context.TestContextBootstrapper; /** @@ -30,10 +29,8 @@ class DataLdapTestContextBootstrapper extends SpringBootTestContextBootstrapper @Override protected String[] getProperties(Class testClass) { - return MergedAnnotations.from(testClass, SearchStrategy.INHERITED_ANNOTATIONS) - .get(DataLdapTest.class) - .getValue("properties", String[].class) - .orElse(null); + DataLdapTest dataLdapTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, DataLdapTest.class); + return (dataLdapTest != null) ? dataLdapTest.properties() : null; } } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestContextBootstrapper.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestContextBootstrapper.java index 6a973d302df..70803b42eb2 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestContextBootstrapper.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestContextBootstrapper.java @@ -17,8 +17,7 @@ package org.springframework.boot.test.autoconfigure.data.mongo; import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; -import org.springframework.core.annotation.MergedAnnotations; -import org.springframework.core.annotation.MergedAnnotations.SearchStrategy; +import org.springframework.test.context.TestContextAnnotationUtils; import org.springframework.test.context.TestContextBootstrapper; /** @@ -30,10 +29,8 @@ class DataMongoTestContextBootstrapper extends SpringBootTestContextBootstrapper @Override protected String[] getProperties(Class testClass) { - return MergedAnnotations.from(testClass, SearchStrategy.INHERITED_ANNOTATIONS) - .get(DataMongoTest.class) - .getValue("properties", String[].class) - .orElse(null); + DataMongoTest dataMongoTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, DataMongoTest.class); + return (dataMongoTest != null) ? dataMongoTest.properties() : null; } } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestContextBootstrapper.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestContextBootstrapper.java index 85bc9639d54..5bc499c6c96 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestContextBootstrapper.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestContextBootstrapper.java @@ -17,8 +17,7 @@ package org.springframework.boot.test.autoconfigure.data.neo4j; import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; -import org.springframework.core.annotation.MergedAnnotations; -import org.springframework.core.annotation.MergedAnnotations.SearchStrategy; +import org.springframework.test.context.TestContextAnnotationUtils; import org.springframework.test.context.TestContextBootstrapper; /** @@ -30,10 +29,8 @@ class DataNeo4jTestContextBootstrapper extends SpringBootTestContextBootstrapper @Override protected String[] getProperties(Class testClass) { - return MergedAnnotations.from(testClass, SearchStrategy.INHERITED_ANNOTATIONS) - .get(DataNeo4jTest.class) - .getValue("properties", String[].class) - .orElse(null); + DataNeo4jTest dataNeo4jTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, DataNeo4jTest.class); + return (dataNeo4jTest != null) ? dataNeo4jTest.properties() : null; } } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/r2dbc/DataR2dbcTestContextBootstrapper.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/r2dbc/DataR2dbcTestContextBootstrapper.java index 26e1308e98e..282e27059f8 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/r2dbc/DataR2dbcTestContextBootstrapper.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/r2dbc/DataR2dbcTestContextBootstrapper.java @@ -17,8 +17,7 @@ package org.springframework.boot.test.autoconfigure.data.r2dbc; import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; -import org.springframework.core.annotation.MergedAnnotations; -import org.springframework.core.annotation.MergedAnnotations.SearchStrategy; +import org.springframework.test.context.TestContextAnnotationUtils; import org.springframework.test.context.TestContextBootstrapper; /** @@ -30,10 +29,8 @@ class DataR2dbcTestContextBootstrapper extends SpringBootTestContextBootstrapper @Override protected String[] getProperties(Class testClass) { - return MergedAnnotations.from(testClass, SearchStrategy.INHERITED_ANNOTATIONS) - .get(DataR2dbcTest.class) - .getValue("properties", String[].class) - .orElse(null); + DataR2dbcTest dataR2dbcTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, DataR2dbcTest.class); + return (dataR2dbcTest != null) ? dataR2dbcTest.properties() : null; } } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestContextBootstrapper.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestContextBootstrapper.java index a5530b4beaa..aaba8abdc4d 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestContextBootstrapper.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestContextBootstrapper.java @@ -17,8 +17,7 @@ package org.springframework.boot.test.autoconfigure.data.redis; import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; -import org.springframework.core.annotation.MergedAnnotations; -import org.springframework.core.annotation.MergedAnnotations.SearchStrategy; +import org.springframework.test.context.TestContextAnnotationUtils; import org.springframework.test.context.TestContextBootstrapper; /** @@ -30,10 +29,8 @@ class DataRedisTestContextBootstrapper extends SpringBootTestContextBootstrapper @Override protected String[] getProperties(Class testClass) { - return MergedAnnotations.from(testClass, SearchStrategy.INHERITED_ANNOTATIONS) - .get(DataRedisTest.class) - .getValue("properties", String[].class) - .orElse(null); + DataRedisTest dataRedisTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, DataRedisTest.class); + return (dataRedisTest != null) ? dataRedisTest.properties() : null; } } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/GraphQlTestContextBootstrapper.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/GraphQlTestContextBootstrapper.java index 4f8971fe090..9b9345b12ed 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/GraphQlTestContextBootstrapper.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/GraphQlTestContextBootstrapper.java @@ -17,7 +17,7 @@ package org.springframework.boot.test.autoconfigure.graphql; import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; -import org.springframework.core.annotation.MergedAnnotations; +import org.springframework.test.context.TestContextAnnotationUtils; import org.springframework.test.context.TestContextBootstrapper; /** @@ -29,10 +29,8 @@ class GraphQlTestContextBootstrapper extends SpringBootTestContextBootstrapper { @Override protected String[] getProperties(Class testClass) { - return MergedAnnotations.from(testClass, MergedAnnotations.SearchStrategy.INHERITED_ANNOTATIONS) - .get(GraphQlTest.class) - .getValue("properties", String[].class) - .orElse(null); + GraphQlTest graphQlTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, GraphQlTest.class); + return (graphQlTest != null) ? graphQlTest.properties() : null; } } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestContextBootstrapper.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestContextBootstrapper.java index a2eebe37d63..45211ffde35 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestContextBootstrapper.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestContextBootstrapper.java @@ -17,8 +17,7 @@ package org.springframework.boot.test.autoconfigure.jdbc; import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; -import org.springframework.core.annotation.MergedAnnotations; -import org.springframework.core.annotation.MergedAnnotations.SearchStrategy; +import org.springframework.test.context.TestContextAnnotationUtils; import org.springframework.test.context.TestContextBootstrapper; /** @@ -30,10 +29,8 @@ class JdbcTestContextBootstrapper extends SpringBootTestContextBootstrapper { @Override protected String[] getProperties(Class testClass) { - return MergedAnnotations.from(testClass, SearchStrategy.INHERITED_ANNOTATIONS) - .get(JdbcTest.class) - .getValue("properties", String[].class) - .orElse(null); + JdbcTest jdbcTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, JdbcTest.class); + return (jdbcTest != null) ? jdbcTest.properties() : null; } } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestContextBootstrapper.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestContextBootstrapper.java index 770bdd79b09..a99bc141885 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestContextBootstrapper.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestContextBootstrapper.java @@ -17,8 +17,7 @@ package org.springframework.boot.test.autoconfigure.jooq; import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; -import org.springframework.core.annotation.MergedAnnotations; -import org.springframework.core.annotation.MergedAnnotations.SearchStrategy; +import org.springframework.test.context.TestContextAnnotationUtils; import org.springframework.test.context.TestContextBootstrapper; /** @@ -30,10 +29,8 @@ class JooqTestContextBootstrapper extends SpringBootTestContextBootstrapper { @Override protected String[] getProperties(Class testClass) { - return MergedAnnotations.from(testClass, SearchStrategy.INHERITED_ANNOTATIONS) - .get(JooqTest.class) - .getValue("properties", String[].class) - .orElse(null); + JooqTest jooqTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, JooqTest.class); + return (jooqTest != null) ? jooqTest.properties() : null; } } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTestContextBootstrapper.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTestContextBootstrapper.java index 55a2119879e..752c887ec9a 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTestContextBootstrapper.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTestContextBootstrapper.java @@ -17,8 +17,7 @@ package org.springframework.boot.test.autoconfigure.json; import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; -import org.springframework.core.annotation.MergedAnnotations; -import org.springframework.core.annotation.MergedAnnotations.SearchStrategy; +import org.springframework.test.context.TestContextAnnotationUtils; import org.springframework.test.context.TestContextBootstrapper; /** @@ -30,10 +29,8 @@ class JsonTestContextBootstrapper extends SpringBootTestContextBootstrapper { @Override protected String[] getProperties(Class testClass) { - return MergedAnnotations.from(testClass, SearchStrategy.INHERITED_ANNOTATIONS) - .get(JsonTest.class) - .getValue("properties", String[].class) - .orElse(null); + JsonTest jsonTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, JsonTest.class); + return (jsonTest != null) ? jsonTest.properties() : null; } } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestContextBootstrapper.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestContextBootstrapper.java index 726489cae0c..53de234318d 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestContextBootstrapper.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestContextBootstrapper.java @@ -17,8 +17,7 @@ package org.springframework.boot.test.autoconfigure.web.client; import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; -import org.springframework.core.annotation.MergedAnnotations; -import org.springframework.core.annotation.MergedAnnotations.SearchStrategy; +import org.springframework.test.context.TestContextAnnotationUtils; import org.springframework.test.context.TestContextBootstrapper; /** @@ -30,10 +29,9 @@ class RestClientTestContextBootstrapper extends SpringBootTestContextBootstrappe @Override protected String[] getProperties(Class testClass) { - return MergedAnnotations.from(testClass, SearchStrategy.INHERITED_ANNOTATIONS) - .get(RestClientTest.class) - .getValue("properties", String[].class) - .orElse(null); + RestClientTest restClientTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, + RestClientTest.class); + return (restClientTest != null) ? restClientTest.properties() : null; } } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTestContextBootstrapper.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTestContextBootstrapper.java index da6d72dd5a6..3f813f97b60 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTestContextBootstrapper.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTestContextBootstrapper.java @@ -18,9 +18,8 @@ package org.springframework.boot.test.autoconfigure.web.reactive; import org.springframework.boot.test.context.ReactiveWebMergedContextConfiguration; import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; -import org.springframework.core.annotation.MergedAnnotations; -import org.springframework.core.annotation.MergedAnnotations.SearchStrategy; import org.springframework.test.context.MergedContextConfiguration; +import org.springframework.test.context.TestContextAnnotationUtils; import org.springframework.test.context.TestContextBootstrapper; /** @@ -38,10 +37,8 @@ class WebFluxTestContextBootstrapper extends SpringBootTestContextBootstrapper { @Override protected String[] getProperties(Class testClass) { - return MergedAnnotations.from(testClass, SearchStrategy.INHERITED_ANNOTATIONS) - .get(WebFluxTest.class) - .getValue("properties", String[].class) - .orElse(null); + WebFluxTest webFluxTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, WebFluxTest.class); + return (webFluxTest != null) ? webFluxTest.properties() : null; } } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTestContextBootstrapper.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTestContextBootstrapper.java index fc366bc2ca3..0dcf35d2313 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTestContextBootstrapper.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTestContextBootstrapper.java @@ -17,9 +17,8 @@ package org.springframework.boot.test.autoconfigure.web.servlet; import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; -import org.springframework.core.annotation.MergedAnnotations; -import org.springframework.core.annotation.MergedAnnotations.SearchStrategy; import org.springframework.test.context.MergedContextConfiguration; +import org.springframework.test.context.TestContextAnnotationUtils; import org.springframework.test.context.TestContextBootstrapper; import org.springframework.test.context.web.WebMergedContextConfiguration; @@ -40,10 +39,8 @@ class WebMvcTestContextBootstrapper extends SpringBootTestContextBootstrapper { @Override protected String[] getProperties(Class testClass) { - return MergedAnnotations.from(testClass, SearchStrategy.INHERITED_ANNOTATIONS) - .get(WebMvcTest.class) - .getValue("properties", String[].class) - .orElse(null); + WebMvcTest webMvcTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, WebMvcTest.class); + return (webMvcTest != null) ? webMvcTest.properties() : null; } } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientTestContextBootstrapper.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientTestContextBootstrapper.java index 931e76e5ce0..24bf8b79505 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientTestContextBootstrapper.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientTestContextBootstrapper.java @@ -17,8 +17,7 @@ package org.springframework.boot.test.autoconfigure.webservices.client; import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; -import org.springframework.core.annotation.MergedAnnotations; -import org.springframework.core.annotation.MergedAnnotations.SearchStrategy; +import org.springframework.test.context.TestContextAnnotationUtils; import org.springframework.test.context.TestContextBootstrapper; /** @@ -31,10 +30,9 @@ class WebServiceClientTestContextBootstrapper extends SpringBootTestContextBoots @Override protected String[] getProperties(Class testClass) { - return MergedAnnotations.from(testClass, SearchStrategy.INHERITED_ANNOTATIONS) - .get(WebServiceClientTest.class) - .getValue("properties", String[].class) - .orElse(null); + WebServiceClientTest webServiceClientTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, + WebServiceClientTest.class); + return (webServiceClientTest != null) ? webServiceClientTest.properties() : null; } } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/server/WebServiceServerTestContextBootstrapper.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/server/WebServiceServerTestContextBootstrapper.java index 2e5cbe01f3c..8d2e8047b7b 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/server/WebServiceServerTestContextBootstrapper.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/server/WebServiceServerTestContextBootstrapper.java @@ -17,9 +17,8 @@ package org.springframework.boot.test.autoconfigure.webservices.server; import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; -import org.springframework.core.annotation.MergedAnnotations; -import org.springframework.core.annotation.MergedAnnotations.SearchStrategy; import org.springframework.test.context.MergedContextConfiguration; +import org.springframework.test.context.TestContextAnnotationUtils; import org.springframework.test.context.TestContextBootstrapper; import org.springframework.test.context.web.WebMergedContextConfiguration; @@ -39,10 +38,9 @@ class WebServiceServerTestContextBootstrapper extends SpringBootTestContextBoots @Override protected String[] getProperties(Class testClass) { - return MergedAnnotations.from(testClass, SearchStrategy.INHERITED_ANNOTATIONS) - .get(WebServiceServerTest.class) - .getValue("properties", String[].class) - .orElse(null); + WebServiceServerTest webServiceServerTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, + WebServiceServerTest.class); + return (webServiceServerTest != null) ? webServiceServerTest.properties() : null; } } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTestPropertiesIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTestPropertiesIntegrationTests.java index 3083322d6bc..3866fba2d3d 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTestPropertiesIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTestPropertiesIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * 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. @@ -19,11 +19,14 @@ package org.springframework.boot.test.autoconfigure.data.cassandra; import com.datastax.oss.driver.api.core.CqlSession; import com.datastax.oss.driver.api.core.context.DriverContext; import com.datastax.oss.driver.api.core.type.codec.registry.CodecRegistry; +import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.data.cassandra.DataCassandraTestPropertiesIntegrationTests.CassandraMockConfiguration; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Import; import org.springframework.core.env.Environment; import static org.assertj.core.api.Assertions.assertThat; @@ -36,6 +39,7 @@ import static org.mockito.Mockito.mock; * * @author Artsiom Yudovin */ +@Import(CassandraMockConfiguration.class) @DataCassandraTest(properties = "spring.profiles.active=test") class DataCassandraTestPropertiesIntegrationTests { @@ -47,7 +51,22 @@ class DataCassandraTestPropertiesIntegrationTests { assertThat(this.environment.getActiveProfiles()).containsExactly("test"); } - @TestConfiguration(proxyBeanMethods = false) + @Nested + class NestedTests { + + @Autowired + private Environment innerEnvironment; + + @Test + void propertiesFromEnclosingClassAffectNestedTests() { + assertThat(DataCassandraTestPropertiesIntegrationTests.this.environment.getActiveProfiles()) + .containsExactly("test"); + assertThat(this.innerEnvironment.getActiveProfiles()).containsExactly("test"); + } + + } + + @TestConfiguration static class CassandraMockConfiguration { @Bean diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestPropertiesIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestPropertiesIntegrationTests.java index c489be648b1..2322c8e0116 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestPropertiesIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestPropertiesIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2022 the original author or authors. + * 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. @@ -16,6 +16,7 @@ package org.springframework.boot.test.autoconfigure.data.couchbase; +import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -40,4 +41,19 @@ class DataCouchbaseTestPropertiesIntegrationTests { assertThat(this.environment.getActiveProfiles()).containsExactly("test"); } + @Nested + class NestedTests { + + @Autowired + private Environment innerEnvironment; + + @Test + void propertiesFromEnclosingClassAffectNestedTests() { + assertThat(DataCouchbaseTestPropertiesIntegrationTests.this.environment.getActiveProfiles()) + .containsExactly("test"); + assertThat(this.innerEnvironment.getActiveProfiles()).containsExactly("test"); + } + + } + } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestPropertiesIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestPropertiesIntegrationTests.java index 9a15e17e987..41cd7811418 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestPropertiesIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestPropertiesIntegrationTests.java @@ -18,6 +18,7 @@ package org.springframework.boot.test.autoconfigure.data.elasticsearch; import java.time.Duration; +import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.testcontainers.elasticsearch.ElasticsearchContainer; import org.testcontainers.junit.jupiter.Container; @@ -59,4 +60,19 @@ class DataElasticsearchTestPropertiesIntegrationTests { assertThat(this.environment.getActiveProfiles()).containsExactly("test"); } + @Nested + class NestedTests { + + @Autowired + private Environment innerEnvironment; + + @Test + void propertiesFromEnclosingClassAffectNestedTests() { + assertThat(DataElasticsearchTestPropertiesIntegrationTests.this.environment.getActiveProfiles()) + .containsExactly("test"); + assertThat(this.innerEnvironment.getActiveProfiles()).containsExactly("test"); + } + + } + } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTestPropertiesIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTestPropertiesIntegrationTests.java index aeb6d7af084..2b03d7456ad 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTestPropertiesIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTestPropertiesIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * 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. @@ -16,6 +16,7 @@ package org.springframework.boot.test.autoconfigure.data.jdbc; +import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -40,4 +41,19 @@ class DataJdbcTestPropertiesIntegrationTests { assertThat(this.environment.getActiveProfiles()).containsExactly("test"); } + @Nested + class NestedTests { + + @Autowired + private Environment innerEnvironment; + + @Test + void propertiesFromEnclosingClassAffectNestedTests() { + assertThat(DataJdbcTestPropertiesIntegrationTests.this.environment.getActiveProfiles()) + .containsExactly("test"); + assertThat(this.innerEnvironment.getActiveProfiles()).containsExactly("test"); + } + + } + } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTestPropertiesIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTestPropertiesIntegrationTests.java index 31f54f0bfaa..3dc0267ee26 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTestPropertiesIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTestPropertiesIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * 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. @@ -16,6 +16,7 @@ package org.springframework.boot.test.autoconfigure.data.ldap; +import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -40,4 +41,19 @@ class DataLdapTestPropertiesIntegrationTests { assertThat(this.environment.getActiveProfiles()).containsExactly("test"); } + @Nested + class NestedTests { + + @Autowired + private Environment innerEnvironment; + + @Test + void propertiesFromEnclosingClassAffectNestedTests() { + assertThat(DataLdapTestPropertiesIntegrationTests.this.environment.getActiveProfiles()) + .containsExactly("test"); + assertThat(this.innerEnvironment.getActiveProfiles()).containsExactly("test"); + } + + } + } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestPropertiesIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestPropertiesIntegrationTests.java index 88d3cdcc4fb..ae8ba40e466 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestPropertiesIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestPropertiesIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * 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. @@ -16,6 +16,7 @@ package org.springframework.boot.test.autoconfigure.data.mongo; +import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -40,4 +41,19 @@ class DataMongoTestPropertiesIntegrationTests { assertThat(this.environment.getActiveProfiles()).containsExactly("test"); } + @Nested + class NestedTests { + + @Autowired + private Environment innerEnvironment; + + @Test + void propertiesFromEnclosingClassAffectNestedTests() { + assertThat(DataMongoTestPropertiesIntegrationTests.this.environment.getActiveProfiles()) + .containsExactly("test"); + assertThat(this.innerEnvironment.getActiveProfiles()).containsExactly("test"); + } + + } + } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestPropertiesIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestPropertiesIntegrationTests.java index 37413c4434b..272402cf5e2 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestPropertiesIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestPropertiesIntegrationTests.java @@ -18,6 +18,7 @@ package org.springframework.boot.test.autoconfigure.data.neo4j; import java.time.Duration; +import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.testcontainers.containers.Neo4jContainer; import org.testcontainers.junit.jupiter.Container; @@ -59,4 +60,19 @@ class DataNeo4jTestPropertiesIntegrationTests { assertThat(this.environment.getActiveProfiles()).containsExactly("test"); } + @Nested + class NestedTests { + + @Autowired + private Environment innerEnvironment; + + @Test + void propertiesFromEnclosingClassAffectNestedTests() { + assertThat(DataNeo4jTestPropertiesIntegrationTests.this.environment.getActiveProfiles()) + .containsExactly("test"); + assertThat(this.innerEnvironment.getActiveProfiles()).containsExactly("test"); + } + + } + } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/r2dbc/DataR2dbcTestPropertiesIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/r2dbc/DataR2dbcTestPropertiesIntegrationTests.java index d518b252c33..bd1d9a73c64 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/r2dbc/DataR2dbcTestPropertiesIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/r2dbc/DataR2dbcTestPropertiesIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * 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. @@ -16,6 +16,7 @@ package org.springframework.boot.test.autoconfigure.data.r2dbc; +import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -40,4 +41,19 @@ class DataR2dbcTestPropertiesIntegrationTests { assertThat(this.environment.getActiveProfiles()).containsExactly("test"); } + @Nested + class NestedTests { + + @Autowired + private Environment innerEnvironment; + + @Test + void propertiesFromEnclosingClassAffectNestedTests() { + assertThat(DataR2dbcTestPropertiesIntegrationTests.this.environment.getActiveProfiles()) + .containsExactly("test"); + assertThat(this.innerEnvironment.getActiveProfiles()).containsExactly("test"); + } + + } + } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestPropertiesIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestPropertiesIntegrationTests.java index 11968e90e50..92ca1d8066a 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestPropertiesIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestPropertiesIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2022 the original author or authors. + * 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. @@ -16,6 +16,7 @@ package org.springframework.boot.test.autoconfigure.data.redis; +import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; @@ -55,4 +56,19 @@ class DataRedisTestPropertiesIntegrationTests { assertThat(this.environment.getActiveProfiles()).containsExactly("test"); } + @Nested + class NestedTests { + + @Autowired + private Environment innerEnvironment; + + @Test + void propertiesFromEnclosingClassAffectNestedTests() { + assertThat(DataRedisTestPropertiesIntegrationTests.this.environment.getActiveProfiles()) + .containsExactly("test"); + assertThat(this.innerEnvironment.getActiveProfiles()).containsExactly("test"); + } + + } + } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/graphql/GraphQlTestPropertiesIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/graphql/GraphQlTestPropertiesIntegrationTests.java new file mode 100644 index 00000000000..3e50d32ded3 --- /dev/null +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/graphql/GraphQlTestPropertiesIntegrationTests.java @@ -0,0 +1,59 @@ +/* + * 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.graphql; + +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for the {@link GraphQlTest#properties properties} attribute of + * {@link GraphQlTest @GraphQlTest}. + * + * @author Andy Wilkinson + */ +@GraphQlTest(properties = "spring.profiles.active=test") +class GraphQlTestPropertiesIntegrationTests { + + @Autowired + private Environment environment; + + @Test + void environmentWithNewProfile() { + assertThat(this.environment.getActiveProfiles()).containsExactly("test"); + } + + @Nested + class NestedTests { + + @Autowired + private Environment innerEnvironment; + + @Test + void propertiesFromEnclosingClassAffectNestedTests() { + assertThat(GraphQlTestPropertiesIntegrationTests.this.environment.getActiveProfiles()) + .containsExactly("test"); + assertThat(this.innerEnvironment.getActiveProfiles()).containsExactly("test"); + } + + } + +} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestPropertiesIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestPropertiesIntegrationTests.java index d56ad938d04..3d3c12476f7 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestPropertiesIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestPropertiesIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * 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. @@ -16,6 +16,7 @@ package org.springframework.boot.test.autoconfigure.jdbc; +import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -40,4 +41,18 @@ class JdbcTestPropertiesIntegrationTests { assertThat(this.environment.getActiveProfiles()).containsExactly("test"); } + @Nested + class NestedTests { + + @Autowired + private Environment innerEnvironment; + + @Test + void propertiesFromEnclosingClassAffectNestedTests() { + assertThat(JdbcTestPropertiesIntegrationTests.this.environment.getActiveProfiles()).containsExactly("test"); + assertThat(this.innerEnvironment.getActiveProfiles()).containsExactly("test"); + } + + } + } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestPropertiesIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestPropertiesIntegrationTests.java index 7cc3e252628..44583b384a3 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestPropertiesIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestPropertiesIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2022 the original author or authors. + * 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. @@ -16,6 +16,7 @@ package org.springframework.boot.test.autoconfigure.jooq; +import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -40,4 +41,18 @@ class JooqTestPropertiesIntegrationTests { assertThat(this.environment.getActiveProfiles()).containsExactly("test"); } + @Nested + class NestedTests { + + @Autowired + private Environment innerEnvironment; + + @Test + void propertiesFromEnclosingClassAffectNestedTests() { + assertThat(JooqTestPropertiesIntegrationTests.this.environment.getActiveProfiles()).containsExactly("test"); + assertThat(this.innerEnvironment.getActiveProfiles()).containsExactly("test"); + } + + } + } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/JsonTestPropertiesIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/JsonTestPropertiesIntegrationTests.java index 75ffd44952b..53194b8daa4 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/JsonTestPropertiesIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/JsonTestPropertiesIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * 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. @@ -16,6 +16,7 @@ package org.springframework.boot.test.autoconfigure.json; +import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -40,4 +41,18 @@ class JsonTestPropertiesIntegrationTests { assertThat(this.environment.getActiveProfiles()).containsExactly("test"); } + @Nested + class NestedTests { + + @Autowired + private Environment innerEnvironment; + + @Test + void propertiesFromEnclosingClassAffectNestedTests() { + assertThat(JsonTestPropertiesIntegrationTests.this.environment.getActiveProfiles()).containsExactly("test"); + assertThat(this.innerEnvironment.getActiveProfiles()).containsExactly("test"); + } + + } + } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestPropertiesIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestPropertiesIntegrationTests.java index c1fbe2eb53c..c29f77b2a1d 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestPropertiesIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestPropertiesIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * 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. @@ -16,6 +16,7 @@ package org.springframework.boot.test.autoconfigure.web.client; +import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -40,4 +41,19 @@ class RestClientTestPropertiesIntegrationTests { assertThat(this.environment.getActiveProfiles()).containsExactly("test"); } + @Nested + class NestedTests { + + @Autowired + private Environment innerEnvironment; + + @Test + void propertiesFromEnclosingClassAffectNestedTests() { + assertThat(RestClientTestPropertiesIntegrationTests.this.environment.getActiveProfiles()) + .containsExactly("test"); + assertThat(this.innerEnvironment.getActiveProfiles()).containsExactly("test"); + } + + } + } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTestPropertiesIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTestPropertiesIntegrationTests.java index 870aafa09d4..70a23ceb25b 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTestPropertiesIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTestPropertiesIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * 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. @@ -16,6 +16,7 @@ package org.springframework.boot.test.autoconfigure.web.reactive; +import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -40,4 +41,19 @@ class WebFluxTestPropertiesIntegrationTests { assertThat(this.environment.getActiveProfiles()).containsExactly("test"); } + @Nested + class NestedTests { + + @Autowired + private Environment innerEnvironment; + + @Test + void propertiesFromEnclosingClassAffectNestedTests() { + assertThat(WebFluxTestPropertiesIntegrationTests.this.environment.getActiveProfiles()) + .containsExactly("test"); + assertThat(this.innerEnvironment.getActiveProfiles()).containsExactly("test"); + } + + } + } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTestPropertiesIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTestPropertiesIntegrationTests.java index 12a8dcc6b76..cdef209ee1d 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTestPropertiesIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTestPropertiesIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * 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. @@ -16,6 +16,7 @@ package org.springframework.boot.test.autoconfigure.web.servlet; +import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -40,4 +41,19 @@ class WebMvcTestPropertiesIntegrationTests { assertThat(this.environment.getActiveProfiles()).containsExactly("test"); } + @Nested + class NestedTests { + + @Autowired + private Environment innerEnvironment; + + @Test + void propertiesFromEnclosingClassAffectNestedTests() { + assertThat(WebMvcTestPropertiesIntegrationTests.this.environment.getActiveProfiles()) + .containsExactly("test"); + assertThat(this.innerEnvironment.getActiveProfiles()).containsExactly("test"); + } + + } + } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientPropertiesIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientPropertiesIntegrationTests.java index b1d01217acc..4ea165c4861 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientPropertiesIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientPropertiesIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * 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. @@ -16,6 +16,7 @@ package org.springframework.boot.test.autoconfigure.webservices.client; +import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -40,4 +41,19 @@ class WebServiceClientPropertiesIntegrationTests { assertThat(this.environment.getActiveProfiles()).containsExactly("test"); } + @Nested + class NestedTests { + + @Autowired + private Environment innerEnvironment; + + @Test + void propertiesFromEnclosingClassAffectNestedTests() { + assertThat(WebServiceClientPropertiesIntegrationTests.this.environment.getActiveProfiles()) + .containsExactly("test"); + assertThat(this.innerEnvironment.getActiveProfiles()).containsExactly("test"); + } + + } + } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/server/WebServiceServerPropertiesIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/server/WebServiceServerPropertiesIntegrationTests.java index cad7886cac2..436731ecdda 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/server/WebServiceServerPropertiesIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/server/WebServiceServerPropertiesIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * 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. @@ -16,6 +16,7 @@ package org.springframework.boot.test.autoconfigure.webservices.server; +import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -40,4 +41,19 @@ class WebServiceServerPropertiesIntegrationTests { assertThat(this.environment.getActiveProfiles()).containsExactly("test"); } + @Nested + class NestedTests { + + @Autowired + private Environment innerEnvironment; + + @Test + void propertiesFromEnclosingClassAffectNestedTests() { + assertThat(WebServiceServerPropertiesIntegrationTests.this.environment.getActiveProfiles()) + .containsExactly("test"); + assertThat(this.innerEnvironment.getActiveProfiles()).containsExactly("test"); + } + + } + }