Merge branch '2.7.x' into 3.0.x

Closes gh-34781
This commit is contained in:
Andy Wilkinson 2023-03-27 18:05:03 +01:00
commit d6dbf300ab
36 changed files with 407 additions and 123 deletions

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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

View File

@ -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");
}
}
}

View File

@ -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");
}
}
}

View File

@ -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");
}
}
}

View File

@ -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");
}
}
}

View File

@ -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");
}
}
}

View File

@ -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");
}
}
}

View File

@ -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");
}
}
}

View File

@ -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");
}
}
}

View File

@ -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");
}
}
}

View File

@ -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");
}
}
}

View File

@ -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");
}
}
}

View File

@ -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");
}
}
}

View File

@ -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");
}
}
}

View File

@ -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");
}
}
}

View File

@ -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");
}
}
}

View File

@ -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");
}
}
}

View File

@ -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");
}
}
}