_TestUtil (Lucene 3.6.2 API)
Keywords: org.apache.lucene.util._TestUtil class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.lucene.util
Class _TestUtil

    java.lang.Object
      org.apache.lucene.util._TestUtil

    public class _TestUtil

extends Object

General utility methods for Lucene unit tests.

Constructor Summary
`_TestUtil()`

Method Summary
`static boolean` | `anyFilesExceptWriteLock(org.apache.lucene.store.Directory dir)`
`static String` | `arrayToString(int[] array)` Deprecated. -- in 3.0 we can use Arrays.toString instead
`static String` | `arrayToString(Object[] array)` Deprecated. -- in 3.0 we can use Arrays.toString instead
`static
`<T> void`
` | `assertAttributeReflection(org.apache.lucene.util.AttributeImpl att, Map<String,T> reflectedValues)` Checks some basic behaviour of an AttributeImpl
`static void` | `assertEquals(org.apache.lucene.search.TopDocs expected, org.apache.lucene.search.TopDocs actual)`
`static CharSequence` | `bytesToCharSequence(org.apache.lucene.util.BytesRef ref, Random random)`
`static org.apache.lucene.index.CheckIndex.Status` | `checkIndex(org.apache.lucene.store.Directory dir)` This runs the CheckIndex tool on the index in.
`static org.apache.lucene.document.Document` | `cloneDocument(org.apache.lucene.document.Document doc1)`
`static File` | `createTempFile(String prefix, String suffix, File directory)` insecure, fast version of File.createTempFile uses Random instead of SecureRandom.
`static File` | `getTempDir(String desc)` Returns temp dir, based on String arg in its name; does not create the directory.
`static void` | `keepFullyDeletedSegments(org.apache.lucene.index.IndexWriter w)`
`static int` | `nextInt(Random r, int start, int end)` start and end are BOTH inclusive
`static String` | `randomFixedByteLengthUnicodeString(Random r, int length)` Returns random string, with a given UTF-8 byte length
`static void` | `randomFixedLengthUnicodeString(Random random, char[] chars, int offset, int length)` Fills provided char[] with valid random unicode code unit sequence.
`static String` | `randomHtmlishString(Random random, int numElements)`
`static String` | `randomlyRecaseCodePoints(Random random, String str)` Randomly upcases, downcases, or leaves intact each code point in the given string
`static String` | `randomRealisticUnicodeString(Random r)` Returns random string of length between 0-20 codepoints, all codepoints within the same unicode block.
`static String` | `randomRealisticUnicodeString(Random r, int maxLength)` Returns random string of length up to maxLength codepoints , all codepoints within the same unicode block.
`static String` | `randomRealisticUnicodeString(Random r, int minLength, int maxLength)` Returns random string of length between min and max codepoints, all codepoints within the same unicode block.
`static String` | `randomRegexpishString(Random r)` Returns a String thats "regexpish" (contains lots of operators typically found in regular expressions) If you call this enough times, you might get a valid regex!
`static String` | `randomRegexpishString(Random r, int maxLength)` Returns a String thats "regexpish" (contains lots of operators typically found in regular expressions) If you call this enough times, you might get a valid regex!
`static String` | `randomSimpleString(Random r)`
`static String` | `randomSimpleString(Random r, int maxLength)`
`static String` | `randomUnicodeString(Random r)` Returns random string, including full unicode range.
`static String` | `randomUnicodeString(Random r, int maxLength)` Returns a random string up to a certain length.
`static void` | `reduceOpenFiles(org.apache.lucene.index.IndexWriter w)` just tries to configure things to keep the open file count lowish
`static void` | `rmDir(File dir)` Deletes a directory and everything underneath it.
`static void` | `setUseCompoundFile(org.apache.lucene.index.MergePolicy mp, boolean v)`
`static CharSequence` | `stringToCharSequence(String string, Random random)`
`static void` | `syncConcurrentMerges(org.apache.lucene.index.IndexWriter writer)`
`static void` | `syncConcurrentMerges(org.apache.lucene.index.MergeScheduler ms)`
`static void` | `unzip(File zipName, File destDir)` Convenience method: Unzip zipName + ".zip" under destDir, removing destDir first

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### _TestUtil

    public _TestUtil()

Method Detail

### getTempDir

    public static File getTempDir(String desc)

  Returns temp dir, based on String arg in its name; does not create the directory.

### rmDir

    public static void rmDir(File dir)
                      throws IOException

  Deletes a directory and everything underneath it.

  Throws:
    `IOException`

### unzip

    public static void unzip(File zipName,
                             File destDir)
                      throws IOException

  Convenience method: Unzip zipName + ".zip" under destDir, removing destDir first

  Throws:
    `IOException`

### syncConcurrentMerges

    public static void syncConcurrentMerges(org.apache.lucene.index.IndexWriter writer)

### syncConcurrentMerges

    public static void syncConcurrentMerges(org.apache.lucene.index.MergeScheduler ms)

### checkIndex

    public static org.apache.lucene.index.CheckIndex.Status checkIndex(org.apache.lucene.store.Directory dir)
                                                                throws IOException

  This runs the CheckIndex tool on the index in. If any issues are hit, a RuntimeException is thrown; else, true is returned.

  Throws:
    `IOException`

### arrayToString

    @Deprecated
    public static String arrayToString(int[] array)

  Deprecated. -- in 3.0 we can use Arrays.toString instead

  Use only for testing.

### nextInt

    public static int nextInt(Random r,
                              int start,
                              int end)

  start and end are BOTH inclusive

### setUseCompoundFile

    public static void setUseCompoundFile(org.apache.lucene.index.MergePolicy mp,
                                          boolean v)

### arrayToString

    @Deprecated
    public static String arrayToString(Object[] array)

  Deprecated. -- in 3.0 we can use Arrays.toString instead

  Use only for testing.

### randomSimpleString

    public static String randomSimpleString(Random r,
                                            int maxLength)

### randomSimpleString

    public static String randomSimpleString(Random r)

### randomUnicodeString

    public static String randomUnicodeString(Random r)

  Returns random string, including full unicode range.

### randomUnicodeString

    public static String randomUnicodeString(Random r,
                                             int maxLength)

  Returns a random string up to a certain length.

### randomFixedLengthUnicodeString

    public static void randomFixedLengthUnicodeString(Random random,
                                                      char[] chars,
                                                      int offset,
                                                      int length)

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

### randomRegexpishString

    public static String randomRegexpishString(Random r)

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

### randomRegexpishString

    public static String randomRegexpishString(Random r,
                                               int maxLength)

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

### randomHtmlishString

    public static String randomHtmlishString(Random random,
                                             int numElements)

### randomlyRecaseCodePoints

    public static String randomlyRecaseCodePoints(Random random,
                                                  String str)

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

### randomRealisticUnicodeString

    public static String randomRealisticUnicodeString(Random r)

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

### randomRealisticUnicodeString

    public static String randomRealisticUnicodeString(Random r,
                                                      int maxLength)

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

### randomRealisticUnicodeString

    public static String randomRealisticUnicodeString(Random r,
                                                      int minLength,
                                                      int maxLength)

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

### randomFixedByteLengthUnicodeString

    public static String randomFixedByteLengthUnicodeString(Random r,
                                                            int length)

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

### anyFilesExceptWriteLock

    public static boolean anyFilesExceptWriteLock(org.apache.lucene.store.Directory dir)
                                           throws IOException

  Throws:
    `IOException`

### reduceOpenFiles

    public static void reduceOpenFiles(org.apache.lucene.index.IndexWriter w)

  just tries to configure things to keep the open file count lowish

### assertAttributeReflection

    public static <T> void assertAttributeReflection(org.apache.lucene.util.AttributeImpl att,
                                                     Map<String,T> reflectedValues)

  Checks some basic behaviour of an AttributeImpl

  Parameters:
    `reflectedValues` - contains a map with "AttributeClass#key" as values

### keepFullyDeletedSegments

    public static void keepFullyDeletedSegments(org.apache.lucene.index.IndexWriter w)

### createTempFile

    public static File createTempFile(String prefix,
                                      String suffix,
                                      File directory)
                               throws IOException

  insecure, fast version of File.createTempFile uses Random instead of SecureRandom.

  Throws:
    `IOException`

### assertEquals

    public static void assertEquals(org.apache.lucene.search.TopDocs expected,
                                    org.apache.lucene.search.TopDocs actual)

### cloneDocument

    public static org.apache.lucene.document.Document cloneDocument(org.apache.lucene.document.Document doc1)

### stringToCharSequence

    public static CharSequence stringToCharSequence(String string,
                                                    Random random)

### bytesToCharSequence

    public static CharSequence bytesToCharSequence(org.apache.lucene.util.BytesRef ref,
                                                   Random random)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD