LUCENE-8275: Fix TestDirectoryTaxonomyWriter.testRecreateAndRefresh

This commit is contained in:
Simon Willnauer 2018-04-30 12:06:06 +02:00
parent b43b09190d
commit fe018e37f3
1 changed files with 32 additions and 27 deletions

View File

@ -44,6 +44,7 @@ import org.apache.lucene.index.SegmentInfos;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.store.AlreadyClosedException;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.Constants;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.TestUtil;
import org.junit.Test;
@ -191,7 +192,7 @@ public class TestDirectoryTaxonomyWriter extends FacetTestCase {
// DirTaxoWriter lost the INDEX_EPOCH property if it was opened in
// CREATE_OR_APPEND (or commit(userData) called twice), which could lead to
// DirTaxoReader succeeding to refresh().
Directory dir = newDirectory();
try (Directory dir = newDirectory()) {
DirectoryTaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(dir, OpenMode.CREATE_OR_APPEND, NO_OP_CACHE);
touchTaxo(taxoWriter, new FacetLabel("a"));
@ -207,10 +208,15 @@ public class TestDirectoryTaxonomyWriter extends FacetTestCase {
// now recreate the taxonomy, and check that the epoch is preserved after opening DirTW again.
taxoWriter.close();
assumeFalse("if we are on windows and we have pending deletions we can't execute this test",
Constants.WINDOWS && dir.checkPendingDeletions());
taxoWriter = new DirectoryTaxonomyWriter(dir, OpenMode.CREATE, NO_OP_CACHE);
touchTaxo(taxoWriter, new FacetLabel("c"));
taxoWriter.close();
assumeFalse("if we are on windows and we have pending deletions we can't execute this test",
Constants.WINDOWS && dir.checkPendingDeletions());
taxoWriter = new DirectoryTaxonomyWriter(dir, OpenMode.CREATE_OR_APPEND, NO_OP_CACHE);
touchTaxo(taxoWriter, new FacetLabel("d"));
taxoWriter.close();
@ -219,9 +225,8 @@ public class TestDirectoryTaxonomyWriter extends FacetTestCase {
taxoReader.close();
taxoReader = newtr;
assertEquals(2, Integer.parseInt(taxoReader.getCommitUserData().get(DirectoryTaxonomyWriter.INDEX_EPOCH)));
taxoReader.close();
dir.close();
}
}
@Test