public abstract class BaseTokenStreamTestCase extends LuceneTestCase
When writing unit tests for analysis components, it's highly recommended
to use the helper methods here (especially in conjunction with MockAnalyzer
or
MockTokenizer
), as they contain many assertions and checks to
catch bugs.
MockAnalyzer
,
MockTokenizer
Modifier and Type | Class and Description |
---|---|
static interface |
BaseTokenStreamTestCase.CheckClearAttributesAttribute
Attribute that records if it was cleared or not.
|
static class |
BaseTokenStreamTestCase.CheckClearAttributesAttributeImpl
Attribute that records if it was cleared or not.
|
LuceneTestCase.AwaitsFix, LuceneTestCase.BadApple, LuceneTestCase.Monster, LuceneTestCase.Nightly, LuceneTestCase.Slow, LuceneTestCase.SuppressCodecs, LuceneTestCase.SuppressFileSystems, LuceneTestCase.SuppressFsync, LuceneTestCase.SuppressReproduceLine, LuceneTestCase.SuppressSysoutChecks, LuceneTestCase.SuppressTempFileChecks, LuceneTestCase.ThrowingRunnable, LuceneTestCase.Weekly
assertsAreEnabled, classRules, DEFAULT_LINE_DOCS_FILE, INFOSTREAM, JENKINS_LARGE_LINE_DOCS_FILE, LEAVE_TEMPORARY, MAYBE_CACHE_POLICY, RANDOM_MULTIPLIER, ruleChain, suiteFailureMarker, SYSPROP_AWAITSFIX, SYSPROP_BADAPPLES, SYSPROP_FAILFAST, SYSPROP_MAXFAILURES, SYSPROP_MONSTER, SYSPROP_NIGHTLY, SYSPROP_SLOW, SYSPROP_WEEKLY, TEST_ASSERTS_ENABLED, TEST_AWAITSFIX, TEST_CODEC, TEST_DIRECTORY, TEST_DOCVALUESFORMAT, TEST_LINE_DOCS_FILE, TEST_NIGHTLY, TEST_POSTINGSFORMAT, TEST_SLOW, TEST_THROTTLING, TEST_WEEKLY, VERBOSE
Constructor and Description |
---|
BaseTokenStreamTestCase() |
Modifier and Type | Method and Description |
---|---|
static void |
assertAnalyzesTo(Analyzer a,
String input,
String[] output) |
static void |
assertAnalyzesTo(Analyzer a,
String input,
String[] output,
int[] posIncrements) |
static void |
assertAnalyzesTo(Analyzer a,
String input,
String[] output,
int[] startOffsets,
int[] endOffsets) |
static void |
assertAnalyzesTo(Analyzer a,
String input,
String[] output,
int[] startOffsets,
int[] endOffsets,
int[] posIncrements) |
static void |
assertAnalyzesTo(Analyzer a,
String input,
String[] output,
int[] startOffsets,
int[] endOffsets,
String[] types,
int[] posIncrements) |
static void |
assertAnalyzesTo(Analyzer a,
String input,
String[] output,
int[] startOffsets,
int[] endOffsets,
String[] types,
int[] posIncrements,
int[] posLengths) |
static void |
assertAnalyzesTo(Analyzer a,
String input,
String[] output,
int[] startOffsets,
int[] endOffsets,
String[] types,
int[] posIncrements,
int[] posLengths,
boolean offsetsAreCorrect) |
static void |
assertAnalyzesTo(Analyzer a,
String input,
String[] output,
String[] types) |
static void |
assertAnalyzesToPositions(Analyzer a,
String input,
String[] output,
int[] posIncrements,
int[] posLengths) |
static void |
assertStreamHasNumberOfTokens(TokenStream ts,
int expectedCount)
Asserts that the given stream has expected number of tokens.
|
static void |
assertTokenStreamContents(TokenStream ts,
String[] output) |
static void |
assertTokenStreamContents(TokenStream ts,
String[] output,
int[] posIncrements) |
static void |
assertTokenStreamContents(TokenStream ts,
String[] output,
int[] startOffsets,
int[] endOffsets) |
static void |
assertTokenStreamContents(TokenStream ts,
String[] output,
int[] startOffsets,
int[] endOffsets,
int[] posIncrements) |
static void |
assertTokenStreamContents(TokenStream ts,
String[] output,
int[] startOffsets,
int[] endOffsets,
int[] posIncrements,
int[] posLengths,
Integer finalOffset) |
static void |
assertTokenStreamContents(TokenStream ts,
String[] output,
int[] startOffsets,
int[] endOffsets,
int[] posIncrements,
Integer finalOffset) |
static void |
assertTokenStreamContents(TokenStream ts,
String[] output,
int[] startOffsets,
int[] endOffsets,
Integer finalOffset) |
static void |
assertTokenStreamContents(TokenStream ts,
String[] output,
int[] startOffsets,
int[] endOffsets,
String[] types,
int[] posIncrements) |
static void |
assertTokenStreamContents(TokenStream ts,
String[] output,
int[] startOffsets,
int[] endOffsets,
String[] types,
int[] posIncrements,
int[] posLengths,
Integer finalOffset) |
static void |
assertTokenStreamContents(TokenStream ts,
String[] output,
int[] startOffsets,
int[] endOffsets,
String[] types,
int[] posIncrements,
int[] posLengths,
Integer finalOffset,
boolean offsetsAreCorrect) |
static void |
assertTokenStreamContents(TokenStream ts,
String[] output,
int[] startOffsets,
int[] endOffsets,
String[] types,
int[] posIncrements,
int[] posLengths,
Integer finalOffset,
boolean[] keywordAtts,
boolean offsetsAreCorrect) |
static void |
assertTokenStreamContents(TokenStream ts,
String[] output,
int[] startOffsets,
int[] endOffsets,
String[] types,
int[] posIncrements,
int[] posLengths,
Integer finalOffset,
Integer finalPosInc,
boolean[] keywordAtts,
boolean offsetsAreCorrect) |
static void |
assertTokenStreamContents(TokenStream ts,
String[] output,
int[] startOffsets,
int[] endOffsets,
String[] types,
int[] posIncrements,
Integer finalOffset) |
static void |
assertTokenStreamContents(TokenStream ts,
String[] output,
String[] types) |
static void |
checkAnalysisConsistency(Random random,
Analyzer a,
boolean useCharFilter,
String text) |
static void |
checkAnalysisConsistency(Random random,
Analyzer a,
boolean useCharFilter,
String text,
boolean offsetsAreCorrect) |
static void |
checkOneTerm(Analyzer a,
String input,
String expected) |
static void |
checkRandomData(Random random,
Analyzer a,
int iterations)
utility method for blasting tokenstreams with data to make sure they don't do anything crazy
|
static void |
checkRandomData(Random random,
Analyzer a,
int iterations,
boolean simple)
utility method for blasting tokenstreams with data to make sure they don't do anything crazy
|
static void |
checkRandomData(Random random,
Analyzer a,
int iterations,
int maxWordLength)
utility method for blasting tokenstreams with data to make sure they don't do anything crazy
|
static void |
checkRandomData(Random random,
Analyzer a,
int iterations,
int maxWordLength,
boolean simple) |
static void |
checkRandomData(Random random,
Analyzer a,
int iterations,
int maxWordLength,
boolean simple,
boolean offsetsAreCorrect) |
static String |
escape(String s) |
protected static MockTokenizer |
keywordMockTokenizer(Reader input) |
protected static MockTokenizer |
keywordMockTokenizer(String input) |
static AttributeFactory |
newAttributeFactory()
Returns a random AttributeFactory impl
|
static AttributeFactory |
newAttributeFactory(Random random)
Returns a random AttributeFactory impl
|
protected String |
toDot(Analyzer a,
String inputText) |
protected void |
toDotFile(Analyzer a,
String inputText,
String localFileName) |
protected static MockTokenizer |
whitespaceMockTokenizer(Reader input) |
protected static MockTokenizer |
whitespaceMockTokenizer(String input) |
addVirusChecker, assertDeletedDocsEquals, assertDocsAndPositionsEnumEquals, assertDocsEnumEquals, assertDocsSkippingEquals, assertDocValuesEquals, assertDocValuesEquals, assertFieldInfosEquals, assertFieldsEquals, assertFieldStatisticsEquals, assertNormsEquals, assertPointsEquals, assertPositionsSkippingEquals, assertReaderEquals, assertReaderStatisticsEquals, assertStoredFieldEquals, assertStoredFieldsEquals, assertTermsEnumEquals, assertTermsEquals, assertTermsStatisticsEquals, assertTermStatsEquals, assertTermVectorsEquals, asSet, assumeFalse, assumeNoException, assumeTrue, atLeast, atLeast, closeAfterSuite, closeAfterTest, collate, createTempDir, createTempDir, createTempFile, createTempFile, dumpArray, dumpIterator, expectThrows, getBaseTempDirForTestClass, getDataInputStream, getDataPath, getOnlyLeafReader, getTestClass, getTestName, isTestThread, localeForLanguageTag, maybeChangeLiveIndexWriterConfig, maybeWrapReader, newAlcoholicMergePolicy, newAlcoholicMergePolicy, newDirectory, newDirectory, newDirectory, newDirectory, newDirectory, newField, newField, newFSDirectory, newFSDirectory, newIndexWriterConfig, newIndexWriterConfig, newIndexWriterConfig, newIOContext, newIOContext, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newMaybeVirusCheckingDirectory, newMaybeVirusCheckingFSDirectory, newMergePolicy, newMergePolicy, newMockDirectory, newMockDirectory, newMockDirectory, newMockFSDirectory, newMockFSDirectory, newSearcher, newSearcher, newSearcher, newStringField, newStringField, newStringField, newStringField, newTextField, newTextField, newTieredMergePolicy, newTieredMergePolicy, overrideDefaultQueryCache, overrideTestDefaultQueryCache, random, randomLocale, randomTimeZone, rarely, rarely, replaceMaxFailureRule, resetDefaultQueryCache, restoreCPUCoreCount, restoreIndexWriterMaxDocs, restoreSpins, runWithRestrictedPermissions, setIndexWriterMaxDocs, setUp, setupCPUCoreCount, setupSpins, slowFileExists, tearDown, usually, usually, wrapReader
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, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertThat, assertThat, assertTrue, assertTrue, fail, fail
public static void assertTokenStreamContents(TokenStream ts, String[] output, int[] startOffsets, int[] endOffsets, String[] types, int[] posIncrements, int[] posLengths, Integer finalOffset, Integer finalPosInc, boolean[] keywordAtts, boolean offsetsAreCorrect) throws IOException
IOException
public static void assertTokenStreamContents(TokenStream ts, String[] output, int[] startOffsets, int[] endOffsets, String[] types, int[] posIncrements, int[] posLengths, Integer finalOffset, boolean[] keywordAtts, boolean offsetsAreCorrect) throws IOException
IOException
public static void assertTokenStreamContents(TokenStream ts, String[] output, int[] startOffsets, int[] endOffsets, String[] types, int[] posIncrements, int[] posLengths, Integer finalOffset, boolean offsetsAreCorrect) throws IOException
IOException
public static void assertTokenStreamContents(TokenStream ts, String[] output, int[] startOffsets, int[] endOffsets, String[] types, int[] posIncrements, int[] posLengths, Integer finalOffset) throws IOException
IOException
public static void assertTokenStreamContents(TokenStream ts, String[] output, int[] startOffsets, int[] endOffsets, String[] types, int[] posIncrements, Integer finalOffset) throws IOException
IOException
public static void assertTokenStreamContents(TokenStream ts, String[] output, int[] startOffsets, int[] endOffsets, String[] types, int[] posIncrements) throws IOException
IOException
public static void assertTokenStreamContents(TokenStream ts, String[] output) throws IOException
IOException
public static void assertTokenStreamContents(TokenStream ts, String[] output, String[] types) throws IOException
IOException
public static void assertTokenStreamContents(TokenStream ts, String[] output, int[] posIncrements) throws IOException
IOException
public static void assertTokenStreamContents(TokenStream ts, String[] output, int[] startOffsets, int[] endOffsets) throws IOException
IOException
public static void assertTokenStreamContents(TokenStream ts, String[] output, int[] startOffsets, int[] endOffsets, Integer finalOffset) throws IOException
IOException
public static void assertTokenStreamContents(TokenStream ts, String[] output, int[] startOffsets, int[] endOffsets, int[] posIncrements) throws IOException
IOException
public static void assertTokenStreamContents(TokenStream ts, String[] output, int[] startOffsets, int[] endOffsets, int[] posIncrements, Integer finalOffset) throws IOException
IOException
public static void assertTokenStreamContents(TokenStream ts, String[] output, int[] startOffsets, int[] endOffsets, int[] posIncrements, int[] posLengths, Integer finalOffset) throws IOException
IOException
public static void assertAnalyzesTo(Analyzer a, String input, String[] output, int[] startOffsets, int[] endOffsets, String[] types, int[] posIncrements) throws IOException
IOException
public static void assertAnalyzesTo(Analyzer a, String input, String[] output, int[] startOffsets, int[] endOffsets, String[] types, int[] posIncrements, int[] posLengths) throws IOException
IOException
public static void assertAnalyzesTo(Analyzer a, String input, String[] output, int[] startOffsets, int[] endOffsets, String[] types, int[] posIncrements, int[] posLengths, boolean offsetsAreCorrect) throws IOException
IOException
public static void assertAnalyzesTo(Analyzer a, String input, String[] output) throws IOException
IOException
public static void assertAnalyzesTo(Analyzer a, String input, String[] output, String[] types) throws IOException
IOException
public static void assertAnalyzesTo(Analyzer a, String input, String[] output, int[] posIncrements) throws IOException
IOException
public static void assertAnalyzesToPositions(Analyzer a, String input, String[] output, int[] posIncrements, int[] posLengths) throws IOException
IOException
public static void assertAnalyzesTo(Analyzer a, String input, String[] output, int[] startOffsets, int[] endOffsets) throws IOException
IOException
public static void assertAnalyzesTo(Analyzer a, String input, String[] output, int[] startOffsets, int[] endOffsets, int[] posIncrements) throws IOException
IOException
public static void checkOneTerm(Analyzer a, String input, String expected) throws IOException
IOException
public static void checkRandomData(Random random, Analyzer a, int iterations) throws IOException
IOException
public static void checkRandomData(Random random, Analyzer a, int iterations, int maxWordLength) throws IOException
IOException
public static void checkRandomData(Random random, Analyzer a, int iterations, boolean simple) throws IOException
simple
- true if only ascii strings will be used (try to avoid)IOException
public static void assertStreamHasNumberOfTokens(TokenStream ts, int expectedCount) throws IOException
IOException
public static void checkRandomData(Random random, Analyzer a, int iterations, int maxWordLength, boolean simple) throws IOException
IOException
public static void checkRandomData(Random random, Analyzer a, int iterations, int maxWordLength, boolean simple, boolean offsetsAreCorrect) throws IOException
IOException
public static void checkAnalysisConsistency(Random random, Analyzer a, boolean useCharFilter, String text) throws IOException
IOException
public static void checkAnalysisConsistency(Random random, Analyzer a, boolean useCharFilter, String text, boolean offsetsAreCorrect) throws IOException
IOException
protected String toDot(Analyzer a, String inputText) throws IOException
IOException
protected void toDotFile(Analyzer a, String inputText, String localFileName) throws IOException
IOException
protected static MockTokenizer whitespaceMockTokenizer(Reader input) throws IOException
IOException
protected static MockTokenizer whitespaceMockTokenizer(String input) throws IOException
IOException
protected static MockTokenizer keywordMockTokenizer(Reader input) throws IOException
IOException
protected static MockTokenizer keywordMockTokenizer(String input) throws IOException
IOException
public static AttributeFactory newAttributeFactory(Random random)
public static AttributeFactory newAttributeFactory()
Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.