[SPR-8386][SPR-8387] Revised Javadoc in the TestContext framework regarding changes in 3.1.

This commit is contained in:
Sam Brannen 2011-08-20 23:14:20 +00:00
parent 1c7cc172d9
commit 72da569aa3
10 changed files with 87 additions and 76 deletions

View File

@ -44,7 +44,7 @@ import java.lang.annotation.Target;
public @interface ActiveProfiles { public @interface ActiveProfiles {
/** /**
* Alias for {@link #profiles() profiles}. * Alias for {@link #profiles}.
* *
* <p>This attribute may <strong>not</strong> be used in conjunction * <p>This attribute may <strong>not</strong> be used in conjunction
* with {@link #profiles}, but it may be used <em>instead</em> of * with {@link #profiles}, but it may be used <em>instead</em> of

View File

@ -158,9 +158,9 @@ class ContextCache {
* {@link #remove removing} the context from the cache and explicitly * {@link #remove removing} the context from the cache and explicitly
* {@link ConfigurableApplicationContext#close() closing} it if * {@link ConfigurableApplicationContext#close() closing} it if
* it is an instance of {@link ConfigurableApplicationContext}. * it is an instance of {@link ConfigurableApplicationContext}.
* <p>Generally speaking, you would only call this method only if you change * <p>Generally speaking, you would only call this method if you change the
* the state of a singleton bean, potentially affecting future interaction * state of a singleton bean, potentially affecting future interaction with
* with the context. * the context.
* @param key the context key (never <code>null</code>) * @param key the context key (never <code>null</code>)
* @see #remove * @see #remove
*/ */

View File

@ -41,6 +41,8 @@ import java.lang.annotation.Target;
* @since 2.5 * @since 2.5
* @see ContextLoader * @see ContextLoader
* @see SmartContextLoader * @see SmartContextLoader
* @see ContextConfigurationAttributes
* @see MergedContextConfiguration
* @see org.springframework.context.ApplicationContext * @see org.springframework.context.ApplicationContext
* @see ActiveProfiles * @see ActiveProfiles
*/ */
@ -51,7 +53,7 @@ import java.lang.annotation.Target;
public @interface ContextConfiguration { public @interface ContextConfiguration {
/** /**
* Alias for {@link #locations() locations}. * Alias for {@link #locations}.
* *
* <p>This attribute may <strong>not</strong> be used in conjunction * <p>This attribute may <strong>not</strong> be used in conjunction
* with {@link #locations} or {@link #classes}, but it may be used * with {@link #locations} or {@link #classes}, but it may be used
@ -64,7 +66,7 @@ public @interface ContextConfiguration {
* The resource locations to use for loading an * The resource locations to use for loading an
* {@link org.springframework.context.ApplicationContext ApplicationContext}. * {@link org.springframework.context.ApplicationContext ApplicationContext}.
* *
* <p>Check out the javadoc for * <p>Check out the Javadoc for
* {@link org.springframework.test.context.support.AbstractContextLoader#modifyLocations * {@link org.springframework.test.context.support.AbstractContextLoader#modifyLocations
* AbstractContextLoader.modifyLocations()} for details on how a location * AbstractContextLoader.modifyLocations()} for details on how a location
* String will be interpreted at runtime, in particular in case of a relative * String will be interpreted at runtime, in particular in case of a relative
@ -78,7 +80,9 @@ public @interface ContextConfiguration {
* AbstractContextLoader} subclass such as * AbstractContextLoader} subclass such as
* {@link org.springframework.test.context.support.GenericXmlContextLoader * {@link org.springframework.test.context.support.GenericXmlContextLoader
* GenericXmlContextLoader} which is the effective default implementation * GenericXmlContextLoader} which is the effective default implementation
* used at runtime. * used at runtime if <code>locations</code> are configured. See the
* documentation for {@link #loader} for further details regarding default
* loaders.
* *
* <p>This attribute may <strong>not</strong> be used in conjunction with * <p>This attribute may <strong>not</strong> be used in conjunction with
* {@link #value} or {@link #classes}, but it may be used instead of * {@link #value} or {@link #classes}, but it may be used instead of
@ -88,20 +92,16 @@ public @interface ContextConfiguration {
String[] locations() default {}; String[] locations() default {};
/** /**
* The {@link org.springframework.context.annotation.Configuration configuration classes} * The {@link org.springframework.context.annotation.Configuration
* to use for loading an * configuration classes} to use for loading an
* {@link org.springframework.context.ApplicationContext ApplicationContext}. * {@link org.springframework.context.ApplicationContext ApplicationContext}.
* *
* <p>To enable support for configuration class processing, an appropriate * <p>Check out the Javadoc for
* {@link SmartContextLoader} must be {@link #loader configured}. * {@link org.springframework.test.context.support.AnnotationConfigContextLoader#detectDefaultConfigurationClasses
* {@link org.springframework.test.context.support.AnnotationConfigContextLoader * AnnotationConfigContextLoader.detectDefaultConfigurationClasses()} for details
* AnnotationConfigContextLoader} is one such loader provided by the Spring Framework. * on how default configuration classes will be detected if none are specified.
* * See the documentation for {@link #loader} for further details regarding
* <p>Check out the javadoc for * default loaders.
* {@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.
* *
* <p>This attribute may <strong>not</strong> be used in conjunction with * <p>This attribute may <strong>not</strong> be used in conjunction with
* {@link #locations} or {@link #value}. * {@link #locations} or {@link #value}.

View File

@ -19,11 +19,12 @@ package org.springframework.test.context;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
/** /**
* Strategy interface for loading an {@link ApplicationContext application context}. * Strategy interface for loading an {@link ApplicationContext application context}
* for an integration test managed by the Spring TestContext Framework.
* *
* <p><b>Note</b>: as of Spring 3.1, consider implementing {@link SmartContextLoader} * <p><b>Note</b>: as of Spring 3.1, implement {@link SmartContextLoader} instead
* instead of this interface in order to provide support for configuration classes * of this interface in order to provide support for configuration classes and
* and active bean definition profiles. * active bean definition profiles.
* *
* <p>Clients of a ContextLoader should call * <p>Clients of a ContextLoader should call
* {@link #processLocations(Class,String...) processLocations()} prior to * {@link #processLocations(Class,String...) processLocations()} prior to
@ -38,7 +39,6 @@ import org.springframework.context.ApplicationContext;
* <p>Spring provides the following out-of-the-box implementations: * <p>Spring provides the following out-of-the-box implementations:
* <ul> * <ul>
* <li>{@link org.springframework.test.context.support.GenericXmlContextLoader GenericXmlContextLoader}</li> * <li>{@link org.springframework.test.context.support.GenericXmlContextLoader GenericXmlContextLoader}</li>
* <li>{@link org.springframework.test.context.support.AnnotationConfigContextLoader AnnotationConfigContextLoader}</li>
* <li>{@link org.springframework.test.context.support.GenericPropertiesContextLoader GenericPropertiesContextLoader}</li> * <li>{@link org.springframework.test.context.support.GenericPropertiesContextLoader GenericPropertiesContextLoader}</li>
* </ul> * </ul>
* *
@ -46,6 +46,7 @@ import org.springframework.context.ApplicationContext;
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 2.5 * @since 2.5
* @see SmartContextLoader * @see SmartContextLoader
* @see org.springframework.test.context.support.AnnotationConfigContextLoader AnnotationConfigContextLoader
*/ */
public interface ContextLoader { public interface ContextLoader {
@ -68,12 +69,12 @@ public interface ContextLoader {
* <p>Configuration locations are generally considered to be classpath * <p>Configuration locations are generally considered to be classpath
* resources by default. * resources by default.
* <p>Concrete implementations should register annotation configuration * <p>Concrete implementations should register annotation configuration
* processors with bean factories of * processors with bean factories of {@link ApplicationContext application
* {@link ApplicationContext application contexts} loaded by this * contexts} loaded by this ContextLoader. Beans will therefore automatically
* ContextLoader. Beans will therefore automatically be candidates for * be candidates for annotation-based dependency injection using
* annotation-based dependency injection using * {@link org.springframework.beans.factory.annotation.Autowired @Autowired},
* {@link org.springframework.beans.factory.annotation.Autowired @Autowired} * {@link javax.annotation.Resource @Resource}, and
* and {@link javax.annotation.Resource @Resource}. * {@link javax.inject.Inject @Inject}.
* <p>Any ApplicationContext loaded by a ContextLoader <strong>must</strong> * <p>Any ApplicationContext loaded by a ContextLoader <strong>must</strong>
* register a JVM shutdown hook for itself. Unless the context gets closed * register a JVM shutdown hook for itself. Unless the context gets closed
* early, all context instances will be automatically closed on JVM * early, all context instances will be automatically closed on JVM

View File

@ -19,7 +19,7 @@ package org.springframework.test.context;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
/** /**
* <p>Strategy interface for loading an {@link ApplicationContext application context} * Strategy interface for loading an {@link ApplicationContext application context}
* for an integration test managed by the Spring TestContext Framework. * for an integration test managed by the Spring TestContext Framework.
* *
* <p>The {@code SmartContextLoader} SPI supersedes the {@link ContextLoader} SPI * <p>The {@code SmartContextLoader} SPI supersedes the {@link ContextLoader} SPI
@ -34,8 +34,9 @@ import org.springframework.context.ApplicationContext;
* processContextConfiguration()} prior to calling * processContextConfiguration()} prior to calling
* {@link #loadContext(MergedContextConfiguration) loadContext()}. This gives a * {@link #loadContext(MergedContextConfiguration) loadContext()}. This gives a
* {@code SmartContextLoader} the opportunity to provide custom support for * {@code SmartContextLoader} the opportunity to provide custom support for
* modifying or generating resource locations or configuration classes. The * modifying resource locations or detecting default resource locations or
* results of {@link #processContextConfiguration(ContextConfigurationAttributes) * default configuration classes. The results of
* {@link #processContextConfiguration(ContextConfigurationAttributes)
* processContextConfiguration()} should be merged for all classes in the * processContextConfiguration()} should be merged for all classes in the
* hierarchy of the root test class and then supplied to * hierarchy of the root test class and then supplied to
* {@link #loadContext(MergedContextConfiguration) loadContext()}. * {@link #loadContext(MergedContextConfiguration) loadContext()}.

View File

@ -108,7 +108,8 @@ public class TestContext extends AttributeAccessorSupport {
/** /**
* Load an <code>ApplicationContext</code> for this test context using the * Load an <code>ApplicationContext</code> for this test context using the
* configured {@code ContextLoader} and configuration attributes. * configured {@code ContextLoader} and merged context configuration. Supports
* both the {@link SmartContextLoader} and {@link ContextLoader} SPIs.
* @throws Exception if an error occurs while loading the application context * @throws Exception if an error occurs while loading the application context
*/ */
private ApplicationContext loadApplicationContext() throws Exception { private ApplicationContext loadApplicationContext() throws Exception {

View File

@ -31,7 +31,7 @@ import org.springframework.util.ResourceUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
/** /**
* Abstract application context loader, which provides a basis for all concrete * Abstract application context loader that provides a basis for all concrete
* implementations of the {@link ContextLoader} SPI. Provides a * implementations of the {@link ContextLoader} SPI. Provides a
* <em>Template Method</em> based approach for {@link #processLocations processing} * <em>Template Method</em> based approach for {@link #processLocations processing}
* resource locations. * resource locations.
@ -190,6 +190,13 @@ public abstract class AbstractContextLoader implements SmartContextLoader {
* Determine whether or not <em>default</em> resource locations should be * Determine whether or not <em>default</em> resource locations should be
* generated if the <code>locations</code> provided to * generated if the <code>locations</code> provided to
* {@link #processLocations()} are <code>null</code> or empty. * {@link #processLocations()} are <code>null</code> or empty.
* <p>As of Spring 3.1, the semantics of this method have been overloaded
* to include detection of either default resource locations or default
* configuration classes. Consequently, this method can also be used to
* determine whether or not <em>default</em> configuration classes should be
* detected if the <code>classes</code> present in the
* {@link ContextConfigurationAttributes configuration attributes} supplied
* to {@link #processContextConfiguration()} are <code>null</code> or empty.
* <p>Can be overridden by subclasses to change the default behavior. * <p>Can be overridden by subclasses to change the default behavior.
* @return always <code>true</code> by default * @return always <code>true</code> by default
* @since 2.5 * @since 2.5

View File

@ -68,18 +68,18 @@ public abstract class AbstractGenericContextLoader extends AbstractContextLoader
* <li>Sets the <em>active bean definition profiles</em> from the supplied * <li>Sets the <em>active bean definition profiles</em> from the supplied
* <code>MergedContextConfiguration</code> in the * <code>MergedContextConfiguration</code> in the
* {@link org.springframework.core.env.Environment Environment} of the context.</li> * {@link org.springframework.core.env.Environment Environment} of the context.</li>
* <li>Calls {@link #prepareContext(GenericApplicationContext)} to * <li>Calls {@link #prepareContext()} to allow for customizing the context
* prepare the context.</li> * before bean definitions are loaded.</li>
* <li>Calls {@link #customizeBeanFactory(DefaultListableBeanFactory)} to * <li>Calls {@link #customizeBeanFactory()} to allow for customizing the
* allow for customizing the context's <code>DefaultListableBeanFactory</code>.</li> * context's <code>DefaultListableBeanFactory</code>.</li>
* <li>Delegates to {@link #loadBeanDefinitions()} to populate the context * <li>Delegates to {@link #loadBeanDefinitions()} to populate the context
* from the configuration locations or classes in the supplied * from the configuration locations or classes in the supplied
* <code>MergedContextConfiguration</code>.</li> * <code>MergedContextConfiguration</code>.</li>
* <li>Delegates to {@link AnnotationConfigUtils} for * <li>Delegates to {@link AnnotationConfigUtils} for
* {@link AnnotationConfigUtils#registerAnnotationConfigProcessors registering} * {@link AnnotationConfigUtils#registerAnnotationConfigProcessors registering}
* annotation configuration processors.</li> * annotation configuration processors.</li>
* <li>Calls {@link #customizeContext(GenericApplicationContext)} to allow * <li>Calls {@link #customizeContext()} to allow for customizing the context
* for customizing the context before it is refreshed.</li> * before it is refreshed.</li>
* <li>{@link ConfigurableApplicationContext#refresh Refreshes} the * <li>{@link ConfigurableApplicationContext#refresh Refreshes} the
* context and registers a JVM shutdown hook for it.</li> * context and registers a JVM shutdown hook for it.</li>
* </ul> * </ul>
@ -110,18 +110,18 @@ public abstract class AbstractGenericContextLoader extends AbstractContextLoader
* <p>Implementation details: * <p>Implementation details:
* <ul> * <ul>
* <li>Creates a {@link GenericApplicationContext} instance.</li> * <li>Creates a {@link GenericApplicationContext} instance.</li>
* <li>Calls {@link #prepareContext(GenericApplicationContext)} to * <li>Calls {@link #prepareContext()} to allow for customizing the context
* prepare the context.</li> * before bean definitions are loaded.</li>
* <li>Calls {@link #customizeBeanFactory(DefaultListableBeanFactory)} to * <li>Calls {@link #customizeBeanFactory()} to allow for customizing the
* allow for customizing the context's <code>DefaultListableBeanFactory</code>.</li> * context's <code>DefaultListableBeanFactory</code>.</li>
* <li>Delegates to {@link #createBeanDefinitionReader()} to create a * <li>Delegates to {@link #createBeanDefinitionReader()} to create a
* {@link BeanDefinitionReader} which is then used to populate the context * {@link BeanDefinitionReader} which is then used to populate the context
* from the specified config locations.</li> * from the specified config locations.</li>
* <li>Delegates to {@link AnnotationConfigUtils} for * <li>Delegates to {@link AnnotationConfigUtils} for
* {@link AnnotationConfigUtils#registerAnnotationConfigProcessors registering} * {@link AnnotationConfigUtils#registerAnnotationConfigProcessors registering}
* annotation configuration processors.</li> * annotation configuration processors.</li>
* <li>Calls {@link #customizeContext(GenericApplicationContext)} to allow * <li>Calls {@link #customizeContext()} to allow for customizing the context
* for customizing the context before it is refreshed.</li> * before it is refreshed.</li>
* <li>{@link ConfigurableApplicationContext#refresh Refreshes} the * <li>{@link ConfigurableApplicationContext#refresh Refreshes} the
* context and registers a JVM shutdown hook for it.</li> * context and registers a JVM shutdown hook for it.</li>
* </ul> * </ul>

View File

@ -51,7 +51,7 @@ import org.springframework.util.ObjectUtils;
* @author Sam Brannen * @author Sam Brannen
* @since 3.1 * @since 3.1
* @see #processContextConfiguration() * @see #processContextConfiguration()
* @see #generateDefaultConfigurationClasses() * @see #detectDefaultConfigurationClasses()
* @see #loadBeanDefinitions() * @see #loadBeanDefinitions()
*/ */
public class AnnotationConfigContextLoader extends AbstractGenericContextLoader { public class AnnotationConfigContextLoader extends AbstractGenericContextLoader {
@ -65,18 +65,20 @@ public class AnnotationConfigContextLoader extends AbstractGenericContextLoader
* Process configuration classes in the supplied {@link ContextConfigurationAttributes}. * Process configuration classes in the supplied {@link ContextConfigurationAttributes}.
* <p>If the configuration classes are <code>null</code> or empty and * <p>If the configuration classes are <code>null</code> or empty and
* {@link #isGenerateDefaultLocations()} returns <code>true</code>, this * {@link #isGenerateDefaultLocations()} returns <code>true</code>, this
* <code>SmartContextLoader</code> will attempt to * <code>SmartContextLoader</code> will attempt to {@link
* {@link #generateDefaultConfigurationClasses generate default configuration classes}. * #detectDefaultConfigurationClasses detect default configuration classes}.
* Otherwise, properties in the supplied configuration attributes will not * If defaults are detected they will be
* be modified. * {@link ContextConfigurationAttributes#setClasses(Class[]) set} in the
* supplied configuration attributes. Otherwise, properties in the supplied
* configuration attributes will not be modified.
* @param configAttributes the context configuration attributes to process * @param configAttributes the context configuration attributes to process
* @see org.springframework.test.context.SmartContextLoader#processContextConfiguration() * @see org.springframework.test.context.SmartContextLoader#processContextConfiguration()
* @see #isGenerateDefaultLocations() * @see #isGenerateDefaultLocations()
* @see #generateDefaultConfigurationClasses() * @see #detectDefaultConfigurationClasses()
*/ */
public void processContextConfiguration(ContextConfigurationAttributes configAttributes) { public void processContextConfiguration(ContextConfigurationAttributes configAttributes) {
if (ObjectUtils.isEmpty(configAttributes.getClasses()) && isGenerateDefaultLocations()) { if (ObjectUtils.isEmpty(configAttributes.getClasses()) && isGenerateDefaultLocations()) {
Class<?>[] defaultConfigClasses = generateDefaultConfigurationClasses(configAttributes.getDeclaringClass()); Class<?>[] defaultConfigClasses = detectDefaultConfigurationClasses(configAttributes.getDeclaringClass());
configAttributes.setClasses(defaultConfigClasses); configAttributes.setClasses(defaultConfigClasses);
} }
} }
@ -108,24 +110,23 @@ public class AnnotationConfigContextLoader extends AbstractGenericContextLoader
} }
/** /**
* Generate the default configuration class array for the supplied test class. * Detect the default configuration classes for the supplied test class.
* <p>The generated class array will contain all static inner classes of * <p>The returned class array will contain all static inner classes of
* the supplied class that meet the requirements for {@code @Configuration} * the supplied class that meet the requirements for {@code @Configuration}
* class implementations as specified in the documentation for * class implementations as specified in the documentation for
* {@link Configuration @Configuration}. * {@link Configuration @Configuration}.
* <p>The implementation of this method adheres to the contract defined in the * <p>The implementation of this method adheres to the contract defined in the
* {@link org.springframework.test.context.SmartContextLoader SmartContextLoader} * {@link org.springframework.test.context.SmartContextLoader SmartContextLoader}
* SPI. Specifically, this method will <em>preemptively</em> verify that the * SPI. Specifically, this method uses introspection to detect default
* generated default configuration classes exist <b>and</b> that such classes * configuration classes that comply with the constraints required of
* comply with the constraints required of {@code @Configuration} class * {@code @Configuration} class implementations. If a potential candidate
* implementations. If a candidate configuration class does meet these * configuration class does meet these requirements, this method will log a
* requirements, this method will log a warning, and the candidate class will * warning, and the potential candidate class will be ignored.
* be ignored.
* @param declaringClass the test class that declared {@code @ContextConfiguration} * @param declaringClass the test class that declared {@code @ContextConfiguration}
* @return an array of default configuration classes, potentially empty but * @return an array of default configuration classes, potentially empty but
* never <code>null</code> * never <code>null</code>
*/ */
protected Class<?>[] generateDefaultConfigurationClasses(Class<?> declaringClass) { protected Class<?>[] detectDefaultConfigurationClasses(Class<?> declaringClass) {
Assert.notNull(declaringClass, "Declaring class must not be null"); Assert.notNull(declaringClass, "Declaring class must not be null");
List<Class<?>> configClasses = new ArrayList<Class<?>>(); List<Class<?>> configClasses = new ArrayList<Class<?>>();

View File

@ -33,47 +33,47 @@ public class AnnotationConfigContextLoaderTests {
@Test @Test
public void generateDefaultConfigurationClassesForAnnotatedInnerClass() { public void detectDefaultConfigurationClassesForAnnotatedInnerClass() {
Class<?>[] configClasses = contextLoader.generateDefaultConfigurationClasses(ContextConfigurationInnerClassTestCase.class); Class<?>[] configClasses = contextLoader.detectDefaultConfigurationClasses(ContextConfigurationInnerClassTestCase.class);
assertNotNull(configClasses); assertNotNull(configClasses);
assertEquals("annotated static ContextConfiguration should be considered.", 1, configClasses.length); assertEquals("annotated static ContextConfiguration should be considered.", 1, configClasses.length);
configClasses = contextLoader.generateDefaultConfigurationClasses(AnnotatedFooConfigInnerClassTestCase.class); configClasses = contextLoader.detectDefaultConfigurationClasses(AnnotatedFooConfigInnerClassTestCase.class);
assertNotNull(configClasses); assertNotNull(configClasses);
assertEquals("annotated static FooConfig should be considered.", 1, configClasses.length); assertEquals("annotated static FooConfig should be considered.", 1, configClasses.length);
} }
@Test @Test
public void generateDefaultConfigurationClassesForMultipleAnnotatedInnerClasses() { public void detectDefaultConfigurationClassesForMultipleAnnotatedInnerClasses() {
Class<?>[] configClasses = contextLoader.generateDefaultConfigurationClasses(MultipleStaticConfigurationClassesTestCase.class); Class<?>[] configClasses = contextLoader.detectDefaultConfigurationClasses(MultipleStaticConfigurationClassesTestCase.class);
assertNotNull(configClasses); assertNotNull(configClasses);
assertEquals("multiple annotated static classes should be considered.", 2, configClasses.length); assertEquals("multiple annotated static classes should be considered.", 2, configClasses.length);
} }
@Test @Test
public void generateDefaultConfigurationClassesForNonAnnotatedInnerClass() { public void detectDefaultConfigurationClassesForNonAnnotatedInnerClass() {
Class<?>[] configClasses = contextLoader.generateDefaultConfigurationClasses(PlainVanillaFooConfigInnerClassTestCase.class); Class<?>[] configClasses = contextLoader.detectDefaultConfigurationClasses(PlainVanillaFooConfigInnerClassTestCase.class);
assertNotNull(configClasses); assertNotNull(configClasses);
assertEquals("non-annotated static FooConfig should NOT be considered.", 0, configClasses.length); assertEquals("non-annotated static FooConfig should NOT be considered.", 0, configClasses.length);
} }
@Test @Test
public void generateDefaultConfigurationClassesForFinalAnnotatedInnerClass() { public void detectDefaultConfigurationClassesForFinalAnnotatedInnerClass() {
Class<?>[] configClasses = contextLoader.generateDefaultConfigurationClasses(FinalConfigInnerClassTestCase.class); Class<?>[] configClasses = contextLoader.detectDefaultConfigurationClasses(FinalConfigInnerClassTestCase.class);
assertNotNull(configClasses); assertNotNull(configClasses);
assertEquals("final annotated static Config should NOT be considered.", 0, configClasses.length); assertEquals("final annotated static Config should NOT be considered.", 0, configClasses.length);
} }
@Test @Test
public void generateDefaultConfigurationClassesForPrivateAnnotatedInnerClass() { public void detectDefaultConfigurationClassesForPrivateAnnotatedInnerClass() {
Class<?>[] configClasses = contextLoader.generateDefaultConfigurationClasses(PrivateConfigInnerClassTestCase.class); Class<?>[] configClasses = contextLoader.detectDefaultConfigurationClasses(PrivateConfigInnerClassTestCase.class);
assertNotNull(configClasses); assertNotNull(configClasses);
assertEquals("private annotated inner classes should NOT be considered.", 0, configClasses.length); assertEquals("private annotated inner classes should NOT be considered.", 0, configClasses.length);
} }
@Test @Test
public void generateDefaultConfigurationClassesForNonStaticAnnotatedInnerClass() { public void detectDefaultConfigurationClassesForNonStaticAnnotatedInnerClass() {
Class<?>[] configClasses = contextLoader.generateDefaultConfigurationClasses(NonStaticConfigInnerClassesTestCase.class); Class<?>[] configClasses = contextLoader.detectDefaultConfigurationClasses(NonStaticConfigInnerClassesTestCase.class);
assertNotNull(configClasses); assertNotNull(configClasses);
assertEquals("non-static annotated inner classes should NOT be considered.", 0, configClasses.length); assertEquals("non-static annotated inner classes should NOT be considered.", 0, configClasses.length);
} }