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
and
@ActiveProfiles
.
Merged resource locations, annotated 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
@ContextConfiguration
and @ActiveProfiles
, respectively.
A SmartContextLoader
uses MergedContextConfiguration
to load an ApplicationContext
.
MergedContextConfiguration
is also used by the TestContext
as the context cache key for caching an
ApplicationContext
that was loaded using properties of this MergedContextConfiguration
.
ContextConfiguration
,
ActiveProfiles
,
ContextConfigurationAttributes
,
SmartContextLoader.loadContext(MergedContextConfiguration)
,
Serialized FormModifier and Type | Field and Description |
---|---|
private java.lang.String[] |
activeProfiles |
private CacheAwareContextLoaderDelegate |
cacheAwareContextLoaderDelegate |
private java.lang.Class<?>[] |
classes |
private java.util.Set<java.lang.Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> |
contextInitializerClasses |
private ContextLoader |
contextLoader |
private static java.lang.Class<?>[] |
EMPTY_CLASS_ARRAY |
private static java.util.Set<java.lang.Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> |
EMPTY_INITIALIZER_CLASSES |
private static java.lang.String[] |
EMPTY_STRING_ARRAY |
private java.lang.String[] |
locations |
private MergedContextConfiguration |
parent |
private static long |
serialVersionUID |
private java.lang.Class<?> |
testClass |
Constructor and Description |
---|
MergedContextConfiguration(java.lang.Class<?> testClass,
java.lang.String[] locations,
java.lang.Class<?>[] classes,
java.util.Set<java.lang.Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> contextInitializerClasses,
java.lang.String[] activeProfiles,
ContextLoader contextLoader)
Create a new
MergedContextConfiguration instance for the
supplied test class, resource locations, annotated classes, context
initializers, active profiles, and ContextLoader . |
MergedContextConfiguration(java.lang.Class<?> testClass,
java.lang.String[] locations,
java.lang.Class<?>[] classes,
java.util.Set<java.lang.Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> contextInitializerClasses,
java.lang.String[] activeProfiles,
ContextLoader contextLoader,
CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate,
MergedContextConfiguration parent)
Create a new
MergedContextConfiguration instance for the
supplied test class, resource locations, annotated classes, context
initializers, active profiles, ContextLoader , and parent
configuration. |
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 test class, resource locations, annotated classes, active
profiles, and ContextLoader . |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj)
Determine if the supplied object is equal to this
MergedContextConfiguration
instance by comparing both object's locations,
annotated classes,
context initializer classes,
active profiles,
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<java.lang.Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> |
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 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.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 resource locations. |
boolean |
hasResources()
Determine if this
MergedContextConfiguration instance has
either path-based resource locations or class-based resources. |
protected static java.lang.String |
nullSafeToString(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 loaded is null . |
private static java.lang.String[] |
processActiveProfiles(java.lang.String[] activeProfiles) |
private static java.lang.Class<?>[] |
processClasses(java.lang.Class<?>[] classes) |
private static java.util.Set<java.lang.Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> |
processContextInitializerClasses(java.util.Set<java.lang.Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> contextInitializerClasses) |
private static java.lang.String[] |
processLocations(java.lang.String[] locations) |
java.lang.String |
toString()
Provide a String representation of the test class,
locations, annotated classes,
context initializer classes,
active profiles, the name of the
ContextLoader , and the
parent configuration. |
private static final long serialVersionUID
private static final java.lang.String[] EMPTY_STRING_ARRAY
private static final java.lang.Class<?>[] EMPTY_CLASS_ARRAY
private static final java.util.Set<java.lang.Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> EMPTY_INITIALIZER_CLASSES
private final java.lang.Class<?> testClass
private final java.lang.String[] locations
private final java.lang.Class<?>[] classes
private final java.util.Set<java.lang.Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> contextInitializerClasses
private final java.lang.String[] activeProfiles
private final ContextLoader contextLoader
private final CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate
private final MergedContextConfiguration parent
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 test class, resource locations, annotated classes, active
profiles, and 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.
testClass
- the test class for which the configuration was mergedlocations
- the merged resource locationsclasses
- the merged annotated classesactiveProfiles
- the merged active bean definition profilescontextLoader
- the resolved ContextLoader
MergedContextConfiguration(Class, String[], Class[], Set, String[], ContextLoader)
public MergedContextConfiguration(java.lang.Class<?> testClass, java.lang.String[] locations, java.lang.Class<?>[] classes, java.util.Set<java.lang.Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> contextInitializerClasses, java.lang.String[] activeProfiles, ContextLoader contextLoader)
MergedContextConfiguration
instance for the
supplied test class, resource locations, annotated classes, context
initializers, active profiles, and ContextLoader
.
If a null
value is supplied for locations
,
classes
, or activeProfiles
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 resource locationsclasses
- the merged annotated classescontextInitializerClasses
- the merged context initializer classesactiveProfiles
- the merged active bean definition profilescontextLoader
- the resolved ContextLoader
MergedContextConfiguration(Class, String[], Class[], Set, String[], ContextLoader, CacheAwareContextLoaderDelegate, MergedContextConfiguration)
public MergedContextConfiguration(java.lang.Class<?> testClass, java.lang.String[] locations, java.lang.Class<?>[] classes, java.util.Set<java.lang.Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> contextInitializerClasses, java.lang.String[] activeProfiles, ContextLoader contextLoader, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, MergedContextConfiguration parent)
MergedContextConfiguration
instance for the
supplied test class, resource locations, annotated classes, context
initializers, active profiles, ContextLoader
, and parent
configuration.
If a null
value is supplied for locations
,
classes
, or activeProfiles
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 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 parentprivate static java.lang.String[] processLocations(java.lang.String[] locations)
private static java.lang.Class<?>[] processClasses(java.lang.Class<?>[] classes)
private static java.util.Set<java.lang.Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> processContextInitializerClasses(java.util.Set<java.lang.Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> contextInitializerClasses)
private static java.lang.String[] processActiveProfiles(java.lang.String[] activeProfiles)
protected static java.lang.String nullSafeToString(ContextLoader contextLoader)
String
representation of the supplied
ContextLoader
based solely on the fully qualified name of the
loader or "null" if the supplied loaded is null
.public java.lang.Class<?> getTestClass()
MergedContextConfiguration
.public java.lang.String[] getLocations()
public java.lang.Class<?>[] getClasses()
public boolean hasLocations()
MergedContextConfiguration
instance has
path-based 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 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<? extends ConfigurableApplicationContext>>> getContextInitializerClasses()
ApplicationContextInitializer
classes for the
test class.public java.lang.String[] getActiveProfiles()
public ContextLoader getContextLoader()
ContextLoader
for the test class.public MergedContextConfiguration getParent()
MergedContextConfiguration
for the parent application context in a
context hierarchy.null
if there is no parentgetParentApplicationContext()
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 int hashCode()
MergedContextConfiguration
excluding the
test class.hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
MergedContextConfiguration
instance by comparing both object's locations,
annotated classes,
context initializer classes,
active profiles,
parents, and the fully qualified names of their
ContextLoaders
.equals
in class java.lang.Object
public java.lang.String toString()
ContextLoader
, and the
parent configuration.toString
in class java.lang.Object