From 8b80aac67945f506a7cd68a6b0ccaa782733a0e9 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Tue, 6 Dec 2011 01:11:08 +0000 Subject: [PATCH] LUCENE-3606: fix test git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3606@1210734 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/lucene/index/TestSumDocFreq.java | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/lucene/src/test/org/apache/lucene/index/TestSumDocFreq.java b/lucene/src/test/org/apache/lucene/index/TestSumDocFreq.java index 0c7a77e7f37..3d494f2c847 100644 --- a/lucene/src/test/org/apache/lucene/index/TestSumDocFreq.java +++ b/lucene/src/test/org/apache/lucene/index/TestSumDocFreq.java @@ -17,9 +17,9 @@ package org.apache.lucene.index; * limitations under the License. */ -import org.apache.lucene.analysis.MockAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; +import org.apache.lucene.document.StringField; import org.apache.lucene.document.TextField; import org.apache.lucene.store.Directory; import org.apache.lucene.util.LuceneTestCase; @@ -38,11 +38,14 @@ public class TestSumDocFreq extends LuceneTestCase { RandomIndexWriter writer = new RandomIndexWriter(random, dir); Document doc = new Document(); + Field id = newField("id", "", StringField.TYPE_UNSTORED); Field field1 = newField("foo", "", TextField.TYPE_UNSTORED); Field field2 = newField("bar", "", TextField.TYPE_UNSTORED); + doc.add(id); doc.add(field1); doc.add(field2); for (int i = 0; i < numDocs; i++) { + id.setValue("" + i); char ch1 = (char) _TestUtil.nextInt(random, 'a', 'z'); char ch2 = (char) _TestUtil.nextInt(random, 'a', 'z'); field1.setValue("" + ch1 + " " + ch2); @@ -53,28 +56,20 @@ public class TestSumDocFreq extends LuceneTestCase { } IndexReader ir = writer.getReader(); - writer.close(); assertSumDocFreq(ir); ir.close(); - /* nocommit: fix this to use IW to delete documents - ir = IndexReader.open(dir); int numDeletions = atLeast(20); for (int i = 0; i < numDeletions; i++) { - ir.deleteDocument(random.nextInt(ir.maxDoc())); + writer.deleteDocuments(new Term("id", "" + random.nextInt(numDocs))); } - ir.close(); - - IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random))); - w.forceMerge(1); - w.close(); + writer.forceMerge(1); + writer.close(); ir = IndexReader.open(dir); assertSumDocFreq(ir); ir.close(); - */ - dir.close(); }