You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2012/01/29 20:39:43 UTC

svn commit: r1237432 - /lucene/dev/branches/lucene2858/lucene/src/test/org/apache/lucene/util/TestFieldCacheSanityChecker.java

Author: uschindler
Date: Sun Jan 29 19:39:42 2012
New Revision: 1237432

URL: http://svn.apache.org/viewvc?rev=1237432&view=rev
Log:
LUCENE-2858: Fix broken insanity tests.

Modified:
    lucene/dev/branches/lucene2858/lucene/src/test/org/apache/lucene/util/TestFieldCacheSanityChecker.java

Modified: lucene/dev/branches/lucene2858/lucene/src/test/org/apache/lucene/util/TestFieldCacheSanityChecker.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2858/lucene/src/test/org/apache/lucene/util/TestFieldCacheSanityChecker.java?rev=1237432&r1=1237431&r2=1237432&view=diff
==============================================================================
--- lucene/dev/branches/lucene2858/lucene/src/test/org/apache/lucene/util/TestFieldCacheSanityChecker.java (original)
+++ lucene/dev/branches/lucene2858/lucene/src/test/org/apache/lucene/util/TestFieldCacheSanityChecker.java Sun Jan 29 19:39:42 2012
@@ -20,7 +20,8 @@ import org.apache.lucene.analysis.MockAn
 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
     }
     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
     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
     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
     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.
-  }
-
 }