Generated by
JDiff

org.springframework.test.context.support Documentation Differences

This file contains all the changes in documentation in the package org.springframework.test.context.support 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 AbstractContextLoader

Abstract application context loader that provides a basis for all concrete implementations of the ContextLoader SPI. Provides a Template Method based approach for processing resource locations.

As of Spring 3.1, AbstractContextLoader also provides a basis for all concrete implementations of the SmartContextLoader SPI. For backwards compatibility with the {@code ContextLoader} SPI, .processContextConfiguration(ContextConfigurationAttributes) delegatesdelegates to .processLocations(Class, String...). @author Sam Brannen @author Juergen Hoeller @since 2.5 @see #generateDefaultLocations @see #modifyLocations

Class AbstractContextLoader, String[] generateDefaultLocations(Class<?>)

Generate the default classpath resource locations array based on the supplied class.

For example, if the supplied class is com.example.MyTest, the generated locations will contain a single string with a value of "classpath:/com/example/MyTest<suffix>", where <suffix> is the value of the resource suffix string.

As of Spring 3.1, the implementation of this method adheres to the contract defined in the SmartContextLoader SPI. Specifically, this method will preemptively verify that the generated default location actually exists. If it does not exist, this method will log a warning and return an empty array.

Subclasses can override this method to implement a different default location generation strategy. @param clazz the class for which the default locations are to be generated @return an array of default application context resource locations @since 2.5 @see #getResourceSuffix()

Class AbstractContextLoader, String getResourceSuffix()

Get the suffix to append to ApplicationContext resource locationsresource locations when generating default locations.

Must be implemented by subclasses. @return the resource suffix; should not be null or empty @since 2.5 @see #generateDefaultLocations(Class)

Class AbstractContextLoader, boolean isGenerateDefaultLocations()

Determine whether or not default resource locations should be generated if the locations provided to .processLocations(Class, String...) are null or empty.

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 to determine whether or not default configuration classes should be detected if the classes present in the configuration attributes supplied to .processContextConfiguration(ContextConfigurationAttributes) are null or empty.

Can be overridden by subclasses to change the default behavior. @return always true by default @since 2.5

Class AbstractContextLoader, String[] modifyLocations(Class<?>, String[])

Generate a modified version of the supplied locations array and return it.

A plain path — for example, "context.xml" — will be treated as a classpath resource that is relative to the package in which the specified class is defined. A path starting with a slash is treated as an absolute classpath location, for example: "/org/springframework/whatever/foo.xml". A path which references a URL (e.g., a path prefixed with classpath:, file:, http:, etc.) will be added to the results unchanged.

Subclasses can override this method to implement a different location modification strategy. @param clazz the class with which the locations are associated @param locations the resource locations to be modified @return an array of modified application context resource locations @since 2.5

Class AbstractContextLoader, void processContextConfiguration(ContextConfigurationAttributes)

For backwards compatibility with the ContextLoader SPI, the default implementation simply delegates to .processLocations(Class, String...), passing it the declaring class and resource locations retrieved from the supplied configuration attributes. The processed locations are then set in the supplied configuration attributes.

Can be overridden in subclasses — for example, to process configurationannotated classes instead of resource locations. @since 3.1 @see #processLocations(Class, String...)

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

If the supplied locations are null or empty and .isGenerateDefaultLocations() returns true, default locations will be generated for the specified class and the configured resource suffix; otherwise, the supplied locations will be modified if necessary and returned. @param clazz the class with which the locations are associated: to be used when generating default locations @param locations the unmodified locations to use for loading the application context (can be null or empty) @return a processed array of application context resource locations @since 2.5 @see #isGenerateDefaultLocations() @see #generateDefaultLocations(Class) @see #modifyLocations(Class, String...) @see org.springframework.test.context.ContextLoader#processLocations(Class, String...) @see #processContextConfiguration(ContextConfigurationAttributes)

Class AbstractGenericContextLoader

Abstract, generic extension of AbstractContextLoader that loads a GenericApplicationContext.

Concrete subclasses must provide an appropriate implementation of createBeanDefinitionReader(), potentially overriding loadBeanDefinitions() as well. @author Sam Brannen @author Juergen Hoeller @since 2.5 @see #loadContext(MergedContextConfiguration) @see #loadContext(String...)

Class AbstractGenericContextLoader, BeanDefinitionReader createBeanDefinitionReader(GenericApplicationContext)

Factory method for creating a new BeanDefinitionReader for loading bean definitions into the supplied context. @param context the context for which the BeanDefinitionReader should be created @return a BeanDefinitionReader for the supplied context @see #loadContext(String...) @see #loadBeanDefinitions @see BeanDefinitionReader @since 2.5
Class AbstractGenericContextLoader, void customizeBeanFactory(DefaultListableBeanFactory)

Customize the internal bean factory of the ApplicationContext created by this ContextLoader.

The default implementation is empty but can be overridden in subclasses to customize DefaultListableBeanFactory's standard settings. @param beanFactory the bean factory created by this ContextLoader @see #loadContext(MergedContextConfiguration) @see #loadContext(String...) @see DefaultListableBeanFactory#setAllowBeanDefinitionOverriding @see DefaultListableBeanFactory#setAllowEagerClassLoading @see DefaultListableBeanFactory#setAllowCircularReferences @see DefaultListableBeanFactory#setAllowRawInjectionDespiteWrapping @since 2.5

Class AbstractGenericContextLoader, void customizeContext(GenericApplicationContext)

Customize the GenericApplicationContext created by this ContextLoader after bean definitions have been loaded into the context but before the context is refreshed.

The default implementation is empty but can be overridden in subclasses to customize the application context. @param context the newly created application context @see #loadContext(MergedContextConfiguration) @see #loadContext(String...) @since 2.5

Class AbstractGenericContextLoader, void loadBeanDefinitions(GenericApplicationContext, MergedContextConfiguration)

Load bean definitions into the supplied context from the configuration locations or classes in the supplied supplied MergedContextConfiguration.

The default implementation delegates to the BeanDefinitionReader returned by .createBeanDefinitionReader(GenericApplicationContext) to to load the bean definitions.

Subclasses must provide an appropriate implementation of .createBeanDefinitionReader(GenericApplicationContext). Alternatively subclasses may subclasses may provide a no-op implementation of {@code createBeanDefinitionReader()} and override this method to provide a custom strategy for loading or registering bean definitions. @param context the context into which the bean definitions should be loaded @param mergedConfig the merged context configuration configuration @see #loadContext(MergedContextConfiguration) @since 3.1

Class AbstractGenericContextLoader, ConfigurableApplicationContext loadContext(MergedContextConfiguration)

Load a Spring ApplicationContext from the supplied MergedContextConfiguration.

Implementation details:

@return a new application context @see org.springframework.test.context.SmartContextLoader#loadContext(MergedContextConfiguration) @see GenericApplicationContext @since 3.1
Class AbstractGenericContextLoader, ConfigurableApplicationContext loadContext(String[])

Load a Spring ApplicationContext from the supplied locations.

Implementation details:

Note: this method does not provide a means to set active bean definition profiles for the loaded context. See .loadContext(MergedContextConfiguration) and AbstractContextLoader.prepareContext(ConfigurableApplicationContext, MergedContextConfiguration) for an alternative. @return a new application context @see org.springframework.test.context.ContextLoader#loadContext @see GenericApplicationContext @see #loadContext(MergedContextConfiguration) @since 2.5

Class AbstractGenericContextLoader, void prepareContext(GenericApplicationContext)

Prepare the GenericApplicationContext created by this ContextLoader. Called before bean definitions are read.

The default implementation is empty. Can be overridden in subclasses to customize GenericApplicationContext's standard settings. @param context the context that should be prepared @see #loadContext(MergedContextConfiguration) @see #loadContext(String...) @see GenericApplicationContext#setAllowBeanDefinitionOverriding @see GenericApplicationContext#setResourceLoader @see GenericApplicationContext#setId @since 2.5


Class AnnotationConfigContextLoader

Concrete implementation of AbstractGenericContextLoader that loads bean definitions from from configurationannotated classes.

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

Note: AnnotationConfigContextLoader supports supports configurationannotated classes rather than the String-based resource locations defined by the legacy ContextLoader API. Thus, although AnnotationConfigContextLoader extends AbstractGenericContextLoader, AnnotationConfigContextLoader does not support any String-based methods defined by AbstractContextLoader or AbstractGenericContextLoader. Consequently, AnnotationConfigContextLoader should chiefly be considered a SmartContextLoader rather than a ContextLoader. @author Sam Brannen @since 3.1 @see #processContextConfiguration(ContextConfigurationAttributes) @see #detectDefaultConfigurationClasses(Class) @see #loadBeanDefinitions(GenericApplicationContext, MergedContextConfiguration)

Class AnnotationConfigContextLoader, BeanDefinitionReader createBeanDefinitionReader(GenericApplicationContext)

AnnotationConfigContextLoader should be used as a a SmartContextLoader, not as a legacy ContextLoader. Consequently, this method is not supported. @see #loadBeanDefinitions @see AbstractGenericContextLoader#createBeanDefinitionReader @throws UnsupportedOperationException
Class AnnotationConfigContextLoader, Class[] detectDefaultConfigurationClasses(Class<?>)

Detect the default configuration classes for the supplied test class.

The returned class array will contain all static inner classes of the supplied class that meet the requirements for {@code @Configuration} class implementations as specified in the documentation for @Configuration. Thedefault implementation of this method adheres to the contractsimply defined indelegates to the SmartContextLoaderAnnotationConfigContextLoaderUtils.detectDefaultConfigurationClasses(Class) SPI. Specifically, this method uses introspection to detect default configuration classes that comply with the constraints required of {@code @Configuration} class implementations. If a potential candidate configuration class does meet these requirements, this method will log a warning, and the potential candidate class will be ignored. @param declaringClass the test class that declared {@code @ContextConfiguration} @return an array of default configuration classes, potentially empty but never null @see AnnotationConfigContextLoaderUtils

Class AnnotationConfigContextLoader, String[] generateDefaultLocations(Class<?>)

AnnotationConfigContextLoader should be used as a SmartContextLoader, not as a legacy ContextLoader. Consequently, this method is not supported. @see AbstractContextLoader#generateDefaultLocations @throws UnsupportedOperationException
Class AnnotationConfigContextLoader, String getResourceSuffix()

AnnotationConfigContextLoader should be used as a a SmartContextLoader, not as a legacy ContextLoader. Consequently, this method is not supported. @see AbstractContextLoader#getResourceSuffix @throws UnsupportedOperationException
Class AnnotationConfigContextLoader, void loadBeanDefinitions(GenericApplicationContext, MergedContextConfiguration)

Register configuration classes in the supplied context from the classes classes in the supplied MergedContextConfiguration.

Each class must represent an annotated configuration class or component. An AnnotatedBeanDefinitionReader is used to register the appropriate bean definitions.

Note that this method does not call .createBeanDefinitionReader since AnnotatedBeanDefinitionReader is not an instance of BeanDefinitionReader. @param context the context in which the configurationannotated classes should be registered @param mergedConfig the merged configuration from which the classes should be retrieved retrieved @see AbstractGenericContextLoader#loadBeanDefinitions

Class AnnotationConfigContextLoader, String[] modifyLocations(Class<?>, String[])

AnnotationConfigContextLoader should be used as a SmartContextLoader, not as a legacy ContextLoader. Consequently, this method is not supported. @see AbstractContextLoader#modifyLocations @throws UnsupportedOperationException
Class AnnotationConfigContextLoader, void processContextConfiguration(ContextConfigurationAttributes)

Process configurationannotated classes in the supplied ContextConfigurationAttributes.

If the configurationannotated classes are null or empty and .isGenerateDefaultLocations() returns true, this SmartContextLoader will attempt to detect default configuration classes. If defaults are detected they will be 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 @see org.springframework.test.context.SmartContextLoader#processContextConfiguration(ContextConfigurationAttributes) @see #isGenerateDefaultLocations() @see #detectDefaultConfigurationClasses(Class)


Class DelegatingSmartContextLoader

{@code DelegatingSmartContextLoader} is an implementation of the a concrete implementation of SmartContextLoaderAbstractDelegatingSmartContextLoader SPI that delegates to a set of candidate SmartContextLoaders (i.e., a GenericXmlContextLoader and AnnotationConfigContextLoader) to determine which context loader is appropriate for a given test class#s configuration. Each candidate is given a chance to process the ContextConfigurationAttributes for each class in the test class hierarchy that is annotated with @ContextConfiguration, and the candidate that supports the merged, processed configuration will be used to actually load the context. Placing an empty {@code @ContextConfiguration} annotation on a test class signals that default resource locations (i.e., XML configuration files) or default configuration classes should be detected. Furthermore, if a specific ContextLoader or SmartContextLoaderAnnotationConfigContextLoader is not explicitly declared via {@code @ContextConfiguration}, {@code DelegatingSmartContextLoader} will be used as the default loader, thus providing automatic support for either XML configuration files or configuration classes, but not both simultaneously. @author Sam Brannen @since 3.1 @see SmartContextLoader @see AbstractDelegatingSmartContextLoader @see GenericXmlContextLoader @see AnnotationConfigContextLoader
Class DelegatingSmartContextLoader, void processContextConfiguration(ContextConfigurationAttributes)

Delegates to candidate {@code SmartContextLoaders} to process the supplied ContextConfigurationAttributes.

Delegation is based on explicit knowledge of the implementations of of the default loaders for GenericXmlContextLoaderXML configuration files and and AnnotationConfigContextLoaderannotated classes. Specifically, thethe delegation algorithm is as follows:

@param configAttributes the context configuration attributes to process @throws IllegalArgumentException if the supplied configuration attributes are null, or if the supplied configuration attributes include both resource locations and configurationannotated classes @throws IllegalStateException if {@codethe GenericXmlContextLoader}XML-based loader detects default configuration classes; if {@codethe AnnotationConfigContextLoader}annotation-based loader detects default resource locations; if neither candidate loader detects defaults for the supplied context configuration; or if both candidate loaders detect defaults for the supplied context configuration
Class DelegatingSmartContextLoader, String[] processLocations(Class<?>, String[])

{@code DelegatingSmartContextLoaderAbstractDelegatingSmartContextLoader} does not support the ContextLoader.processLocations(Class, String...) method. Call .processContextConfiguration(ContextConfigurationAttributes) instead. @throws UnsupportedOperationException

Class DirtiesContextTestExecutionListener, void dirtyContext(TestContext)

Marks the application context of the supplied test context as dirty, and sets the REINJECT_DEPENDENCIES_ATTRIBUTE in the test context to true .