Skip to content

Commit e2c9dc7

Browse files
committed
Revert to previous behavior for 7.0.2 (based on Boot/Data impact)
Preparing the revised behavior for 7.1 instead. See gh-31456
1 parent 1818161 commit e2c9dc7

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ private MergedContextConfiguration buildDefaultMergedContextConfiguration(Class<
252252
CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate) {
253253

254254
List<ContextConfigurationAttributes> defaultConfigAttributesList =
255-
ContextLoaderUtils.resolveDefaultContextConfigurationAttributes(testClass);
255+
Collections.singletonList(new ContextConfigurationAttributes(testClass));
256+
// for 7.1: ContextLoaderUtils.resolveDefaultContextConfigurationAttributes(testClass);
256257

257258
ContextLoader contextLoader = resolveContextLoader(testClass, defaultConfigAttributesList);
258259
if (logger.isTraceEnabled()) {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class ImplicitDefaultConfigClassesBaseTests {
4141
@Autowired
4242
String greeting1;
4343

44+
4445
@Test
4546
void greeting1() {
4647
// This class must NOT be annotated with @SpringJUnitConfig or @ContextConfiguration.
@@ -49,6 +50,7 @@ void greeting1() {
4950
assertThat(greeting1).isEqualTo("TEST 1");
5051
}
5152

53+
5254
@Configuration
5355
static class DefaultConfig {
5456

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ class ImplicitDefaultConfigClassesInheritedTests extends ImplicitDefaultConfigCl
4040
@Autowired
4141
String greeting2;
4242

43+
44+
// To be removed in favor of base class method in 7.1
45+
@Test
46+
void greeting1() {
47+
assertThat(greeting1).isEqualTo("TEST 2");
48+
}
49+
4350
@Test
4451
void greeting2() {
4552
// This class must NOT be annotated with @SpringJUnitConfig or @ContextConfiguration.
@@ -50,9 +57,11 @@ void greeting2() {
5057

5158
@Test
5259
void greetings(@Autowired List<String> greetings) {
53-
assertThat(greetings).containsExactly("TEST 1", "TEST 2");
60+
assertThat(greetings).containsExactly("TEST 2");
61+
// for 7.1: assertThat(greetings).containsExactly("TEST 1", "TEST 2");
5462
}
5563

64+
5665
@Configuration
5766
static class DefaultConfig {
5867

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package org.springframework.test.context.junit.jupiter.nested;
1818

19-
import org.junit.jupiter.api.Nested;
2019
import org.junit.jupiter.api.Test;
2120
import org.junit.jupiter.api.extension.ExtendWith;
2221

@@ -43,6 +42,7 @@ class DefaultContextConfigurationDetectionWithNestedTests {
4342
@Autowired
4443
String greeting;
4544

45+
4646
@Test
4747
void test(@Autowired String localGreeting) {
4848
// This class must NOT be annotated with @SpringJUnitConfig or @ContextConfiguration.
@@ -52,6 +52,8 @@ void test(@Autowired String localGreeting) {
5252
assertThat(localGreeting).isEqualTo("TEST");
5353
}
5454

55+
56+
/** for 7.1:
5557
@Nested
5658
class NestedTests {
5759
@@ -61,6 +63,8 @@ void test(@Autowired String localGreeting) {
6163
assertThat(localGreeting).isEqualTo("TEST");
6264
}
6365
}
66+
*/
67+
6468

6569
@Configuration
6670
static class DefaultConfig {

0 commit comments

Comments
 (0)