public virtual void TestCloneClose()
{
MMapDirectory mmapDir = new MMapDirectory(CreateTempDir("testCloneClose"));
IndexOutput io = mmapDir.CreateOutput("bytes", NewIOContext(Random()));
io.WriteVInt(5);
io.Dispose();
IndexInput one = mmapDir.OpenInput("bytes", IOContext.DEFAULT);
IndexInput two = (IndexInput)one.Clone();
IndexInput three = (IndexInput)two.Clone(); // clone of clone
two.Dispose();
Assert.AreEqual(5, one.ReadVInt());
try
{
two.ReadVInt();
Assert.Fail("Must throw AlreadyClosedException");
}
catch (AlreadyClosedException ignore)
{
// pass
}
Assert.AreEqual(5, three.ReadVInt());
one.Dispose();
three.Dispose();
mmapDir.Dispose();
}