Class MockDirectoryWrapper
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 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.
Inherited Members
Assembly: Lucene.Net.TestFramework.dll
Syntax
public class MockDirectoryWrapper : BaseDirectoryWrapper
Constructors
Name | Description |
---|---|
MockDirectoryWrapper(Random, Directory) |
Fields
Name | Description |
---|---|
LockFactory_Renamed |
Properties
Name | Description |
---|---|
AllowRandomFileNotFoundException | If set to true (the default), when we throw random System.IO.IOException on openInput or createOutput, we may sometimes throw FileNotFoundException or NoSuchFileException. |
AllowReadingFilesStillOpenForWrite | If set to true, you can open an inputstream on a file that is still open for writes. |
AssertNoDeleteOpenFile | Trip a test assert if there is an attempt to delete an open file. |
AssertNoUnrefencedFilesOnClose | |
FailOnCreateOutput | |
FailOnOpenInput | |
InputCloneCount | |
LockFactory | |
MaxSizeInBytes | |
MaxUsedSizeInBytes | Returns the peek actual storage used (bytes) in this directory. |
NoDeleteOpenFile | Emulate windows whereby deleting an open file is not allowed (raiseSystem.IO.IOException). |
OpenDeletedFiles | |
PreventDoubleWrite | If set to true, we throw anSystem.IO.IOException if the same file is opened by createOutput, ever. |
RandomIOExceptionRate | If 0.0, no exceptions will be thrown. Else this should be a double 0.0 - 1.0. We will randomly throw an System.IO.IOException on the first write to an OutputStream based on this probability. |
RandomIOExceptionRateOnOpen | If 0.0, no exceptions will be thrown during openInput and createOutput. Else this should be a double 0.0 - 1.0 and we will randomly throw an System.IO.IOException in openInput and createOutput with this probability. |
RecomputedActualSizeInBytes | Like getRecomputedSizeInBytes(), but, uses actual file lengths rather than buffer allocations (which are quantized up to nearest RAMOutputStream.BUFFER_SIZE (now 1024) bytes. |
RecomputedSizeInBytes | Provided for testing purposes. Use sizeInBytes() instead. |
Throttling | |
TrackDiskUsage | |
WrapLockFactory |
Methods
Name | Description |
---|---|
ClearCrash() | |
ClearLock(String) | |
Copy(Directory, String, String, IOContext) | |
Crash() | Simulates a crash of OS or machine by overwriting unsynced files. |
CreateOutput(String, IOContext) | |
CreateSlicer(String, IOContext) | |
DeleteFile(String) | |
Dispose(Boolean) | |
FailOn(MockDirectoryWrapper.Failure) | add a Failure object to the list of objects to be evaluated at every potential failure point |
FileExists(String) | |
FileLength(String) | |
GetLockID() | |
GetSizeInBytes() | |
ListAll() | |
MakeLock(String) | |
OpenInput(String, IOContext) | |
RemoveIndexInput(IndexInput, String) | |
RemoveIndexOutput(IndexOutput, String) | |
ResetMaxUsedSizeInBytes() | |
SetLockFactory(LockFactory) | |
Sync(ICollection<String>) |