Skip to content

Commit b057e50

Browse files
committed
Adapted exception message expectations
Issue: SPR-13621
1 parent c88877f commit b057e50

File tree

2 files changed

+32
-28
lines changed

2 files changed

+32
-28
lines changed

spring-test/src/test/java/org/springframework/test/context/support/AbstractContextConfigurationUtilsTests.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,24 @@
5151
abstract class AbstractContextConfigurationUtilsTests {
5252

5353
static final Class<?>[] EMPTY_CLASS_ARRAY = new Class<?>[0];
54+
5455
static final String[] EMPTY_STRING_ARRAY = new String[0];
55-
static final Set<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> EMPTY_INITIALIZER_CLASSES = //
56-
Collections.<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> emptySet();
56+
57+
static final Set<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>>
58+
EMPTY_INITIALIZER_CLASSES = Collections.<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> emptySet();
5759

5860

5961
MergedContextConfiguration buildMergedContextConfiguration(Class<?> testClass) {
6062
CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate = Mockito.mock(CacheAwareContextLoaderDelegate.class);
61-
BootstrapContext bootstrapContext = BootstrapTestUtils.buildBootstrapContext(testClass,
62-
cacheAwareContextLoaderDelegate);
63+
BootstrapContext bootstrapContext = BootstrapTestUtils.buildBootstrapContext(testClass, cacheAwareContextLoaderDelegate);
6364
TestContextBootstrapper bootstrapper = BootstrapTestUtils.resolveTestContextBootstrapper(bootstrapContext);
6465
return bootstrapper.buildMergedContextConfiguration();
6566
}
6667

6768
void assertAttributes(ContextConfigurationAttributes attributes, Class<?> expectedDeclaringClass,
6869
String[] expectedLocations, Class<?>[] expectedClasses,
6970
Class<? extends ContextLoader> expectedContextLoaderClass, boolean expectedInheritLocations) {
71+
7072
assertEquals("declaring class", expectedDeclaringClass, attributes.getDeclaringClass());
7173
assertArrayEquals("locations", expectedLocations, attributes.getLocations());
7274
assertArrayEquals("classes", expectedClasses, attributes.getClasses());
@@ -77,8 +79,9 @@ void assertAttributes(ContextConfigurationAttributes attributes, Class<?> expect
7779
void assertMergedConfig(MergedContextConfiguration mergedConfig, Class<?> expectedTestClass,
7880
String[] expectedLocations, Class<?>[] expectedClasses,
7981
Class<? extends ContextLoader> expectedContextLoaderClass) {
82+
8083
assertMergedConfig(mergedConfig, expectedTestClass, expectedLocations, expectedClasses,
81-
EMPTY_INITIALIZER_CLASSES, expectedContextLoaderClass);
84+
EMPTY_INITIALIZER_CLASSES, expectedContextLoaderClass);
8285
}
8386

8487
void assertMergedConfig(
@@ -88,6 +91,7 @@ void assertMergedConfig(
8891
Class<?>[] expectedClasses,
8992
Set<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> expectedInitializerClasses,
9093
Class<? extends ContextLoader> expectedContextLoaderClass) {
94+
9195
assertNotNull(mergedConfig);
9296
assertEquals(expectedTestClass, mergedConfig.getTestClass());
9397
assertNotNull(mergedConfig.getLocations());
@@ -159,7 +163,7 @@ static class MetaLocationsBar extends MetaLocationsFoo {
159163
static class MetaLocationsFooWithOverrides {
160164
}
161165

162-
@MetaLocationsFooConfigWithOverrides(locations = { "foo1.xml", "foo2.xml" }, profiles = { "foo1", "foo2" })
166+
@MetaLocationsFooConfigWithOverrides(locations = {"foo1.xml", "foo2.xml"}, profiles = {"foo1", "foo2"})
163167
static class MetaLocationsFooWithOverriddenAttributes {
164168
}
165169

spring-test/src/test/java/org/springframework/test/context/support/ContextLoaderUtilsConfigurationAttributesTests.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,35 +45,35 @@ public class ContextLoaderUtilsConfigurationAttributesTests extends AbstractCont
4545

4646
private void assertLocationsFooAttributes(ContextConfigurationAttributes attributes) {
4747
assertAttributes(attributes, LocationsFoo.class, new String[] { "/foo.xml" }, EMPTY_CLASS_ARRAY,
48-
ContextLoader.class, false);
48+
ContextLoader.class, false);
4949
}
5050

5151
private void assertClassesFooAttributes(ContextConfigurationAttributes attributes) {
52-
assertAttributes(attributes, ClassesFoo.class, EMPTY_STRING_ARRAY, new Class<?>[] { FooConfig.class },
53-
ContextLoader.class, false);
52+
assertAttributes(attributes, ClassesFoo.class, EMPTY_STRING_ARRAY, new Class<?>[] {FooConfig.class},
53+
ContextLoader.class, false);
5454
}
5555

5656
private void assertLocationsBarAttributes(ContextConfigurationAttributes attributes) {
57-
assertAttributes(attributes, LocationsBar.class, new String[] { "/bar.xml" }, EMPTY_CLASS_ARRAY,
58-
AnnotationConfigContextLoader.class, true);
57+
assertAttributes(attributes, LocationsBar.class, new String[] {"/bar.xml"}, EMPTY_CLASS_ARRAY,
58+
AnnotationConfigContextLoader.class, true);
5959
}
6060

6161
private void assertClassesBarAttributes(ContextConfigurationAttributes attributes) {
62-
assertAttributes(attributes, ClassesBar.class, EMPTY_STRING_ARRAY, new Class<?>[] { BarConfig.class },
63-
AnnotationConfigContextLoader.class, true);
62+
assertAttributes(attributes, ClassesBar.class, EMPTY_STRING_ARRAY, new Class<?>[] {BarConfig.class},
63+
AnnotationConfigContextLoader.class, true);
6464
}
6565

6666
@Test
6767
public void resolveConfigAttributesWithConflictingLocations() {
6868
exception.expect(AnnotationConfigurationException.class);
6969
exception.expectMessage(containsString(ConflictingLocations.class.getName()));
7070
exception.expectMessage(either(
71-
containsString("attribute [value] and its alias [locations]")).or(
72-
containsString("attribute [locations] and its alias [value]")));
71+
containsString("attribute 'value' and its alias 'locations'")).or(
72+
containsString("attribute 'locations' and its alias 'value'")));
7373
exception.expectMessage(either(
7474
containsString("values of [{x}] and [{y}]")).or(
7575
containsString("values of [{y}] and [{x}]")));
76-
exception.expectMessage(containsString("but only one declaration is permitted"));
76+
exception.expectMessage(containsString("but only one is permitted"));
7777
resolveContextConfigurationAttributes(ConflictingLocations.class);
7878
}
7979

@@ -83,8 +83,8 @@ public void resolveConfigAttributesWithBareAnnotations() {
8383
List<ContextConfigurationAttributes> attributesList = resolveContextConfigurationAttributes(testClass);
8484
assertNotNull(attributesList);
8585
assertEquals(1, attributesList.size());
86-
assertAttributes(attributesList.get(0), testClass, EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, ContextLoader.class,
87-
true);
86+
assertAttributes(attributesList.get(0),
87+
testClass, EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, ContextLoader.class, true);
8888
}
8989

9090
@Test
@@ -101,8 +101,8 @@ public void resolveConfigAttributesWithMetaAnnotationAndLocations() {
101101
List<ContextConfigurationAttributes> attributesList = resolveContextConfigurationAttributes(testClass);
102102
assertNotNull(attributesList);
103103
assertEquals(1, attributesList.size());
104-
assertAttributes(attributesList.get(0), testClass, new String[] { "/foo.xml" }, EMPTY_CLASS_ARRAY,
105-
ContextLoader.class, true);
104+
assertAttributes(attributesList.get(0),
105+
testClass, new String[] {"/foo.xml"}, EMPTY_CLASS_ARRAY, ContextLoader.class, true);
106106
}
107107

108108
@Test
@@ -111,8 +111,8 @@ public void resolveConfigAttributesWithMetaAnnotationAndLocationsAndOverrides()
111111
List<ContextConfigurationAttributes> attributesList = resolveContextConfigurationAttributes(testClass);
112112
assertNotNull(attributesList);
113113
assertEquals(1, attributesList.size());
114-
assertAttributes(attributesList.get(0), testClass, new String[] { "/foo.xml" }, EMPTY_CLASS_ARRAY,
115-
ContextLoader.class, true);
114+
assertAttributes(attributesList.get(0),
115+
testClass, new String[] {"/foo.xml"}, EMPTY_CLASS_ARRAY, ContextLoader.class, true);
116116
}
117117

118118
@Test
@@ -121,8 +121,8 @@ public void resolveConfigAttributesWithMetaAnnotationAndLocationsAndOverriddenAt
121121
List<ContextConfigurationAttributes> attributesList = resolveContextConfigurationAttributes(testClass);
122122
assertNotNull(attributesList);
123123
assertEquals(1, attributesList.size());
124-
assertAttributes(attributesList.get(0), testClass, new String[] { "foo1.xml", "foo2.xml" }, EMPTY_CLASS_ARRAY,
125-
ContextLoader.class, true);
124+
assertAttributes(attributesList.get(0),
125+
testClass, new String[] {"foo1.xml", "foo2.xml"}, EMPTY_CLASS_ARRAY, ContextLoader.class, true);
126126
}
127127

128128
@Test
@@ -131,10 +131,10 @@ public void resolveConfigAttributesWithMetaAnnotationAndLocationsInClassHierarch
131131
List<ContextConfigurationAttributes> attributesList = resolveContextConfigurationAttributes(testClass);
132132
assertNotNull(attributesList);
133133
assertEquals(2, attributesList.size());
134-
assertAttributes(attributesList.get(0), testClass, new String[] { "/bar.xml" }, EMPTY_CLASS_ARRAY,
135-
ContextLoader.class, true);
136-
assertAttributes(attributesList.get(1), MetaLocationsFoo.class, new String[] { "/foo.xml" },
137-
EMPTY_CLASS_ARRAY, ContextLoader.class, true);
134+
assertAttributes(attributesList.get(0),
135+
testClass, new String[] {"/bar.xml"}, EMPTY_CLASS_ARRAY, ContextLoader.class, true);
136+
assertAttributes(attributesList.get(1),
137+
MetaLocationsFoo.class, new String[] {"/foo.xml"}, EMPTY_CLASS_ARRAY, ContextLoader.class, true);
138138
}
139139

140140
@Test

0 commit comments

Comments
 (0)