Package org.apache.lucene.analysis
Class BaseTokenStreamTestCase
- java.lang.Object
-
- org.junit.Assert
-
- org.apache.lucene.util.LuceneTestCase
-
- org.apache.lucene.analysis.BaseTokenStreamTestCase
-
public abstract class BaseTokenStreamTestCase extends LuceneTestCase
Base class for all Lucene unit tests that use TokenStreams.When writing unit tests for analysis components, its highly recommended to use the helper methods here (especially in conjunction with
MockAnalyzerorMockTokenizer), as they contain many assertions and checks to catch bugs.- See Also:
MockAnalyzer,MockTokenizer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceBaseTokenStreamTestCase.CheckClearAttributesAttributeAttribute that records if it was cleared or not.static classBaseTokenStreamTestCase.CheckClearAttributesAttributeImplAttribute that records if it was cleared or not.-
Nested classes/interfaces inherited from class org.apache.lucene.util.LuceneTestCase
LuceneTestCase.Nightly
-
-
Field Summary
-
Fields inherited from class org.apache.lucene.util.LuceneTestCase
classRules, random, RANDOM_MULTIPLIER, ruleChain, stores, TEMP_DIR, TEST_CLEAN_THREADS, TEST_DIRECTORY, TEST_ITER, TEST_ITER_MIN, TEST_LINE_DOCS_FILE, TEST_LOCALE, TEST_NIGHTLY, TEST_SEED, TEST_TIMEZONE, TEST_VERSION_CURRENT, testsFailed, VERBOSE
-
-
Constructor Summary
Constructors Constructor Description BaseTokenStreamTestCase()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidassertAnalyzesTo(Analyzer a, String input, String[] output)static voidassertAnalyzesTo(Analyzer a, String input, String[] output, int[] posIncrements)static voidassertAnalyzesTo(Analyzer a, String input, String[] output, int[] startOffsets, int[] endOffsets)static voidassertAnalyzesTo(Analyzer a, String input, String[] output, int[] startOffsets, int[] endOffsets, int[] posIncrements)static voidassertAnalyzesTo(Analyzer a, String input, String[] output, int[] startOffsets, int[] endOffsets, String[] types, int[] posIncrements)static voidassertAnalyzesTo(Analyzer a, String input, String[] output, int[] startOffsets, int[] endOffsets, String[] types, int[] posIncrements, int[] posLengths)static voidassertAnalyzesTo(Analyzer a, String input, String[] output, int[] startOffsets, int[] endOffsets, String[] types, int[] posIncrements, int[] posLengths, boolean offsetsAreCorrect)static voidassertAnalyzesTo(Analyzer a, String input, String[] output, String[] types)static voidassertAnalyzesToPositions(Analyzer a, String input, String[] output, int[] posIncrements, int[] posLengths)static voidassertAnalyzesToReuse(Analyzer a, String input, String[] output)static voidassertAnalyzesToReuse(Analyzer a, String input, String[] output, int[] posIncrements)static voidassertAnalyzesToReuse(Analyzer a, String input, String[] output, int[] startOffsets, int[] endOffsets)static voidassertAnalyzesToReuse(Analyzer a, String input, String[] output, int[] startOffsets, int[] endOffsets, int[] posIncrements)static voidassertAnalyzesToReuse(Analyzer a, String input, String[] output, int[] startOffsets, int[] endOffsets, String[] types, int[] posIncrements)static voidassertAnalyzesToReuse(Analyzer a, String input, String[] output, String[] types)static voidassertTokenStreamContents(TokenStream ts, String[] output)static voidassertTokenStreamContents(TokenStream ts, String[] output, int[] posIncrements)static voidassertTokenStreamContents(TokenStream ts, String[] output, int[] startOffsets, int[] endOffsets)static voidassertTokenStreamContents(TokenStream ts, String[] output, int[] startOffsets, int[] endOffsets, int[] posIncrements)static voidassertTokenStreamContents(TokenStream ts, String[] output, int[] startOffsets, int[] endOffsets, int[] posIncrements, int[] posLengths, Integer finalOffset)static voidassertTokenStreamContents(TokenStream ts, String[] output, int[] startOffsets, int[] endOffsets, int[] posIncrements, Integer finalOffset)static voidassertTokenStreamContents(TokenStream ts, String[] output, int[] startOffsets, int[] endOffsets, Integer finalOffset)static voidassertTokenStreamContents(TokenStream ts, String[] output, int[] startOffsets, int[] endOffsets, String[] types, int[] posIncrements)static voidassertTokenStreamContents(TokenStream ts, String[] output, int[] startOffsets, int[] endOffsets, String[] types, int[] posIncrements, int[] posLengths, Integer finalOffset)static voidassertTokenStreamContents(TokenStream ts, String[] output, int[] startOffsets, int[] endOffsets, String[] types, int[] posIncrements, int[] posLengths, Integer finalOffset, boolean offsetsAreCorrect)static voidassertTokenStreamContents(TokenStream ts, String[] output, int[] startOffsets, int[] endOffsets, String[] types, int[] posIncrements, Integer finalOffset)static voidassertTokenStreamContents(TokenStream ts, String[] output, String[] types)static voidcheckAnalysisConsistency(Random random, Analyzer a, boolean useCharFilter, String text)static voidcheckAnalysisConsistency(Random random, Analyzer a, boolean useCharFilter, String text, boolean offsetsAreCorrect)static voidcheckOneTerm(Analyzer a, String input, String expected)static voidcheckOneTermReuse(Analyzer a, String input, String expected)static voidcheckRandomData(Random random, Analyzer a, int iterations)utility method for blasting tokenstreams with data to make sure they don't do anything crazystatic voidcheckRandomData(Random random, Analyzer a, int iterations, boolean simple)utility method for blasting tokenstreams with data to make sure they don't do anything crazystatic voidcheckRandomData(Random random, Analyzer a, int iterations, int maxWordLength)utility method for blasting tokenstreams with data to make sure they don't do anything crazystatic voidcheckRandomData(Random random, Analyzer a, int iterations, int maxWordLength, boolean simple)static voidcheckRandomData(Random random, Analyzer a, int iterations, int maxWordLength, boolean simple, boolean offsetsAreCorrect)static Stringescape(String s)protected StringtoDot(Analyzer a, String inputText)protected voidtoDotFile(Analyzer a, String inputText, String localFileName)-
Methods inherited from class org.apache.lucene.util.LuceneTestCase
afterClassLuceneTestCaseJ4, alwaysIgnoredTestMethod, assertEquals, assertEquals, assertEquals, assertEquals, assertSaneFieldCaches, asSet, assumeFalse, assumeNoException, assumeTrue, atLeast, atLeast, beforeClassLuceneTestCaseJ4, dumpArray, dumpIterator, getDataFile, getName, getTestClass, getTestLabel, isTestThread, localeForName, newDirectory, newDirectory, newDirectory, newDirectory, newField, newField, newField, newField, newField, newField, newFSDirectory, newFSDirectory, newIndexWriterConfig, newIndexWriterConfig, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newSearcher, newSearcher, newTieredMergePolicy, newTieredMergePolicy, purgeFieldCache, randomDirectory, randomLocale, randomTimeZone, rarely, rarely, reportAdditionalFailureInfo, reportPartialFailureInfo, setMergeFactor, setUp, setUseCompoundFile, tearDown, usually, usually
-
Methods inherited from class org.junit.Assert
assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertThat, assertThat, assertTrue, assertTrue, fail, fail
-
-
-
-
Method Detail
-
assertTokenStreamContents
public static void assertTokenStreamContents(TokenStream ts, String[] output, int[] startOffsets, int[] endOffsets, String[] types, int[] posIncrements, int[] posLengths, Integer finalOffset, boolean offsetsAreCorrect) throws IOException
- Throws:
IOException
-
assertTokenStreamContents
public static void assertTokenStreamContents(TokenStream ts, String[] output, int[] startOffsets, int[] endOffsets, String[] types, int[] posIncrements, int[] posLengths, Integer finalOffset) throws IOException
- Throws:
IOException
-
assertTokenStreamContents
public static void assertTokenStreamContents(TokenStream ts, String[] output, int[] startOffsets, int[] endOffsets, String[] types, int[] posIncrements, Integer finalOffset) throws IOException
- Throws:
IOException
-
assertTokenStreamContents
public static void assertTokenStreamContents(TokenStream ts, String[] output, int[] startOffsets, int[] endOffsets, String[] types, int[] posIncrements) throws IOException
- Throws:
IOException
-
assertTokenStreamContents
public static void assertTokenStreamContents(TokenStream ts, String[] output) throws IOException
- Throws:
IOException
-
assertTokenStreamContents
public static void assertTokenStreamContents(TokenStream ts, String[] output, String[] types) throws IOException
- Throws:
IOException
-
assertTokenStreamContents
public static void assertTokenStreamContents(TokenStream ts, String[] output, int[] posIncrements) throws IOException
- Throws:
IOException
-
assertTokenStreamContents
public static void assertTokenStreamContents(TokenStream ts, String[] output, int[] startOffsets, int[] endOffsets) throws IOException
- Throws:
IOException
-
assertTokenStreamContents
public static void assertTokenStreamContents(TokenStream ts, String[] output, int[] startOffsets, int[] endOffsets, Integer finalOffset) throws IOException
- Throws:
IOException
-
assertTokenStreamContents
public static void assertTokenStreamContents(TokenStream ts, String[] output, int[] startOffsets, int[] endOffsets, int[] posIncrements) throws IOException
- Throws:
IOException
-
assertTokenStreamContents
public static void assertTokenStreamContents(TokenStream ts, String[] output, int[] startOffsets, int[] endOffsets, int[] posIncrements, Integer finalOffset) throws IOException
- Throws:
IOException
-
assertTokenStreamContents
public static void assertTokenStreamContents(TokenStream ts, String[] output, int[] startOffsets, int[] endOffsets, int[] posIncrements, int[] posLengths, Integer finalOffset) throws IOException
- Throws:
IOException
-
assertAnalyzesTo
public static void assertAnalyzesTo(Analyzer a, String input, String[] output, int[] startOffsets, int[] endOffsets, String[] types, int[] posIncrements) throws IOException
- Throws:
IOException
-
assertAnalyzesTo
public static void assertAnalyzesTo(Analyzer a, String input, String[] output, int[] startOffsets, int[] endOffsets, String[] types, int[] posIncrements, int[] posLengths) throws IOException
- Throws:
IOException
-
assertAnalyzesTo
public static void assertAnalyzesTo(Analyzer a, String input, String[] output, int[] startOffsets, int[] endOffsets, String[] types, int[] posIncrements, int[] posLengths, boolean offsetsAreCorrect) throws IOException
- Throws:
IOException
-
assertAnalyzesTo
public static void assertAnalyzesTo(Analyzer a, String input, String[] output) throws IOException
- Throws:
IOException
-
assertAnalyzesTo
public static void assertAnalyzesTo(Analyzer a, String input, String[] output, String[] types) throws IOException
- Throws:
IOException
-
assertAnalyzesTo
public static void assertAnalyzesTo(Analyzer a, String input, String[] output, int[] posIncrements) throws IOException
- Throws:
IOException
-
assertAnalyzesToPositions
public static void assertAnalyzesToPositions(Analyzer a, String input, String[] output, int[] posIncrements, int[] posLengths) throws IOException
- Throws:
IOException
-
assertAnalyzesTo
public static void assertAnalyzesTo(Analyzer a, String input, String[] output, int[] startOffsets, int[] endOffsets) throws IOException
- Throws:
IOException
-
assertAnalyzesTo
public static void assertAnalyzesTo(Analyzer a, String input, String[] output, int[] startOffsets, int[] endOffsets, int[] posIncrements) throws IOException
- Throws:
IOException
-
assertAnalyzesToReuse
public static void assertAnalyzesToReuse(Analyzer a, String input, String[] output, int[] startOffsets, int[] endOffsets, String[] types, int[] posIncrements) throws IOException
- Throws:
IOException
-
assertAnalyzesToReuse
public static void assertAnalyzesToReuse(Analyzer a, String input, String[] output) throws IOException
- Throws:
IOException
-
assertAnalyzesToReuse
public static void assertAnalyzesToReuse(Analyzer a, String input, String[] output, String[] types) throws IOException
- Throws:
IOException
-
assertAnalyzesToReuse
public static void assertAnalyzesToReuse(Analyzer a, String input, String[] output, int[] posIncrements) throws IOException
- Throws:
IOException
-
assertAnalyzesToReuse
public static void assertAnalyzesToReuse(Analyzer a, String input, String[] output, int[] startOffsets, int[] endOffsets) throws IOException
- Throws:
IOException
-
assertAnalyzesToReuse
public static void assertAnalyzesToReuse(Analyzer a, String input, String[] output, int[] startOffsets, int[] endOffsets, int[] posIncrements) throws IOException
- Throws:
IOException
-
checkOneTerm
public static void checkOneTerm(Analyzer a, String input, String expected) throws IOException
- Throws:
IOException
-
checkOneTermReuse
public static void checkOneTermReuse(Analyzer a, String input, String expected) throws IOException
- Throws:
IOException
-
checkRandomData
public static void checkRandomData(Random random, Analyzer a, int iterations) throws IOException
utility method for blasting tokenstreams with data to make sure they don't do anything crazy- Throws:
IOException
-
checkRandomData
public static void checkRandomData(Random random, Analyzer a, int iterations, int maxWordLength) throws IOException
utility method for blasting tokenstreams with data to make sure they don't do anything crazy- Throws:
IOException
-
checkRandomData
public static void checkRandomData(Random random, Analyzer a, int iterations, boolean simple) throws IOException
utility method for blasting tokenstreams with data to make sure they don't do anything crazy- Parameters:
simple- true if only ascii strings will be used (try to avoid)- Throws:
IOException
-
checkRandomData
public static void checkRandomData(Random random, Analyzer a, int iterations, int maxWordLength, boolean simple) throws IOException
- Throws:
IOException
-
checkRandomData
public static void checkRandomData(Random random, Analyzer a, int iterations, int maxWordLength, boolean simple, boolean offsetsAreCorrect) throws IOException
- Throws:
IOException
-
checkAnalysisConsistency
public static void checkAnalysisConsistency(Random random, Analyzer a, boolean useCharFilter, String text) throws IOException
- Throws:
IOException
-
checkAnalysisConsistency
public static void checkAnalysisConsistency(Random random, Analyzer a, boolean useCharFilter, String text, boolean offsetsAreCorrect) throws IOException
- Throws:
IOException
-
toDot
protected String toDot(Analyzer a, String inputText) throws IOException
- Throws:
IOException
-
toDotFile
protected void toDotFile(Analyzer a, String inputText, String localFileName) throws IOException
- Throws:
IOException
-
-