Class WebMergedContextConfiguration
- All Implemented Interfaces:
Serializable
WebMergedContextConfiguration
encapsulates the merged context
configuration declared on a test class and all of its superclasses and
enclosing classes via
@ContextConfiguration
,
@WebAppConfiguration
,
@ActiveProfiles
, and
@TestPropertySource
.
WebMergedContextConfiguration
extends the contract of
MergedContextConfiguration
by adding support for the resource base path configured via @WebAppConfiguration
.
This allows the ContextCache
to properly cache the corresponding WebApplicationContext
that was loaded using properties of this WebMergedContextConfiguration
.
- Since:
- 3.2
- Author:
- Sam Brannen
- See Also:
-
Constructor Summary
ConstructorDescriptionWebMergedContextConfiguration
(Class<?> testClass, String[] locations, Class<?>[] classes, Set<Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses, String[] activeProfiles, String[] propertySourceLocations, String[] propertySourceProperties, String resourceBasePath, ContextLoader contextLoader, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, MergedContextConfiguration parent) Deprecated.WebMergedContextConfiguration
(Class<?> testClass, String[] locations, Class<?>[] classes, Set<Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses, String[] activeProfiles, String[] propertySourceLocations, String[] propertySourceProperties, Set<ContextCustomizer> contextCustomizers, String resourceBasePath, ContextLoader contextLoader, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, MergedContextConfiguration parent) WebMergedContextConfiguration
(Class<?> testClass, String[] locations, Class<?>[] classes, Set<Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses, String[] activeProfiles, List<PropertySourceDescriptor> propertySourceDescriptors, String[] propertySourceProperties, Set<ContextCustomizer> contextCustomizers, String resourceBasePath, ContextLoader contextLoader, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, MergedContextConfiguration parent) Create a newWebMergedContextConfiguration
instance for the supplied parameters.WebMergedContextConfiguration
(MergedContextConfiguration mergedConfig, String resourceBasePath) Create a newWebMergedContextConfiguration
instance by copying all properties from the suppliedMergedContextConfiguration
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Determine if the supplied object is equal to thisWebMergedContextConfiguration
instance by comparing both objects' locations, annotated classes, context initializer classes, active profiles, resource base paths, property source descriptors, property source properties, context customizers, parents, and the fully qualified names of theirContextLoaders
.Get the resource path to the root directory of the web application for the test class, configured via@WebAppConfiguration
.int
hashCode()
Generate a unique hash code for all properties of thisWebMergedContextConfiguration
excluding the test class.toString()
Provide a String representation of the test class, locations, annotated classes, context initializer classes, active profiles, property source descriptors, property source properties, context customizers, resource base path, the name of theContextLoader
, and the parent configuration.Methods inherited from class org.springframework.test.context.MergedContextConfiguration
getActiveProfiles, getClasses, getContextCustomizers, getContextInitializerClasses, getContextLoader, getLocations, getParent, getParentApplicationContext, getPropertySourceDescriptors, getPropertySourceLocations, getPropertySourceProperties, getTestClass, hasClasses, hasLocations, hasResources, nullSafeClassName, processStrings
-
Constructor Details
-
WebMergedContextConfiguration
public WebMergedContextConfiguration(MergedContextConfiguration mergedConfig, String resourceBasePath) Create a newWebMergedContextConfiguration
instance by copying all properties from the suppliedMergedContextConfiguration
.If an empty value is supplied for the
resourceBasePath
an empty string will be used.- Parameters:
resourceBasePath
- the resource path to the root directory of the web application- Since:
- 4.1
-
WebMergedContextConfiguration
@Deprecated(since="6.1") public WebMergedContextConfiguration(Class<?> testClass, @Nullable String[] locations, @Nullable Class<?>[] classes, @Nullable Set<Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses, @Nullable String[] activeProfiles, @Nullable String[] propertySourceLocations, @Nullable String[] propertySourceProperties, String resourceBasePath, ContextLoader contextLoader, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, @Nullable MergedContextConfiguration parent) Deprecated.Create a newWebMergedContextConfiguration
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. If an empty value is supplied for theresourceBasePath
an empty string will be used. Furthermore, active profiles will be sorted, and duplicate profiles will be removed.- Parameters:
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 profilespropertySourceLocations
- the mergedPropertySource
locationspropertySourceProperties
- the mergedPropertySource
propertiesresourceBasePath
- the resource path to the root directory of the web applicationcontextLoader
- 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- Since:
- 4.1
-
WebMergedContextConfiguration
@Deprecated(since="6.1") public WebMergedContextConfiguration(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, String resourceBasePath, ContextLoader contextLoader, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, @Nullable MergedContextConfiguration parent) Deprecated.Create a newWebMergedContextConfiguration
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. If an empty value is supplied for theresourceBasePath
an empty string will be used. Furthermore, active profiles will be sorted, and duplicate profiles will be removed.- 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 profilespropertySourceLocations
- the mergedPropertySource
locationspropertySourceProperties
- the mergedPropertySource
propertiescontextCustomizers
- the context customizersresourceBasePath
- the resource path to the root directory of the web applicationcontextLoader
- 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- Since:
- 4.3
-
WebMergedContextConfiguration
public WebMergedContextConfiguration(Class<?> testClass, @Nullable String[] locations, @Nullable Class<?>[] classes, @Nullable Set<Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses, @Nullable String[] activeProfiles, List<PropertySourceDescriptor> propertySourceDescriptors, @Nullable String[] propertySourceProperties, @Nullable Set<ContextCustomizer> contextCustomizers, String resourceBasePath, ContextLoader contextLoader, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, @Nullable MergedContextConfiguration parent) Create a newWebMergedContextConfiguration
instance for the supplied parameters.If a
null
value is supplied forlocations
,classes
,activeProfiles
, 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.- 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 profilespropertySourceDescriptors
- the merged property source descriptorspropertySourceProperties
- the merged inlined propertiescontextCustomizers
- the context customizersresourceBasePath
- the resource path to the root directory of the web applicationcontextLoader
- the resolvedContextLoader
cacheAwareContextLoaderDelegate
- a cache-aware context loader delegate with which to retrieve the parentApplicationContext
parent
- the parent configuration ornull
if there is no parent- Since:
- 6.1
-
-
Method Details
-
getResourceBasePath
Get the resource path to the root directory of the web application for the test class, configured via@WebAppConfiguration
.- See Also:
-
equals
Determine if the supplied object is equal to thisWebMergedContextConfiguration
instance by comparing both objects' locations, annotated classes, context initializer classes, active profiles, resource base paths, property source descriptors, property source properties, context customizers, parents, and the fully qualified names of theirContextLoaders
.- Overrides:
equals
in classMergedContextConfiguration
-
hashCode
public int hashCode()Generate a unique hash code for all properties of thisWebMergedContextConfiguration
excluding the test class.- Overrides:
hashCode
in classMergedContextConfiguration
-
toString
Provide a String representation of the test class, locations, annotated classes, context initializer classes, active profiles, property source descriptors, property source properties, context customizers, resource base path, the name of theContextLoader
, and the parent configuration.- Overrides:
toString
in classMergedContextConfiguration
-
WebMergedContextConfiguration(Class, String[], Class[], Set, String[], List, String[], Set, String, ContextLoader, CacheAwareContextLoaderDelegate, MergedContextConfiguration)