lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gsing...@apache.org
Subject svn commit: r960147 - /lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermVectors.java
Date Sat, 03 Jul 2010 01:21:28 GMT
Author: gsingers
Date: Sat Jul  3 01:21:28 2010
New Revision: 960147

URL: http://svn.apache.org/viewvc?rev=960147&view=rev
Log:
Test some edge conditions

Modified:
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermVectors.java

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermVectors.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermVectors.java?rev=960147&r1=960146&r2=960147&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermVectors.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermVectors.java Sat Jul
 3 01:21:28 2010
@@ -66,6 +66,9 @@ public class TestTermVectors extends Luc
       }
       doc.add(new Field("field", English.intToEnglish(i),
           Field.Store.YES, Field.Index.ANALYZED, termVector));
+      //test no term vectors too
+      doc.add(new Field("noTV", English.intToEnglish(i),
+          Field.Store.YES, Field.Index.ANALYZED));
       writer.addDocument(doc);
     }
     writer.close();
@@ -88,6 +91,14 @@ public class TestTermVectors extends Luc
         assertTrue(vector != null);
         assertTrue(vector.length == 1);
       }
+      TermFreqVector vector;
+      vector = searcher.reader.getTermFreqVector(hits[0].doc, "noTV");
+      assertNull(vector);
+
+      TestTermVectorMapper mapper = new TestTermVectorMapper();
+      searcher.reader.getTermFreqVector(hits[0].doc, "noTV", mapper);
+      assertNull(mapper.field);
+
     } catch (IOException e) {
       assertTrue(false);
     }
@@ -426,4 +437,18 @@ public class TestTermVectors extends Luc
       assertEquals(4*i+3, offsets[i].getEndOffset());
     }
   }
+
+  private static class TestTermVectorMapper extends TermVectorMapper {
+    public String field = null;
+
+    @Override
+    public void setExpectations(String field, int numTerms, boolean storeOffsets, boolean
storePositions) {
+      this.field = field;
+    }
+
+    @Override
+    public void map(String term, int frequency, TermVectorOffsetInfo[] offsets, int[] positions)
{
+
+    }
+  }
 }



Mime
View raw message