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
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 Details

    • WebMergedContextConfiguration

      public WebMergedContextConfiguration(MergedContextConfiguration mergedConfig, String resourceBasePath)
      Create a new WebMergedContextConfiguration instance by copying all properties from the supplied MergedContextConfiguration.

      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 new WebMergedContextConfiguration instance for the supplied parameters.

      If a null value is supplied for locations, classes, activeProfiles, propertySourceLocations, or propertySourceProperties an empty array will be stored instead. If a null value is supplied for the contextInitializerClasses an empty set will be stored instead. If an empty value is supplied for the resourceBasePath 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 merged
      locations - the merged resource locations
      classes - the merged annotated classes
      contextInitializerClasses - the merged context initializer classes
      activeProfiles - the merged active bean definition profiles
      propertySourceLocations - the merged PropertySource locations
      propertySourceProperties - the merged PropertySource properties
      resourceBasePath - the resource path to the root directory of the web application
      contextLoader - the resolved ContextLoader
      cacheAwareContextLoaderDelegate - a cache-aware context loader delegate with which to retrieve the parent context
      parent - the parent configuration or null 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 new WebMergedContextConfiguration instance for the supplied parameters.

      If a null value is supplied for locations, classes, activeProfiles, propertySourceLocations, or propertySourceProperties an empty array will be stored instead. If a null value is supplied for contextInitializerClasses or contextCustomizers, an empty set will be stored instead. If an empty value is supplied for the resourceBasePath 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 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 PropertySource locations
      propertySourceProperties - the merged PropertySource properties
      contextCustomizers - the context customizers
      resourceBasePath - the resource path to the root directory of the web application
      contextLoader - the resolved ContextLoader
      cacheAwareContextLoaderDelegate - a cache-aware context loader delegate with which to retrieve the parent context
      parent - the parent configuration or null if there is no parent
      Since:
      4.3
  • Method Details