Skip to content

Commit 8916ee9

Browse files
committed
Set inheritLocations to true in ContextConfigurationAttributes constructor
Closes gh-36000
1 parent d835fe3 commit 8916ee9

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

spring-test/src/main/java/org/springframework/test/context/ContextConfigurationAttributes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public class ContextConfigurationAttributes {
7676
*/
7777
@SuppressWarnings({ "unchecked", "rawtypes" })
7878
public ContextConfigurationAttributes(Class<?> declaringClass) {
79-
this(declaringClass, EMPTY_LOCATIONS, EMPTY_CLASSES, false, (Class[]) EMPTY_CLASSES, true, ContextLoader.class);
79+
this(declaringClass, EMPTY_LOCATIONS, EMPTY_CLASSES, true, (Class[]) EMPTY_CLASSES, true, ContextLoader.class);
8080
}
8181

8282
/**
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright 2002-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.test.context;
18+
19+
import org.junit.jupiter.api.Test;
20+
21+
import static org.assertj.core.api.Assertions.assertThat;
22+
23+
/**
24+
* Tests for {@link ContextConfigurationAttributes}.
25+
*
26+
* @author Sam Brannen
27+
* @since 7.0.2
28+
*/
29+
class ContextConfigurationAttributesTests {
30+
31+
@Test // gh-36000
32+
void defaultsConstructor() {
33+
var configAttributes = new ContextConfigurationAttributes(getClass());
34+
35+
assertThat(configAttributes.getDeclaringClass()).isEqualTo(getClass());
36+
assertThat(configAttributes.getClasses()).isEmpty();
37+
assertThat(configAttributes.getLocations()).isEmpty();
38+
assertThat(configAttributes.getInitializers()).isEmpty();
39+
assertThat(configAttributes.getContextLoaderClass()).isEqualTo(ContextLoader.class);
40+
assertThat(configAttributes.isInheritInitializers()).isTrue();
41+
assertThat(configAttributes.isInheritLocations()).isTrue();
42+
}
43+
44+
}

0 commit comments

Comments
 (0)