Generated by
JDiff

org.springframework.test.context Documentation Differences

This file contains all the changes in documentation in the package org.springframework.test.context as colored differences. Deletions are shown like this, and additions are shown like this.
If no deletions or additions are shown in an entry, the HTML tags will be what has changed. The new HTML tags are shown in the differences. If no documentation existed, and then some was added in a later version, this change is noted in the appropriate class pages of differences, but the change is not shown on this page. Only changes in existing text are shown here. Similarly, documentation which was inherited from another class or interface is not shown here.
Note that an HTML error in the new documentation may cause the display of other documentation changes to be presented incorrectly. For instance, failure to close a <code> tag will cause all subsequent paragraphs to be displayed differently.

Class ContextConfiguration

{@code @ContextConfiguration} defines class-level metadata that is used to determine how to load and configure an ApplicationContext for test classesintegration tests.

Supported Resource Types

Prior to Spring 3.1, only path-based resource locations were supported. As of Spring 3.1, #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 .locations or .value attribute) or configurationannotated classes (via the .classes attribute).

Annotated Classes

The term annotated class can refer to any of the following.

Consult the Javadoc for @Configuration and @Bean for further information regarding the configuration and semantics of annotated classes. @author Sam Brannen @since 2.5 @see ContextLoader @see SmartContextLoader @see ContextConfigurationAttributes @see MergedContextConfiguration @see ActiveProfiles @see org.springframework.context.ApplicationContext @see ActiveProfilesApplicationContext

Class ContextConfigurationAttributes

{@code ContextConfigurationAttributes} encapsulates the context context configuration attributes declared on a test class via @ContextConfiguration. @author Sam Brannen @since 3.1 @see ContextConfiguration @see SmartContextLoader#processContextConfiguration(ContextConfigurationAttributes) @see MergedContextConfiguration
Class ContextConfigurationAttributes, constructor ContextConfigurationAttributes(Class<?>, ContextConfiguration)

Construct a new ContextConfigurationAttributes instance for the supplied @ContextConfiguration annotation and the Class test class that declared it. @param declaringClass the test class that declared {@code @ContextConfiguration} @param contextConfiguration the annotation from which to retrieve the attributes
Class ContextConfigurationAttributes, constructor ContextConfigurationAttributes(Class<?>, String[], Class[], boolean, Class<ContextLoader>)

Construct a new ContextConfigurationAttributes instance for the Class test class that declared the @ContextConfiguration annotation and its corresponding attributes. @param declaringClass the test class that declared {@code @ContextConfiguration} @param locations the resource locations declared via {@code @ContextConfiguration} @param classes the configurationannotated classes declared via {@code @ContextConfiguration} @param inheritLocations the {@code inheritLocations} flag declared via {@code @ContextConfiguration} @param contextLoaderClass the {@code ContextLoader} class declared via {@code @ContextConfiguration} @throws IllegalArgumentException if the {@code declaringClass} or {@code contextLoaderClass} is {@code null}, or if the {@code locations} and {@code classes} are both non-emptyempty @deprecated as of Spring 3.2, use .ContextConfigurationAttributes(Class, String[], Class[], boolean, Class[], boolean, Class) instead
Class ContextConfigurationAttributes, Class[] getClasses()

Get the configurationannotated classes that were declared via @ContextConfiguration.

Note: this is a mutable property. The returned value may therefore represent a processed value that does not match the original value value declared via @ContextConfiguration. @return the configurationannotated classes; potentially {@code null} or empty @see ContextConfiguration#classes @see #setClasses(Class[])

Class ContextConfigurationAttributes, Class<ContextLoader> getContextLoaderClass()

Get the {@code ContextLoader} class that was declared via @ContextConfiguration. @return the {@code ContextLoader} class @see ContextConfiguration#loader
Class ContextConfigurationAttributes, Class<?> getDeclaringClass()

Get the Class class that declared the @ContextConfiguration annotation. @return the declaring class; never {@code null}
Class ContextConfigurationAttributes, String[] getLocations()

Get the resource locations that were declared via @ContextConfiguration.

Note: this is a mutable property. The returned value may therefore represent a processed value that does not match the original value value declared via @ContextConfiguration. @return the resource locations; potentially {@code null} or empty @see ContextConfiguration#value @see ContextConfiguration#locations @see #setLocations(String[])

Class ContextConfigurationAttributes, boolean hasClasses()

Determine if this {@code ContextConfigurationAttributes} instance hashas class-based resources. @return {@code true} if the classes array is not empty @see #hasResources() @see #hasLocations()
Class ContextConfigurationAttributes, boolean hasLocations()

Determine if this {@code ContextConfigurationAttributes} instance hashas path-based resource locations. @return {@code true} if the locations array is not empty @see #hasResources() @see #hasClasses()
Class ContextConfigurationAttributes, boolean hasResources()

Determine if this {@code ContextConfigurationAttributes} instance hashas either path-based resource locations or class-based resources. @return {@code true} if either the locations or the classes array is not empty @see #hasLocations() @see #hasClasses()
Class ContextConfigurationAttributes, boolean isInheritLocations()

Get the {@code inheritLocations} flag that was declared via @ContextConfiguration. @return the {@code inheritLocations} flag @see ContextConfiguration#inheritLocations
Class ContextConfigurationAttributes, void setClasses(Class[])

Set the processed configurationannotated classes, effectively overriding the original value declared via @ContextConfiguration. @see #getClasses()
Class ContextConfigurationAttributes, void setLocations(String[])

Set the processed resource locations, effectively overriding the original value declared via @ContextConfiguration. @see #getLocations()

Class ContextLoader

Strategy interface for loading an application context for an integration test managed by the Spring TestContext Framework.

Note: as of Spring 3.1, implement SmartContextLoader instead of this interface in order to provide support for configurationannotated classes and , activeactive bean definition profiles, and application context initializers.

Clients of a ContextLoader should call processLocations() prior to calling loadContext() in case the ContextLoader provides custom support for modifying or generating locations. The results of processLocations() should then be supplied to loadContext().

Concrete implementations must provide a public no-args constructor.

Spring provides the following out-of-the-box implementations:

@author Sam Brannen @author Juergen Hoeller @since 2.5 @see SmartContextLoader @see org.springframework.test.context.support.AnnotationConfigContextLoader AnnotationConfigContextLoader
Class ContextLoader, ApplicationContext loadContext(String[])

Loads a new context based on the supplied locations, configures the context, and finally returns the context in fully refreshed state.

Configuration locations are generally considered to be classpath resources by default.

Concrete implementations should register annotation configuration processors with bean factories of application contexts loaded by this ContextLoader. Beans will therefore automatically be candidates for annotation-based dependency injection using @Autowired, @Resource, and @Inject.

Any ApplicationContext loaded by a ContextLoader must register a JVM shutdown hook for itself. Unless the context gets closed early, all context instances will be automatically closed on JVM shutdown. This allows for freeing external resources held by beans within the context, e.g. temporary files. @param locations the resource locations to use to load the application context @return a new application context @throws Exception if context loading failed

Class ContextLoader, String[] processLocations(Class<?>, String[])

Processes application context resource locations for a specified class.

Concrete implementations may choose to modify the supplied locations, generate new locations, or simply return the supplied locations unchanged. @param clazz the class with which the locations are associated: used to determine how to process the supplied locations @param locations the unmodified locations to use for loading the application context (can be null or empty) @return an array of application context resource locations


Class MergedContextConfiguration

{@code MergedContextConfiguration} encapsulates the merged context configuration declared on a test class and all of its superclasses via @ContextConfiguration and @ActiveProfiles.

Merged resource locations, configurationannotated classes, and active profiles represent all declared values in the test class hierarchy taking into consideration the semantics of the inheritLocations and inheritProfiles flags in {@code @ContextConfiguration} and {@code @ActiveProfiles}, respectively.

A SmartContextLoader uses {@code MergedContextConfiguration} to load an ApplicationContext.

{@code MergedContextConfiguration} is also used by the TestContext as the context cache key for caching an ApplicationContext that was loaded using properties of this {@code MergedContextConfiguration}. @author Sam Brannen @since 3.1 @see ContextConfiguration @see ActiveProfiles @see ContextConfigurationAttributes @see SmartContextLoader#loadContext(MergedContextConfiguration)

Class MergedContextConfiguration, constructor MergedContextConfiguration(Class<?>, String[], Class[], String[], ContextLoader)

Create a new {@code MergedContextConfiguration} instance for the supplied test class, resource locations, configuration annotated classes, activeactive profiles, and {@code ContextLoader}.

If a null value is supplied for locations, classes, or activeProfiles an empty array will be stored instead. Furthermore, active profiles will be sorted, and duplicate profiles will be removed. @param testClass the test class for which the configuration was merged @param locations the merged resource locations @param classes the merged configurationannotated classes @param activeProfiles the merged active bean definition profiles @param contextLoader the resolved ContextLoader @see #MergedContextConfiguration(Class, String[], Class[], Set, String[], ContextLoader)

Class MergedContextConfiguration, boolean equals(Object)

Determine if the supplied object is equal to this {@code MergedContextConfiguration} instance by comparing both object's #getLocations() locations, #getClasses() annotated classes, configuration#getContextInitializerClasses() context initializer classes, #getActiveProfiles() active profiles, and the fully qualifiedqualified names of their their ContextLoaders.
Class MergedContextConfiguration, String[] getActiveProfiles()

Get the merged active bean definition profiles for the the #getTestClass() test class.
Class MergedContextConfiguration, Class[] getClasses()

Get the merged configurationannotated classes for the the #getTestClass() test class.
Class MergedContextConfiguration, ContextLoader getContextLoader()

Get the resolved ContextLoader for the the #getTestClass() test class.
Class MergedContextConfiguration, String[] getLocations()

Get the merged resource locations for the the #getTestClass() test class.
Class MergedContextConfiguration, Class<?> getTestClass()

Get the Class test class associated with this this {@code MergedContextConfiguration}.
Class MergedContextConfiguration, int hashCode()

Generate a unique hash code for all properties of this {@code MergedContextConfiguration} excluding the #getTestClass() test class.
Class MergedContextConfiguration, String toString()

Provide a String representation of the #getTestClass() test class, #getLocations() locations, #getClasses() annotated classes, configuration#getContextInitializerClasses() context initializer classes, #getActiveProfiles() active profiles, and the name of the ContextLoader.

Class SmartContextLoader

Strategy interface for loading an application context for an integration test managed by the Spring TestContext Framework.

The {@code SmartContextLoader} SPI supersedes the ContextLoader SPI introduced in Spring 2.5: a {@code SmartContextLoader} can choose to process either resource locations or configurationannotated classes. Furthermore, a {@code SmartContextLoader} can set active bean definition profiles in the context that it loads (see MergedContextConfiguration.getActiveProfiles() and .loadContext(MergedContextConfiguration)).

See the Javadoc for @ContextConfiguration for a definition of annotated class.

Clients of a {@code SmartContextLoader} should call processContextConfiguration() prior to calling loadContext(). This gives a {@code SmartContextLoader} the opportunity to provide custom support for modifying resource locations or detecting default resource locations or or default configuration classes. The results of processContextConfiguration() should be merged for all classes in the hierarchy of the root test class and then supplied to loadContext().

Even though {@code SmartContextLoader} extends {@code ContextLoader}, clients should favor {@code SmartContextLoader}-specific methods over those defined in {@code ContextLoader}, particularly because a {@code SmartContextLoader} may choose not to support methods defined in the {@code ContextLoader} SPI.

Concrete implementations must provide a public no-args constructor.

Spring provides the following out-of-the-box implementations:

@author Sam Brannen @since 3.1 @see ContextConfiguration @see ActiveProfiles @see ContextConfigurationAttributes @see MergedContextConfiguration
Class SmartContextLoader, ApplicationContext loadContext(MergedContextConfiguration)

Loads a new context based on the supplied merged context configuration, configures the context, and finally returns the context in a fully refreshed state.

Concrete implementations should register annotation configuration processors with bean factories of application contexts loaded by this {@code SmartContextLoader}. Beans will therefore automatically be candidates for annotation-based dependency injection using @Autowired, @Resource, and @Inject. In addition, concrete implementations should set the active bean definition profiles in the context'ss Environment.

Any ApplicationContext loaded by a {@code SmartContextLoader} must register a JVM shutdown hook for itself. Unless the context gets closed early, all context instances will be automatically closed on JVM shutdown. This allows for freeing of external resources held by beans within the context (e.g., temporary files). @param mergedConfig the merged context configuration to use to load the application context @return a new application context @throws Exception if context loading failed @see #processContextConfiguration(ContextConfigurationAttributes) @see org.springframework.context.annotation.AnnotationConfigUtilsAnnotationConfigUtils #registerAnnotationConfigProcessors(org.springframework.beans.factory.support.BeanDefinitionRegistry) @see org.springframework.test.context.MergedContextConfiguration#getActiveProfiles() @see org.springframework.context.ConfigurableApplicationContext#getEnvironment()