diff --git a/org.springframework.test/src/main/java/org/springframework/test/context/ContextConfiguration.java b/org.springframework.test/src/main/java/org/springframework/test/context/ContextConfiguration.java index 367601b96ec51675f76271a7e83d48d85d7d16e2..7c0332be5e121a6d82e4a0bc3f50fb13968e7e7b 100644 --- a/org.springframework.test/src/main/java/org/springframework/test/context/ContextConfiguration.java +++ b/org.springframework.test/src/main/java/org/springframework/test/context/ContextConfiguration.java @@ -30,7 +30,7 @@ import java.lang.annotation.Target; * for test classes. * *

Prior to Spring 3.1, only path-based resource locations were supported. - * As of Spring 3.1 {@link #loader context loaders} may choose to support + * As of Spring 3.1, {@link #loader context loaders} may choose to support * either path-based or class-based resources (but not both). Consequently * {@code @ContextConfiguration} can be used to declare either path-based * resource locations (via the {@link #locations} or {@link #value} @@ -40,7 +40,9 @@ import java.lang.annotation.Target; * @author Sam Brannen * @since 2.5 * @see ContextLoader + * @see SmartContextLoader * @see org.springframework.context.ApplicationContext + * @see ActiveProfiles */ @Documented @Inherited @@ -62,20 +64,26 @@ public @interface ContextConfiguration { * The resource locations to use for loading an * {@link org.springframework.context.ApplicationContext ApplicationContext}. * - *

Check out the javadoc for {@link org.springframework.test.context.support.AbstractContextLoader#modifyLocations AbstractContextLoader.modifyLocations()} - * for details on how a location String will be interpreted at runtime, - * in particular in case of a relative path. Also, check out the documentation on - * {@link org.springframework.test.context.support.AbstractContextLoader#generateDefaultLocations AbstractContextLoader.generateDefaultLocations()} - * for details on the default locations that are going to be used if none are specified. + *

Check out the javadoc for + * {@link org.springframework.test.context.support.AbstractContextLoader#modifyLocations + * AbstractContextLoader.modifyLocations()} for details on how a location + * String will be interpreted at runtime, in particular in case of a relative + * path. Also, check out the documentation on + * {@link org.springframework.test.context.support.AbstractContextLoader#generateDefaultLocations + * AbstractContextLoader.generateDefaultLocations()} for details on the default + * locations that are going to be used if none are specified. * *

Note that the above-mentioned default rules only apply for a standard - * {@link org.springframework.test.context.support.AbstractContextLoader AbstractContextLoader} subclass - * such as {@link org.springframework.test.context.support.GenericXmlContextLoader GenericXmlContextLoader} - * which is the effective default implementation used at runtime. + * {@link org.springframework.test.context.support.AbstractContextLoader + * AbstractContextLoader} subclass such as + * {@link org.springframework.test.context.support.GenericXmlContextLoader + * GenericXmlContextLoader} which is the effective default implementation + * used at runtime. * - *

This attribute may not be used in conjunction - * with {@link #value} or {@link #classes}, but it may be used - * instead of {@link #value}. + *

This attribute may not be used in conjunction with + * {@link #value} or {@link #classes}, but it may be used instead of + * {@link #value}. + * @since 2.5 */ String[] locations() default {}; @@ -85,13 +93,15 @@ public @interface ContextConfiguration { * {@link org.springframework.context.ApplicationContext ApplicationContext}. * *

To enable support for configuration class processing, an appropriate - * {@link ContextLoader} must be {@link #loader configured}. - * {@link org.springframework.test.context.support.AnnotationConfigContextLoader AnnotationConfigContextLoader} - * is one such loader provided by the Spring Framework. + * {@link SmartContextLoader} must be {@link #loader configured}. + * {@link org.springframework.test.context.support.AnnotationConfigContextLoader + * AnnotationConfigContextLoader} is one such loader provided by the Spring Framework. * *

Check out the javadoc for - * {@link org.springframework.test.context.support.AnnotationConfigContextLoader#generateDefaultLocations AnnotationConfigContextLoader.generateDefaultLocations()} - * for details on the default configuration classes that will be used if none are specified. + * {@link org.springframework.test.context.support.AnnotationConfigContextLoader#generateDefaultConfigurationClasses + * AnnotationConfigContextLoader.generateDefaultConfigurationClasses()} + * for details on the default configuration classes that will be used if none + * are specified. * *

Note that this attribute may not be used in * conjunction with {@link #locations} or {@link #value}. @@ -158,22 +168,27 @@ public @interface ContextConfiguration { * // ... * } * + * @since 2.5 */ boolean inheritLocations() default true; + // TODO Update regarding default --> DelegatingSmartContextLoader /** - * The type of {@link ContextLoader} to use for loading an - * {@link org.springframework.context.ApplicationContext ApplicationContext}. + * The type of {@link ContextLoader} (or {@link SmartContextLoader}) to use + * for loading an {@link org.springframework.context.ApplicationContext + * ApplicationContext}. * *

If not specified, the loader will be inherited from the first superclass - * which is annotated with @ContextConfiguration and specifies - * an explicit loader. If no class in the hierarchy specifies an explicit + * that is annotated with {@code @ContextConfiguration} and specifies an + * explicit loader. If no class in the hierarchy specifies an explicit * loader, a default loader will be used instead. * *

The default concrete implementation chosen at runtime will be - * {@link org.springframework.test.context.support.GenericXmlContextLoader GenericXmlContextLoader}. - * Also check out {@link org.springframework.test.context.support.AbstractContextLoader AbstractContextLoader}'s - * javadoc for details on the default behavior there. + * {@link org.springframework.test.context.support.GenericXmlContextLoader + * GenericXmlContextLoader}. Also check out + * {@link org.springframework.test.context.support.AbstractContextLoader + * AbstractContextLoader}'s javadoc for details on the default behavior there. + * @since 2.5 */ Class loader() default ContextLoader.class; diff --git a/org.springframework.test/src/main/java/org/springframework/test/context/support/AbstractContextLoader.java b/org.springframework.test/src/main/java/org/springframework/test/context/support/AbstractContextLoader.java index 341e327936cc5aa11131fe2e61e9337ea31650e6..faf88f520e1232ac377499d05de8cd4610e3dda0 100644 --- a/org.springframework.test/src/main/java/org/springframework/test/context/support/AbstractContextLoader.java +++ b/org.springframework.test/src/main/java/org/springframework/test/context/support/AbstractContextLoader.java @@ -143,9 +143,10 @@ public abstract class AbstractContextLoader implements SmartContextLoader { String resourcePath = SLASH + ClassUtils.convertClassNameToResourcePath(clazz.getName()) + suffix; if (!new ClassPathResource(resourcePath, clazz).exists()) { - logger.warn(String.format( - "Cannot generate default resource location for test class [%s]: classpath resource [%s] does not exist.", - clazz.getName(), resourcePath)); + if (logger.isInfoEnabled()) { + logger.info(String.format("Cannot generate default resource locations for test class [%s]: " + + "classpath resource [%s] does not exist.", clazz.getName(), resourcePath)); + } return EMPTY_STRING_ARRAY; } 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 ec36e44cf431aa914e8cb9f43de1c8487ff2bc05..1cbf1a467ef224138dd7e97370066c734a2d8952 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 @@ -145,9 +145,11 @@ public class AnnotationConfigContextLoader extends AbstractGenericContextLoader } if (configClasses.isEmpty()) { - logger.warn(String.format( - "Test class [%s] does not declare any static, non-private, non-final, inner classes annotated " - + "with @Configuration that can be used as a default configuration class.", declaringClass)); + 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)); + } } return configClasses.toArray(new Class[configClasses.size()]);