org.springframework.test.context

Interface CacheAwareContextLoaderDelegate

    • Method Detail

      • loadContext

        ApplicationContext loadContext(MergedContextConfiguration mergedContextConfiguration)
        Load the application context for the supplied MergedContextConfiguration by delegating to the ContextLoader configured in the given MergedContextConfiguration.

        If the context is present in the ContextCache it will simply be returned; otherwise, it will be loaded, stored in the cache, and returned.

        The cache statistics should be logged by invoking ContextCache.logStatistics().

        Parameters:
        mergedContextConfiguration - the merged context configuration to use to load the application context; never null
        Returns:
        the application context
        Throws:
        java.lang.IllegalStateException - if an error occurs while retrieving or loading the application context
      • closeContext

        void closeContext(MergedContextConfiguration mergedContextConfiguration,
                          @Nullable
                          DirtiesContext.HierarchyMode hierarchyMode)
        Remove the application context for the supplied MergedContextConfiguration from the ContextCache and close it if it is an instance of ConfigurableApplicationContext.

        The semantics of the supplied HierarchyMode must be honored when removing the context from the cache. See the Javadoc for DirtiesContext.HierarchyMode for details.

        Generally speaking, this method should only be called if the state of a singleton bean has been changed (potentially affecting future interaction with the context) or if the context needs to be prematurely removed from the cache.

        Parameters:
        mergedContextConfiguration - the merged context configuration for the application context to close; never null
        hierarchyMode - the hierarchy mode; may be null if the context is not part of a hierarchy
        Since:
        4.1