[SPR-8387] refined logging.

This commit is contained in:
Sam Brannen 2011-06-26 15:47:30 +00:00
parent 4ef895a018
commit 19fc2004f5
2 changed files with 7 additions and 5 deletions

View File

@ -19,6 +19,7 @@ package org.springframework.test.context;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.style.ToStringCreator;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
/**
@ -55,14 +56,15 @@ public class ContextConfigurationAttributes {
* @throws IllegalStateException if both the locations and value attributes have been declared
*/
static String[] resolveLocations(Class<?> declaringClass, ContextConfiguration contextConfiguration) {
Assert.notNull(declaringClass, "declaringClass must not be null");
String[] locations = contextConfiguration.locations();
String[] valueLocations = contextConfiguration.value();
if (!ObjectUtils.isEmpty(valueLocations) && !ObjectUtils.isEmpty(locations)) {
String msg = String.format("Test class [%s] has been configured with @ContextConfiguration's 'value' [%s] "
+ "and 'locations' [%s] attributes. Only one declaration of resource "
+ "locations is permitted per @ContextConfiguration annotation.", declaringClass,
String msg = String.format("Test class [%s] has been configured with @ContextConfiguration's 'value' %s "
+ "and 'locations' %s attributes. Only one declaration of resource "
+ "locations is permitted per @ContextConfiguration annotation.", declaringClass.getName(),
ObjectUtils.nullSafeToString(valueLocations), ObjectUtils.nullSafeToString(locations));
logger.error(msg);
throw new IllegalStateException(msg);

View File

@ -147,8 +147,8 @@ public class AnnotationConfigContextLoader extends AbstractGenericContextLoader
if (configClasses.isEmpty()) {
if (logger.isInfoEnabled()) {
logger.info(String.format("Cannot generate default configuration classes for test class [%s]: "
+ "test class does not declare any static, non-private, non-final, inner classes "
+ "annotated with @Configuration.", declaringClass));
+ "%s does not declare any static, non-private, non-final, inner classes "
+ "annotated with @Configuration.", declaringClass.getName(), declaringClass.getSimpleName()));
}
}