Skip to content

Commit 5cbe4b9

Browse files
committed
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
1 parent ca91956 commit 5cbe4b9

14 files changed

+47
-35
lines changed

spring-test/src/main/java/org/springframework/test/context/BootstrapUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ abstract class BootstrapUtils {
4040

4141
private static final String DEFAULT_BOOTSTRAP_CONTEXT_CLASS_NAME = "org.springframework.test.context.support.DefaultBootstrapContext";
4242

43-
private static final String DEFAULT_CACHE_AWARE_CONTEXT_LOADER_DELEGATE_CLASS_NAME = "org.springframework.test.context.support.DefaultCacheAwareContextLoaderDelegate";
43+
private static final String DEFAULT_CACHE_AWARE_CONTEXT_LOADER_DELEGATE_CLASS_NAME = "org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate";
4444

4545
private static final String DEFAULT_TEST_CONTEXT_BOOTSTRAPPER_CLASS_NAME = "org.springframework.test.context.support.DefaultTestContextBootstrapper";
4646

@@ -55,7 +55,7 @@ private BootstrapUtils() {
5555
* Create the {@code BootstrapContext} for the specified {@linkplain Class test class}.
5656
*
5757
* <p>Uses reflection to create a {@link org.springframework.test.context.support.DefaultBootstrapContext}
58-
* that uses a {@link org.springframework.test.context.support.DefaultCacheAwareContextLoaderDelegate}.
58+
* that uses a {@link org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate}.
5959
*
6060
* @param testClass the test class for which the bootstrap context should be created
6161
* @return a new {@code BootstrapContext}; never {@code null}

spring-test/src/main/java/org/springframework/test/context/CacheAwareContextLoaderDelegate.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
/**
2424
* A {@code CacheAwareContextLoaderDelegate} is responsible for {@linkplain
2525
* #loadContext loading} and {@linkplain #closeContext closing} application
26-
* contexts, interacting transparently with a {@link ContextCache} behind
27-
* the scenes.
26+
* contexts, interacting transparently with a
27+
* {@link org.springframework.test.context.cache.ContextCache ContextCache}
28+
* behind the scenes.
2829
*
2930
* <p>Note: {@code CacheAwareContextLoaderDelegate} does not extend the
3031
* {@link ContextLoader} or {@link SmartContextLoader} interface.
@@ -41,7 +42,7 @@ public interface CacheAwareContextLoaderDelegate {
4142
* <p>If the context is present in the {@code ContextCache} it will simply
4243
* be returned; otherwise, it will be loaded, stored in the cache, and returned.
4344
* <p>The cache statistics should be logged by invoking
44-
* {@link ContextCache#logStatistics()}.
45+
* {@link org.springframework.test.context.cache.ContextCache#logStatistics()}.
4546
* @param mergedContextConfiguration the merged context configuration to use
4647
* to load the application context; never {@code null}
4748
* @return the application context

spring-test/src/main/java/org/springframework/test/context/ContextCache.java renamed to spring-test/src/main/java/org/springframework/test/context/cache/ContextCache.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.test.context;
17+
package org.springframework.test.context.cache;
1818

1919
import org.springframework.context.ApplicationContext;
2020
import org.springframework.test.annotation.DirtiesContext.HierarchyMode;
21+
import org.springframework.test.context.MergedContextConfiguration;
2122

2223
/**
2324
* {@code ContextCache} defines the SPI for caching Spring
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.test.context.support;
17+
package org.springframework.test.context.cache;
1818

1919
import org.apache.commons.logging.Log;
2020
import org.apache.commons.logging.LogFactory;
2121

2222
import org.springframework.context.ApplicationContext;
2323
import org.springframework.test.annotation.DirtiesContext.HierarchyMode;
2424
import org.springframework.test.context.CacheAwareContextLoaderDelegate;
25-
import org.springframework.test.context.ContextCache;
2625
import org.springframework.test.context.ContextLoader;
2726
import org.springframework.test.context.MergedContextConfiguration;
2827
import org.springframework.test.context.SmartContextLoader;

spring-test/src/main/java/org/springframework/test/context/support/DefaultContextCache.java renamed to spring-test/src/main/java/org/springframework/test/context/cache/DefaultContextCache.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.test.context.support;
17+
package org.springframework.test.context.cache;
1818

1919
import java.util.ArrayList;
2020
import java.util.HashSet;
@@ -31,7 +31,6 @@
3131
import org.springframework.context.ConfigurableApplicationContext;
3232
import org.springframework.core.style.ToStringCreator;
3333
import org.springframework.test.annotation.DirtiesContext.HierarchyMode;
34-
import org.springframework.test.context.ContextCache;
3534
import org.springframework.test.context.MergedContextConfiguration;
3635
import org.springframework.util.Assert;
3736

spring-test/src/main/java/org/springframework/test/context/support/AbstractTestContextBootstrapper.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import org.springframework.core.io.support.SpringFactoriesLoader;
3939
import org.springframework.test.context.BootstrapContext;
4040
import org.springframework.test.context.CacheAwareContextLoaderDelegate;
41-
import org.springframework.test.context.ContextCache;
4241
import org.springframework.test.context.ContextConfiguration;
4342
import org.springframework.test.context.ContextConfigurationAttributes;
4443
import org.springframework.test.context.ContextHierarchy;
@@ -68,8 +67,9 @@
6867
* <li>{@link #processMergedContextConfiguration}
6968
* </ul>
7069
*
71-
* <p>To plug in custom {@link ContextCache} support, override
72-
* {@link #getCacheAwareContextLoaderDelegate()}.
70+
* <p>To plug in custom
71+
* {@link org.springframework.test.context.cache.ContextCache ContextCache}
72+
* support, override {@link #getCacheAwareContextLoaderDelegate()}.
7373
*
7474
* @author Sam Brannen
7575
* @author Juergen Hoeller
@@ -481,8 +481,9 @@ protected Class<? extends ContextLoader> resolveExplicitContextLoaderClass(
481481
* <p>The default implementation simply delegates to
482482
* {@code getBootstrapContext().getCacheAwareContextLoaderDelegate()}.
483483
* <p>Concrete subclasses may choose to override this method to return a
484-
* custom {@code CacheAwareContextLoaderDelegate} implementation with
485-
* custom {@link ContextCache} support.
484+
* custom {@code CacheAwareContextLoaderDelegate} implementation with custom
485+
* {@link org.springframework.test.context.cache.ContextCache ContextCache}
486+
* support.
486487
* @return the context loader delegate (never {@code null})
487488
*/
488489
protected CacheAwareContextLoaderDelegate getCacheAwareContextLoaderDelegate() {

spring-test/src/test/java/org/springframework/test/context/MergedContextConfigurationTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,7 +33,8 @@
3333
* Unit tests for {@link MergedContextConfiguration}.
3434
*
3535
* <p>These tests primarily exist to ensure that {@code MergedContextConfiguration}
36-
* can safely be used as the cache key for {@link ContextCache}.
36+
* can safely be used as the cache key for
37+
* {@link org.springframework.test.context.cache.ContextCache ContextCache}.
3738
*
3839
* @author Sam Brannen
3940
* @since 3.1

spring-test/src/test/java/org/springframework/test/context/TestContextTestUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616

1717
package org.springframework.test.context;
1818

19+
import org.springframework.test.context.cache.ContextCache;
20+
import org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate;
1921
import org.springframework.test.context.support.DefaultBootstrapContext;
20-
import org.springframework.test.context.support.DefaultCacheAwareContextLoaderDelegate;
2122

2223
/**
2324
* Collection of test-related utility methods for working with {@link TestContext TestContexts}.

spring-test/src/test/java/org/springframework/test/context/ClassLevelDirtiesContextTestNGTests.java renamed to spring-test/src/test/java/org/springframework/test/context/cache/ClassLevelDirtiesContextTestNGTests.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.test.context;
17+
package org.springframework.test.context.cache;
1818

1919
import java.util.concurrent.atomic.AtomicInteger;
2020

@@ -29,6 +29,8 @@
2929
import org.springframework.context.annotation.Configuration;
3030
import org.springframework.test.annotation.DirtiesContext;
3131
import org.springframework.test.annotation.DirtiesContext.ClassMode;
32+
import org.springframework.test.context.ContextConfiguration;
33+
import org.springframework.test.context.TestExecutionListeners;
3234
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
3335
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;
3436
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
@@ -37,7 +39,7 @@
3739
import org.testng.TestNG;
3840

3941
import static org.junit.Assert.*;
40-
import static org.springframework.test.context.support.ContextCacheTestUtils.*;
42+
import static org.springframework.test.context.cache.ContextCacheTestUtils.*;
4143

4244
/**
4345
* JUnit 4 based integration test which verifies correct {@linkplain ContextCache

spring-test/src/test/java/org/springframework/test/context/ClassLevelDirtiesContextTests.java renamed to spring-test/src/test/java/org/springframework/test/context/cache/ClassLevelDirtiesContextTests.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.test.context;
17+
package org.springframework.test.context.cache;
1818

1919
import java.util.concurrent.atomic.AtomicInteger;
2020

@@ -30,13 +30,15 @@
3030
import org.springframework.context.annotation.Configuration;
3131
import org.springframework.test.annotation.DirtiesContext;
3232
import org.springframework.test.annotation.DirtiesContext.ClassMode;
33+
import org.springframework.test.context.ContextConfiguration;
34+
import org.springframework.test.context.TestExecutionListeners;
3335
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
3436
import org.springframework.test.context.junit4.TrackingRunListener;
3537
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
3638
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;
3739

3840
import static org.junit.Assert.*;
39-
import static org.springframework.test.context.support.ContextCacheTestUtils.*;
41+
import static org.springframework.test.context.cache.ContextCacheTestUtils.*;
4042

4143
/**
4244
* JUnit 4 based integration test which verifies correct {@linkplain ContextCache

spring-test/src/test/java/org/springframework/test/context/support/ContextCacheTestUtils.java renamed to spring-test/src/test/java/org/springframework/test/context/cache/ContextCacheTestUtils.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.test.context.support;
18-
19-
import org.springframework.test.context.ContextCache;
17+
package org.springframework.test.context.cache;
2018

2119
import static org.junit.Assert.*;
2220

spring-test/src/test/java/org/springframework/test/context/ContextCacheTests.java renamed to spring-test/src/test/java/org/springframework/test/context/cache/ContextCacheTests.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,26 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.test.context;
17+
package org.springframework.test.context.cache;
1818

1919
import org.junit.Before;
2020
import org.junit.Test;
2121

2222
import org.springframework.context.ApplicationContext;
2323
import org.springframework.context.annotation.Configuration;
2424
import org.springframework.test.annotation.DirtiesContext.HierarchyMode;
25+
import org.springframework.test.context.ActiveProfiles;
26+
import org.springframework.test.context.ActiveProfilesResolver;
27+
import org.springframework.test.context.ContextConfiguration;
28+
import org.springframework.test.context.ContextHierarchy;
29+
import org.springframework.test.context.MergedContextConfiguration;
30+
import org.springframework.test.context.TestContext;
31+
import org.springframework.test.context.TestContextTestUtils;
2532
import org.springframework.test.context.support.AnnotationConfigContextLoader;
26-
import org.springframework.test.context.support.DefaultContextCache;
2733
import org.springframework.test.util.ReflectionTestUtils;
2834

2935
import static org.junit.Assert.*;
30-
import static org.springframework.test.context.support.ContextCacheTestUtils.*;
36+
import static org.springframework.test.context.cache.ContextCacheTestUtils.*;
3137

3238
/**
3339
* Integration tests for verifying proper behavior of the {@link ContextCache} in

spring-test/src/test/java/org/springframework/test/context/SpringRunnerContextCacheTests.java renamed to spring-test/src/test/java/org/springframework/test/context/cache/SpringRunnerContextCacheTests.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.test.context;
17+
package org.springframework.test.context.cache;
1818

1919
import org.junit.AfterClass;
2020
import org.junit.BeforeClass;
@@ -26,12 +26,14 @@
2626
import org.springframework.beans.factory.annotation.Autowired;
2727
import org.springframework.context.ApplicationContext;
2828
import org.springframework.test.annotation.DirtiesContext;
29+
import org.springframework.test.context.ContextConfiguration;
30+
import org.springframework.test.context.TestExecutionListeners;
2931
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
3032
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
3133
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;
3234

3335
import static org.junit.Assert.*;
34-
import static org.springframework.test.context.support.ContextCacheTestUtils.*;
36+
import static org.springframework.test.context.cache.ContextCacheTestUtils.*;
3537

3638
/**
3739
* JUnit 4 based unit test which verifies correct {@link ContextCache
@@ -47,7 +49,7 @@
4749
@RunWith(SpringJUnit4ClassRunner.class)
4850
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
4951
@TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DirtiesContextTestExecutionListener.class })
50-
@ContextConfiguration("junit4/SpringJUnit4ClassRunnerAppCtxTests-context.xml")
52+
@ContextConfiguration("../junit4/SpringJUnit4ClassRunnerAppCtxTests-context.xml")
5153
public class SpringRunnerContextCacheTests {
5254

5355
private static ApplicationContext dirtiedApplicationContext;

spring-test/src/test/java/org/springframework/test/context/junit4/SpringJUnit4TestSuite.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,9 +19,8 @@
1919
import org.junit.runner.RunWith;
2020
import org.junit.runners.Suite;
2121
import org.junit.runners.Suite.SuiteClasses;
22-
23-
import org.springframework.test.context.ClassLevelDirtiesContextTests;
24-
import org.springframework.test.context.SpringRunnerContextCacheTests;
22+
import org.springframework.test.context.cache.ClassLevelDirtiesContextTests;
23+
import org.springframework.test.context.cache.SpringRunnerContextCacheTests;
2524
import org.springframework.test.context.junit4.annotation.AnnotationConfigSpringJUnit4ClassRunnerAppCtxTests;
2625
import org.springframework.test.context.junit4.annotation.BeanOverridingDefaultConfigClassesInheritedTests;
2726
import org.springframework.test.context.junit4.annotation.BeanOverridingExplicitConfigClassesInheritedTests;

0 commit comments

Comments
 (0)