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)

    Returns a random System.Int32 from minValue (inclusive) to maxValue (inclusive).

    Declaration
    public static int NextInt32(Random random, int minValue, int maxValue)
    Parameters
    Type Name Description
    System.Random random

    A System.Random instance.

    System.Int32 minValue

    The inclusive start of the range.

    System.Int32 maxValue

    The inclusive end of the range.

    Returns
    Type Description
    System.Int32

    A random System.Int32 from minValue (inclusive) to maxValue (inclusive).

    Exceptions
    Type Condition
    System.ArgumentException

    minValue is greater than maxValue.

    System.ArgumentNullException

    random is null.

    | Improve this Doc View Source

    NextInt64(Random, Int64, Int64)

    Returns a random System.Int64 from minValue to maxValue (inclusive).

    Declaration
    public static long NextInt64(Random random, long minValue, long maxValue)
    Parameters
    Type Name Description
    System.Random random

    A System.Random instance.

    System.Int64 minValue

    The inclusive start of the range.

    System.Int64 maxValue

    The inclusive end of the range.

    Returns
    Type Description
    System.Int64

    A random System.Int64 from minValue to maxValue (inclusive).

    Exceptions
    Type Condition
    System.ArgumentException

    minValue is greater than maxValue.

    System.ArgumentNullException

    random is null.

    | 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 random, int length)
    Parameters
    Type Name Description
    System.Random random
    System.Int32 length
    Returns
    Type Description
    System.String
    Exceptions
    Type Condition
    System.ArgumentOutOfRangeException

    length is less than 0.

    System.ArgumentNullException

    random is null.

    | 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 startIndex, int length)
    Parameters
    Type Name Description
    System.Random random

    This System.Random.

    System.Char[] chars

    A char[] with preallocated space to put the characters.

    System.Int32 startIndex

    The index of chars to begin populating with characters.

    System.Int32 length

    The number of characters to populate.

    Exceptions
    Type Condition
    System.ArgumentOutOfRangeException

    startIndex or length is less than 0.

    -or-

    startIndex + length refers to a position outside of the range of chars.

    System.ArgumentNullException

    random or chars is null.

    | 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

    This System.Random.

    System.Int32 numElements

    The maximum number of HTML elements to include in the string.

    Returns
    Type Description
    System.String
    Exceptions
    Type Condition
    System.ArgumentOutOfRangeException

    numElements is less than 0.

    System.ArgumentNullException

    random is null.

    | Improve this Doc View Source

    RandomlyRecaseString(Random, String)

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

    Declaration
    public static string RandomlyRecaseString(Random random, string value)
    Parameters
    Type Name Description
    System.Random random

    This System.Random.

    System.String value

    The string to recase randomly.

    Returns
    Type Description
    System.String
    Exceptions
    Type Condition
    System.ArgumentNullException

    random or value is null.

    | Improve this Doc View Source

    RandomlyRecaseString(Random, String, CultureInfo)

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

    Declaration
    public static string RandomlyRecaseString(Random random, string value, CultureInfo culture)
    Parameters
    Type Name Description
    System.Random random

    This System.Random.

    System.String value

    The string to recase randomly.

    System.Globalization.CultureInfo culture

    The culture to use when recasing the string.

    Returns
    Type Description
    System.String
    Exceptions
    Type Condition
    System.ArgumentNullException

    random, value or culture is null.

    | 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 random)
    Parameters
    Type Name Description
    System.Random random

    This System.Random.

    Returns
    Type Description
    System.String
    Exceptions
    Type Condition
    System.ArgumentNullException

    random is null.

    | 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 random, int maxLength)
    Parameters
    Type Name Description
    System.Random random

    This System.Random.

    System.Int32 maxLength

    The maximum length of the string to return (inclusive).

    Returns
    Type Description
    System.String
    Exceptions
    Type Condition
    System.ArgumentOutOfRangeException

    maxLength is less than 0.

    System.ArgumentNullException

    random is null.

    | 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 random, int minLength, int maxLength)
    Parameters
    Type Name Description
    System.Random random

    This System.Random.

    System.Int32 minLength

    The minimum length of the string to return (inclusive).

    System.Int32 maxLength

    The maximum length of the string to return (inclusive).

    Returns
    Type Description
    System.String
    Exceptions
    Type Condition
    System.ArgumentException

    minLength is greater than maxLength.

    System.ArgumentOutOfRangeException

    minLength or maxLength is less than 0.

    System.ArgumentNullException

    random is null.

    | 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

    RandomRegexishString(Random)

    Returns a System.String thats "regexish" (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 RandomRegexishString(Random random)
    Parameters
    Type Name Description
    System.Random random

    This System.Random.

    Returns
    Type Description
    System.String
    Exceptions
    Type Condition
    System.ArgumentNullException

    random is null.

    | Improve this Doc View Source

    RandomRegexpishString(Random, Int32)

    Returns a System.String thats "regexish" (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 random, int maxLength)
    Parameters
    Type Name Description
    System.Random random

    This System.Random.

    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
    Exceptions
    Type Condition
    System.ArgumentOutOfRangeException

    maxLength is less than 0.

    System.ArgumentNullException

    random is null.

    | Improve this Doc View Source

    RandomSimpleString(Random)

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

    Declaration
    public static string RandomSimpleString(Random random)
    Parameters
    Type Name Description
    System.Random random

    This System.Random.

    Returns
    Type Description
    System.String
    Exceptions
    Type Condition
    System.ArgumentNullException

    random is null.

    | Improve this Doc View Source

    RandomSimpleString(Random, Int32)

    Returns a random string consisting only of lowercase characters 'a' through 'z'. May be an empty string.

    Declaration
    public static string RandomSimpleString(Random random, int maxLength)
    Parameters
    Type Name Description
    System.Random random

    This System.Random.

    System.Int32 maxLength

    The maximum length of the string to return (inclusive).

    Returns
    Type Description
    System.String
    Exceptions
    Type Condition
    System.ArgumentOutOfRangeException

    maxLength is less than 0.

    System.ArgumentNullException

    random is null.

    | Improve this Doc View Source

    RandomSimpleString(Random, Int32, Int32)

    Returns a random string consisting only of lowercase characters 'a' through 'z'. May be an empty string.

    Declaration
    public static string RandomSimpleString(Random random, int minLength, int maxLength)
    Parameters
    Type Name Description
    System.Random random

    This System.Random.

    System.Int32 minLength

    The minimum length of the string to return (inclusive).

    System.Int32 maxLength

    The maximum length of the string to return (inclusive).

    Returns
    Type Description
    System.String
    Exceptions
    Type Condition
    System.ArgumentException

    minLength is greater than maxLength.

    System.ArgumentOutOfRangeException

    minLength or maxLength is less than 0.

    System.ArgumentNullException

    random is null.

    | Improve this Doc View Source

    RandomSimpleStringRange(Random, Char, Char, Int32)

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

    Declaration
    public static string RandomSimpleStringRange(Random random, char minChar, char maxChar, int maxLength)
    Parameters
    Type Name Description
    System.Random random

    This System.Random.

    System.Char minChar

    The minimum System.Char value of the range (inclusive).

    System.Char maxChar

    The maximum System.Char value of the range (inclusive).

    System.Int32 maxLength

    The maximum length of the string to generate.

    Returns
    Type Description
    System.String

    a random string consisting only of characters between minChar (inclusive) and maxChar (inclusive).

    Exceptions
    Type Condition
    System.ArgumentException

    minChar is greater than maxChar.

    System.ArgumentOutOfRangeException

    minChar or maxChar is not in the range between System.Char.MinValue and System.Char.MaxValue.

    -or-

    maxLength is less than 0.

    System.ArgumentNullException

    random is null.

    | 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 with up to 20 characters, including full unicode range.

    Declaration
    public static string RandomUnicodeString(Random random)
    Parameters
    Type Name Description
    System.Random random

    This System.Random.

    Returns
    Type Description
    System.String
    Exceptions
    Type Condition
    System.ArgumentNullException

    random is null.

    | Improve this Doc View Source

    RandomUnicodeString(Random, Int32)

    Returns a random string up to a certain length.

    Declaration
    public static string RandomUnicodeString(Random random, int maxLength)
    Parameters
    Type Name Description
    System.Random random

    This System.Random.

    System.Int32 maxLength

    The maximum length of the string to return.

    Returns
    Type Description
    System.String
    Exceptions
    Type Condition
    System.ArgumentOutOfRangeException

    maxLength is less than 0.

    System.ArgumentNullException

    random is null.

    | 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 random, int minLength, int maxLength)
    Parameters
    Type Name Description
    System.Random random
    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.