Browse Source

Introduce resetContextCache() in ContextCacheTestUtils

pull/780/head
Sam Brannen 10 years ago
parent
commit
0e287c1a90
  1. 5
      spring-test/src/test/java/org/springframework/test/context/ClassLevelDirtiesContextTestNGTests.java
  2. 5
      spring-test/src/test/java/org/springframework/test/context/ClassLevelDirtiesContextTests.java
  3. 7
      spring-test/src/test/java/org/springframework/test/context/ContextCacheTestUtils.java
  4. 3
      spring-test/src/test/java/org/springframework/test/context/SpringRunnerContextCacheTests.java

5
spring-test/src/test/java/org/springframework/test/context/ClassLevelDirtiesContextTestNGTests.java

@ -79,8 +79,9 @@ public class ClassLevelDirtiesContextTestNGTests { @@ -79,8 +79,9 @@ public class ClassLevelDirtiesContextTestNGTests {
@BeforeClass
public static void verifyInitialCacheState() {
ContextCache contextCache = TestContextManager.contextCache;
contextCache.reset();
resetContextCache();
// Reset static counters in case tests are run multiple times in a test suite --
// for example, via JUnit's @Suite.
cacheHits.set(0);
cacheMisses.set(0);
assertContextCacheStatistics("BeforeClass", 0, cacheHits.get(), cacheMisses.get());

5
spring-test/src/test/java/org/springframework/test/context/ClassLevelDirtiesContextTests.java

@ -74,8 +74,9 @@ public class ClassLevelDirtiesContextTests { @@ -74,8 +74,9 @@ public class ClassLevelDirtiesContextTests {
@BeforeClass
public static void verifyInitialCacheState() {
ContextCache contextCache = TestContextManager.contextCache;
contextCache.reset();
resetContextCache();
// Reset static counters in case tests are run multiple times in a test suite --
// for example, via JUnit's @Suite.
cacheHits.set(0);
cacheMisses.set(0);
assertContextCacheStatistics("BeforeClass", 0, cacheHits.get(), cacheMisses.get());

7
spring-test/src/test/java/org/springframework/test/context/ContextCacheTestUtils.java

@ -27,6 +27,13 @@ import static org.junit.Assert.*; @@ -27,6 +27,13 @@ import static org.junit.Assert.*;
*/
public class ContextCacheTestUtils {
/**
* Reset the state of the context cache.
*/
public static final void resetContextCache() {
TestContextManager.contextCache.reset();
}
/**
* Assert the statistics of the context cache in {@link TestContextManager}.
*

3
spring-test/src/test/java/org/springframework/test/context/SpringRunnerContextCacheTests.java

@ -58,8 +58,7 @@ public class SpringRunnerContextCacheTests { @@ -58,8 +58,7 @@ public class SpringRunnerContextCacheTests {
@BeforeClass
public static void verifyInitialCacheState() {
dirtiedApplicationContext = null;
ContextCache contextCache = TestContextManager.contextCache;
contextCache.reset();
resetContextCache();
assertContextCacheStatistics("BeforeClass", 0, 0, 0);
}

Loading…
Cancel
Save