Fix tests reproducibility.

Some tests instantiate an IndexSearcher in an @BeforeClass method. So we need
to reset the query cache in @BeforeClass too or they would use a shared cache.


git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1664053 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Adrien Grand 2015-03-04 15:41:37 +00:00
parent 4d6df6a480
commit 5406a2ae14
1 changed files with 9 additions and 1 deletions

View File

@ -1651,7 +1651,15 @@ public abstract class LuceneTestCase extends Assert {
}
@Before
public void resetDefaultQueryCache() {
public void resetTestDefaultQueryCache() {
// Make sure each test method has its own cache
resetDefaultQueryCache();
}
@BeforeClass
public static void resetDefaultQueryCache() {
// we need to reset the query cache in an @BeforeClass so that tests that
// instantiate an IndexSearcher in an @BeforeClass method use a fresh new cache
IndexSearcher.setDefaultQueryCache(new LRUQueryCache(10000, 1 << 25));
IndexSearcher.setDefaultQueryCachingPolicy(MAYBE_CACHE_POLICY);
}