Introduce resetContextCache() in ContextCacheTestUtils

This commit is contained in:
Sam Brannen 2015-04-18 19:16:59 +02:00
parent dc345dcb3d
commit 0e287c1a90
4 changed files with 14 additions and 6 deletions

View File

@ -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());

View File

@ -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());

View File

@ -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}.
*

View File

@ -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);
}