diff --git a/spring-test/src/main/java/org/springframework/test/context/support/AbstractTestContextBootstrapper.java b/spring-test/src/main/java/org/springframework/test/context/support/AbstractTestContextBootstrapper.java index d1a6b189ddc..407e5ea3dee 100644 --- a/spring-test/src/main/java/org/springframework/test/context/support/AbstractTestContextBootstrapper.java +++ b/spring-test/src/main/java/org/springframework/test/context/support/AbstractTestContextBootstrapper.java @@ -252,7 +252,8 @@ public abstract class AbstractTestContextBootstrapper implements TestContextBoot CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate) { List defaultConfigAttributesList = - ContextLoaderUtils.resolveDefaultContextConfigurationAttributes(testClass); + Collections.singletonList(new ContextConfigurationAttributes(testClass)); + // for 7.1: ContextLoaderUtils.resolveDefaultContextConfigurationAttributes(testClass); ContextLoader contextLoader = resolveContextLoader(testClass, defaultConfigAttributesList); if (logger.isTraceEnabled()) { diff --git a/spring-test/src/test/java/org/springframework/test/context/config/ImplicitDefaultConfigClassesBaseTests.java b/spring-test/src/test/java/org/springframework/test/context/config/ImplicitDefaultConfigClassesBaseTests.java index 3c7bd9d3abe..b622023a541 100644 --- a/spring-test/src/test/java/org/springframework/test/context/config/ImplicitDefaultConfigClassesBaseTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/config/ImplicitDefaultConfigClassesBaseTests.java @@ -41,6 +41,7 @@ class ImplicitDefaultConfigClassesBaseTests { @Autowired String greeting1; + @Test void greeting1() { // This class must NOT be annotated with @SpringJUnitConfig or @ContextConfiguration. @@ -49,6 +50,7 @@ class ImplicitDefaultConfigClassesBaseTests { assertThat(greeting1).isEqualTo("TEST 1"); } + @Configuration static class DefaultConfig { diff --git a/spring-test/src/test/java/org/springframework/test/context/config/ImplicitDefaultConfigClassesInheritedTests.java b/spring-test/src/test/java/org/springframework/test/context/config/ImplicitDefaultConfigClassesInheritedTests.java index 8960f876abd..2f1d28d1df9 100644 --- a/spring-test/src/test/java/org/springframework/test/context/config/ImplicitDefaultConfigClassesInheritedTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/config/ImplicitDefaultConfigClassesInheritedTests.java @@ -40,6 +40,13 @@ class ImplicitDefaultConfigClassesInheritedTests extends ImplicitDefaultConfigCl @Autowired String greeting2; + + // To be removed in favor of base class method in 7.1 + @Test + void greeting1() { + assertThat(greeting1).isEqualTo("TEST 2"); + } + @Test void greeting2() { // This class must NOT be annotated with @SpringJUnitConfig or @ContextConfiguration. @@ -50,9 +57,11 @@ class ImplicitDefaultConfigClassesInheritedTests extends ImplicitDefaultConfigCl @Test void greetings(@Autowired List greetings) { - assertThat(greetings).containsExactly("TEST 1", "TEST 2"); + assertThat(greetings).containsExactly("TEST 2"); + // for 7.1: assertThat(greetings).containsExactly("TEST 1", "TEST 2"); } + @Configuration static class DefaultConfig { diff --git a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/DefaultContextConfigurationDetectionWithNestedTests.java b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/DefaultContextConfigurationDetectionWithNestedTests.java index c1c81528e39..615c2355837 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/DefaultContextConfigurationDetectionWithNestedTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/DefaultContextConfigurationDetectionWithNestedTests.java @@ -16,7 +16,6 @@ package org.springframework.test.context.junit.jupiter.nested; -import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -43,6 +42,7 @@ class DefaultContextConfigurationDetectionWithNestedTests { @Autowired String greeting; + @Test void test(@Autowired String localGreeting) { // This class must NOT be annotated with @SpringJUnitConfig or @ContextConfiguration. @@ -52,6 +52,8 @@ class DefaultContextConfigurationDetectionWithNestedTests { assertThat(localGreeting).isEqualTo("TEST"); } + + /** for 7.1: @Nested class NestedTests { @@ -61,6 +63,8 @@ class DefaultContextConfigurationDetectionWithNestedTests { assertThat(localGreeting).isEqualTo("TEST"); } } + */ + @Configuration static class DefaultConfig {