Class MergedContextConfiguration

java.lang.Object
org.springframework.test.context.MergedContextConfiguration
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
WebMergedContextConfiguration

public class MergedContextConfiguration extends Object implements Serializable
MergedContextConfiguration encapsulates the merged context configuration declared on a test class and all of its superclasses and enclosing classes 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 and enclosing 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 Details

    • MergedContextConfiguration

      public MergedContextConfiguration(Class<?> testClass, @Nullable String[] locations, @Nullable Class<?>[] classes, @Nullable String[] activeProfiles, @Nullable ContextLoader contextLoader)
      Create a new MergedContextConfiguration instance 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
    • MergedContextConfiguration

      public MergedContextConfiguration(Class<?> testClass, @Nullable String[] locations, @Nullable Class<?>[] classes, @Nullable Set<Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses, @Nullable String[] activeProfiles, @Nullable ContextLoader contextLoader)
      Create a new MergedContextConfiguration instance 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
    • MergedContextConfiguration

      public 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 new MergedContextConfiguration instance 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 null if there is no parent
      Since:
      3.2.2
    • MergedContextConfiguration

      public MergedContextConfiguration(MergedContextConfiguration mergedConfig)
      Create a new MergedContextConfiguration instance by copying all fields from the supplied MergedContextConfiguration.
      Since:
      4.1
    • MergedContextConfiguration

      public 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 new MergedContextConfiguration 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. 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
      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
    • MergedContextConfiguration

      public 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 new MergedContextConfiguration 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. 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
      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