Class MergedContextConfiguration
- All Implemented Interfaces:
- Serializable
- Direct Known Subclasses:
- WebMergedContextConfiguration
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.
- Since:
- 3.1
- Author:
- Sam Brannen, Phillip Webb
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionMergedContextConfiguration(Class<?> testClass, String[] locations, Class<?>[] classes, String[] activeProfiles, ContextLoader contextLoader) Create a newMergedContextConfigurationinstance for the supplied parameters.MergedContextConfiguration(Class<?> testClass, String[] locations, Class<?>[] classes, Set<Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses, String[] activeProfiles, String[] propertySourceLocations, String[] propertySourceProperties, Set<ContextCustomizer> contextCustomizers, ContextLoader contextLoader, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, MergedContextConfiguration parent) Create a newMergedContextConfigurationinstance for the supplied parameters.MergedContextConfiguration(Class<?> testClass, String[] locations, Class<?>[] classes, Set<Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses, String[] activeProfiles, String[] propertySourceLocations, String[] propertySourceProperties, ContextLoader contextLoader, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, MergedContextConfiguration parent) Create a newMergedContextConfigurationinstance for the supplied parameters.MergedContextConfiguration(Class<?> testClass, String[] locations, Class<?>[] classes, Set<Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses, String[] activeProfiles, ContextLoader contextLoader) Create a newMergedContextConfigurationinstance for the supplied parameters.MergedContextConfiguration(Class<?> testClass, String[] locations, Class<?>[] classes, Set<Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses, String[] activeProfiles, ContextLoader contextLoader, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, MergedContextConfiguration parent) Create a newMergedContextConfigurationinstance for the supplied parameters.MergedContextConfiguration(MergedContextConfiguration mergedConfig) Create a newMergedContextConfigurationinstance by copying all fields from the suppliedMergedContextConfiguration.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanDetermine if the supplied object is equal to thisMergedContextConfigurationinstance 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[]Get the merged active bean definition profiles for the test class.Class<?>[]Get the merged annotated classes for the test class.Get the mergedContextCustomizersthat will be applied when the application context is loaded.Set<Class<? extends ApplicationContextInitializer<?>>>Get the mergedApplicationContextInitializerclasses for the test class.Get the resolvedContextLoaderfor the test class.String[]Get the merged resource locations forApplicationContextconfiguration files for the test class.Get theMergedContextConfigurationfor the parent application context in a context hierarchy.Get the parentApplicationContextfor the context defined by thisMergedContextConfigurationfrom the context cache.String[]Get the merged resource locations for testPropertySourcesfor the test class.String[]Get the merged testPropertySourceproperties for the test class.Class<?>Get the test class associated with thisMergedContextConfiguration.booleanDetermine if thisMergedContextConfigurationinstance has class-based resources.inthashCode()Generate a unique hash code for all properties of thisMergedContextConfigurationexcluding the test class.booleanDetermine if thisMergedContextConfigurationinstance has path-based context resource locations.booleanDetermine if thisMergedContextConfigurationinstance has either path-based context resource locations or class-based resources.protected static StringnullSafeClassName(ContextLoader contextLoader) Generate a null-safeStringrepresentation of the suppliedContextLoaderbased solely on the fully qualified name of the loader or "null" if the supplied loader isnull.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.
- 
Constructor Details- 
MergedContextConfigurationpublic MergedContextConfiguration(Class<?> testClass, @Nullable String[] locations, @Nullable Class<?>[] classes, @Nullable String[] activeProfiles, @Nullable ContextLoader contextLoader) Create a newMergedContextConfigurationinstance for the supplied parameters.- Parameters:
- testClass- the test class for which the configuration was merged
- locations- the merged context resource locations
- classes- the merged annotated classes
- activeProfiles- the merged active bean definition profiles
- contextLoader- the resolved- ContextLoader
 
- 
MergedContextConfigurationpublic MergedContextConfiguration(Class<?> testClass, @Nullable String[] locations, @Nullable Class<?>[] classes, @Nullable Set<Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses, @Nullable String[] activeProfiles, @Nullable ContextLoader contextLoader) Create a newMergedContextConfigurationinstance for the supplied parameters.- Parameters:
- testClass- the test class for which the configuration was merged
- locations- the merged context resource locations
- classes- the merged annotated classes
- contextInitializerClasses- the merged context initializer classes
- activeProfiles- the merged active bean definition profiles
- contextLoader- the resolved- ContextLoader
 
- 
MergedContextConfigurationpublic MergedContextConfiguration(Class<?> testClass, @Nullable String[] locations, @Nullable Class<?>[] classes, @Nullable Set<Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses, @Nullable String[] activeProfiles, @Nullable ContextLoader contextLoader, @Nullable CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, @Nullable MergedContextConfiguration parent) Create a newMergedContextConfigurationinstance for the supplied parameters.- Parameters:
- testClass- the test class for which the configuration was merged
- locations- the merged context resource locations
- classes- the merged annotated classes
- contextInitializerClasses- the merged context initializer classes
- activeProfiles- the merged active bean definition profiles
- contextLoader- the resolved- ContextLoader
- cacheAwareContextLoaderDelegate- a cache-aware context loader delegate with which to retrieve the parent context
- parent- the parent configuration or- nullif there is no parent
- Since:
- 3.2.2
 
- 
MergedContextConfigurationCreate a newMergedContextConfigurationinstance by copying all fields from the suppliedMergedContextConfiguration.- Since:
- 4.1
 
- 
MergedContextConfigurationpublic MergedContextConfiguration(Class<?> testClass, @Nullable String[] locations, @Nullable Class<?>[] classes, @Nullable Set<Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses, @Nullable String[] activeProfiles, @Nullable String[] propertySourceLocations, @Nullable String[] propertySourceProperties, @Nullable ContextLoader contextLoader, @Nullable CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, @Nullable MergedContextConfiguration parent) Create a newMergedContextConfigurationinstance for the supplied parameters.If a nullvalue is supplied forlocations,classes,activeProfiles,propertySourceLocations, orpropertySourcePropertiesan empty array will be stored instead. If anullvalue is supplied for thecontextInitializerClassesan empty set will be stored instead. Furthermore, active profiles will be sorted, and duplicate profiles will be removed.- Parameters:
- testClass- the test class for which the configuration was merged
- locations- the merged context resource locations
- classes- the merged annotated classes
- contextInitializerClasses- the merged context initializer classes
- activeProfiles- the merged active bean definition profiles
- propertySourceLocations- the merged- PropertySourcelocations
- propertySourceProperties- the merged- PropertySourceproperties
- contextLoader- the resolved- ContextLoader
- cacheAwareContextLoaderDelegate- a cache-aware context loader delegate with which to retrieve the parent context
- parent- the parent configuration or- nullif there is no parent
- Since:
- 4.1
 
- 
MergedContextConfigurationpublic MergedContextConfiguration(Class<?> testClass, @Nullable String[] locations, @Nullable Class<?>[] classes, @Nullable Set<Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses, @Nullable String[] activeProfiles, @Nullable String[] propertySourceLocations, @Nullable String[] propertySourceProperties, @Nullable Set<ContextCustomizer> contextCustomizers, @Nullable ContextLoader contextLoader, @Nullable CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, @Nullable MergedContextConfiguration parent) Create a newMergedContextConfigurationinstance for the supplied parameters.If a nullvalue is supplied forlocations,classes,activeProfiles,propertySourceLocations, orpropertySourcePropertiesan empty array will be stored instead. If anullvalue is supplied forcontextInitializerClassesorcontextCustomizers, an empty set will be stored instead. Furthermore, active profiles will be sorted, and duplicate profiles will be removed.- Parameters:
- testClass- the test class for which the configuration was merged
- locations- the merged context resource locations
- classes- the merged annotated classes
- contextInitializerClasses- the merged context initializer classes
- activeProfiles- the merged active bean definition profiles
- propertySourceLocations- the merged- PropertySourcelocations
- propertySourceProperties- the merged- PropertySourceproperties
- contextCustomizers- the context customizers
- contextLoader- the resolved- ContextLoader
- cacheAwareContextLoaderDelegate- a cache-aware context loader delegate with which to retrieve the parent context
- parent- the parent configuration or- nullif there is no parent
- Since:
- 4.3
 
 
- 
- 
Method Details- 
getTestClassGet the test class associated with thisMergedContextConfiguration.
- 
getLocationsGet the merged resource locations forApplicationContextconfiguration files for the test class.Context resource locations typically represent XML configuration files or Groovy scripts. 
- 
getClassesGet the merged annotated classes for the test class.
- 
hasLocationspublic boolean hasLocations()Determine if thisMergedContextConfigurationinstance has path-based context resource locations.- Returns:
- trueif the- locationsarray is not empty
- Since:
- 4.0.4
- See Also:
 
- 
hasClassespublic boolean hasClasses()Determine if thisMergedContextConfigurationinstance has class-based resources.- Returns:
- trueif the- classesarray is not empty
- Since:
- 4.0.4
- See Also:
 
- 
hasResourcespublic boolean hasResources()Determine if thisMergedContextConfigurationinstance has either path-based context resource locations or class-based resources.
- 
getContextInitializerClassesGet the mergedApplicationContextInitializerclasses for the test class.
- 
getActiveProfilesGet the merged active bean definition profiles for the test class.- See Also:
 
- 
getPropertySourceLocationsGet the merged resource locations for testPropertySourcesfor the test class.- See Also:
 
- 
getPropertySourcePropertiesGet the merged testPropertySourceproperties for the test class.Properties will be loaded into the Environment's set ofPropertySources.- See Also:
 
- 
getContextCustomizersGet the mergedContextCustomizersthat will be applied when the application context is loaded.
- 
getContextLoaderGet the resolvedContextLoaderfor the test class.
- 
getParentGet theMergedContextConfigurationfor the parent application context in a context hierarchy.- Returns:
- the parent configuration or nullif there is no parent
- Since:
- 3.2.2
- See Also:
 
- 
getParentApplicationContextGet the parentApplicationContextfor the context defined by thisMergedContextConfigurationfrom the context cache.If the parent context has not yet been loaded, it will be loaded, stored in the cache, and then returned. - Returns:
- the parent ApplicationContextornullif there is no parent
- Since:
- 3.2.2
- See Also:
 
- 
equalsDetermine if the supplied object is equal to thisMergedContextConfigurationinstance 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.
- 
hashCodepublic int hashCode()Generate a unique hash code for all properties of thisMergedContextConfigurationexcluding the test class.
- 
toStringProvide 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.
- 
nullSafeClassNameGenerate a null-safeStringrepresentation of the suppliedContextLoaderbased solely on the fully qualified name of the loader or "null" if the supplied loader isnull.
 
-