LUCENE-3529: add test for trunk

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1188284 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2011-10-24 18:42:55 +00:00
parent 8602dd54fd
commit 15f471a737
1 changed files with 22 additions and 0 deletions

View File

@ -888,6 +888,28 @@ public class TestIndexWriter extends LuceneTestCase {
dir.close();
}
public void testEmptyFieldNameWithEmptyTerm() throws IOException {
Directory dir = newDirectory();
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random)));
Document doc = new Document();
doc.add(newField("", "", StringField.TYPE_UNSTORED));
doc.add(newField("", "a", StringField.TYPE_UNSTORED));
doc.add(newField("", "b", StringField.TYPE_UNSTORED));
doc.add(newField("", "c", StringField.TYPE_UNSTORED));
writer.addDocument(doc);
writer.close();
IndexReader reader = IndexReader.open(dir, true);
IndexReader subreader = getOnlySegmentReader(reader);
TermsEnum te = subreader.fields().terms("").iterator();
assertEquals(new BytesRef(""), te.next());
assertEquals(new BytesRef("a"), te.next());
assertEquals(new BytesRef("b"), te.next());
assertEquals(new BytesRef("c"), te.next());
assertNull(te.next());
reader.close();
dir.close();
}
private static final class MockIndexWriter extends IndexWriter {