Browse Source

Revert to previous behavior for 7.0.2 (based on Boot/Data impact)

Preparing the revised behavior for 7.1 instead.

See gh-31456
pull/36004/head
Juergen Hoeller 6 days ago
parent
commit
e2c9dc7138
  1. 3
      spring-test/src/main/java/org/springframework/test/context/support/AbstractTestContextBootstrapper.java
  2. 2
      spring-test/src/test/java/org/springframework/test/context/config/ImplicitDefaultConfigClassesBaseTests.java
  3. 11
      spring-test/src/test/java/org/springframework/test/context/config/ImplicitDefaultConfigClassesInheritedTests.java
  4. 6
      spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/DefaultContextConfigurationDetectionWithNestedTests.java

3
spring-test/src/main/java/org/springframework/test/context/support/AbstractTestContextBootstrapper.java

@ -252,7 +252,8 @@ public abstract class AbstractTestContextBootstrapper implements TestContextBoot @@ -252,7 +252,8 @@ public abstract class AbstractTestContextBootstrapper implements TestContextBoot
CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate) {
List<ContextConfigurationAttributes> defaultConfigAttributesList =
ContextLoaderUtils.resolveDefaultContextConfigurationAttributes(testClass);
Collections.singletonList(new ContextConfigurationAttributes(testClass));
// for 7.1: ContextLoaderUtils.resolveDefaultContextConfigurationAttributes(testClass);
ContextLoader contextLoader = resolveContextLoader(testClass, defaultConfigAttributesList);
if (logger.isTraceEnabled()) {

2
spring-test/src/test/java/org/springframework/test/context/config/ImplicitDefaultConfigClassesBaseTests.java

@ -41,6 +41,7 @@ class ImplicitDefaultConfigClassesBaseTests { @@ -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 { @@ -49,6 +50,7 @@ class ImplicitDefaultConfigClassesBaseTests {
assertThat(greeting1).isEqualTo("TEST 1");
}
@Configuration
static class DefaultConfig {

11
spring-test/src/test/java/org/springframework/test/context/config/ImplicitDefaultConfigClassesInheritedTests.java

@ -40,6 +40,13 @@ class ImplicitDefaultConfigClassesInheritedTests extends ImplicitDefaultConfigCl @@ -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 @@ -50,9 +57,11 @@ class ImplicitDefaultConfigClassesInheritedTests extends ImplicitDefaultConfigCl
@Test
void greetings(@Autowired List<String> 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 {

6
spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/DefaultContextConfigurationDetectionWithNestedTests.java

@ -16,7 +16,6 @@ @@ -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 { @@ -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 { @@ -52,6 +52,8 @@ class DefaultContextConfigurationDetectionWithNestedTests {
assertThat(localGreeting).isEqualTo("TEST");
}
/** for 7.1:
@Nested
class NestedTests {
@ -61,6 +63,8 @@ class DefaultContextConfigurationDetectionWithNestedTests { @@ -61,6 +63,8 @@ class DefaultContextConfigurationDetectionWithNestedTests {
assertThat(localGreeting).isEqualTo("TEST");
}
}
*/
@Configuration
static class DefaultConfig {

Loading…
Cancel
Save