Apache Solr open-source search software
LUCENE-2858: Fix broken insanity tests.
Uwe Schindlerc1d1dfbabf1e
diff --git a/lucene/src/test/org/apache/lucene/util/TestFieldCacheSanityChecker.java b/lucene/src/test/org/apache/lucene/util/TestFieldCacheSanityChecker.javaindex d803912c06e..2134a4760d2 100644--- a/lucene/src/test/org/apache/lucene/util/TestFieldCacheSanityChecker.java+++ b/lucene/src/test/org/apache/lucene/util/TestFieldCacheSanityChecker.java@@ -20,7 +20,8 @@ import org.apache.lucene.analysis.MockAnalyzer;import org.apache.lucene.document.Document;import org.apache.lucene.document.StringField;import org.apache.lucene.search.FieldCache;-import org.apache.lucene.index.IndexReader;+import org.apache.lucene.index.AtomicIndexReader;+import org.apache.lucene.index.DirectoryReader;import org.apache.lucene.index.MultiReader;import org.apache.lucene.index.IndexWriter;import org.apache.lucene.index.SlowCompositeReaderWrapper;@@ -32,9 +33,9 @@ import java.io.IOException;public class TestFieldCacheSanityChecker extends LuceneTestCase {- protected IndexReader readerA;- protected IndexReader readerB;- protected IndexReader readerX;+ protected AtomicIndexReader readerA;+ protected AtomicIndexReader readerB;+ protected AtomicIndexReader readerX;protected Directory dirA, dirB;private static final int NUM_DOCS = 1000;@@ -69,9 +70,9 @@ public class TestFieldCacheSanityChecker extends LuceneTestCase {}wA.close();wB.close();- readerA = IndexReader.open(dirA);- readerB = IndexReader.open(dirB);- readerX = new MultiReader(readerA, readerB);+ readerA = SlowCompositeReaderWrapper.wrap(DirectoryReader.open(dirA));+ readerB = SlowCompositeReaderWrapper.wrap(DirectoryReader.open(dirB));+ readerX = SlowCompositeReaderWrapper.wrap(new MultiReader(readerA, readerB));}@Override@@ -88,12 +89,12 @@ public class TestFieldCacheSanityChecker extends LuceneTestCase {FieldCache cache = FieldCache.DEFAULT;cache.purgeAllCaches();- cache.getDoubles(SlowCompositeReaderWrapper.wrap(readerA), "theDouble", false);- cache.getDoubles(SlowCompositeReaderWrapper.wrap(readerA), "theDouble", FieldCache.DEFAULT_DOUBLE_PARSER, false);- cache.getDoubles(SlowCompositeReaderWrapper.wrap(readerB), "theDouble", FieldCache.DEFAULT_DOUBLE_PARSER, false);+ cache.getDoubles(readerA, "theDouble", false);+ cache.getDoubles(readerA, "theDouble", FieldCache.DEFAULT_DOUBLE_PARSER, false);+ cache.getDoubles(readerB, "theDouble", FieldCache.DEFAULT_DOUBLE_PARSER, false);- cache.getInts(SlowCompositeReaderWrapper.wrap(readerX), "theInt", false);- cache.getInts(SlowCompositeReaderWrapper.wrap(readerX), "theInt", FieldCache.DEFAULT_INT_PARSER, false);+ cache.getInts(readerX, "theInt", false);+ cache.getInts(readerX, "theInt", FieldCache.DEFAULT_INT_PARSER, false);// // //@@ -111,9 +112,9 @@ public class TestFieldCacheSanityChecker extends LuceneTestCase {FieldCache cache = FieldCache.DEFAULT;cache.purgeAllCaches();- cache.getInts(SlowCompositeReaderWrapper.wrap(readerX), "theInt", FieldCache.DEFAULT_INT_PARSER, false);- cache.getTerms(SlowCompositeReaderWrapper.wrap(readerX), "theInt");- cache.getBytes(SlowCompositeReaderWrapper.wrap(readerX), "theByte", false);+ cache.getInts(readerX, "theInt", FieldCache.DEFAULT_INT_PARSER, false);+ cache.getTerms(readerX, "theInt");+ cache.getBytes(readerX, "theByte", false);// // //@@ -131,36 +132,4 @@ public class TestFieldCacheSanityChecker extends LuceneTestCase {cache.purgeAllCaches();}- public void testInsanity2() throws IOException {- FieldCache cache = FieldCache.DEFAULT;- cache.purgeAllCaches();-- cache.getTerms(SlowCompositeReaderWrapper.wrap(readerA), "theString");- cache.getTerms(SlowCompositeReaderWrapper.wrap(readerB), "theString");- cache.getTerms(SlowCompositeReaderWrapper.wrap(readerX), "theString");-- cache.getBytes(SlowCompositeReaderWrapper.wrap(readerX), "theByte", false);--- // // //-- Insanity[] insanity =- FieldCacheSanityChecker.checkSanity(cache.getCacheEntries());-- assertEquals("wrong number of cache errors", 1, insanity.length);- assertEquals("wrong type of cache error",- InsanityType.SUBREADER,- insanity[0].getType());- assertEquals("wrong number of entries in cache error", 3,- insanity[0].getCacheEntries().length);-- // we expect bad things, don't let tearDown complain about them- cache.purgeAllCaches();- }-- public void testInsanity3() throws IOException {-- // :TODO: subreader tree walking is really hairy ... add more crazy tests.- }-}