lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r888448 - /lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestFlex.java
Date Tue, 08 Dec 2009 15:46:07 GMT
Author: mikemccand
Date: Tue Dec  8 15:46:07 2009
New Revision: 888448

URL: http://svn.apache.org/viewvc?rev=888448&view=rev
Log:
LUCENE-2111: add to test case: make sure with emulation of old API that seeking beyond end
results in .term() returning null

Modified:
    lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestFlex.java

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestFlex.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestFlex.java?rev=888448&r1=888447&r2=888448&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestFlex.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestFlex.java Tue Dec
 8 15:46:07 2009
@@ -35,24 +35,33 @@
 
     IndexWriter w = new IndexWriter(d, new WhitespaceAnalyzer(),
                                     IndexWriter.MaxFieldLength.UNLIMITED);
-    w.setMaxBufferedDocs(7);
-    Document doc = new Document();
-    doc.add(new Field("field1", "this is field1", Field.Store.NO, Field.Index.ANALYZED));
-    doc.add(new Field("field2", "this is field2", Field.Store.NO, Field.Index.ANALYZED));
-    doc.add(new Field("field3", "aaa", Field.Store.NO, Field.Index.ANALYZED));
-    doc.add(new Field("field4", "bbb", Field.Store.NO, Field.Index.ANALYZED));
-    for(int i=0;i<DOC_COUNT;i++) {
-      w.addDocument(doc);
-    }
-
-    IndexReader r = w.getReader();
 
-    TermEnum terms = r.terms(new Term("field3", "bbb"));
-    // pre-flex API should seek to the next field
-    assertNotNull(terms.term());
-    assertEquals("field4", terms.term().field());
+    for(int iter=0;iter<2;iter++) {
+      if (iter == 0) {
+        w.setMaxBufferedDocs(7);
+        Document doc = new Document();
+        doc.add(new Field("field1", "this is field1", Field.Store.NO, Field.Index.ANALYZED));
+        doc.add(new Field("field2", "this is field2", Field.Store.NO, Field.Index.ANALYZED));
+        doc.add(new Field("field3", "aaa", Field.Store.NO, Field.Index.ANALYZED));
+        doc.add(new Field("field4", "bbb", Field.Store.NO, Field.Index.ANALYZED));
+        for(int i=0;i<DOC_COUNT;i++) {
+          w.addDocument(doc);
+        }
+      } else {
+        w.optimize();
+      }
+
+      IndexReader r = w.getReader();
+      TermEnum terms = r.terms(new Term("field3", "bbb"));
+      // pre-flex API should seek to the next field
+      assertNotNull(terms.term());
+      assertEquals("field4", terms.term().field());
+      
+      terms = r.terms(new Term("field5", "abc"));
+      assertNull(terms.term());
+      r.close();
+    }
 
-    r.close();
     w.close();
     d.close();
   }



Mime
View raw message