[SPR-6184] Simplified AnnotationConfigContextLoader in TestContext.
This commit is contained in:
parent
dd4d6e63ae
commit
744facbf64
|
|
@ -236,39 +236,41 @@ public class TestContext extends AttributeAccessorSupport {
|
||||||
Assert.notNull(declaringClass, "Could not find an 'annotation declaring class' for annotation type ["
|
Assert.notNull(declaringClass, "Could not find an 'annotation declaring class' for annotation type ["
|
||||||
+ annotationType + "] and class [" + clazz + "]");
|
+ annotationType + "] and class [" + clazz + "]");
|
||||||
|
|
||||||
|
// --- configuration class resources ----------------------------
|
||||||
|
|
||||||
// TODO [SPR-6184] Implement recursive search for configuration classes.
|
// TODO [SPR-6184] Implement recursive search for configuration classes.
|
||||||
// This needs to integrate seamlessly (i.e., analogous yet mutually
|
// This needs to integrate seamlessly (i.e., analogous yet mutually
|
||||||
// exclusive) with the existing locations search.
|
// exclusive) with the existing locations search. Furthermore, the
|
||||||
|
// solution must not depend on an explicit ACCL check.
|
||||||
|
if (contextLoader instanceof AnnotationConfigContextLoader) {
|
||||||
|
|
||||||
ContextConfiguration cc = declaringClass.getAnnotation(annotationType);
|
ContextConfiguration cc = declaringClass.getAnnotation(annotationType);
|
||||||
if (cc != null) {
|
|
||||||
if (logger.isTraceEnabled()) {
|
if (logger.isTraceEnabled()) {
|
||||||
logger.trace("Retrieved @ContextConfiguration [" + cc + "] for declaring class [" + declaringClass
|
logger.trace(String.format("Retrieved @ContextConfiguration [%s] for declaring class [%s].", cc,
|
||||||
+ "]");
|
declaringClass));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String[] classNames = null;
|
||||||
|
|
||||||
Class<?>[] configClasses = cc.classes();
|
Class<?>[] configClasses = cc.classes();
|
||||||
|
|
||||||
if (!ObjectUtils.isEmpty(configClasses)) {
|
if (!ObjectUtils.isEmpty(configClasses)) {
|
||||||
for (Class<?> configClass : configClasses) {
|
classNames = new String[configClasses.length];
|
||||||
locationsList.add(configClass.getName());
|
|
||||||
|
for (int i = 0; i < configClasses.length; i++) {
|
||||||
|
classNames[i] = configClasses[i].getName();
|
||||||
}
|
}
|
||||||
return locationsList.toArray(new String[locationsList.size()]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO [SPR-6184] Remove interim-solution ACCL check.
|
return contextLoader.processLocations(declaringClass, classNames);
|
||||||
//
|
|
||||||
// Config classes are not defined, but the context loader might
|
|
||||||
// have been set to AnnotationConfigContextLoader.
|
|
||||||
if (AnnotationConfigContextLoader.class.isAssignableFrom(cc.loader())) {
|
|
||||||
return contextLoader.processLocations(declaringClass, new String[] {});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- location/value resources ---------------------------------
|
||||||
|
|
||||||
while (declaringClass != null) {
|
while (declaringClass != null) {
|
||||||
ContextConfiguration contextConfiguration = declaringClass.getAnnotation(annotationType);
|
ContextConfiguration contextConfiguration = declaringClass.getAnnotation(annotationType);
|
||||||
if (logger.isTraceEnabled()) {
|
if (logger.isTraceEnabled()) {
|
||||||
logger.trace("Retrieved @ContextConfiguration [" + contextConfiguration + "] for declaring class ["
|
logger.trace(String.format("Retrieved @ContextConfiguration [%s] for declaring class [%s].",
|
||||||
+ declaringClass + "]");
|
contextConfiguration, declaringClass));
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] valueLocations = contextConfiguration.value();
|
String[] valueLocations = contextConfiguration.value();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue