lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ehatc...@apache.org
Subject svn commit: r348137 - in /lucene/java/trunk/src/test/org/apache/lucene/index: DocHelper.java TestDocumentWriter.java
Date Sat, 03 Dec 2005 22:16:26 GMT
Author: ehatcher
Date: Tue Nov 22 01:35:58 2005
New Revision: 348137

URL: http://svn.apache.org/viewcvs?rev=348137&view=rev
Log:
Fix TestSegmentReader, which broke due to previous changes to DocHelper.  getPositionIncrementGap
tests no longer use DocHelper, to avoid testing conflicts.


Modified:
    lucene/java/trunk/src/test/org/apache/lucene/index/DocHelper.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestDocumentWriter.java

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/DocHelper.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/test/org/apache/lucene/index/DocHelper.java?rev=348137&r1=348136&r2=348137&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/DocHelper.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/DocHelper.java Tue Nov 22 01:35:58
2005
@@ -71,14 +71,6 @@
   public static Field unStoredField2 = new Field(UNSTORED_FIELD_2_KEY, UNSTORED_2_FIELD_TEXT,
       Field.Store.NO, Field.Index.TOKENIZED, Field.TermVector.YES);
 
-  public static final String REPEATED_1_TEXT = "repeated one";
-  public static final String REPEATED_KEY = "repeated";
-  public static Field repeatedField1 = new Field(REPEATED_KEY, REPEATED_1_TEXT,
-      Field.Store.YES, Field.Index.TOKENIZED, Field.TermVector.NO);
-  public static final String REPEATED_2_TEXT = "repeated two";
-  public static Field repeatedField2 = new Field(REPEATED_KEY, REPEATED_2_TEXT,
-      Field.Store.YES, Field.Index.TOKENIZED, Field.TermVector.NO);
-
   public static Map nameValues = null;
 
   // ordered list of all the fields...
@@ -92,8 +84,6 @@
     unIndField,
     unStoredField1,
     unStoredField2,
-    repeatedField1,
-    repeatedField2
   };
 
   // Map<String fieldName, Field field>

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestDocumentWriter.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/test/org/apache/lucene/index/TestDocumentWriter.java?rev=348137&r1=348136&r2=348137&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestDocumentWriter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestDocumentWriter.java Tue Nov 22
01:35:58 2005
@@ -27,18 +27,17 @@
 import org.apache.lucene.store.RAMDirectory;
 
 import java.io.Reader;
+import java.io.IOException;
 
 public class TestDocumentWriter extends TestCase {
-  private RAMDirectory dir = new RAMDirectory();
-  private Document testDoc = new Document();
-
+  private RAMDirectory dir;
 
   public TestDocumentWriter(String s) {
     super(s);
   }
 
   protected void setUp() {
-    DocHelper.setupDoc(testDoc);
+    dir = new RAMDirectory();
   }
 
   protected void tearDown() {
@@ -51,15 +50,9 @@
   }
 
   public void testAddDocument() throws Exception {
-    Analyzer analyzer = new Analyzer() {
-      public TokenStream tokenStream(String fieldName, Reader reader) {
-        return new WhitespaceTokenizer(reader);
-      }
-
-      public int getPositionIncrementGap(String fieldName) {
-        return 500;
-      }
-    };
+    Document testDoc = new Document();
+    DocHelper.setupDoc(testDoc);
+    Analyzer analyzer = new WhitespaceAnalyzer();
     Similarity similarity = Similarity.getDefault();
     DocumentWriter writer = new DocumentWriter(dir, analyzer, similarity, 50);
     String segName = "test";
@@ -101,7 +94,30 @@
       }
     }
 
-    TermPositions termPositions = reader.termPositions(new Term(DocHelper.REPEATED_KEY, "repeated"));
+  }
+
+  public void testPositionIncrementGap() throws IOException {
+    Analyzer analyzer = new Analyzer() {
+      public TokenStream tokenStream(String fieldName, Reader reader) {
+        return new WhitespaceTokenizer(reader);
+      }
+
+      public int getPositionIncrementGap(String fieldName) {
+        return 500;
+      }
+    };
+
+    Similarity similarity = Similarity.getDefault();
+    DocumentWriter writer = new DocumentWriter(dir, analyzer, similarity, 50);
+    Document doc = new Document();
+    doc.add(new Field("repeated", "repeated one", Field.Store.YES, Field.Index.TOKENIZED));
+    doc.add(new Field("repeated", "repeated two", Field.Store.YES, Field.Index.TOKENIZED));
+
+    String segName = "test";
+    writer.addDocument(segName, doc);
+    SegmentReader reader = SegmentReader.get(new SegmentInfo(segName, 1, dir));
+
+    TermPositions termPositions = reader.termPositions(new Term("repeated", "repeated"));
     assertTrue(termPositions.next());
     int freq = termPositions.freq();
     assertEquals(2, freq);



Mime
View raw message