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
36 changed files with 407 additions and 123 deletions

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