parent
c88877f1c4
commit
b057e503ef
|
|
@ -51,15 +51,16 @@ import static org.junit.Assert.*;
|
||||||
abstract class AbstractContextConfigurationUtilsTests {
|
abstract class AbstractContextConfigurationUtilsTests {
|
||||||
|
|
||||||
static final Class<?>[] EMPTY_CLASS_ARRAY = new Class<?>[0];
|
static final Class<?>[] EMPTY_CLASS_ARRAY = new Class<?>[0];
|
||||||
|
|
||||||
static final String[] EMPTY_STRING_ARRAY = new String[0];
|
static final String[] EMPTY_STRING_ARRAY = new String[0];
|
||||||
static final Set<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> EMPTY_INITIALIZER_CLASSES = //
|
|
||||||
Collections.<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> emptySet();
|
static final Set<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>>
|
||||||
|
EMPTY_INITIALIZER_CLASSES = Collections.<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> emptySet();
|
||||||
|
|
||||||
|
|
||||||
MergedContextConfiguration buildMergedContextConfiguration(Class<?> testClass) {
|
MergedContextConfiguration buildMergedContextConfiguration(Class<?> testClass) {
|
||||||
CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate = Mockito.mock(CacheAwareContextLoaderDelegate.class);
|
CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate = Mockito.mock(CacheAwareContextLoaderDelegate.class);
|
||||||
BootstrapContext bootstrapContext = BootstrapTestUtils.buildBootstrapContext(testClass,
|
BootstrapContext bootstrapContext = BootstrapTestUtils.buildBootstrapContext(testClass, cacheAwareContextLoaderDelegate);
|
||||||
cacheAwareContextLoaderDelegate);
|
|
||||||
TestContextBootstrapper bootstrapper = BootstrapTestUtils.resolveTestContextBootstrapper(bootstrapContext);
|
TestContextBootstrapper bootstrapper = BootstrapTestUtils.resolveTestContextBootstrapper(bootstrapContext);
|
||||||
return bootstrapper.buildMergedContextConfiguration();
|
return bootstrapper.buildMergedContextConfiguration();
|
||||||
}
|
}
|
||||||
|
|
@ -67,6 +68,7 @@ abstract class AbstractContextConfigurationUtilsTests {
|
||||||
void assertAttributes(ContextConfigurationAttributes attributes, Class<?> expectedDeclaringClass,
|
void assertAttributes(ContextConfigurationAttributes attributes, Class<?> expectedDeclaringClass,
|
||||||
String[] expectedLocations, Class<?>[] expectedClasses,
|
String[] expectedLocations, Class<?>[] expectedClasses,
|
||||||
Class<? extends ContextLoader> expectedContextLoaderClass, boolean expectedInheritLocations) {
|
Class<? extends ContextLoader> expectedContextLoaderClass, boolean expectedInheritLocations) {
|
||||||
|
|
||||||
assertEquals("declaring class", expectedDeclaringClass, attributes.getDeclaringClass());
|
assertEquals("declaring class", expectedDeclaringClass, attributes.getDeclaringClass());
|
||||||
assertArrayEquals("locations", expectedLocations, attributes.getLocations());
|
assertArrayEquals("locations", expectedLocations, attributes.getLocations());
|
||||||
assertArrayEquals("classes", expectedClasses, attributes.getClasses());
|
assertArrayEquals("classes", expectedClasses, attributes.getClasses());
|
||||||
|
|
@ -77,6 +79,7 @@ abstract class AbstractContextConfigurationUtilsTests {
|
||||||
void assertMergedConfig(MergedContextConfiguration mergedConfig, Class<?> expectedTestClass,
|
void assertMergedConfig(MergedContextConfiguration mergedConfig, Class<?> expectedTestClass,
|
||||||
String[] expectedLocations, Class<?>[] expectedClasses,
|
String[] expectedLocations, Class<?>[] expectedClasses,
|
||||||
Class<? extends ContextLoader> expectedContextLoaderClass) {
|
Class<? extends ContextLoader> expectedContextLoaderClass) {
|
||||||
|
|
||||||
assertMergedConfig(mergedConfig, expectedTestClass, expectedLocations, expectedClasses,
|
assertMergedConfig(mergedConfig, expectedTestClass, expectedLocations, expectedClasses,
|
||||||
EMPTY_INITIALIZER_CLASSES, expectedContextLoaderClass);
|
EMPTY_INITIALIZER_CLASSES, expectedContextLoaderClass);
|
||||||
}
|
}
|
||||||
|
|
@ -88,6 +91,7 @@ abstract class AbstractContextConfigurationUtilsTests {
|
||||||
Class<?>[] expectedClasses,
|
Class<?>[] expectedClasses,
|
||||||
Set<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> expectedInitializerClasses,
|
Set<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> expectedInitializerClasses,
|
||||||
Class<? extends ContextLoader> expectedContextLoaderClass) {
|
Class<? extends ContextLoader> expectedContextLoaderClass) {
|
||||||
|
|
||||||
assertNotNull(mergedConfig);
|
assertNotNull(mergedConfig);
|
||||||
assertEquals(expectedTestClass, mergedConfig.getTestClass());
|
assertEquals(expectedTestClass, mergedConfig.getTestClass());
|
||||||
assertNotNull(mergedConfig.getLocations());
|
assertNotNull(mergedConfig.getLocations());
|
||||||
|
|
|
||||||
|
|
@ -68,12 +68,12 @@ public class ContextLoaderUtilsConfigurationAttributesTests extends AbstractCont
|
||||||
exception.expect(AnnotationConfigurationException.class);
|
exception.expect(AnnotationConfigurationException.class);
|
||||||
exception.expectMessage(containsString(ConflictingLocations.class.getName()));
|
exception.expectMessage(containsString(ConflictingLocations.class.getName()));
|
||||||
exception.expectMessage(either(
|
exception.expectMessage(either(
|
||||||
containsString("attribute [value] and its alias [locations]")).or(
|
containsString("attribute 'value' and its alias 'locations'")).or(
|
||||||
containsString("attribute [locations] and its alias [value]")));
|
containsString("attribute 'locations' and its alias 'value'")));
|
||||||
exception.expectMessage(either(
|
exception.expectMessage(either(
|
||||||
containsString("values of [{x}] and [{y}]")).or(
|
containsString("values of [{x}] and [{y}]")).or(
|
||||||
containsString("values of [{y}] and [{x}]")));
|
containsString("values of [{y}] and [{x}]")));
|
||||||
exception.expectMessage(containsString("but only one declaration is permitted"));
|
exception.expectMessage(containsString("but only one is permitted"));
|
||||||
resolveContextConfigurationAttributes(ConflictingLocations.class);
|
resolveContextConfigurationAttributes(ConflictingLocations.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -83,8 +83,8 @@ public class ContextLoaderUtilsConfigurationAttributesTests extends AbstractCont
|
||||||
List<ContextConfigurationAttributes> attributesList = resolveContextConfigurationAttributes(testClass);
|
List<ContextConfigurationAttributes> attributesList = resolveContextConfigurationAttributes(testClass);
|
||||||
assertNotNull(attributesList);
|
assertNotNull(attributesList);
|
||||||
assertEquals(1, attributesList.size());
|
assertEquals(1, attributesList.size());
|
||||||
assertAttributes(attributesList.get(0), testClass, EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, ContextLoader.class,
|
assertAttributes(attributesList.get(0),
|
||||||
true);
|
testClass, EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, ContextLoader.class, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -101,8 +101,8 @@ public class ContextLoaderUtilsConfigurationAttributesTests extends AbstractCont
|
||||||
List<ContextConfigurationAttributes> attributesList = resolveContextConfigurationAttributes(testClass);
|
List<ContextConfigurationAttributes> attributesList = resolveContextConfigurationAttributes(testClass);
|
||||||
assertNotNull(attributesList);
|
assertNotNull(attributesList);
|
||||||
assertEquals(1, attributesList.size());
|
assertEquals(1, attributesList.size());
|
||||||
assertAttributes(attributesList.get(0), testClass, new String[] { "/foo.xml" }, EMPTY_CLASS_ARRAY,
|
assertAttributes(attributesList.get(0),
|
||||||
ContextLoader.class, true);
|
testClass, new String[] {"/foo.xml"}, EMPTY_CLASS_ARRAY, ContextLoader.class, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -111,8 +111,8 @@ public class ContextLoaderUtilsConfigurationAttributesTests extends AbstractCont
|
||||||
List<ContextConfigurationAttributes> attributesList = resolveContextConfigurationAttributes(testClass);
|
List<ContextConfigurationAttributes> attributesList = resolveContextConfigurationAttributes(testClass);
|
||||||
assertNotNull(attributesList);
|
assertNotNull(attributesList);
|
||||||
assertEquals(1, attributesList.size());
|
assertEquals(1, attributesList.size());
|
||||||
assertAttributes(attributesList.get(0), testClass, new String[] { "/foo.xml" }, EMPTY_CLASS_ARRAY,
|
assertAttributes(attributesList.get(0),
|
||||||
ContextLoader.class, true);
|
testClass, new String[] {"/foo.xml"}, EMPTY_CLASS_ARRAY, ContextLoader.class, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -121,8 +121,8 @@ public class ContextLoaderUtilsConfigurationAttributesTests extends AbstractCont
|
||||||
List<ContextConfigurationAttributes> attributesList = resolveContextConfigurationAttributes(testClass);
|
List<ContextConfigurationAttributes> attributesList = resolveContextConfigurationAttributes(testClass);
|
||||||
assertNotNull(attributesList);
|
assertNotNull(attributesList);
|
||||||
assertEquals(1, attributesList.size());
|
assertEquals(1, attributesList.size());
|
||||||
assertAttributes(attributesList.get(0), testClass, new String[] { "foo1.xml", "foo2.xml" }, EMPTY_CLASS_ARRAY,
|
assertAttributes(attributesList.get(0),
|
||||||
ContextLoader.class, true);
|
testClass, new String[] {"foo1.xml", "foo2.xml"}, EMPTY_CLASS_ARRAY, ContextLoader.class, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -131,10 +131,10 @@ public class ContextLoaderUtilsConfigurationAttributesTests extends AbstractCont
|
||||||
List<ContextConfigurationAttributes> attributesList = resolveContextConfigurationAttributes(testClass);
|
List<ContextConfigurationAttributes> attributesList = resolveContextConfigurationAttributes(testClass);
|
||||||
assertNotNull(attributesList);
|
assertNotNull(attributesList);
|
||||||
assertEquals(2, attributesList.size());
|
assertEquals(2, attributesList.size());
|
||||||
assertAttributes(attributesList.get(0), testClass, new String[] { "/bar.xml" }, EMPTY_CLASS_ARRAY,
|
assertAttributes(attributesList.get(0),
|
||||||
ContextLoader.class, true);
|
testClass, new String[] {"/bar.xml"}, EMPTY_CLASS_ARRAY, ContextLoader.class, true);
|
||||||
assertAttributes(attributesList.get(1), MetaLocationsFoo.class, new String[] { "/foo.xml" },
|
assertAttributes(attributesList.get(1),
|
||||||
EMPTY_CLASS_ARRAY, ContextLoader.class, true);
|
MetaLocationsFoo.class, new String[] {"/foo.xml"}, EMPTY_CLASS_ARRAY, ContextLoader.class, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue