Class MockDirectoryWrapper

All Implemented Interfaces:
Closeable, AutoCloseable

public class MockDirectoryWrapper extends BaseDirectoryWrapper
This is a Directory Wrapper that adds methods intended to be used only by unit tests. It also adds a number of features useful for testing:
  • Instances created by LuceneTestCase.newDirectory() are tracked to ensure they are closed by the test.
  • When a MockDirectoryWrapper is closed, it will throw an exception if it has any open files against it (with a stacktrace indicating where they were opened from).
  • When a MockDirectoryWrapper is closed, it runs CheckIndex to test if the index was corrupted.
  • MockDirectoryWrapper simulates some "features" of Windows, such as refusing to write/delete to open files.