diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/OverrideConfigurationPropertiesScan.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/OverrideConfigurationPropertiesScan.java deleted file mode 100644 index faef170e3c..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/OverrideConfigurationPropertiesScan.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2012-2019 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; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.springframework.boot.context.properties.ConfigurationPropertiesScan; - -/** - * Annotation that can be used to override - * {@link ConfigurationPropertiesScan @ConfigurationPropertiesScan}. - * - * @author Madhura Bhave - * @since 2.2.0 - * @see ConfigurationPropertiesScan#CONFIGURATION_PROPERTIES_SCAN_ENABLED_PROPERTY - */ -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface OverrideConfigurationPropertiesScan { - - /** - * The value of the - * {@link ConfigurationPropertiesScan#CONFIGURATION_PROPERTIES_SCAN_ENABLED_PROPERTY - * enabled override property}. - * @return the override value - */ - boolean enabled(); - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/OverrideConfigurationPropertiesScanContextCustomizerFactory.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/OverrideConfigurationPropertiesScanContextCustomizerFactory.java deleted file mode 100644 index ce4cbdfa5c..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/OverrideConfigurationPropertiesScanContextCustomizerFactory.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2012-2019 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; - -import java.util.List; - -import org.springframework.boot.context.properties.ConfigurationPropertiesScan; -import org.springframework.boot.test.util.TestPropertyValues; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.core.annotation.MergedAnnotations; -import org.springframework.core.annotation.MergedAnnotations.SearchStrategy; -import org.springframework.test.context.ContextConfigurationAttributes; -import org.springframework.test.context.ContextCustomizer; -import org.springframework.test.context.ContextCustomizerFactory; -import org.springframework.test.context.MergedContextConfiguration; - -/** - * {@link ContextCustomizerFactory} to support - * {@link OverrideConfigurationPropertiesScan @OverrideConfigurationPropertiesScan}. - * - * @author Madhura Bhave - */ -class OverrideConfigurationPropertiesScanContextCustomizerFactory - implements ContextCustomizerFactory { - - @Override - public ContextCustomizer createContextCustomizer(Class testClass, - List configurationAttributes) { - boolean enabled = MergedAnnotations.from(testClass, SearchStrategy.EXHAUSTIVE) - .get(OverrideConfigurationPropertiesScan.class) - .getValue("enabled", Boolean.class).orElse(true); - return !enabled ? new DisableConfigurationPropertiesContextCustomizer() : null; - } - - /** - * {@link ContextCustomizer} to disable configuration properties scanning. - */ - private static class DisableConfigurationPropertiesContextCustomizer - implements ContextCustomizer { - - @Override - public void customizeContext(ConfigurableApplicationContext context, - MergedContextConfiguration mergedConfig) { - TestPropertyValues.of( - ConfigurationPropertiesScan.CONFIGURATION_PROPERTIES_SCAN_ENABLED_PROPERTY - + "=false") - .applyTo(context); - } - - @Override - public boolean equals(Object obj) { - return (obj != null && obj.getClass() == getClass()); - } - - @Override - public int hashCode() { - return getClass().hashCode(); - } - - } - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTest.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTest.java index f48fe16ad2..63941f2807 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTest.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTest.java @@ -28,7 +28,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.OverrideConfigurationPropertiesScan; import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; @@ -56,7 +55,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; @BootstrapWith(DataJdbcTestContextBootstrapper.class) @ExtendWith(SpringExtension.class) @OverrideAutoConfiguration(enabled = false) -@OverrideConfigurationPropertiesScan(enabled = false) @TypeExcludeFilters(DataJdbcTypeExcludeFilter.class) @AutoConfigureCache @AutoConfigureDataJdbc diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTest.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTest.java index 01a75a833b..c3d8a59fe1 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTest.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTest.java @@ -28,7 +28,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.OverrideConfigurationPropertiesScan; import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; import org.springframework.context.annotation.ComponentScan.Filter; @@ -59,7 +58,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; @BootstrapWith(DataLdapTestContextBootstrapper.class) @ExtendWith(SpringExtension.class) @OverrideAutoConfiguration(enabled = false) -@OverrideConfigurationPropertiesScan(enabled = false) @TypeExcludeFilters(DataLdapTypeExcludeFilter.class) @AutoConfigureCache @AutoConfigureDataLdap diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTest.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTest.java index 5dfcae99d2..567c609ff6 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTest.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTest.java @@ -28,7 +28,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.OverrideConfigurationPropertiesScan; import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; import org.springframework.context.annotation.ComponentScan.Filter; @@ -60,7 +59,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; @BootstrapWith(DataMongoTestContextBootstrapper.class) @ExtendWith(SpringExtension.class) @OverrideAutoConfiguration(enabled = false) -@OverrideConfigurationPropertiesScan(enabled = false) @TypeExcludeFilters(DataMongoTypeExcludeFilter.class) @AutoConfigureCache @AutoConfigureDataMongo diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTest.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTest.java index 015c35ab40..14b3b4386f 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTest.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTest.java @@ -28,7 +28,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.OverrideConfigurationPropertiesScan; import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; import org.springframework.context.annotation.ComponentScan.Filter; @@ -62,7 +61,6 @@ import org.springframework.transaction.annotation.Transactional; @BootstrapWith(DataNeo4jTestContextBootstrapper.class) @ExtendWith(SpringExtension.class) @OverrideAutoConfiguration(enabled = false) -@OverrideConfigurationPropertiesScan(enabled = false) @TypeExcludeFilters(DataNeo4jTypeExcludeFilter.class) @Transactional @AutoConfigureCache diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTest.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTest.java index 69a776f527..feced0a032 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTest.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTest.java @@ -28,7 +28,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.OverrideConfigurationPropertiesScan; import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; import org.springframework.context.annotation.ComponentScan.Filter; @@ -56,7 +55,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; @BootstrapWith(DataRedisTestContextBootstrapper.class) @ExtendWith(SpringExtension.class) @OverrideAutoConfiguration(enabled = false) -@OverrideConfigurationPropertiesScan(enabled = false) @TypeExcludeFilters(DataRedisTypeExcludeFilter.class) @AutoConfigureCache @AutoConfigureDataRedis diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest.java index 4db6465bc5..364ff3e368 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest.java @@ -28,7 +28,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.OverrideConfigurationPropertiesScan; import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; import org.springframework.boot.test.context.SpringBootTest; @@ -70,7 +69,6 @@ import org.springframework.transaction.annotation.Transactional; @BootstrapWith(JdbcTestContextBootstrapper.class) @ExtendWith(SpringExtension.class) @OverrideAutoConfiguration(enabled = false) -@OverrideConfigurationPropertiesScan(enabled = false) @TypeExcludeFilters(JdbcTypeExcludeFilter.class) @Transactional @AutoConfigureCache diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/JooqTest.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/JooqTest.java index 8bc224bd2f..c5de7aa4cc 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/JooqTest.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/JooqTest.java @@ -28,7 +28,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.OverrideConfigurationPropertiesScan; import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.context.annotation.ComponentScan.Filter; @@ -63,7 +62,6 @@ import org.springframework.transaction.annotation.Transactional; @BootstrapWith(JooqTestContextBootstrapper.class) @ExtendWith(SpringExtension.class) @OverrideAutoConfiguration(enabled = false) -@OverrideConfigurationPropertiesScan(enabled = false) @TypeExcludeFilters(JooqTypeExcludeFilter.class) @Transactional @AutoConfigureJooq diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTest.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTest.java index a9715353fa..818142fff8 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTest.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTest.java @@ -28,7 +28,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.OverrideConfigurationPropertiesScan; import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; import org.springframework.boot.test.json.GsonTester; @@ -68,7 +67,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; @BootstrapWith(JsonTestContextBootstrapper.class) @ExtendWith(SpringExtension.class) @OverrideAutoConfiguration(enabled = false) -@OverrideConfigurationPropertiesScan(enabled = false) @TypeExcludeFilters(JsonExcludeFilter.class) @AutoConfigureCache @AutoConfigureJson diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTest.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTest.java index c8285bc22b..357e4a024f 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTest.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTest.java @@ -28,7 +28,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.OverrideConfigurationPropertiesScan; import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; @@ -73,7 +72,6 @@ import org.springframework.transaction.annotation.Transactional; @BootstrapWith(DataJpaTestContextBootstrapper.class) @ExtendWith(SpringExtension.class) @OverrideAutoConfiguration(enabled = false) -@OverrideConfigurationPropertiesScan(enabled = false) @TypeExcludeFilters(DataJpaTypeExcludeFilter.class) @Transactional @AutoConfigureCache diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTest.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTest.java index 1f89e2a942..c35fa8a478 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTest.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTest.java @@ -28,7 +28,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.OverrideConfigurationPropertiesScan; import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; import org.springframework.boot.web.client.RestTemplateBuilder; @@ -71,7 +70,6 @@ import org.springframework.web.client.RestTemplate; @BootstrapWith(RestClientTestContextBootstrapper.class) @ExtendWith(SpringExtension.class) @OverrideAutoConfiguration(enabled = false) -@OverrideConfigurationPropertiesScan(enabled = false) @TypeExcludeFilters(RestClientExcludeFilter.class) @AutoConfigureCache @AutoConfigureWebClient diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTest.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTest.java index d3708f85b4..1b0444648f 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTest.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTest.java @@ -28,7 +28,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.OverrideConfigurationPropertiesScan; import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; import org.springframework.boot.test.autoconfigure.json.AutoConfigureJson; @@ -79,7 +78,6 @@ import org.springframework.test.web.reactive.server.WebTestClient; @BootstrapWith(WebFluxTestContextBootstrapper.class) @ExtendWith(SpringExtension.class) @OverrideAutoConfiguration(enabled = false) -@OverrideConfigurationPropertiesScan(enabled = false) @TypeExcludeFilters(WebFluxTypeExcludeFilter.class) @AutoConfigureCache @AutoConfigureJson diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTest.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTest.java index 2a6e908d5f..29f3bc7a1f 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTest.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTest.java @@ -28,7 +28,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.OverrideConfigurationPropertiesScan; import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; import org.springframework.boot.test.context.SpringBootTest; @@ -80,7 +79,6 @@ import org.springframework.test.web.servlet.MockMvc; @BootstrapWith(WebMvcTestContextBootstrapper.class) @ExtendWith(SpringExtension.class) @OverrideAutoConfiguration(enabled = false) -@OverrideConfigurationPropertiesScan(enabled = false) @TypeExcludeFilters(WebMvcTypeExcludeFilter.class) @AutoConfigureCache @AutoConfigureWebMvc diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring.factories b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring.factories index 0983f676af..d05127f942 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring.factories +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring.factories @@ -160,7 +160,6 @@ org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExe # Spring Test ContextCustomizerFactories org.springframework.test.context.ContextCustomizerFactory=\ org.springframework.boot.test.autoconfigure.OverrideAutoConfigurationContextCustomizerFactory,\ -org.springframework.boot.test.autoconfigure.OverrideConfigurationPropertiesScanContextCustomizerFactory,\ org.springframework.boot.test.autoconfigure.filter.TypeExcludeFiltersContextCustomizerFactory,\ org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizerFactory,\ org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/OverrideConfigurationPropertiesScanContextCustomizerFactoryTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/OverrideConfigurationPropertiesScanContextCustomizerFactoryTests.java deleted file mode 100644 index abe593a35f..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/OverrideConfigurationPropertiesScanContextCustomizerFactoryTests.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2012-2019 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; - -import org.junit.Test; - -import org.springframework.boot.context.properties.ConfigurationPropertiesScan; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.test.context.ContextCustomizer; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Madhura Bhave - */ -public class OverrideConfigurationPropertiesScanContextCustomizerFactoryTests { - - private OverrideConfigurationPropertiesScanContextCustomizerFactory factory = new OverrideConfigurationPropertiesScanContextCustomizerFactory(); - - @Test - public void getContextCustomizerWhenHasNoAnnotationShouldReturnNull() { - ContextCustomizer customizer = this.factory - .createContextCustomizer(NoAnnotation.class, null); - assertThat(customizer).isNull(); - } - - @Test - public void getContextCustomizerWhenHasAnnotationEnabledTrueShouldReturnNull() { - ContextCustomizer customizer = this.factory - .createContextCustomizer(WithAnnotationEnabledTrue.class, null); - assertThat(customizer).isNull(); - } - - @Test - public void getContextCustomizerWhenHasAnnotationEnabledFalseShouldReturnCustomizer() { - ContextCustomizer customizer = this.factory - .createContextCustomizer(WithAnnotationEnabledFalse.class, null); - assertThat(customizer).isNotNull(); - ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(); - customizer.customizeContext(context, null); - String property = context.getEnvironment().getProperty( - ConfigurationPropertiesScan.CONFIGURATION_PROPERTIES_SCAN_ENABLED_PROPERTY); - assertThat(property).isEqualTo("false"); - } - - @Test - public void hashCodeAndEquals() { - ContextCustomizer customizer1 = this.factory - .createContextCustomizer(WithAnnotationEnabledFalse.class, null); - ContextCustomizer customizer2 = this.factory - .createContextCustomizer(WithSameAnnotation.class, null); - assertThat(customizer1.hashCode()).isEqualTo(customizer2.hashCode()); - assertThat(customizer1).isEqualTo(customizer1).isEqualTo(customizer2); - } - - static class NoAnnotation { - - } - - @OverrideConfigurationPropertiesScan(enabled = true) - static class WithAnnotationEnabledTrue { - - } - - @OverrideConfigurationPropertiesScan(enabled = false) - static class WithAnnotationEnabledFalse { - - } - - @OverrideConfigurationPropertiesScan(enabled = false) - static class WithSameAnnotation { - - } - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTestConfigurationPropertiesScanDisabledTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTestConfigurationPropertiesScanDisabledTests.java deleted file mode 100644 index 5f0ca04a8a..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTestConfigurationPropertiesScanDisabledTests.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.test.autoconfigure.data.jdbc; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.NoSuchBeanDefinitionException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - -/** - * Tests to ensure that configuration properties scanning is disabled for - * {@link DataJdbcTest @DataJdbcTest}. - * - * @author Madhura Bhave - */ -@RunWith(SpringRunner.class) -@DataJdbcTest -public class DataJdbcTestConfigurationPropertiesScanDisabledTests { - - @Autowired - private ApplicationContext context; - - @Test - public void configurationProperiesScanDisabled() { - assertThatExceptionOfType(NoSuchBeanDefinitionException.class) - .isThrownBy(() -> this.context.getBean(ExampleProperties.class)); - } - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/ExampleProperties.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/ExampleProperties.java deleted file mode 100644 index e2a3fc6413..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/ExampleProperties.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.test.autoconfigure.data.jdbc; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * Example {@link ConfigurationProperties @ConfigurationProperties} for use with - * {@link DataJdbcTest @DataJdbcTest} tests. - * - * @author Madhura Bhave - */ -@ConfigurationProperties(prefix = "example") -public class ExampleProperties { - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTestConfigurationPropertiesScanDisabledTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTestConfigurationPropertiesScanDisabledTests.java deleted file mode 100644 index d7590397ff..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTestConfigurationPropertiesScanDisabledTests.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.test.autoconfigure.data.ldap; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.NoSuchBeanDefinitionException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - -/** - * Tests to ensure that configuration properties scanning is disabled for - * {@link DataLdapTest @DataLdapTest}. - * - * @author Madhura Bhave - */ -@RunWith(SpringRunner.class) -@DataLdapTest -public class DataLdapTestConfigurationPropertiesScanDisabledTests { - - @Autowired - private ApplicationContext context; - - @Test - public void configurationProperiesScanDisabled() { - assertThatExceptionOfType(NoSuchBeanDefinitionException.class) - .isThrownBy(() -> this.context.getBean(ExampleProperties.class)); - } - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/ExampleProperties.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/ExampleProperties.java deleted file mode 100644 index a253dbb296..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/ExampleProperties.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.test.autoconfigure.data.ldap; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * Example {@link ConfigurationProperties @ConfigurationProperties} for use with - * {@link DataLdapTest @DataLdapTest} tests. - * - * @author Madhura Bhave - */ -@ConfigurationProperties(prefix = "example") -public class ExampleProperties { - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestConfigurationPropertiesScanDisabledTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestConfigurationPropertiesScanDisabledTests.java deleted file mode 100644 index bed0b832cf..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestConfigurationPropertiesScanDisabledTests.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.test.autoconfigure.data.mongo; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.NoSuchBeanDefinitionException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - -/** - * Tests to ensure that configuration properties scanning is disabled for - * {@link DataMongoTest @DataMongoTest}. - * - * @author Madhura Bhave - */ -@RunWith(SpringRunner.class) -@DataMongoTest -public class DataMongoTestConfigurationPropertiesScanDisabledTests { - - @Autowired - private ApplicationContext context; - - @Test - public void configurationProperiesScanDisabled() { - assertThatExceptionOfType(NoSuchBeanDefinitionException.class) - .isThrownBy(() -> this.context.getBean(ExampleProperties.class)); - } - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/mongo/ExampleProperties.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/mongo/ExampleProperties.java deleted file mode 100644 index 80750e8c67..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/mongo/ExampleProperties.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.test.autoconfigure.data.mongo; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * Example {@link ConfigurationProperties @ConfigurationProperties} for use with - * {@link DataMongoTest @DataMongoTest} tests. - * - * @author Madhura Bhave - */ -@ConfigurationProperties(prefix = "example") -public class ExampleProperties { - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestConfigurationPropertiesScanDisabledTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestConfigurationPropertiesScanDisabledTests.java deleted file mode 100644 index ecd7498d79..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestConfigurationPropertiesScanDisabledTests.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.test.autoconfigure.data.neo4j; - -import org.junit.jupiter.api.Test; -import org.testcontainers.containers.Neo4jContainer; -import org.testcontainers.junit.jupiter.Container; -import org.testcontainers.junit.jupiter.Testcontainers; - -import org.springframework.beans.factory.NoSuchBeanDefinitionException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.util.TestPropertyValues; -import org.springframework.boot.testsupport.testcontainers.SkippableContainer; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextInitializer; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.test.context.ContextConfiguration; - -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - -/** - * Tests to ensure that configuration properties scanning is disabled for - * {@link DataNeo4jTest @DataNeo4jTest}. - * - * @author Madhura Bhave - */ -@ContextConfiguration( - initializers = DataNeo4jTestConfigurationPropertiesScanDisabledTests.Initializer.class) -@Testcontainers -@DataNeo4jTest -public class DataNeo4jTestConfigurationPropertiesScanDisabledTests { - - @Container - public static SkippableContainer> neo4j = new SkippableContainer<>( - () -> new Neo4jContainer<>().withAdminPassword(null)); - - @Autowired - private ApplicationContext context; - - @Test - public void configurationProperiesScanDisabled() { - assertThatExceptionOfType(NoSuchBeanDefinitionException.class) - .isThrownBy(() -> this.context.getBean(ExampleProperties.class)); - } - - static class Initializer - implements ApplicationContextInitializer { - - @Override - public void initialize( - ConfigurableApplicationContext configurableApplicationContext) { - TestPropertyValues - .of("spring.data.neo4j.uri=" + neo4j.getContainer().getBoltUrl()) - .applyTo(configurableApplicationContext.getEnvironment()); - } - - } - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/ExampleProperties.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/ExampleProperties.java deleted file mode 100644 index 2c35c33682..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/ExampleProperties.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.test.autoconfigure.data.neo4j; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * Example {@link ConfigurationProperties @ConfigurationProperties} for use with - * {@link DataNeo4jTest @DataNeo4jTest} tests. - * - * @author Madhura Bhave - */ -@ConfigurationProperties(prefix = "example") -public class ExampleProperties { - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestConfigurationPropertiesScanDisabledTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestConfigurationPropertiesScanDisabledTests.java deleted file mode 100644 index f241a9a975..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestConfigurationPropertiesScanDisabledTests.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.test.autoconfigure.data.redis; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.NoSuchBeanDefinitionException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - -/** - * Tests to ensure that configuration properties scanning is disabled for - * {@link DataRedisTest @DataRedisTest}. - * - * @author Madhura Bhave - */ -@RunWith(SpringRunner.class) -@DataRedisTest -public class DataRedisTestConfigurationPropertiesScanDisabledTests { - - @Autowired - private ApplicationContext context; - - @Test - public void configurationProperiesScanDisabled() { - assertThatExceptionOfType(NoSuchBeanDefinitionException.class) - .isThrownBy(() -> this.context.getBean(ExampleProperties.class)); - } - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/ExampleProperties.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/ExampleProperties.java deleted file mode 100644 index 4905a2fa02..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/ExampleProperties.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.test.autoconfigure.data.redis; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * Example {@link ConfigurationProperties @ConfigurationProperties} for use with - * {@link DataRedisTest @DataRedisTest} tests. - * - * @author Madhura Bhave - */ -@ConfigurationProperties(prefix = "example") -public class ExampleProperties { - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/ExampleProperties.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/ExampleProperties.java deleted file mode 100644 index 3b48f57722..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/ExampleProperties.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2012-2019 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.jdbc; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * Example {@link ConfigurationProperties @ConfigurationProperties} for use with - * {@link JdbcTest @JdbcTest} tests. - * - * @author Madhura Bhave - */ -@ConfigurationProperties(prefix = "example") -public class ExampleProperties { - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestConfigurationPropertiesScanDisabledTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestConfigurationPropertiesScanDisabledTests.java deleted file mode 100644 index fcb0d156fa..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestConfigurationPropertiesScanDisabledTests.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2012-2019 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.jdbc; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.NoSuchBeanDefinitionException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - -/** - * Tests to ensure that configuration properties scanning is disabled for - * {@link JdbcTest @JdbcTest}. - * - * @author Madhura Bhave - */ -@RunWith(SpringRunner.class) -@JdbcTest -public class JdbcTestConfigurationPropertiesScanDisabledTests { - - @Autowired - private ApplicationContext context; - - @Test - public void configurationProperiesScanDisabled() { - assertThatExceptionOfType(NoSuchBeanDefinitionException.class) - .isThrownBy(() -> this.context.getBean(ExampleProperties.class)); - } - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jooq/ExampleProperties.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jooq/ExampleProperties.java deleted file mode 100644 index 45bc850cca..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jooq/ExampleProperties.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2012-2019 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.jooq; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * Example {@link ConfigurationProperties @ConfigurationProperties} for use with - * {@link JooqTest @JooqTest} tests. - * - * @author Madhura Bhave - */ -@ConfigurationProperties(prefix = "example") -public class ExampleProperties { - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestConfigurationPropertiesScanDisabledTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestConfigurationPropertiesScanDisabledTests.java deleted file mode 100644 index fc28f6b29a..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestConfigurationPropertiesScanDisabledTests.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2012-2019 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.jooq; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.NoSuchBeanDefinitionException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - -/** - * Tests to ensure that configuration properties scanning is disabled for - * {@link JooqTest @JooqTest}. - * - * @author Madhura Bhave - */ -@RunWith(SpringRunner.class) -@JooqTest -public class JooqTestConfigurationPropertiesScanDisabledTests { - - @Autowired - private ApplicationContext context; - - @Test - public void configurationProperiesScanDisabled() { - assertThatExceptionOfType(NoSuchBeanDefinitionException.class) - .isThrownBy(() -> this.context.getBean(ExampleProperties.class)); - } - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/JsonTestConfigurationPropertiesScanDisabledTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/JsonTestConfigurationPropertiesScanDisabledTests.java deleted file mode 100644 index 999b7fc9b2..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/JsonTestConfigurationPropertiesScanDisabledTests.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2012-2019 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.json; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.NoSuchBeanDefinitionException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.json.app.ExampleJsonApplication; -import org.springframework.boot.test.autoconfigure.json.app.ExampleProperties; -import org.springframework.context.ApplicationContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - -/** - * Tests to ensure that configuration properties scanning is disabled for - * {@link JsonTest @JsonTest}. - * - * @author Madhura Bhave - */ -@RunWith(SpringRunner.class) -@JsonTest -@ContextConfiguration(classes = ExampleJsonApplication.class) -public class JsonTestConfigurationPropertiesScanDisabledTests { - - @Autowired - private ApplicationContext context; - - @Test - public void configurationProperiesScanDisabled() { - assertThatExceptionOfType(NoSuchBeanDefinitionException.class) - .isThrownBy(() -> this.context.getBean(ExampleProperties.class)); - } - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleProperties.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleProperties.java deleted file mode 100644 index aa03dfd54a..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleProperties.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2012-2019 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.json.app; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.test.autoconfigure.json.JsonTest; - -/** - * Example {@link ConfigurationProperties @ConfigurationProperties} for use with - * {@link JsonTest @JsonTest} tests. - * - * @author Madhura Bhave - */ -@ConfigurationProperties(prefix = "example") -public class ExampleProperties { - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestConfigurationPropertiesScanDisabledTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestConfigurationPropertiesScanDisabledTests.java deleted file mode 100644 index 815401f180..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestConfigurationPropertiesScanDisabledTests.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2012-2019 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.orm.jpa; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.NoSuchBeanDefinitionException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - -/** - * Tests to ensure that configuration properties scanning is disabled for - * {@link DataJpaTest @DataJpaTest}. - * - * @author Madhura Bhave - */ -@RunWith(SpringRunner.class) -@DataJpaTest -public class DataJpaTestConfigurationPropertiesScanDisabledTests { - - @Autowired - private ApplicationContext context; - - @Test - public void configurationProperiesScanDisabled() { - assertThatExceptionOfType(NoSuchBeanDefinitionException.class) - .isThrownBy(() -> this.context.getBean(ExampleProperties.class)); - } - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/ExampleProperties.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/ExampleProperties.java deleted file mode 100644 index 4607a8113a..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/ExampleProperties.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2012-2019 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.orm.jpa; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * Example {@link ConfigurationProperties @ConfigurationProperties} for use with - * {@link DataJpaTest @DataJpaTest} tests. - * - * @author Madhura Bhave - */ -@ConfigurationProperties(prefix = "example") -public class ExampleProperties { - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/override/ExampleTestProperties.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/override/ExampleTestProperties.java deleted file mode 100644 index 0b78bc229e..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/override/ExampleTestProperties.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2012-2019 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.override; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.test.autoconfigure.OverrideConfigurationPropertiesScan; - -/** - * Example {@link ConfigurationProperties @ConfigurationProperties} for use with - * {@link OverrideConfigurationPropertiesScan @OverrideConfigurationPropertiesScan} tests. - * - * @author Madhura Bhave - */ -@ConfigurationProperties(prefix = "example") -public class ExampleTestProperties { - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/override/scan/ExampleProperties.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/override/scan/ExampleProperties.java deleted file mode 100644 index 35bd021e25..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/override/scan/ExampleProperties.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2012-2019 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.override.scan; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.test.autoconfigure.OverrideConfigurationPropertiesScan; - -/** - * Example {@link ConfigurationProperties @ConfigurationProperties} for use with - * {@link OverrideConfigurationPropertiesScan @OverrideConfigurationPropertiesScan} tests. - * - * @author Madhura Bhave - */ -@ConfigurationProperties(prefix = "example") -public class ExampleProperties { - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/override/scan/OverrideConfigurationPropertiesScanApplication.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/override/scan/OverrideConfigurationPropertiesScanApplication.java deleted file mode 100644 index b1293c0f22..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/override/scan/OverrideConfigurationPropertiesScanApplication.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2012-2019 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.override.scan; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.autoconfigure.OverrideConfigurationPropertiesScan; - -/** - * Example {@link SpringBootApplication @SpringBootApplication} for use with - * {@link OverrideConfigurationPropertiesScan @OverrideConfigurationPropertiesScan} tests. - * - * @author Madhura Bhave - */ -@SpringBootApplication -public class OverrideConfigurationPropertiesScanApplication { - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/override/scan/OverrideConfigurationPropertiesScanEnabledFalseIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/override/scan/OverrideConfigurationPropertiesScanEnabledFalseIntegrationTests.java deleted file mode 100644 index c88f51ac05..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/override/scan/OverrideConfigurationPropertiesScanEnabledFalseIntegrationTests.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2012-2019 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.override.scan; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.NoSuchBeanDefinitionException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.test.autoconfigure.OverrideConfigurationPropertiesScan; -import org.springframework.boot.test.autoconfigure.override.ExampleTestProperties; -import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.test.context.BootstrapWith; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - -/** - * Integration tests for - * {@link OverrideConfigurationPropertiesScan @OverrideConfigurationPropertiesScan} when - * {@code enabled} is {@code false}. - * - * @author Madhura Bhave - */ -@RunWith(SpringRunner.class) -@BootstrapWith(SpringBootTestContextBootstrapper.class) -@OverrideConfigurationPropertiesScan(enabled = false) -@Import(OverrideConfigurationPropertiesScanEnabledFalseIntegrationTests.TestConfiguration.class) -public class OverrideConfigurationPropertiesScanEnabledFalseIntegrationTests { - - @Autowired - private ApplicationContext context; - - @Test - public void disabledConfigurationPropertiesScan() { - ApplicationContext context = this.context; - assertThat(context.getBean(ExampleTestProperties.class)).isNotNull(); - assertThatExceptionOfType(NoSuchBeanDefinitionException.class) - .isThrownBy(() -> context.getBean(ExampleProperties.class)); - } - - @Configuration - @EnableConfigurationProperties(ExampleTestProperties.class) - static class TestConfiguration { - - } - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/override/scan/OverrideConfigurationPropertiesScanEnabledTrueIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/override/scan/OverrideConfigurationPropertiesScanEnabledTrueIntegrationTests.java deleted file mode 100644 index a18544a4be..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/override/scan/OverrideConfigurationPropertiesScanEnabledTrueIntegrationTests.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2012-2019 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.override.scan; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.OverrideConfigurationPropertiesScan; -import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; -import org.springframework.context.ApplicationContext; -import org.springframework.test.context.BootstrapWith; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Integration tests for - * {@link OverrideConfigurationPropertiesScan @OverrideConfigurationPropertiesScan} when - * {@code enabled} is {@code true}. - * - * @author Madhura Bhave - */ -@RunWith(SpringRunner.class) -@OverrideConfigurationPropertiesScan(enabled = true) -@BootstrapWith(SpringBootTestContextBootstrapper.class) -public class OverrideConfigurationPropertiesScanEnabledTrueIntegrationTests { - - @Autowired - private ApplicationContext context; - - @Test - public void configurationPropertiesScanEnabled() { - assertThat(this.context.getBean(ExampleProperties.class)).isNotNull(); - } - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/ExampleProperties.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/ExampleProperties.java deleted file mode 100644 index 554b8ebef1..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/ExampleProperties.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2012-2019 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.web.client; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * Example {@link ConfigurationProperties @ConfigurationProperties} for use with - * {@link RestClientTest @RestClientTest} tests. - * - * @author Madhura Bhave - */ -@ConfigurationProperties(prefix = "example") -public class ExampleProperties { - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestConfigurationPropertiesScanDisabledTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestConfigurationPropertiesScanDisabledTests.java deleted file mode 100644 index 1f4fd4bd6a..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestConfigurationPropertiesScanDisabledTests.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2012-2019 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.web.client; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.NoSuchBeanDefinitionException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - -/** - * Tests to ensure that configuration properties scanning is disabled for - * {@link RestClientTest @RestClientTest}. - * - * @author Madhura Bhave - */ -@RunWith(SpringRunner.class) -@RestClientTest -public class RestClientTestConfigurationPropertiesScanDisabledTests { - - @Autowired - private ApplicationContext context; - - @Test - public void configurationProperiesScanDisabled() { - assertThatExceptionOfType(NoSuchBeanDefinitionException.class) - .isThrownBy(() -> this.context.getBean(ExampleProperties.class)); - } - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/ExampleProperties.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/ExampleProperties.java deleted file mode 100644 index 90d6a959bf..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/ExampleProperties.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2012-2019 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.web.reactive.webclient; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; - -/** - * Example {@link ConfigurationProperties @ConfigurationProperties} for use with - * {@link WebFluxTest @WebFluxTest} tests. - * - * @author Madhura Bhave - */ -@ConfigurationProperties(prefix = "example") -public class ExampleProperties { - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/WebFluxTestConfigurationPropertiesScanDisabledTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/WebFluxTestConfigurationPropertiesScanDisabledTests.java deleted file mode 100644 index 27d7e78aa3..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/WebFluxTestConfigurationPropertiesScanDisabledTests.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2012-2019 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.web.reactive.webclient; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.NoSuchBeanDefinitionException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; -import org.springframework.context.ApplicationContext; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - -/** - * Tests to ensure that configuration properties scanning is disabled for - * {@link WebFluxTest @WebFluxTest}. - * - * @author Madhura Bhave - */ -@RunWith(SpringRunner.class) -@WebFluxTest -public class WebFluxTestConfigurationPropertiesScanDisabledTests { - - @Autowired - private ApplicationContext context; - - @Test - public void configurationProperiesScanDisabled() { - assertThatExceptionOfType(NoSuchBeanDefinitionException.class) - .isThrownBy(() -> this.context.getBean(ExampleProperties.class)); - } - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleProperties.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleProperties.java deleted file mode 100644 index dd45db0b93..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleProperties.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2012-2019 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.web.servlet.mockmvc; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; - -/** - * Example {@link ConfigurationProperties @ConfigurationProperties} for use with - * {@link WebMvcTest @WebMvcTest} tests. - * - * @author Madhura Bhave - */ -@ConfigurationProperties(prefix = "example") -public class ExampleProperties { - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestConfigurationPropertiesScanDisabledTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestConfigurationPropertiesScanDisabledTests.java deleted file mode 100644 index c53b0ba682..0000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestConfigurationPropertiesScanDisabledTests.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2012-2019 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.web.servlet.mockmvc; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.NoSuchBeanDefinitionException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.context.ApplicationContext; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - -/** - * Tests to ensure that configuration properties scanning is disabled for - * {@link WebMvcTest @WebMvcTest}. - * - * @author Madhura Bhave - */ -@RunWith(SpringRunner.class) -@WebMvcTest -public class WebMvcTestConfigurationPropertiesScanDisabledTests { - - @Autowired - private ApplicationContext context; - - @Test - public void configurationProperiesScanDisabled() { - assertThatExceptionOfType(NoSuchBeanDefinitionException.class) - .isThrownBy(() -> this.context.getBean(ExampleProperties.class)); - } - -} diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesScan.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesScan.java index 1cee3c4f60..c4d7ef4b63 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesScan.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesScan.java @@ -40,11 +40,6 @@ import org.springframework.core.annotation.AliasFor; @Import(ConfigurationPropertiesScanRegistrar.class) public @interface ConfigurationPropertiesScan { - /** - * Whether configuration properties should be automatically scanned. - */ - String CONFIGURATION_PROPERTIES_SCAN_ENABLED_PROPERTY = "spring.boot.configurationpropertiesscan.enabled"; - /** * Alias for the {@link #basePackages()} attribute. Allows for more concise annotation * declarations e.g.: {@code @ConfigurationPropertiesScan("org.my.pkg")} instead of diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesScanRegistrar.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesScanRegistrar.java index 1867efbbc0..0e1c45da36 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesScanRegistrar.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesScanRegistrar.java @@ -53,17 +53,8 @@ class ConfigurationPropertiesScanRegistrar @Override public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) { - if (isEnabled()) { - Set packagesToScan = getPackagesToScan(importingClassMetadata); - register(registry, (ConfigurableListableBeanFactory) registry, - packagesToScan); - } - } - - protected boolean isEnabled() { - return this.environment.getProperty( - ConfigurationPropertiesScan.CONFIGURATION_PROPERTIES_SCAN_ENABLED_PROPERTY, - Boolean.class, true); + Set packagesToScan = getPackagesToScan(importingClassMetadata); + register(registry, (ConfigurableListableBeanFactory) registry, packagesToScan); } private Set getPackagesToScan(AnnotationMetadata metadata) { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesScanRegistrarTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesScanRegistrarTests.java index 3ac41b4905..cc76cc8176 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesScanRegistrarTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesScanRegistrarTests.java @@ -20,7 +20,6 @@ import java.io.IOException; import org.junit.Before; import org.junit.Test; -import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.GenericBeanDefinition; @@ -45,25 +44,9 @@ public class ConfigurationPropertiesScanRegistrarTests { private final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); - private MockEnvironment environment; - @Before public void setup() { - this.environment = new MockEnvironment(); - this.registrar.setEnvironment(this.environment); - } - - @Test - public void scanningDisabled() throws IOException { - this.environment.setProperty( - ConfigurationPropertiesScan.CONFIGURATION_PROPERTIES_SCAN_ENABLED_PROPERTY, - "false"); - this.registrar.registerBeanDefinitions( - getAnnotationMetadata(ConfigurationPropertiesScanConfiguration.class), - this.beanFactory); - assertThatExceptionOfType(NoSuchBeanDefinitionException.class) - .isThrownBy(() -> this.beanFactory.getBeanDefinition( - "bing-org.springframework.boot.context.properties.scan.valid.ConfigurationPropertiesScanConfiguration$BingProperties")); + this.registrar.setEnvironment(new MockEnvironment()); } @Test