public virtual void TestMissingCommits()
{
// Tests the behavior of SDP when commits that are given at ctor are missing
// on onInit().
Directory dir = NewDirectory();
IndexWriter writer = new IndexWriter(dir, GetConfig(Random(), DeletionPolicy));
SnapshotDeletionPolicy sdp = (SnapshotDeletionPolicy)writer.Config.DelPolicy;
writer.AddDocument(new Document());
writer.Commit();
IndexCommit s1 = sdp.Snapshot();
// create another commit, not snapshotted.
writer.AddDocument(new Document());
writer.Dispose();
// open a new writer w/ KeepOnlyLastCommit policy, so it will delete "s1"
// commit.
(new IndexWriter(dir, GetConfig(Random(), null))).Dispose();
Assert.IsFalse(SlowFileExists(dir, s1.SegmentsFileName), "snapshotted commit should not exist");
dir.Dispose();
}
}