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()
    
   
  
  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
  
  
  
  Return a 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
  
  Returns
  
  
    |
    Improve this Doc
  
  
    View Source
  
  
  AlwaysPostingsFormat(PostingsFormat)
  Return a 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
  
  Returns
  
  
    |
    Improve this Doc
  
  
    View Source
  
  
  AnyFilesExceptWriteLock(Directory)
  
  
  Declaration
  
    public static bool AnyFilesExceptWriteLock(Directory dir)
   
  Parameters
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Boolean | 
         | 
      
    
  
  
    |
    Improve this Doc
  
  
    View Source
  
  
  AssertAttributeReflection(Attribute, IDictionary<String, Object>)
  
  
  Declaration
  
    public static void AssertAttributeReflection(Attribute att, IDictionary<string, object> reflectedValues)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | Attribute | 
        att | 
        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
  
  
    |
    Improve this Doc
  
  
    View Source
  
  
  BytesToCharSequence(BytesRef, Random)
  
  
  Declaration
  
    public static ICharSequence BytesToCharSequence(BytesRef ref, Random random)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | BytesRef | 
        ref | 
         | 
      
      
        | System.Random | 
        random | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | J2N.Text.ICharSequence | 
         | 
      
    
  
  
    |
    Improve this Doc
  
  
    View Source
  
  
  CheckIndex(Directory)
  This runs the 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
  
  Returns
  
  
    |
    Improve this Doc
  
  
    View Source
  
  
  CheckIndex(Directory, Boolean)
  
  
  Declaration
  
    public static CheckIndex.Status CheckIndex(Directory dir, bool crossCheckTermVectors)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | Directory | 
        dir | 
         | 
      
      
        | System.Boolean | 
        crossCheckTermVectors | 
         | 
      
    
  
  Returns
  
  
    |
    Improve this Doc
  
  
    View Source
  
  
  CheckReader(AtomicReader, Boolean)
  
  
  Declaration
  
    public static void CheckReader(AtomicReader reader, bool crossCheckTermVectors)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | AtomicReader | 
        reader | 
         | 
      
      
        | System.Boolean | 
        crossCheckTermVectors | 
         | 
      
    
  
  
    |
    Improve this Doc
  
  
    View Source
  
  
  CheckReader(IndexReader)
  
  
  Declaration
  
    public static void CheckReader(IndexReader reader)
   
  Parameters
  
  
    |
    Improve this Doc
  
  
    View Source
  
  
  CloneDocument(Document)
  
  
  Declaration
  
    public static Document CloneDocument(Document doc1)
   
  Parameters
  
  Returns
  
  
    |
    Improve this Doc
  
  
    View Source
  
  
  Docs(Random, IndexReader, String, BytesRef, IBits, DocsEnum, DocsFlags)
  
  
  Declaration
  
    public static DocsEnum Docs(Random random, IndexReader r, string field, BytesRef term, IBits liveDocs, DocsEnum reuse, DocsFlags flags)
   
  Parameters
  
  Returns
  
  
    |
    Improve this Doc
  
  
    View Source
  
  
  Docs(Random, TermsEnum, IBits, DocsEnum, DocsFlags)
  
  
  Declaration
  
    public static DocsEnum Docs(Random random, TermsEnum termsEnum, IBits liveDocs, DocsEnum reuse, DocsFlags flags)
   
  Parameters
  
  Returns
  
  
    |
    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
  
  
  
  
  
  Declaration
  
    public static string GetDocValuesFormat(Codec codec, string field)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | Codec | 
        codec | 
         | 
      
      
        | System.String | 
        field | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.String | 
         | 
      
    
  
  
    |
    Improve this Doc
  
  
    View Source
  
  
  
  
  
  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 | 
      
    
    
      
        | 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
  
  
    |
    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
  
  
    |
    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
  
  
    |
    Improve this Doc
  
  
    View Source
  
  
  Rm(DirectoryInfo[])
  Deletes one or more files or directories (and everything underneath it).
 
  
  Declaration
  
    public static void Rm(params DirectoryInfo[] locations)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.IO.DirectoryInfo[] | 
        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
  
  
    |
    Improve this Doc
  
  
    View Source
  
  
  SyncConcurrentMerges(IndexWriter)
  
  
  Declaration
  
    public static void SyncConcurrentMerges(IndexWriter writer)
   
  Parameters
  
  
    |
    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 | 
         |