|
Generated by JDiff |
||||||||
PREV PACKAGE NEXT PACKAGE FRAMES NO FRAMES |
This file contains all the changes in documentation in the packageorg.springframework.test.context
as colored differences. Deletions are shownlike 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.
{@code @ContextConfiguration} defines class-level metadata that is used to determine how to load and configure an ApplicationContext fortest 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.
- A class annotated with @Configuration
- A component (i.e., a class annotated with @Component, @Service, @Repository, etc.)
- A JSR-330 compliant class that is annotated with {@code javax.inject} annotations
- Any other class that contains @Bean-methods
ApplicationContext @see ActiveProfilesApplicationContext
{@code ContextConfigurationAttributes} encapsulates theClass ContextConfigurationAttributes, constructor ContextConfigurationAttributes(Class<?>, ContextConfiguration)contextcontext configuration attributes declared on a test class via @ContextConfiguration.@author Sam Brannen @since 3.1 @see ContextConfiguration @see SmartContextLoader#processContextConfiguration(ContextConfigurationAttributes) @see MergedContextConfiguration
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 attributesClass 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.Class ContextConfigurationAttributes, Class[] getClasses()@param declaringClass the test class that declared {@code @ContextConfiguration} @param locations the resource locations declared via {@code @ContextConfiguration} @param classes theconfigurationannotated 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
Get theClass ContextConfigurationAttributes, Class<ContextLoader> getContextLoaderClass()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
valuevalue declared via @ContextConfiguration.@return theconfigurationannotated classes; potentially {@code null} or empty @see ContextConfiguration#classes @see #setClasses(Class[])
Get the {@code ContextLoader} class that was declared via @ContextConfiguration.Class ContextConfigurationAttributes, Class<?> getDeclaringClass()@return the {@code ContextLoader} class @see ContextConfiguration#loader
Get the Class class that declared the @ContextConfiguration annotation.Class ContextConfigurationAttributes, String[] getLocations()@return the declaring class; never {@code null}
Get the resource locations that were declared via @ContextConfiguration.Class ContextConfigurationAttributes, boolean hasClasses()Note: this is a mutable property. The returned value may therefore represent a processed value that does not match the original
valuevalue declared via @ContextConfiguration.@return the resource locations; potentially {@code null} or empty @see ContextConfiguration#value @see ContextConfiguration#locations @see #setLocations(String[])
Determine if this {@code ContextConfigurationAttributes} instanceClass ContextConfigurationAttributes, boolean hasLocations()hashasclass-based resources.@return {@code true} if the classes array is not empty @see #hasResources() @see #hasLocations()
Determine if this {@code ContextConfigurationAttributes} instanceClass ContextConfigurationAttributes, boolean hasResources()hashaspath-based resource locations.@return {@code true} if the locations array is not empty @see #hasResources() @see #hasClasses()
Determine if this {@code ContextConfigurationAttributes} instanceClass ContextConfigurationAttributes, boolean isInheritLocations()hashaseither 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()
Get the {@code inheritLocations} flag that was declared via @ContextConfiguration.Class ContextConfigurationAttributes, void setClasses(Class[])@return the {@code inheritLocations} flag @see ContextConfiguration#inheritLocations
Set the processedClass ContextConfigurationAttributes, void setLocations(String[])configurationannotated classes, effectively overriding the original value declared via @ContextConfiguration.@see #getClasses()
Set the processed resource locations, effectively overriding the original value declared via @ContextConfiguration.@see #getLocations()
Strategy interface for loading an application context for an integration test managed by the Spring TestContext Framework.Class ContextLoader, ApplicationContext loadContext(String[])Note: as of Spring 3.1, implement SmartContextLoader instead of this interface in order to provide support for
configurationannotated classesand,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
Loads a new context based on the suppliedClass ContextLoader, String[] processLocations(Class<?>, String[])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
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 benull
or empty) @return an array of application context resource locations
{@code MergedContextConfiguration} encapsulates the merged context configuration declared on a test class and all of its superclasses via @ContextConfiguration and @ActiveProfiles.Class MergedContextConfiguration, constructor MergedContextConfiguration(Class<?>, String[], Class[], String[], ContextLoader)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)
Create a new {@code MergedContextConfiguration} instance for the supplied test class, resource locations,Class MergedContextConfiguration, boolean equals(Object)configurationannotated classes,activeactive profiles, and {@code ContextLoader}.If a
null
value is supplied forlocations
,classes
, oractiveProfiles
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 mergedconfigurationannotated classes @param activeProfiles the merged active bean definition profiles @param contextLoader the resolvedContextLoader
@see #MergedContextConfiguration(Class, String[], Class[], Set, String[], ContextLoader)
Determine if the supplied object is equal to this {@code MergedContextConfiguration} instance by comparing both object's #getLocations() locations, #getClasses() annotated classes,Class MergedContextConfiguration, String[] getActiveProfiles()configuration#getContextInitializerClasses() context initializer classes, #getActiveProfiles() active profiles, and the fullyqualifiedqualified names oftheirtheir ContextLoaders.
Get the merged active bean definition profiles forClass MergedContextConfiguration, Class[] getClasses()thethe #getTestClass() test class.
Get the mergedClass MergedContextConfiguration, ContextLoader getContextLoader()configurationannotated classes forthethe #getTestClass() test class.
Get the resolved ContextLoader forClass MergedContextConfiguration, String[] getLocations()thethe #getTestClass() test class.
Get the merged resource locations forClass MergedContextConfiguration, Class<?> getTestClass()thethe #getTestClass() test class.
Get the Class test class associated withClass MergedContextConfiguration, int hashCode()thisthis {@code MergedContextConfiguration}.
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.
Strategy interface for loading an application context for an integration test managed by the Spring TestContext Framework.Class SmartContextLoader, ApplicationContext loadContext(MergedContextConfiguration)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
oror 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
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'
ssEnvironment.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()