Introduce dedicated 'cache' subpackage in the TCF
Since the ContextCache is now a published SPI, it and its collaborators have been moved to a dedicated 'org.sfw.test.context.cache' subpackage. Issue: SPR-12683
This commit is contained in:
parent
ca91956bdb
commit
5cbe4b948d
|
@ -40,7 +40,7 @@ abstract class BootstrapUtils {
|
|||
|
||||
private static final String DEFAULT_BOOTSTRAP_CONTEXT_CLASS_NAME = "org.springframework.test.context.support.DefaultBootstrapContext";
|
||||
|
||||
private static final String DEFAULT_CACHE_AWARE_CONTEXT_LOADER_DELEGATE_CLASS_NAME = "org.springframework.test.context.support.DefaultCacheAwareContextLoaderDelegate";
|
||||
private static final String DEFAULT_CACHE_AWARE_CONTEXT_LOADER_DELEGATE_CLASS_NAME = "org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate";
|
||||
|
||||
private static final String DEFAULT_TEST_CONTEXT_BOOTSTRAPPER_CLASS_NAME = "org.springframework.test.context.support.DefaultTestContextBootstrapper";
|
||||
|
||||
|
@ -55,7 +55,7 @@ abstract class BootstrapUtils {
|
|||
* Create the {@code BootstrapContext} for the specified {@linkplain Class test class}.
|
||||
*
|
||||
* <p>Uses reflection to create a {@link org.springframework.test.context.support.DefaultBootstrapContext}
|
||||
* that uses a {@link org.springframework.test.context.support.DefaultCacheAwareContextLoaderDelegate}.
|
||||
* that uses a {@link org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate}.
|
||||
*
|
||||
* @param testClass the test class for which the bootstrap context should be created
|
||||
* @return a new {@code BootstrapContext}; never {@code null}
|
||||
|
|
|
@ -23,8 +23,9 @@ import org.springframework.test.annotation.DirtiesContext.HierarchyMode;
|
|||
/**
|
||||
* A {@code CacheAwareContextLoaderDelegate} is responsible for {@linkplain
|
||||
* #loadContext loading} and {@linkplain #closeContext closing} application
|
||||
* contexts, interacting transparently with a {@link ContextCache} behind
|
||||
* the scenes.
|
||||
* contexts, interacting transparently with a
|
||||
* {@link org.springframework.test.context.cache.ContextCache ContextCache}
|
||||
* behind the scenes.
|
||||
*
|
||||
* <p>Note: {@code CacheAwareContextLoaderDelegate} does not extend the
|
||||
* {@link ContextLoader} or {@link SmartContextLoader} interface.
|
||||
|
@ -41,7 +42,7 @@ public interface CacheAwareContextLoaderDelegate {
|
|||
* <p>If the context is present in the {@code ContextCache} it will simply
|
||||
* be returned; otherwise, it will be loaded, stored in the cache, and returned.
|
||||
* <p>The cache statistics should be logged by invoking
|
||||
* {@link ContextCache#logStatistics()}.
|
||||
* {@link org.springframework.test.context.cache.ContextCache#logStatistics()}.
|
||||
* @param mergedContextConfiguration the merged context configuration to use
|
||||
* to load the application context; never {@code null}
|
||||
* @return the application context
|
||||
|
|
|
@ -14,10 +14,11 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.test.context;
|
||||
package org.springframework.test.context.cache;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.test.annotation.DirtiesContext.HierarchyMode;
|
||||
import org.springframework.test.context.MergedContextConfiguration;
|
||||
|
||||
/**
|
||||
* {@code ContextCache} defines the SPI for caching Spring
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.test.context.support;
|
||||
package org.springframework.test.context.cache;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
@ -22,7 +22,6 @@ import org.apache.commons.logging.LogFactory;
|
|||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.test.annotation.DirtiesContext.HierarchyMode;
|
||||
import org.springframework.test.context.CacheAwareContextLoaderDelegate;
|
||||
import org.springframework.test.context.ContextCache;
|
||||
import org.springframework.test.context.ContextLoader;
|
||||
import org.springframework.test.context.MergedContextConfiguration;
|
||||
import org.springframework.test.context.SmartContextLoader;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.test.context.support;
|
||||
package org.springframework.test.context.cache;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
@ -31,7 +31,6 @@ import org.springframework.context.ApplicationContext;
|
|||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.core.style.ToStringCreator;
|
||||
import org.springframework.test.annotation.DirtiesContext.HierarchyMode;
|
||||
import org.springframework.test.context.ContextCache;
|
||||
import org.springframework.test.context.MergedContextConfiguration;
|
||||
import org.springframework.util.Assert;
|
||||
|
|
@ -38,7 +38,6 @@ import org.springframework.core.annotation.AnnotationUtils;
|
|||
import org.springframework.core.io.support.SpringFactoriesLoader;
|
||||
import org.springframework.test.context.BootstrapContext;
|
||||
import org.springframework.test.context.CacheAwareContextLoaderDelegate;
|
||||
import org.springframework.test.context.ContextCache;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.ContextConfigurationAttributes;
|
||||
import org.springframework.test.context.ContextHierarchy;
|
||||
|
@ -68,8 +67,9 @@ import org.springframework.util.StringUtils;
|
|||
* <li>{@link #processMergedContextConfiguration}
|
||||
* </ul>
|
||||
*
|
||||
* <p>To plug in custom {@link ContextCache} support, override
|
||||
* {@link #getCacheAwareContextLoaderDelegate()}.
|
||||
* <p>To plug in custom
|
||||
* {@link org.springframework.test.context.cache.ContextCache ContextCache}
|
||||
* support, override {@link #getCacheAwareContextLoaderDelegate()}.
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @author Juergen Hoeller
|
||||
|
@ -481,8 +481,9 @@ public abstract class AbstractTestContextBootstrapper implements TestContextBoot
|
|||
* <p>The default implementation simply delegates to
|
||||
* {@code getBootstrapContext().getCacheAwareContextLoaderDelegate()}.
|
||||
* <p>Concrete subclasses may choose to override this method to return a
|
||||
* custom {@code CacheAwareContextLoaderDelegate} implementation with
|
||||
* custom {@link ContextCache} support.
|
||||
* custom {@code CacheAwareContextLoaderDelegate} implementation with custom
|
||||
* {@link org.springframework.test.context.cache.ContextCache ContextCache}
|
||||
* support.
|
||||
* @return the context loader delegate (never {@code null})
|
||||
*/
|
||||
protected CacheAwareContextLoaderDelegate getCacheAwareContextLoaderDelegate() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -33,7 +33,8 @@ import static org.junit.Assert.*;
|
|||
* Unit tests for {@link MergedContextConfiguration}.
|
||||
*
|
||||
* <p>These tests primarily exist to ensure that {@code MergedContextConfiguration}
|
||||
* can safely be used as the cache key for {@link ContextCache}.
|
||||
* can safely be used as the cache key for
|
||||
* {@link org.springframework.test.context.cache.ContextCache ContextCache}.
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 3.1
|
||||
|
|
|
@ -16,8 +16,9 @@
|
|||
|
||||
package org.springframework.test.context;
|
||||
|
||||
import org.springframework.test.context.cache.ContextCache;
|
||||
import org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate;
|
||||
import org.springframework.test.context.support.DefaultBootstrapContext;
|
||||
import org.springframework.test.context.support.DefaultCacheAwareContextLoaderDelegate;
|
||||
|
||||
/**
|
||||
* Collection of test-related utility methods for working with {@link TestContext TestContexts}.
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.test.context;
|
||||
package org.springframework.test.context.cache;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
|
@ -29,6 +29,8 @@ import org.springframework.context.ApplicationContext;
|
|||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.annotation.DirtiesContext.ClassMode;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.TestExecutionListeners;
|
||||
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
|
||||
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;
|
||||
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
|
||||
|
@ -37,7 +39,7 @@ import org.springframework.test.context.testng.TrackingTestNGTestListener;
|
|||
import org.testng.TestNG;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.test.context.support.ContextCacheTestUtils.*;
|
||||
import static org.springframework.test.context.cache.ContextCacheTestUtils.*;
|
||||
|
||||
/**
|
||||
* JUnit 4 based integration test which verifies correct {@linkplain ContextCache
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.test.context;
|
||||
package org.springframework.test.context.cache;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
|
@ -30,13 +30,15 @@ import org.springframework.context.ApplicationContext;
|
|||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.annotation.DirtiesContext.ClassMode;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.TestExecutionListeners;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit4.TrackingRunListener;
|
||||
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
|
||||
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.test.context.support.ContextCacheTestUtils.*;
|
||||
import static org.springframework.test.context.cache.ContextCacheTestUtils.*;
|
||||
|
||||
/**
|
||||
* JUnit 4 based integration test which verifies correct {@linkplain ContextCache
|
|
@ -14,9 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.test.context.support;
|
||||
|
||||
import org.springframework.test.context.ContextCache;
|
||||
package org.springframework.test.context.cache;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.test.context;
|
||||
package org.springframework.test.context.cache;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -22,12 +22,18 @@ import org.junit.Test;
|
|||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.annotation.DirtiesContext.HierarchyMode;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.ActiveProfilesResolver;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.ContextHierarchy;
|
||||
import org.springframework.test.context.MergedContextConfiguration;
|
||||
import org.springframework.test.context.TestContext;
|
||||
import org.springframework.test.context.TestContextTestUtils;
|
||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||
import org.springframework.test.context.support.DefaultContextCache;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.test.context.support.ContextCacheTestUtils.*;
|
||||
import static org.springframework.test.context.cache.ContextCacheTestUtils.*;
|
||||
|
||||
/**
|
||||
* Integration tests for verifying proper behavior of the {@link ContextCache} in
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.test.context;
|
||||
package org.springframework.test.context.cache;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
|
@ -26,12 +26,14 @@ import org.junit.runners.MethodSorters;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.TestExecutionListeners;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
|
||||
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.test.context.support.ContextCacheTestUtils.*;
|
||||
import static org.springframework.test.context.cache.ContextCacheTestUtils.*;
|
||||
|
||||
/**
|
||||
* JUnit 4 based unit test which verifies correct {@link ContextCache
|
||||
|
@ -47,7 +49,7 @@ import static org.springframework.test.context.support.ContextCacheTestUtils.*;
|
|||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
@TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DirtiesContextTestExecutionListener.class })
|
||||
@ContextConfiguration("junit4/SpringJUnit4ClassRunnerAppCtxTests-context.xml")
|
||||
@ContextConfiguration("../junit4/SpringJUnit4ClassRunnerAppCtxTests-context.xml")
|
||||
public class SpringRunnerContextCacheTests {
|
||||
|
||||
private static ApplicationContext dirtiedApplicationContext;
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -19,9 +19,8 @@ package org.springframework.test.context.junit4;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
import org.junit.runners.Suite.SuiteClasses;
|
||||
|
||||
import org.springframework.test.context.ClassLevelDirtiesContextTests;
|
||||
import org.springframework.test.context.SpringRunnerContextCacheTests;
|
||||
import org.springframework.test.context.cache.ClassLevelDirtiesContextTests;
|
||||
import org.springframework.test.context.cache.SpringRunnerContextCacheTests;
|
||||
import org.springframework.test.context.junit4.annotation.AnnotationConfigSpringJUnit4ClassRunnerAppCtxTests;
|
||||
import org.springframework.test.context.junit4.annotation.BeanOverridingDefaultConfigClassesInheritedTests;
|
||||
import org.springframework.test.context.junit4.annotation.BeanOverridingExplicitConfigClassesInheritedTests;
|
||||
|
|
Loading…
Reference in New Issue