Class WebMergedContextConfiguration
- java.lang.Object
- org.springframework.test.context.MergedContextConfiguration
- org.springframework.test.context.web.WebMergedContextConfiguration
- All Implemented Interfaces:
Serializable
public class WebMergedContextConfiguration extends MergedContextConfiguration
WebMergedContextConfigurationencapsulates the merged context configuration declared on a test class and all of its superclasses via@ContextConfiguration,@WebAppConfiguration, and@ActiveProfiles.WebMergedContextConfigurationextends the contract ofMergedContextConfigurationby adding support for theresource base pathconfigured via@WebAppConfiguration. This allows theTestContextto properly cache the correspondingWebApplicationContextthat was loaded using properties of thisWebMergedContextConfiguration.- Since:
- 3.2
- Author:
- Sam Brannen
- See Also:
WebAppConfiguration,MergedContextConfiguration,ContextConfiguration,ActiveProfiles,ContextConfigurationAttributes,SmartContextLoader.loadContext(MergedContextConfiguration), Serialized Form
Constructor Summary
Constructors Constructor Description WebMergedContextConfiguration(Class<?> testClass, String[] locations, Class<?>[] classes, Set<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> contextInitializerClasses, String[] activeProfiles, String[] propertySourceLocations, String[] propertySourceProperties, String resourceBasePath, ContextLoader contextLoader, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, MergedContextConfiguration parent)Create a newWebMergedContextConfigurationinstance for the supplied parameters.WebMergedContextConfiguration(Class<?> testClass, String[] locations, Class<?>[] classes, Set<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> contextInitializerClasses, String[] activeProfiles, String[] propertySourceLocations, String[] propertySourceProperties, Set<ContextCustomizer> contextCustomizers, String resourceBasePath, ContextLoader contextLoader, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, MergedContextConfiguration parent)Create a newWebMergedContextConfigurationinstance for the supplied parameters.WebMergedContextConfiguration(Class<?> testClass, String[] locations, Class<?>[] classes, Set<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> contextInitializerClasses, String[] activeProfiles, String resourceBasePath, ContextLoader contextLoader, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, MergedContextConfiguration parent)WebMergedContextConfiguration(MergedContextConfiguration mergedConfig, String resourceBasePath)Create a newWebMergedContextConfigurationinstance by copying all properties from the suppliedMergedContextConfiguration.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object other)Determine if the supplied object is equal to thisWebMergedContextConfigurationinstance by comparing both object's locations, annotated classes, context initializer classes, active profiles, resource base path, parents, and the fully qualified names of theirContextLoaders.StringgetResourceBasePath()Get the resource path to the root directory of the web application for the test class, configured via@WebAppConfiguration.inthashCode()Generate a unique hash code for all properties of thisWebMergedContextConfigurationexcluding the test class.StringtoString()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, nullSafeToString
Constructor Detail
WebMergedContextConfiguration
@Deprecated public WebMergedContextConfiguration(Class<?> testClass, String[] locations, Class<?>[] classes, Set<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> contextInitializerClasses, String[] activeProfiles, String resourceBasePath, ContextLoader contextLoader, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, MergedContextConfiguration parent)
Deprecated.Create a newWebMergedContextConfigurationinstance for the supplied parameters.- 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 profilesresourceBasePath- the resource path to the root directory of the web applicationcontextLoader- the resolvedContextLoadercacheAwareContextLoaderDelegate- a cache-aware context loader delegate with which to retrieve the parent contextparent- the parent configuration ornullif there is no parent- Since:
- 3.2.2
WebMergedContextConfiguration
public WebMergedContextConfiguration(MergedContextConfiguration mergedConfig, String resourceBasePath)
Create a newWebMergedContextConfigurationinstance by copying all properties from the suppliedMergedContextConfiguration.If an empty value is supplied for the
resourceBasePathan 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, String[] locations, Class<?>[] classes, Set<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> contextInitializerClasses, String[] activeProfiles, String[] propertySourceLocations, String[] propertySourceProperties, String resourceBasePath, ContextLoader contextLoader, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, MergedContextConfiguration parent)
Create a newWebMergedContextConfigurationinstance 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. If an empty value is supplied for theresourceBasePathan 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 mergedPropertySourcelocationspropertySourceProperties- the mergedPropertySourcepropertiesresourceBasePath- the resource path to the root directory of the web applicationcontextLoader- the resolvedContextLoadercacheAwareContextLoaderDelegate- a cache-aware context loader delegate with which to retrieve the parent contextparent- the parent configuration ornullif there is no parent- Since:
- 4.1
WebMergedContextConfiguration
public WebMergedContextConfiguration(Class<?> testClass, String[] locations, Class<?>[] classes, Set<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> contextInitializerClasses, String[] activeProfiles, String[] propertySourceLocations, String[] propertySourceProperties, Set<ContextCustomizer> contextCustomizers, String resourceBasePath, ContextLoader contextLoader, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, MergedContextConfiguration parent)
Create a newWebMergedContextConfigurationinstance 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. If an empty value is supplied for theresourceBasePathan 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 mergedPropertySourcelocationspropertySourceProperties- the mergedPropertySourcepropertiescontextCustomizers- the context customizersresourceBasePath- the resource path to the root directory of the web applicationcontextLoader- the resolvedContextLoadercacheAwareContextLoaderDelegate- a cache-aware context loader delegate with which to retrieve the parent contextparent- the parent configuration ornullif there is no parent- Since:
- 4.3
Method Detail
getResourceBasePath
public String getResourceBasePath()
Get the resource path to the root directory of the web application for the test class, configured via@WebAppConfiguration.- See Also:
WebAppConfiguration
equals
public boolean equals(Object other)
Determine if the supplied object is equal to thisWebMergedContextConfigurationinstance 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:
equalsin classMergedContextConfiguration
hashCode
public int hashCode()
Generate a unique hash code for all properties of thisWebMergedContextConfigurationexcluding the test class.- Overrides:
hashCodein classMergedContextConfiguration
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, resource base path, the name of theContextLoader, and the parent configuration.- Overrides:
toStringin classMergedContextConfiguration