类 MergedContextConfiguration
- java.lang.Object
- org.springframework.test.context.MergedContextConfiguration
- 所有已实现的接口:
Serializable
public class MergedContextConfiguration extends Object implements 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()
, andTestPropertySource.inheritProperties()
flags.A
SmartContextLoader
usesMergedContextConfiguration
to load anApplicationContext
.MergedContextConfiguration
is also used by theContextCache
as the key for caching anApplicationContext
that was loaded using properties of thisMergedContextConfiguration
.- 从以下版本开始:
- 3.1
- 作者:
- Sam Brannen, Phillip Webb
- 另请参阅:
ContextConfiguration
,ContextHierarchy
,ActiveProfiles
,TestPropertySource
,ContextConfigurationAttributes
,SmartContextLoader.loadContext(MergedContextConfiguration)
, 序列化表格
构造器概要
构造器 构造器 说明 MergedContextConfiguration(Class<?> testClass, String[] locations, Class<?>[] classes, String[] activeProfiles, ContextLoader contextLoader)
Create a newMergedContextConfiguration
instance for the supplied parameters.MergedContextConfiguration(Class<?> testClass, String[] locations, Class<?>[] classes, Set<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> contextInitializerClasses, String[] activeProfiles, String[] propertySourceLocations, String[] propertySourceProperties, Set<ContextCustomizer> contextCustomizers, ContextLoader contextLoader, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, MergedContextConfiguration parent)
Create a newMergedContextConfiguration
instance for the supplied parameters.MergedContextConfiguration(Class<?> testClass, String[] locations, Class<?>[] classes, Set<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> contextInitializerClasses, String[] activeProfiles, String[] propertySourceLocations, String[] propertySourceProperties, ContextLoader contextLoader, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, MergedContextConfiguration parent)
Create a newMergedContextConfiguration
instance for the supplied parameters.MergedContextConfiguration(Class<?> testClass, String[] locations, Class<?>[] classes, Set<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> contextInitializerClasses, String[] activeProfiles, ContextLoader contextLoader)
Create a newMergedContextConfiguration
instance for the supplied parameters.MergedContextConfiguration(Class<?> testClass, String[] locations, Class<?>[] classes, Set<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> contextInitializerClasses, String[] activeProfiles, ContextLoader contextLoader, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, MergedContextConfiguration parent)
Create a newMergedContextConfiguration
instance for the supplied parameters.MergedContextConfiguration(MergedContextConfiguration mergedConfig)
Create a newMergedContextConfiguration
instance by copying all fields from the suppliedMergedContextConfiguration
.
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 boolean
equals(Object other)
Determine if the supplied object is equal to thisMergedContextConfiguration
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 theirContextLoaders
.String[]
getActiveProfiles()
Get the merged active bean definition profiles for the test class.Class<?>[]
getClasses()
Get the merged annotated classes for the test class.Set<ContextCustomizer>
getContextCustomizers()
Get the mergedContextCustomizers
that will be applied when the application context is loaded.Set<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>>
getContextInitializerClasses()
Get the mergedApplicationContextInitializer
classes for the test class.ContextLoader
getContextLoader()
Get the resolvedContextLoader
for the test class.String[]
getLocations()
Get the merged resource locations forApplicationContext
configuration files for the test class.MergedContextConfiguration
getParent()
Get theMergedContextConfiguration
for the parent application context in a context hierarchy.ApplicationContext
getParentApplicationContext()
Get the parentApplicationContext
for the context defined by thisMergedContextConfiguration
from the context cache.String[]
getPropertySourceLocations()
Get the merged resource locations for testPropertySources
for the test class.String[]
getPropertySourceProperties()
Get the merged testPropertySource
properties for the test class.Class<?>
getTestClass()
Get the test class associated with thisMergedContextConfiguration
.boolean
hasClasses()
Determine if thisMergedContextConfiguration
instance has class-based resources.int
hashCode()
Generate a unique hash code for all properties of thisMergedContextConfiguration
excluding the test class.boolean
hasLocations()
Determine if thisMergedContextConfiguration
instance has path-based context resource locations.boolean
hasResources()
Determine if thisMergedContextConfiguration
instance has either path-based context resource locations or class-based resources.protected static String
nullSafeToString(ContextLoader contextLoader)
Generate a null-safeString
representation of the suppliedContextLoader
based solely on the fully qualified name of the loader or "null" if the supplied loaded isnull
.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 theContextLoader
, and the parent configuration.
构造器详细资料
MergedContextConfiguration
public MergedContextConfiguration(Class<?> testClass, String[] locations, Class<?>[] classes, String[] activeProfiles, ContextLoader contextLoader)
Create a newMergedContextConfiguration
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 resolvedContextLoader
MergedContextConfiguration
public MergedContextConfiguration(Class<?> testClass, String[] locations, Class<?>[] classes, Set<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> contextInitializerClasses, String[] activeProfiles, ContextLoader contextLoader)
Create a newMergedContextConfiguration
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 resolvedContextLoader
- 另请参阅:
MergedContextConfiguration(Class, String[], Class[], Set, String[], ContextLoader, CacheAwareContextLoaderDelegate, MergedContextConfiguration)
MergedContextConfiguration
public MergedContextConfiguration(Class<?> testClass, String[] locations, Class<?>[] classes, Set<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> contextInitializerClasses, String[] activeProfiles, ContextLoader contextLoader, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, MergedContextConfiguration parent)
Create a newMergedContextConfiguration
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 resolvedContextLoader
cacheAwareContextLoaderDelegate
- a cache-aware context loader delegate with which to retrieve the parent contextparent
- the parent configuration ornull
if there is no parent- 从以下版本开始:
- 3.2.2
MergedContextConfiguration
public MergedContextConfiguration(MergedContextConfiguration mergedConfig)
Create a newMergedContextConfiguration
instance by copying all fields from the suppliedMergedContextConfiguration
.- 从以下版本开始:
- 4.1
MergedContextConfiguration
public MergedContextConfiguration(Class<?> testClass, String[] locations, Class<?>[] classes, Set<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> contextInitializerClasses, String[] activeProfiles, String[] propertySourceLocations, String[] propertySourceProperties, ContextLoader contextLoader, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, MergedContextConfiguration parent)
Create a newMergedContextConfiguration
instance for the supplied parameters.If a
null
value is supplied forlocations
,classes
,activeProfiles
,propertySourceLocations
, orpropertySourceProperties
an empty array will be stored instead. If anull
value is supplied for thecontextInitializerClasses
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 mergedPropertySource
locationspropertySourceProperties
- the mergedPropertySource
propertiescontextLoader
- the resolvedContextLoader
cacheAwareContextLoaderDelegate
- a cache-aware context loader delegate with which to retrieve the parent contextparent
- the parent configuration ornull
if there is no parent- 从以下版本开始:
- 4.1
MergedContextConfiguration
public MergedContextConfiguration(Class<?> testClass, String[] locations, Class<?>[] classes, Set<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> contextInitializerClasses, String[] activeProfiles, String[] propertySourceLocations, String[] propertySourceProperties, Set<ContextCustomizer> contextCustomizers, ContextLoader contextLoader, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, MergedContextConfiguration parent)
Create a newMergedContextConfiguration
instance for the supplied parameters.If a
null
value is supplied forlocations
,classes
,activeProfiles
,propertySourceLocations
, orpropertySourceProperties
an empty array will be stored instead. If anull
value is supplied forcontextInitializerClasses
orcontextCustomizers
, 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 mergedPropertySource
locationspropertySourceProperties
- the mergedPropertySource
propertiescontextCustomizers
- the context customizerscontextLoader
- the resolvedContextLoader
cacheAwareContextLoaderDelegate
- a cache-aware context loader delegate with which to retrieve the parent contextparent
- the parent configuration ornull
if there is no parent- 从以下版本开始:
- 4.3
方法详细资料
nullSafeToString
protected static String nullSafeToString(ContextLoader contextLoader)
Generate a null-safeString
representation of the suppliedContextLoader
based solely on the fully qualified name of the loader or "null" if the supplied loaded isnull
.
getTestClass
public Class<?> getTestClass()
Get the test class associated with thisMergedContextConfiguration
.
getLocations
public String[] getLocations()
Get the merged resource locations forApplicationContext
configuration files for the test class.Context resource locations typically represent XML configuration files or Groovy scripts.
getClasses
public Class<?>[] getClasses()
Get the merged annotated classes for the test class.
hasLocations
public boolean hasLocations()
Determine if thisMergedContextConfiguration
instance has path-based context resource locations.- 返回:
true
if thelocations
array is not empty- 从以下版本开始:
- 4.0.4
- 另请参阅:
hasResources()
,hasClasses()
hasClasses
public boolean hasClasses()
Determine if thisMergedContextConfiguration
instance has class-based resources.- 返回:
true
if theclasses
array is not empty- 从以下版本开始:
- 4.0.4
- 另请参阅:
hasResources()
,hasLocations()
hasResources
public boolean hasResources()
Determine if thisMergedContextConfiguration
instance has either path-based context resource locations or class-based resources.- 返回:
true
if either thelocations
or theclasses
array is not empty- 从以下版本开始:
- 4.0.4
- 另请参阅:
hasLocations()
,hasClasses()
getContextInitializerClasses
public Set<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> getContextInitializerClasses()
Get the mergedApplicationContextInitializer
classes for the test class.
getActiveProfiles
public String[] getActiveProfiles()
Get the merged active bean definition profiles for the test class.- 另请参阅:
ActiveProfiles
getPropertySourceLocations
public String[] getPropertySourceLocations()
Get the merged resource locations for testPropertySources
for the test class.
getPropertySourceProperties
public String[] getPropertySourceProperties()
Get the merged testPropertySource
properties for the test class.Properties will be loaded into the
Environment
's set ofPropertySources
.
getContextCustomizers
public Set<ContextCustomizer> getContextCustomizers()
Get the mergedContextCustomizers
that will be applied when the application context is loaded.
getContextLoader
public ContextLoader getContextLoader()
Get the resolvedContextLoader
for the test class.
getParent
public MergedContextConfiguration getParent()
Get theMergedContextConfiguration
for the parent application context in a context hierarchy.- 返回:
- the parent configuration or
null
if there is no parent - 从以下版本开始:
- 3.2.2
- 另请参阅:
getParentApplicationContext()
getParentApplicationContext
public ApplicationContext getParentApplicationContext()
Get the parentApplicationContext
for the context defined by thisMergedContextConfiguration
from the context cache.If the parent context has not yet been loaded, it will be loaded, stored in the cache, and then returned.
- 返回:
- the parent
ApplicationContext
ornull
if there is no parent - 从以下版本开始:
- 3.2.2
- 另请参阅:
getParent()
equals
public boolean equals(Object other)
Determine if the supplied object is equal to thisMergedContextConfiguration
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 theirContextLoaders
.
hashCode
public int hashCode()
Generate a unique hash code for all properties of thisMergedContextConfiguration
excluding the test class.
toString
public 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 theContextLoader
, and the parent configuration.