public class MergedContextConfiguration
extends java.lang.Object
implements java.io.Serializable
MergedContextConfiguration
encapsulates the merged
context configuration declared on a test class and all of its superclasses
via @ContextConfiguration
,
@ActiveProfiles
, and
@TestPropertySource
.
Merged context resource locations, annotated classes, active profiles,
property resource locations, and in-lined properties represent all declared
values in the test class hierarchy taking into consideration the semantics
of the ContextConfiguration.inheritLocations()
,
ActiveProfiles.inheritProfiles()
,
TestPropertySource.inheritLocations()
, and
TestPropertySource.inheritProperties()
flags.
A SmartContextLoader
uses MergedContextConfiguration
to load an ApplicationContext
.
MergedContextConfiguration
is also used by the
ContextCache
as the key for caching an
ApplicationContext
that was loaded using properties of this MergedContextConfiguration
.
ContextConfiguration
,
ContextHierarchy
,
ActiveProfiles
,
TestPropertySource
,
ContextConfigurationAttributes
,
SmartContextLoader.loadContext(MergedContextConfiguration)
,
Serialized FormConstructor and Description |
---|
MergedContextConfiguration(java.lang.Class<?> testClass,
java.lang.String[] locations,
java.lang.Class<?>[] classes,
java.util.Set<java.lang.Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses,
java.lang.String[] activeProfiles,
ContextLoader contextLoader)
Create a new
MergedContextConfiguration instance for the
supplied parameters. |
MergedContextConfiguration(java.lang.Class<?> testClass,
java.lang.String[] locations,
java.lang.Class<?>[] classes,
java.util.Set<java.lang.Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses,
java.lang.String[] activeProfiles,
ContextLoader contextLoader,
CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate,
MergedContextConfiguration parent)
Create a new
MergedContextConfiguration instance for the
supplied parameters. |
MergedContextConfiguration(java.lang.Class<?> testClass,
java.lang.String[] locations,
java.lang.Class<?>[] classes,
java.util.Set<java.lang.Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses,
java.lang.String[] activeProfiles,
java.lang.String[] propertySourceLocations,
java.lang.String[] propertySourceProperties,
ContextLoader contextLoader,
CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate,
MergedContextConfiguration parent)
Create a new
MergedContextConfiguration instance for the
supplied parameters. |
MergedContextConfiguration(java.lang.Class<?> testClass,
java.lang.String[] locations,
java.lang.Class<?>[] classes,
java.util.Set<java.lang.Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses,
java.lang.String[] activeProfiles,
java.lang.String[] propertySourceLocations,
java.lang.String[] propertySourceProperties,
java.util.Set<ContextCustomizer> contextCustomizers,
ContextLoader contextLoader,
CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate,
MergedContextConfiguration parent)
Create a new
MergedContextConfiguration instance for the
supplied parameters. |
MergedContextConfiguration(java.lang.Class<?> testClass,
java.lang.String[] locations,
java.lang.Class<?>[] classes,
java.lang.String[] activeProfiles,
ContextLoader contextLoader)
Create a new
MergedContextConfiguration instance for the
supplied parameters. |
MergedContextConfiguration(MergedContextConfiguration mergedConfig)
Create a new
MergedContextConfiguration instance by copying
all fields from the supplied MergedContextConfiguration . |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object other)
Determine if the supplied object is equal to this
MergedContextConfiguration
instance by comparing both object's locations,
annotated classes,
context initializer classes,
active profiles,
property source locations,
property source properties,
parents, and the fully qualified names of their
ContextLoaders . |
java.lang.String[] |
getActiveProfiles()
Get the merged active bean definition profiles for the
test class.
|
java.lang.Class<?>[] |
getClasses()
Get the merged annotated classes for the test class.
|
java.util.Set<ContextCustomizer> |
getContextCustomizers()
Get the merged
ContextCustomizers that will be applied
when the application context is loaded. |
java.util.Set<java.lang.Class<? extends ApplicationContextInitializer<?>>> |
getContextInitializerClasses()
Get the merged
ApplicationContextInitializer classes for the
test class. |
ContextLoader |
getContextLoader()
Get the resolved
ContextLoader for the test class. |
java.lang.String[] |
getLocations()
Get the merged resource locations for
ApplicationContext
configuration files for the test class. |
MergedContextConfiguration |
getParent()
Get the
MergedContextConfiguration for the parent application context
in a context hierarchy. |
ApplicationContext |
getParentApplicationContext()
Get the parent
ApplicationContext for the context defined by this
MergedContextConfiguration from the context cache. |
java.lang.String[] |
getPropertySourceLocations()
Get the merged resource locations for test
PropertySources
for the test class. |
java.lang.String[] |
getPropertySourceProperties()
Get the merged test
PropertySource properties for the
test class. |
java.lang.Class<?> |
getTestClass()
Get the test class associated with this
MergedContextConfiguration . |
boolean |
hasClasses()
Determine if this
MergedContextConfiguration instance has
class-based resources. |
int |
hashCode()
Generate a unique hash code for all properties of this
MergedContextConfiguration excluding the
test class. |
boolean |
hasLocations()
Determine if this
MergedContextConfiguration instance has
path-based context resource locations. |
boolean |
hasResources()
Determine if this
MergedContextConfiguration instance has
either path-based context resource locations or class-based resources. |
protected static java.lang.String |
nullSafeClassName(ContextLoader contextLoader)
Generate a null-safe
String representation of the supplied
ContextLoader based solely on the fully qualified name of the
loader or "null" if the supplied loader is null . |
java.lang.String |
toString()
Provide a String representation of the test class,
locations, annotated classes,
context initializer classes,
active profiles,
property source locations,
property source properties,
context customizers,
the name of the
ContextLoader , and the
parent configuration. |
public MergedContextConfiguration(java.lang.Class<?> testClass, java.lang.String[] locations, java.lang.Class<?>[] classes, java.lang.String[] activeProfiles, ContextLoader contextLoader)
MergedContextConfiguration
instance for the
supplied parameters.testClass
- the test class for which the configuration was mergedlocations
- the merged context resource locationsclasses
- the merged annotated classesactiveProfiles
- the merged active bean definition profilescontextLoader
- the resolved ContextLoader
public MergedContextConfiguration(java.lang.Class<?> testClass, java.lang.String[] locations, java.lang.Class<?>[] classes, @Nullable java.util.Set<java.lang.Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses, java.lang.String[] activeProfiles, ContextLoader contextLoader)
MergedContextConfiguration
instance for the
supplied parameters.testClass
- the test class for which the configuration was mergedlocations
- the merged context resource locationsclasses
- the merged annotated classescontextInitializerClasses
- the merged context initializer classesactiveProfiles
- the merged active bean definition profilescontextLoader
- the resolved ContextLoader
public MergedContextConfiguration(java.lang.Class<?> testClass, java.lang.String[] locations, java.lang.Class<?>[] classes, @Nullable java.util.Set<java.lang.Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses, java.lang.String[] activeProfiles, ContextLoader contextLoader, @Nullable CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, @Nullable MergedContextConfiguration parent)
MergedContextConfiguration
instance for the
supplied parameters.testClass
- the test class for which the configuration was mergedlocations
- the merged context resource locationsclasses
- the merged annotated classescontextInitializerClasses
- the merged context initializer classesactiveProfiles
- the merged active bean definition profilescontextLoader
- the resolved ContextLoader
cacheAwareContextLoaderDelegate
- a cache-aware context loader
delegate with which to retrieve the parent contextparent
- the parent configuration or null
if there is no parentpublic MergedContextConfiguration(MergedContextConfiguration mergedConfig)
MergedContextConfiguration
instance by copying
all fields from the supplied MergedContextConfiguration
.public MergedContextConfiguration(java.lang.Class<?> testClass, @Nullable java.lang.String[] locations, @Nullable java.lang.Class<?>[] classes, @Nullable java.util.Set<java.lang.Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses, @Nullable java.lang.String[] activeProfiles, @Nullable java.lang.String[] propertySourceLocations, @Nullable java.lang.String[] propertySourceProperties, ContextLoader contextLoader, @Nullable CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, @Nullable MergedContextConfiguration parent)
MergedContextConfiguration
instance for the
supplied parameters.
If a null
value is supplied for locations
,
classes
, activeProfiles
, propertySourceLocations
,
or propertySourceProperties
an empty array will be stored instead.
If a null
value is supplied for the
contextInitializerClasses
an empty set will be stored instead.
Furthermore, active profiles will be sorted, and duplicate profiles
will be removed.
testClass
- the test class for which the configuration was mergedlocations
- the merged context resource locationsclasses
- the merged annotated classescontextInitializerClasses
- the merged context initializer classesactiveProfiles
- the merged active bean definition profilespropertySourceLocations
- the merged PropertySource
locationspropertySourceProperties
- the merged PropertySource
propertiescontextLoader
- the resolved ContextLoader
cacheAwareContextLoaderDelegate
- a cache-aware context loader
delegate with which to retrieve the parent contextparent
- the parent configuration or null
if there is no parentpublic MergedContextConfiguration(java.lang.Class<?> testClass, @Nullable java.lang.String[] locations, @Nullable java.lang.Class<?>[] classes, @Nullable java.util.Set<java.lang.Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses, @Nullable java.lang.String[] activeProfiles, @Nullable java.lang.String[] propertySourceLocations, @Nullable java.lang.String[] propertySourceProperties, @Nullable java.util.Set<ContextCustomizer> contextCustomizers, ContextLoader contextLoader, @Nullable CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, @Nullable MergedContextConfiguration parent)
MergedContextConfiguration
instance for the
supplied parameters.
If a null
value is supplied for locations
,
classes
, activeProfiles
, propertySourceLocations
,
or propertySourceProperties
an empty array will be stored instead.
If a null
value is supplied for contextInitializerClasses
or contextCustomizers
, an empty set will be stored instead.
Furthermore, active profiles will be sorted, and duplicate profiles
will be removed.
testClass
- the test class for which the configuration was mergedlocations
- the merged context resource locationsclasses
- the merged annotated classescontextInitializerClasses
- the merged context initializer classesactiveProfiles
- the merged active bean definition profilespropertySourceLocations
- the merged PropertySource
locationspropertySourceProperties
- the merged PropertySource
propertiescontextCustomizers
- the context customizerscontextLoader
- the resolved ContextLoader
cacheAwareContextLoaderDelegate
- a cache-aware context loader
delegate with which to retrieve the parent contextparent
- the parent configuration or null
if there is no parentpublic java.lang.Class<?> getTestClass()
MergedContextConfiguration
.public java.lang.String[] getLocations()
ApplicationContext
configuration files for the test class.
Context resource locations typically represent XML configuration files or Groovy scripts.
public java.lang.Class<?>[] getClasses()
public boolean hasLocations()
MergedContextConfiguration
instance has
path-based context resource locations.true
if the locations
array is not emptyhasResources()
,
hasClasses()
public boolean hasClasses()
MergedContextConfiguration
instance has
class-based resources.true
if the classes
array is not emptyhasResources()
,
hasLocations()
public boolean hasResources()
MergedContextConfiguration
instance has
either path-based context resource locations or class-based resources.true
if either the locations
or the classes
array is not emptyhasLocations()
,
hasClasses()
public java.util.Set<java.lang.Class<? extends ApplicationContextInitializer<?>>> getContextInitializerClasses()
ApplicationContextInitializer
classes for the
test class.public java.lang.String[] getActiveProfiles()
ActiveProfiles
public java.lang.String[] getPropertySourceLocations()
PropertySources
for the test class.TestPropertySource.locations()
,
Properties
public java.lang.String[] getPropertySourceProperties()
PropertySource
properties for the
test class.
Properties will be loaded into the Environment
's set of
PropertySources
.
TestPropertySource.properties()
,
Properties
public java.util.Set<ContextCustomizer> getContextCustomizers()
ContextCustomizers
that will be applied
when the application context is loaded.public ContextLoader getContextLoader()
ContextLoader
for the test class.@Nullable public MergedContextConfiguration getParent()
MergedContextConfiguration
for the parent application context
in a context hierarchy.null
if there is no parentgetParentApplicationContext()
@Nullable public ApplicationContext getParentApplicationContext()
ApplicationContext
for the context defined by this
MergedContextConfiguration
from the context cache.
If the parent context has not yet been loaded, it will be loaded, stored in the cache, and then returned.
ApplicationContext
or null
if there is no parentgetParent()
public boolean equals(@Nullable java.lang.Object other)
MergedContextConfiguration
instance by comparing both object's locations,
annotated classes,
context initializer classes,
active profiles,
property source locations,
property source properties,
parents, and the fully qualified names of their
ContextLoaders
.equals
in class java.lang.Object
public int hashCode()
MergedContextConfiguration
excluding the
test class.hashCode
in class java.lang.Object
public java.lang.String toString()
ContextLoader
, and the
parent configuration.toString
in class java.lang.Object
protected static java.lang.String nullSafeClassName(@Nullable ContextLoader contextLoader)
String
representation of the supplied
ContextLoader
based solely on the fully qualified name of the
loader or "null" if the supplied loader is null
.