public interface ContextLoader
application contextfor an integration test managed by the Spring TestContext Framework.
Note: as of Spring 3.1, implement
of this interface in order to provide support for annotated classes, active
bean definition profiles, and application context initializers.
Clients of a ContextLoader should call
processLocations() prior to
loadContext() in case the
ContextLoader provides custom support for modifying or generating locations.
The results of
should then be supplied to
Concrete implementations must provide a
Spring provides the following out-of-the-box implementations:
|Modifier and Type||Method and Description|
Loads a new
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.
clazz- the class with which the locations are associated: used to determine how to process the supplied locations
locations- the unmodified locations to use for loading the application context (can be
contextbased 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
contexts loaded by this ContextLoader. Beans will therefore automatically
be candidates for annotation-based dependency injection using
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.
locations- the resource locations to use to load the application context
Exception- if context loading failed