C# Class Lucene.Net.Store.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#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.
Inheritance: Lucene.Net.Store.BaseDirectoryWrapper
显示文件 Open project: paulirwin/lucene.net Class Usage Examples

Protected Properties

Property Type Description
LockFactory_Renamed LockFactory

Public Methods

Method Description
ClearCrash ( ) : void
ClearLock ( string name ) : void
Copy ( Directory to, string src, string dest, IOContext context ) : void
Crash ( ) : void

Simulates a crash of OS or machine by overwriting unsynced files.

CreateOutput ( string name, IOContext context ) : IndexOutput
CreateSlicer ( string name, IOContext context ) : IndexInputSlicer
DeleteFile ( string name ) : void
Dispose ( ) : void
FailOn ( Failure fail ) : void

add a Failure object to the list of objects to be evaluated at every potential failure point

FileExists ( string name ) : bool
FileLength ( string name ) : long
ListAll ( ) : string[]
MakeLock ( string name ) : Lock
MockDirectoryWrapper ( Random random, Directory @delegate ) : NUnit.Framework
OpenInput ( string name, IOContext context ) : IndexInput
RemoveIndexInput ( IndexInput @in, string name ) : void
RemoveIndexOutput ( IndexOutput @out, string name ) : void
ResetMaxUsedSizeInBytes ( ) : void
SizeInBytes ( ) : long
Sync ( ICollection names ) : void

Private Methods

Method Description
AddFileHandle ( IDisposable c, string name, Handle handle ) : void
DeleteFile ( string name, bool forced ) : void
FillOpenTrace ( Exception t, string name, bool input ) : Exception
Init ( ) : void
MaybeThrowDeterministicException ( ) : void

Iterate through the failures list, giving each object a chance to throw an IOE

MaybeThrowIOException ( string message ) : void
MaybeThrowIOExceptionOnOpen ( string name ) : void
MaybeYield ( ) : void
MustSync ( ) : bool

Returns true if #in must sync its files. Currently, only NRTCachingDirectory requires sync'ing its files because otherwise they are cached in an internal RAMDirectory. If other directories require that too, they should be added to this method.

RemoveOpenFile ( IDisposable c, string name ) : void

Method Details

ClearCrash() public method

public ClearCrash ( ) : void
return void

ClearLock() public method

public ClearLock ( string name ) : void
name string
return void

Copy() public method

public Copy ( Directory to, string src, string dest, IOContext context ) : void
to Directory
src string
dest string
context IOContext
return void

Crash() public method

Simulates a crash of OS or machine by overwriting unsynced files.
public Crash ( ) : void
return void

CreateOutput() public method

public CreateOutput ( string name, IOContext context ) : IndexOutput
name string
context IOContext
return IndexOutput

CreateSlicer() public method

public CreateSlicer ( string name, IOContext context ) : IndexInputSlicer
name string
context IOContext
return IndexInputSlicer

DeleteFile() public method

public DeleteFile ( string name ) : void
name string
return void

Dispose() public method

public Dispose ( ) : void
return void

FailOn() public method

add a Failure object to the list of objects to be evaluated at every potential failure point
public FailOn ( Failure fail ) : void
fail Failure
return void

FileExists() public method

public FileExists ( string name ) : bool
name string
return bool

FileLength() public method

public FileLength ( string name ) : long
name string
return long

ListAll() public method

public ListAll ( ) : string[]
return string[]

MakeLock() public method

public MakeLock ( string name ) : Lock
name string
return Lock

MockDirectoryWrapper() public method

public MockDirectoryWrapper ( Random random, Directory @delegate ) : NUnit.Framework
random Random
@delegate Directory
return NUnit.Framework

OpenInput() public method

public OpenInput ( string name, IOContext context ) : IndexInput
name string
context IOContext
return IndexInput

RemoveIndexInput() public method

public RemoveIndexInput ( IndexInput @in, string name ) : void
@in IndexInput
name string
return void

RemoveIndexOutput() public method

public RemoveIndexOutput ( IndexOutput @out, string name ) : void
@out IndexOutput
name string
return void

ResetMaxUsedSizeInBytes() public method

public ResetMaxUsedSizeInBytes ( ) : void
return void

SizeInBytes() public method

public SizeInBytes ( ) : long
return long

Sync() public method

public Sync ( ICollection names ) : void
names ICollection
return void

Property Details

LockFactory_Renamed protected_oe property

protected LockFactory LockFactory_Renamed
return LockFactory