LUCENE-5246: improve test to be more generic

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1527460 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shai Erera 2013-09-30 06:39:52 +00:00
parent f6ae77fc1e
commit d3d61d7192
1 changed files with 14 additions and 7 deletions

View File

@ -1190,17 +1190,24 @@ public class TestNumericDocValuesUpdates extends LuceneTestCase {
doc.add(new NumericDocValuesField("f", 1L));
writer.addDocument(doc);
// create _0_1.fnm
// create first gen of update files
writer.updateNumericDocValue(new Term("id", "d0"), "f", 2L);
writer.commit();
int numFiles = dir.listAll().length;
// create _0_2.fnm, and _0_1.fnm should be deleted
writer.updateNumericDocValue(new Term("id", "d0"), "f", 2L);
writer.commit();
assertTrue(dir.fileExists("_0_2.fnm"));
assertFalse("old generation field infos file should not exist in the directory: _0_1.fnm", dir.fileExists("_0_1.fnm"));
DirectoryReader r = DirectoryReader.open(dir);
assertEquals(2L, r.leaves().get(0).reader().getNumericDocValues("f").get(0));
r.close();
// create second gen of update files, first gen should be deleted
writer.updateNumericDocValue(new Term("id", "d0"), "f", 5L);
writer.commit();
assertEquals(numFiles, dir.listAll().length);
r = DirectoryReader.open(dir);
assertEquals(5L, r.leaves().get(0).reader().getNumericDocValues("f").get(0));
r.close();
writer.close();
dir.close();
}