Show / Hide Table of Contents

    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 NewDirectory() are tracked to ensure they are disposed by the test.
    • When a MockDirectoryWrapper is disposed, 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 disposed, it runs to test if the index was corrupted.
    • MockDirectoryWrapper simulates some "features" of Windows, such as refusing to write/delete to open files.

    Inheritance
    System.Object
    BaseDirectoryWrapper
    MockDirectoryWrapper
    Inherited Members
    BaseDirectoryWrapper.IsOpen
    BaseDirectoryWrapper.CheckIndexOnDispose
    BaseDirectoryWrapper.CrossCheckTermVectorsOnDispose
    Namespace: Lucene.Net.Store
    Assembly: Lucene.Net.TestFramework.dll
    Syntax
    public class MockDirectoryWrapper : BaseDirectoryWrapper

    Constructors

    | Improve this Doc View Source

    MockDirectoryWrapper(Random, Directory)

    Declaration
    public MockDirectoryWrapper(Random random, Directory delegate)
    Parameters
    Type Name Description
    Random random
    Directory delegate

    Fields

    | Improve this Doc View Source

    m_lockFactory

    Declaration
    protected LockFactory m_lockFactory
    Field Value
    Type Description
    LockFactory

    Properties

    | Improve this Doc View Source

    AllowRandomFileNotFoundException

    If set to true (the default), when we throw random on OpenInput(String, IOContext) or CreateOutput(String, IOContext), we may sometimes throw .

    Declaration
    public virtual bool AllowRandomFileNotFoundException { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    AllowReadingFilesStillOpenForWrite

    If set to true, you can open an inputstream on a file that is still open for writes.

    Declaration
    public virtual bool AllowReadingFilesStillOpenForWrite { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    AssertNoDeleteOpenFile

    Trip a test assert if there is an attempt to delete an open file.

    Declaration
    public virtual bool AssertNoDeleteOpenFile { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    AssertNoUnreferencedFilesOnClose

    Declaration
    public virtual bool AssertNoUnreferencedFilesOnClose { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    FailOnCreateOutput

    Declaration
    public virtual bool FailOnCreateOutput { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    FailOnOpenInput

    Declaration
    public virtual bool FailOnOpenInput { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    InputCloneCount

    Declaration
    public virtual int InputCloneCount { get; }
    Property Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    LockFactory

    Declaration
    public override LockFactory LockFactory { get; }
    Property Value
    Type Description
    LockFactory
    | Improve this Doc View Source

    MaxSizeInBytes

    Declaration
    public virtual long MaxSizeInBytes { get; set; }
    Property Value
    Type Description
    System.Int64
    | Improve this Doc View Source

    MaxUsedSizeInBytes

    Returns the peek actual storage used (bytes) in this directory.

    Declaration
    public virtual long MaxUsedSizeInBytes { get; }
    Property Value
    Type Description
    System.Int64
    | Improve this Doc View Source

    NoDeleteOpenFile

    Emulate Windows whereby deleting an open file is not allowed (raise ).

    Declaration
    public virtual bool NoDeleteOpenFile { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    PreventDoubleWrite

    If set to true, we throw an if the same file is opened by CreateOutput(String, IOContext), ever.

    Declaration
    public virtual bool PreventDoubleWrite { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    RandomIOExceptionRate

    If 0.0, no exceptions will be thrown. Else this should be a double 0.0 - 1.0. We will randomly throw an on the first write to a based on this probability.

    Declaration
    public virtual double RandomIOExceptionRate { get; set; }
    Property Value
    Type Description
    System.Double
    | Improve this Doc View Source

    RandomIOExceptionRateOnOpen

    If 0.0, no exceptions will be thrown during OpenInput(String, IOContext) and CreateOutput(String, IOContext). Else this should be a double 0.0 - 1.0 and we will randomly throw an in OpenInput(String, IOContext) and CreateOutput(String, IOContext) with this probability.

    Declaration
    public virtual double RandomIOExceptionRateOnOpen { get; set; }
    Property Value
    Type Description
    System.Double
    | Improve this Doc View Source

    Throttling

    Declaration
    public virtual Throttling Throttling { get; set; }
    Property Value
    Type Description
    Throttling
    | Improve this Doc View Source

    TrackDiskUsage

    Declaration
    public virtual bool TrackDiskUsage { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    WrapLockFactory

    Set to false if you want to return the pure lockfactory and not wrap it with MockLockFactoryWrapper.

    Be careful if you turn this off: MockDirectoryWrapper might no longer be able to detect if you forget to close an , and spit out horribly scary confusing exceptions instead of simply telling you that.

    Declaration
    public virtual bool WrapLockFactory { get; set; }
    Property Value
    Type Description
    System.Boolean

    Methods

    | Improve this Doc View Source

    ClearCrash()

    Declaration
    public virtual void ClearCrash()
    | Improve this Doc View Source

    ClearLock(String)

    Declaration
    public override void ClearLock(string name)
    Parameters
    Type Name Description
    System.String name
    | Improve this Doc View Source

    Copy(Directory, String, String, IOContext)

    Declaration
    public override void Copy(Directory to, string src, string dest, IOContext context)
    Parameters
    Type Name Description
    Directory to
    System.String src
    System.String dest
    IOContext context
    Overrides
    BaseDirectoryWrapper.Copy(Directory, String, String, IOContext)
    | Improve this Doc View Source

    Crash()

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

    Declaration
    public virtual void Crash()
    | Improve this Doc View Source

    CreateOutput(String, IOContext)

    Declaration
    public override IndexOutput CreateOutput(string name, IOContext context)
    Parameters
    Type Name Description
    System.String name
    IOContext context
    Returns
    Type Description
    IndexOutput
    | Improve this Doc View Source

    CreateSlicer(String, IOContext)

    Declaration
    public override IndexInputSlicer CreateSlicer(string name, IOContext context)
    Parameters
    Type Name Description
    System.String name
    IOContext context
    Returns
    Type Description
    IndexInputSlicer
    Overrides
    BaseDirectoryWrapper.CreateSlicer(String, IOContext)
    | Improve this Doc View Source

    DeleteFile(String)

    Declaration
    public override void DeleteFile(string name)
    Parameters
    Type Name Description
    System.String name
    | Improve this Doc View Source

    Dispose(Boolean)

    Declaration
    protected override void Dispose(bool disposing)
    Parameters
    Type Name Description
    System.Boolean disposing
    Overrides
    BaseDirectoryWrapper.Dispose(Boolean)
    | Improve this Doc View Source

    FailOn(Failure)

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

    Declaration
    public virtual void FailOn(Failure fail)
    Parameters
    Type Name Description
    Failure fail
    | Improve this Doc View Source

    FileExists(String)

    Declaration
    public override bool FileExists(string name)
    Parameters
    Type Name Description
    System.String name
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    FileLength(String)

    Declaration
    public override long FileLength(string name)
    Parameters
    Type Name Description
    System.String name
    Returns
    Type Description
    System.Int64
    | Improve this Doc View Source

    GetLockID()

    Declaration
    public override string GetLockID()
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    GetOpenDeletedFiles()

    Declaration
    public virtual ICollection<string> GetOpenDeletedFiles()
    Returns
    Type Description
    ICollection<System.String>
    | Improve this Doc View Source

    GetRecomputedActualSizeInBytes()

    Like GetRecomputedSizeInBytes(), but, uses actual file lengths rather than buffer allocations (which are quantized up to nearest (now 1024) bytes.

    Declaration
    public long GetRecomputedActualSizeInBytes()
    Returns
    Type Description
    System.Int64
    | Improve this Doc View Source

    GetRecomputedSizeInBytes()

    Provided for testing purposes. Use GetSizeInBytes() instead.

    Declaration
    public long GetRecomputedSizeInBytes()
    Returns
    Type Description
    System.Int64
    | Improve this Doc View Source

    GetSizeInBytes()

    Declaration
    public long GetSizeInBytes()
    Returns
    Type Description
    System.Int64
    | Improve this Doc View Source

    ListAll()

    Declaration
    public override string[] ListAll()
    Returns
    Type Description
    System.String[]
    | Improve this Doc View Source

    MakeLock(String)

    Declaration
    public override Lock MakeLock(string name)
    Parameters
    Type Name Description
    System.String name
    Returns
    Type Description
    Lock
    | Improve this Doc View Source

    OpenInput(String, IOContext)

    Declaration
    public override IndexInput OpenInput(string name, IOContext context)
    Parameters
    Type Name Description
    System.String name
    IOContext context
    Returns
    Type Description
    IndexInput
    | Improve this Doc View Source

    RemoveIndexInput(IndexInput, String)

    Declaration
    public virtual void RemoveIndexInput(IndexInput in, string name)
    Parameters
    Type Name Description
    IndexInput in
    System.String name
    | Improve this Doc View Source

    RemoveIndexOutput(IndexOutput, String)

    Declaration
    public virtual void RemoveIndexOutput(IndexOutput out, string name)
    Parameters
    Type Name Description
    IndexOutput out
    System.String name
    | Improve this Doc View Source

    ResetMaxUsedSizeInBytes()

    Declaration
    public virtual void ResetMaxUsedSizeInBytes()
    | Improve this Doc View Source

    SetLockFactory(LockFactory)

    Declaration
    public override void SetLockFactory(LockFactory lockFactory)
    Parameters
    Type Name Description
    LockFactory lockFactory
    | Improve this Doc View Source

    Sync(ICollection<String>)

    Declaration
    public override void Sync(ICollection<string> names)
    Parameters
    Type Name Description
    ICollection<System.String> names
    • Improve this Doc
    • View Source
    Back to top Copyright © 2020 Licensed to the Apache Software Foundation (ASF)