diff --git a/org.springframework.test/src/main/java/org/springframework/test/context/support/AnnotationConfigContextLoader.java b/org.springframework.test/src/main/java/org/springframework/test/context/support/AnnotationConfigContextLoader.java index 0336d93c42c..202cb9b97df 100644 --- a/org.springframework.test/src/main/java/org/springframework/test/context/support/AnnotationConfigContextLoader.java +++ b/org.springframework.test/src/main/java/org/springframework/test/context/support/AnnotationConfigContextLoader.java @@ -16,15 +16,13 @@ package org.springframework.test.context.support; -import java.util.ArrayList; -import java.util.List; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.support.BeanDefinitionReader; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.support.GenericApplicationContext; import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; /** * TODO Document AnnotationConfigContextLoader. @@ -56,25 +54,22 @@ public class AnnotationConfigContextLoader extends AbstractGenericContextLoader AnnotationConfigApplicationContext annotationConfigApplicationContext = (AnnotationConfigApplicationContext) context; - List> configClasses = new ArrayList>(); - for (String location : locations) { + Class[] configClasses = new Class[locations.length]; + for (int i = 0; i < locations.length; i++) { try { - Class clazz = getClass().getClassLoader().loadClass(location); - configClasses.add(clazz); + Class clazz = getClass().getClassLoader().loadClass(locations[i]); + configClasses[i] = clazz; } catch (ClassNotFoundException e) { throw new IllegalArgumentException(String.format( - "The supplied resource location [%s] does not represent a class.", location), e); + "The supplied resource location [%s] does not represent a class.", locations[i]), e); } } if (logger.isDebugEnabled()) { - logger.debug("Registering configuration classes: " + configClasses); - } - - for (Class configClass : configClasses) { - annotationConfigApplicationContext.register(configClass); + logger.debug("Registering configuration classes: " + ObjectUtils.nullSafeToString(configClasses)); } + annotationConfigApplicationContext.register(configClasses); } /**