use of org.apache.lucene.util.SetOnce in project lucene-solr by apache.
the class TestIndexWriter method testMergeAllDeleted.
public void testMergeAllDeleted() throws IOException {
Directory dir = newDirectory();
IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random()));
final SetOnce<IndexWriter> iwRef = new SetOnce<>();
IndexWriter evilWriter = RandomIndexWriter.mockIndexWriter(random(), dir, iwc, new RandomIndexWriter.TestPoint() {
@Override
public void apply(String message) {
if ("startCommitMerge".equals(message)) {
iwRef.get().setKeepFullyDeletedSegments(false);
} else if ("startMergeInit".equals(message)) {
iwRef.get().setKeepFullyDeletedSegments(true);
}
}
});
iwRef.set(evilWriter);
for (int i = 0; i < 1000; i++) {
addDoc(evilWriter);
if (random().nextInt(17) == 0) {
evilWriter.commit();
}
}
evilWriter.deleteDocuments(new MatchAllDocsQuery());
evilWriter.forceMerge(1);
evilWriter.close();
dir.close();
}
Aggregations