LUCENE-3606: fix test

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3606@1211867 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2011-12-08 13:19:32 +00:00
parent a354e99e56
commit 778fbc99d9
1 changed files with 16 additions and 16 deletions

View File

@ -20,6 +20,8 @@ package org.apache.lucene.index;
import java.io.IOException;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.StringField;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
@ -27,8 +29,15 @@ import org.apache.lucene.util.LuceneTestCase;
public class TestSizeBoundedForceMerge extends LuceneTestCase {
private void addDocs(IndexWriter writer, int numDocs) throws IOException {
addDocs(writer, numDocs, false);
}
private void addDocs(IndexWriter writer, int numDocs, boolean withID) throws IOException {
for (int i = 0; i < numDocs; i++) {
Document doc = new Document();
if (withID) {
doc.add(new Field("id", "" + i, StringField.TYPE_UNSTORED));
}
writer.addDocument(doc);
}
writer.commit();
@ -276,7 +285,6 @@ public class TestSizeBoundedForceMerge extends LuceneTestCase {
assertEquals(4, sis.size());
}
/* nocommit: Fix tests to use an id and delete by term
public void testSingleMergeableSegment() throws Exception {
Directory dir = new RAMDirectory();
@ -287,12 +295,9 @@ public class TestSizeBoundedForceMerge extends LuceneTestCase {
addDocs(writer, 5);
addDocs(writer, 3);
writer.close();
// delete the last document, so that the last segment is merged.
IndexReader r = IndexReader.open(dir);
r.deleteDocument(r.numDocs() - 1);
r.close();
writer.deleteDocuments(new Term("id", "10"));
writer.close();
conf = newWriterConfig();
LogMergePolicy lmp = new LogDocMergePolicy();
@ -309,7 +314,6 @@ public class TestSizeBoundedForceMerge extends LuceneTestCase {
assertEquals(3, sis.size());
assertFalse(sis.info(2).hasDeletions());
}
*/
public void testSingleNonMergeableSegment() throws Exception {
Directory dir = new RAMDirectory();
@ -317,7 +321,7 @@ public class TestSizeBoundedForceMerge extends LuceneTestCase {
IndexWriterConfig conf = newWriterConfig();
IndexWriter writer = new IndexWriter(dir, conf);
addDocs(writer, 3);
addDocs(writer, 3, true);
writer.close();
@ -336,21 +340,18 @@ public class TestSizeBoundedForceMerge extends LuceneTestCase {
assertEquals(1, sis.size());
}
/* nocommit: Fix tests to use an id and delete by term
public void testSingleMergeableTooLargeSegment() throws Exception {
Directory dir = new RAMDirectory();
IndexWriterConfig conf = newWriterConfig();
IndexWriter writer = new IndexWriter(dir, conf);
addDocs(writer, 5);
addDocs(writer, 5, true);
writer.close();
// delete the last document
IndexReader r = IndexReader.open(dir);
r.deleteDocument(r.numDocs() - 1);
r.close();
writer.deleteDocuments(new Term("id", "4"));
writer.close();
conf = newWriterConfig();
LogMergePolicy lmp = new LogDocMergePolicy();
@ -367,6 +368,5 @@ public class TestSizeBoundedForceMerge extends LuceneTestCase {
assertEquals(1, sis.size());
assertTrue(sis.info(0).hasDeletions());
}
*/
}