diff --git a/org.springframework.test/src/main/java/org/springframework/test/context/ContextConfigurationAttributes.java b/org.springframework.test/src/main/java/org/springframework/test/context/ContextConfigurationAttributes.java index f27322e6ed1..6ba9d2eec1d 100644 --- a/org.springframework.test/src/main/java/org/springframework/test/context/ContextConfigurationAttributes.java +++ b/org.springframework.test/src/main/java/org/springframework/test/context/ContextConfigurationAttributes.java @@ -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); 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 1cbf1a467ef..bdb8adad6cd 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 @@ -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())); } }