Class WebMergedContextConfiguration
- All Implemented Interfaces:
Serializable
WebMergedContextConfiguration
encapsulates the merged
context configuration declared on a test class and all of its superclasses
via @ContextConfiguration
,
@WebAppConfiguration
, and
@ActiveProfiles
.
WebMergedContextConfiguration
extends the contract of
MergedContextConfiguration
by adding support for the resource base path
configured via @WebAppConfiguration
.
This allows the TestContext
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) Create a newWebMergedContextConfiguration
instance for the supplied parameters.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) 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 object's locations, annotated classes, context initializer classes, active profiles, resource base path, 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 locations, 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, getPropertySourceLocations, getPropertySourceProperties, getTestClass, hasClasses, hasLocations, hasResources, nullSafeClassName
-
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
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) 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
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) 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
-
-
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 object's locations, annotated classes, context initializer classes, active profiles, resource base path, 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 locations, property source properties, context customizers, resource base path, the name of theContextLoader
, and the parent configuration.- Overrides:
toString
in classMergedContextConfiguration
-