Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Class TestUtil

    General utility methods for Lucene unit tests.

    Inheritance
    System.Object
    TestUtil
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: Lucene.Net.Util
    Assembly: Lucene.Net.TestFramework.dll
    Syntax
    public static class TestUtil

    Fields

    | Improve this Doc View Source

    WHITESPACE_CHARACTERS

    List of characters that match System.Char.IsWhiteSpace(System.Char).

    Declaration
    public static readonly char[] WHITESPACE_CHARACTERS
    Field Value
    Type Description
    System.Char[]

    Methods

    | Improve this Doc View Source

    AlwaysDocValuesFormat(DocValuesFormat)

    Return a Lucene.Net.Codecs.Codec that can read any of the default codecs and formats, but always writes in the specified format.

    Declaration
    public static Codec AlwaysDocValuesFormat(DocValuesFormat format)
    Parameters
    Type Name Description
    Lucene.Net.Codecs.DocValuesFormat format
    Returns
    Type Description
    Lucene.Net.Codecs.Codec
    | Improve this Doc View Source

    AlwaysPostingsFormat(PostingsFormat)

    Return a Lucene.Net.Codecs.Codec that can read any of the default codecs and formats, but always writes in the specified format.

    Declaration
    public static Codec AlwaysPostingsFormat(PostingsFormat format)
    Parameters
    Type Name Description
    Lucene.Net.Codecs.PostingsFormat format
    Returns
    Type Description
    Lucene.Net.Codecs.Codec
    | Improve this Doc View Source

    AnyFilesExceptWriteLock(Directory)

    Declaration
    public static bool AnyFilesExceptWriteLock(Directory dir)
    Parameters
    Type Name Description
    Lucene.Net.Store.Directory dir
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    AssertAttributeReflection(Attribute, IDictionary<String, Object>)

    Checks some basic behaviour of an Lucene.Net.Util.Attribute.

    Declaration
    public static void AssertAttributeReflection(Attribute att, IDictionary<string, object> reflectedValues)
    Parameters
    Type Name Description
    Lucene.Net.Util.Attribute att

    Lucene.Net.Util.Attribute to reflect

    System.Collections.Generic.IDictionary<System.String, System.Object> reflectedValues

    Contains a System.Collections.Generic.IDictionary<TKey, TValue> with "AttributeSubclassType/key" as values.

    | Improve this Doc View Source

    AssertEquals(TopDocs, TopDocs)

    Declaration
    public static void AssertEquals(TopDocs expected, TopDocs actual)
    Parameters
    Type Name Description
    Lucene.Net.Search.TopDocs expected
    Lucene.Net.Search.TopDocs actual
    | Improve this Doc View Source

    BytesToCharSequence(BytesRef, Random)

    Declaration
    public static ICharSequence BytesToCharSequence(BytesRef ref, Random random)
    Parameters
    Type Name Description
    Lucene.Net.Util.BytesRef ref
    System.Random random
    Returns
    Type Description
    J2N.Text.ICharSequence
    | Improve this Doc View Source

    CheckIndex(Directory)

    This runs the Lucene.Net.Index.CheckIndex tool on the index in. If any issues are hit, an System.Exception is thrown; else, true is returned.

    Declaration
    public static CheckIndex.Status CheckIndex(Directory dir)
    Parameters
    Type Name Description
    Lucene.Net.Store.Directory dir
    Returns
    Type Description
    Lucene.Net.Index.CheckIndex.Status
    | Improve this Doc View Source

    CheckIndex(Directory, Boolean)

    Declaration
    public static CheckIndex.Status CheckIndex(Directory dir, bool crossCheckTermVectors)
    Parameters
    Type Name Description
    Lucene.Net.Store.Directory dir
    System.Boolean crossCheckTermVectors
    Returns
    Type Description
    Lucene.Net.Index.CheckIndex.Status
    | Improve this Doc View Source

    CheckReader(AtomicReader, Boolean)

    Declaration
    public static void CheckReader(AtomicReader reader, bool crossCheckTermVectors)
    Parameters
    Type Name Description
    Lucene.Net.Index.AtomicReader reader
    System.Boolean crossCheckTermVectors
    | Improve this Doc View Source

    CheckReader(IndexReader)

    This runs the Lucene.Net.Index.CheckIndex tool on the Lucene.Net.Index.IndexReader. If any issues are hit, an System.Exception is thrown.

    Declaration
    public static void CheckReader(IndexReader reader)
    Parameters
    Type Name Description
    Lucene.Net.Index.IndexReader reader
    | Improve this Doc View Source

    CloneDocument(Document)

    Declaration
    public static Document CloneDocument(Document doc1)
    Parameters
    Type Name Description
    Lucene.Net.Documents.Document doc1
    Returns
    Type Description
    Lucene.Net.Documents.Document
    | Improve this Doc View Source

    Docs(Random, IndexReader, String, BytesRef, IBits, DocsEnum, DocsFlags)

    Returns a Lucene.Net.Index.DocsEnum, but randomly sometimes uses a Lucene.Net.Index.MultiDocsEnum, Lucene.Net.Index.DocsAndPositionsEnum. Returns null if field/term doesn't exist.

    Declaration
    public static DocsEnum Docs(Random random, IndexReader r, string field, BytesRef term, IBits liveDocs, DocsEnum reuse, DocsFlags flags)
    Parameters
    Type Name Description
    System.Random random
    Lucene.Net.Index.IndexReader r
    System.String field
    Lucene.Net.Util.BytesRef term
    Lucene.Net.Util.IBits liveDocs
    Lucene.Net.Index.DocsEnum reuse
    Lucene.Net.Index.DocsFlags flags
    Returns
    Type Description
    Lucene.Net.Index.DocsEnum
    | Improve this Doc View Source

    Docs(Random, TermsEnum, IBits, DocsEnum, DocsFlags)

    Returns a Lucene.Net.Index.DocsEnum from a positioned Lucene.Net.Index.TermsEnum, but randomly sometimes uses a Lucene.Net.Index.MultiDocsEnum, Lucene.Net.Index.DocsAndPositionsEnum.

    Declaration
    public static DocsEnum Docs(Random random, TermsEnum termsEnum, IBits liveDocs, DocsEnum reuse, DocsFlags flags)
    Parameters
    Type Name Description
    System.Random random
    Lucene.Net.Index.TermsEnum termsEnum
    Lucene.Net.Util.IBits liveDocs
    Lucene.Net.Index.DocsEnum reuse
    Lucene.Net.Index.DocsFlags flags
    Returns
    Type Description
    Lucene.Net.Index.DocsEnum
    | Improve this Doc View Source

    FieldSupportsHugeBinaryDocValues(String)

    Declaration
    public static bool FieldSupportsHugeBinaryDocValues(string field)
    Parameters
    Type Name Description
    System.String field
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    GetDocValuesFormat(Codec, String)

    Declaration
    public static string GetDocValuesFormat(Codec codec, string field)
    Parameters
    Type Name Description
    Lucene.Net.Codecs.Codec codec
    System.String field
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    GetDocValuesFormat(String)

    Declaration
    public static string GetDocValuesFormat(string field)
    Parameters
    Type Name Description
    System.String field
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    GetPostingsFormat(Codec, String)

    Declaration
    public static string GetPostingsFormat(Codec codec, string field)
    Parameters
    Type Name Description
    Lucene.Net.Codecs.Codec codec
    System.String field
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    GetPostingsFormat(String)

    Declaration
    public static string GetPostingsFormat(string field)
    Parameters
    Type Name Description
    System.String field
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    NextInt32(Random, Int32, Int32)

    start and end are BOTH inclusive

    Declaration
    public static int NextInt32(Random r, int start, int end)
    Parameters
    Type Name Description
    System.Random r
    System.Int32 start
    System.Int32 end
    Returns
    Type Description
    System.Int32
    | Improve this Doc View Source

    NextInt64(Random, Int64, Int64)

    start and end are BOTH inclusive

    Declaration
    public static long NextInt64(Random r, long start, long end)
    Parameters
    Type Name Description
    System.Random r
    System.Int64 start
    System.Int64 end
    Returns
    Type Description
    System.Int64
    | Improve this Doc View Source

    RandomAnalysisString(Random, Int32, Boolean)

    Declaration
    public static string RandomAnalysisString(Random random, int maxLength, bool simple)
    Parameters
    Type Name Description
    System.Random random
    System.Int32 maxLength
    System.Boolean simple
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    RandomFilterStrategy(Random)

    Declaration
    public static FilteredQuery.FilterStrategy RandomFilterStrategy(Random random)
    Parameters
    Type Name Description
    System.Random random
    Returns
    Type Description
    Lucene.Net.Search.FilteredQuery.FilterStrategy
    | Improve this Doc View Source

    RandomFixedByteLengthUnicodeString(Random, Int32)

    Returns random string, with a given UTF-8 byte length.

    Declaration
    public static string RandomFixedByteLengthUnicodeString(Random r, int length)
    Parameters
    Type Name Description
    System.Random r
    System.Int32 length
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    RandomFixedLengthUnicodeString(Random, Char[], Int32, Int32)

    Fills provided char[] with valid random unicode code unit sequence.

    Declaration
    public static void RandomFixedLengthUnicodeString(Random random, char[] chars, int offset, int length)
    Parameters
    Type Name Description
    System.Random random
    System.Char[] chars
    System.Int32 offset
    System.Int32 length
    | Improve this Doc View Source

    RandomHtmlishString(Random, Int32)

    Returns a random HTML-like string.

    Declaration
    public static string RandomHtmlishString(Random random, int numElements)
    Parameters
    Type Name Description
    System.Random random
    System.Int32 numElements
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    RandomlyRecaseString(Random, String)

    Randomly upcases, downcases, or leaves intact each code point in the given string.

    Declaration
    public static string RandomlyRecaseString(Random random, string str)
    Parameters
    Type Name Description
    System.Random random
    System.String str
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    RandomRealisticUnicodeString(Random)

    Returns random string of length between 0-20 codepoints, all codepoints within the same unicode block.

    Declaration
    public static string RandomRealisticUnicodeString(Random r)
    Parameters
    Type Name Description
    System.Random r
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    RandomRealisticUnicodeString(Random, Int32)

    Returns random string of length up to maxLength codepoints, all codepoints within the same unicode block.

    Declaration
    public static string RandomRealisticUnicodeString(Random r, int maxLength)
    Parameters
    Type Name Description
    System.Random r
    System.Int32 maxLength
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    RandomRealisticUnicodeString(Random, Int32, Int32)

    Returns random string of length between min and max codepoints, all codepoints within the same unicode block.

    Declaration
    public static string RandomRealisticUnicodeString(Random r, int minLength, int maxLength)
    Parameters
    Type Name Description
    System.Random r
    System.Int32 minLength
    System.Int32 maxLength
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    RandomRegex(Random)

    Returns a valid (compiling) System.Text.RegularExpressions.Regex instance with random stuff inside. Be careful when applying random patterns to longer strings as certain types of patterns may explode into exponential times in backtracking implementations (such as Java's).

    Declaration
    public static Regex RandomRegex(Random random)
    Parameters
    Type Name Description
    System.Random random
    Returns
    Type Description
    System.Text.RegularExpressions.Regex
    | Improve this Doc View Source

    RandomRegexpishString(Random)

    Returns a System.String thats "regexpish" (contains lots of operators typically found in regular expressions) If you call this enough times, you might get a valid regex!

    Declaration
    public static string RandomRegexpishString(Random r)
    Parameters
    Type Name Description
    System.Random r
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    RandomRegexpishString(Random, Int32)

    Returns a System.String thats "regexpish" (contains lots of operators typically found in regular expressions) If you call this enough times, you might get a valid regex!

    Note: to avoid practically endless backtracking patterns we replace asterisk and plus operators with bounded repetitions. See LUCENE-4111 for more info.

    Declaration
    public static string RandomRegexpishString(Random r, int maxLength)
    Parameters
    Type Name Description
    System.Random r
    System.Int32 maxLength

    A hint about maximum length of the regexpish string. It may be exceeded by a few characters.

    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    RandomSimpleString(Random)

    Returns a random string consisting only of lowercase characters 'a' through 'z', between 0 and 20 characters in length.

    Declaration
    public static string RandomSimpleString(Random r)
    Parameters
    Type Name Description
    System.Random r
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    RandomSimpleString(Random, Int32)

    Returns a random string consisting only of lowercase characters 'a' through 'z'.

    Declaration
    public static string RandomSimpleString(Random r, int maxLength)
    Parameters
    Type Name Description
    System.Random r
    System.Int32 maxLength
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    RandomSimpleString(Random, Int32, Int32)

    Returns a random string consisting only of lowercase characters 'a' through 'z'.

    Declaration
    public static string RandomSimpleString(Random r, int minLength, int maxLength)
    Parameters
    Type Name Description
    System.Random r
    System.Int32 minLength
    System.Int32 maxLength
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    RandomSimpleStringRange(Random, Char, Char, Int32)

    Returns a random string consisting only of characters between minChar and maxChar.

    Declaration
    public static string RandomSimpleStringRange(Random r, char minChar, char maxChar, int maxLength)
    Parameters
    Type Name Description
    System.Random r
    System.Char minChar
    System.Char maxChar
    System.Int32 maxLength
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    RandomSubString(Random, Int32, Boolean)

    Declaration
    public static string RandomSubString(Random random, int wordLength, bool simple)
    Parameters
    Type Name Description
    System.Random random
    System.Int32 wordLength
    System.Boolean simple
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    RandomUnicodeString(Random)

    Returns random string, including full unicode range.

    Declaration
    public static string RandomUnicodeString(Random r)
    Parameters
    Type Name Description
    System.Random r
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    RandomUnicodeString(Random, Int32)

    Returns a random string up to a certain length.

    Declaration
    public static string RandomUnicodeString(Random r, int maxLength)
    Parameters
    Type Name Description
    System.Random r
    System.Int32 maxLength
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    RandomWhitespace(Random, Int32, Int32)

    Returns a random string in the specified length range consisting entirely of whitespace characters.

    Declaration
    public static string RandomWhitespace(Random r, int minLength, int maxLength)
    Parameters
    Type Name Description
    System.Random r
    System.Int32 minLength
    System.Int32 maxLength
    Returns
    Type Description
    System.String
    See Also
    WHITESPACE_CHARACTERS
    | Improve this Doc View Source

    ReduceOpenFiles(IndexWriter)

    Just tries to configure things to keep the open file count lowish.

    Declaration
    public static void ReduceOpenFiles(IndexWriter w)
    Parameters
    Type Name Description
    Lucene.Net.Index.IndexWriter w
    | Improve this Doc View Source

    Rm(FileSystemInfo[])

    Deletes one or more files or directories (and everything underneath it).

    Declaration
    public static void Rm(params FileSystemInfo[] locations)
    Parameters
    Type Name Description
    System.IO.FileSystemInfo[] locations
    Exceptions
    Type Condition
    System.IO.IOException

    If any of the given files (or their subhierarchy files in case of directories) cannot be removed.

    | Improve this Doc View Source

    StringToCharSequence(String, Random)

    Declaration
    public static ICharSequence StringToCharSequence(string string, Random random)
    Parameters
    Type Name Description
    System.String string
    System.Random random
    Returns
    Type Description
    J2N.Text.ICharSequence
    | Improve this Doc View Source

    SyncConcurrentMerges(IMergeScheduler)

    Declaration
    public static void SyncConcurrentMerges(IMergeScheduler ms)
    Parameters
    Type Name Description
    Lucene.Net.Index.IMergeScheduler ms
    | Improve this Doc View Source

    SyncConcurrentMerges(IndexWriter)

    Declaration
    public static void SyncConcurrentMerges(IndexWriter writer)
    Parameters
    Type Name Description
    Lucene.Net.Index.IndexWriter writer
    | Improve this Doc View Source

    Unzip(Stream, DirectoryInfo)

    Convenience method unzipping zipFileStream into destDir, cleaning up destDir first.

    Declaration
    public static void Unzip(Stream zipFileStream, DirectoryInfo destDir)
    Parameters
    Type Name Description
    System.IO.Stream zipFileStream
    System.IO.DirectoryInfo destDir
    • Improve this Doc
    • View Source
    Back to top Copyright © 2021 The Apache Software Foundation, Licensed under the Apache License, Version 2.0
    Apache Lucene.Net, Lucene.Net, Apache, the Apache feather logo, and the Apache Lucene.Net project logo are trademarks of The Apache Software Foundation.
    All other marks mentioned may be trademarks or registered trademarks of their respective owners.