Class TestUtil
General utility methods for Lucene unit tests.
Inheritance
System.Object
TestUtil
Assembly: Lucene.Net.TestFramework.dll
Syntax
public static class TestUtil : object
Fields
|
Improve this Doc
View Source
WHITESPACE_CHARACTERS
List of characters that match .
Declaration
public static readonly char[] WHITESPACE_CHARACTERS
Field Value
Type |
Description |
System.Char[] |
|
Methods
|
Improve this Doc
View Source
Return a 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 |
DocValuesFormat |
format |
|
Returns
|
Improve this Doc
View Source
AlwaysPostingsFormat(PostingsFormat)
Return a 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 |
PostingsFormat |
format |
|
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>)
Checks some basic behaviour of an .
Declaration
public static void AssertAttributeReflection(Attribute att, IDictionary<string, object> reflectedValues)
Parameters
Type |
Name |
Description |
Attribute |
att |
to reflect
|
IDictionary<System.String, System.Object> |
reflectedValues |
Contains a 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 |
TopDocs |
expected |
|
TopDocs |
actual |
|
|
Improve this Doc
View Source
BytesToCharSequence(BytesRef, Random)
Declaration
public static ICharSequence BytesToCharSequence(BytesRef ref, Random random)
Parameters
Type |
Name |
Description |
BytesRef |
ref |
|
Random |
random |
|
Returns
Type |
Description |
ICharSequence |
|
|
Improve this Doc
View Source
CheckIndex(Directory)
This runs the tool on the index in. If any
issues are hit, an is thrown; else,
true is returned.
Declaration
public static CheckIndex.Status CheckIndex(Directory dir)
Parameters
Returns
Type |
Description |
CheckIndex.Status |
|
|
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
Type |
Description |
CheckIndex.Status |
|
|
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)
This runs the tool on the . If any
issues are hit, an is thrown.
Declaration
public static void CheckReader(IndexReader reader)
Parameters
Type |
Name |
Description |
IndexReader |
reader |
|
|
Improve this Doc
View Source
CloneDocument(Document)
Declaration
public static Document CloneDocument(Document doc1)
Parameters
Type |
Name |
Description |
Document |
doc1 |
|
Returns
Type |
Description |
Document |
|
|
Improve this Doc
View Source
Docs(Random, IndexReader, String, BytesRef, IBits, DocsEnum, DocsFlags)
Returns a , but randomly sometimes uses a
, . 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 |
Random |
random |
|
IndexReader |
r |
|
System.String |
field |
|
BytesRef |
term |
|
IBits |
liveDocs |
|
DocsEnum |
reuse |
|
DocsFlags |
flags |
|
Returns
Type |
Description |
DocsEnum |
|
|
Improve this Doc
View Source
Docs(Random, TermsEnum, IBits, DocsEnum, DocsFlags)
Returns a from a positioned , but
randomly sometimes uses a , .
Declaration
public static DocsEnum Docs(Random random, TermsEnum termsEnum, IBits liveDocs, DocsEnum reuse, DocsFlags flags)
Parameters
Type |
Name |
Description |
Random |
random |
|
TermsEnum |
termsEnum |
|
IBits |
liveDocs |
|
DocsEnum |
reuse |
|
DocsFlags |
flags |
|
Returns
Type |
Description |
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
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 |
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 |
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 |
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 |
Random |
random |
|
Returns
Type |
Description |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
Random |
r |
|
System.Int32 |
minLength |
|
System.Int32 |
maxLength |
|
Returns
Type |
Description |
System.String |
|
|
Improve this Doc
View Source
RandomRegex(Random)
Returns a valid (compiling) 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 |
Random |
random |
|
Returns
|
Improve this Doc
View Source
RandomRegexpishString(Random)
Returns a 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 |
Random |
r |
|
Returns
Type |
Description |
System.String |
|
|
Improve this Doc
View Source
RandomRegexpishString(Random, Int32)
Returns a 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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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
Type |
Name |
Description |
IndexWriter |
w |
|
|
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 |
DirectoryInfo[] |
locations |
|
|
Improve this Doc
View Source
StringToCharSequence(String, Random)
Declaration
public static ICharSequence StringToCharSequence(string string, Random random)
Parameters
Type |
Name |
Description |
System.String |
string |
|
Random |
random |
|
Returns
Type |
Description |
ICharSequence |
|
|
Improve this Doc
View Source
SyncConcurrentMerges(IMergeScheduler)
Declaration
public static void SyncConcurrentMerges(IMergeScheduler ms)
Parameters
Type |
Name |
Description |
IMergeScheduler |
ms |
|
|
Improve this Doc
View Source
SyncConcurrentMerges(IndexWriter)
Declaration
public static void SyncConcurrentMerges(IndexWriter writer)
Parameters
Type |
Name |
Description |
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 |
Stream |
zipFileStream |
|
DirectoryInfo |
destDir |
|