Package org.apache.lucene.tests.search
Class MatchesTestBase
- java.lang.Object
-
- org.junit.Assert
-
- org.apache.lucene.tests.util.LuceneTestCase
-
- org.apache.lucene.tests.search.MatchesTestBase
-
public abstract class MatchesTestBase extends LuceneTestCase
Base class for tests checking theWeight.matches(LeafReaderContext, int)implementations
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classMatchesTestBase.TermMatchEncapsulates a term position, start and end offset-
Nested classes/interfaces inherited from class org.apache.lucene.tests.util.LuceneTestCase
LuceneTestCase.AwaitsFix, LuceneTestCase.BadApple, LuceneTestCase.Monster, LuceneTestCase.Nightly, LuceneTestCase.SuppressCodecs, LuceneTestCase.SuppressFileSystems, LuceneTestCase.SuppressFsync, LuceneTestCase.SuppressReproduceLine, LuceneTestCase.SuppressSysoutChecks, LuceneTestCase.SuppressTempFileChecks, LuceneTestCase.ThrowingConsumer<T>, LuceneTestCase.ThrowingRunnable, LuceneTestCase.Weekly
-
-
Field Summary
Fields Modifier and Type Field Description protected Directorydirectoryprotected static StringFIELD_DOCS_ONLYprotected static StringFIELD_FREQSprotected static StringFIELD_NO_OFFSETSprotected static StringFIELD_POINTprotected static StringFIELD_WITH_OFFSETSprotected IndexReaderreaderprotected IndexSearchersearcher-
Fields inherited from class org.apache.lucene.tests.util.LuceneTestCase
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_WEEKLY, TEST_ASSERTS_ENABLED, TEST_AWAITSFIX, TEST_BADAPPLES, TEST_CODEC, TEST_DIRECTORY, TEST_DOCVALUESFORMAT, TEST_LINE_DOCS_FILE, TEST_MONSTER, TEST_NIGHTLY, TEST_POSTINGSFORMAT, TEST_THROTTLING, TEST_WEEKLY, VERBOSE
-
-
Constructor Summary
Constructors Constructor Description MatchesTestBase()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidassertIsLeafMatch(Query q, String field)Assert that query matches from a field are all leaf matches and do not contain sub matchesprotected voidcheckFieldMatches(MatchesIterator it, int[] expected)Given a MatchesIterator, check that it has the expected set of start and end positionsprotected voidcheckLabelCount(Query q, String field, int[] expected)For a given query and field, check that the expected numbers of query labels were foundprotected voidcheckMatches(Query q, String field, int[][] expected)For a given query and field, check that expected matches are retrievedprotected voidcheckNoPositionsMatches(Query q, String field, boolean[] expected)Given a query and field, check that matches are returned from expected documents and that they return -1 for start and end positionsprotected voidcheckSubMatches(Query q, String[][] expectedNames)Given a query, check that matches contain the expected NamedQuery wrapper namesprotected voidcheckTermMatches(Query q, String field, MatchesTestBase.TermMatch[][][] expected)For a query and field, check that each document's submatches conform to an expected TermMatchprotected abstract String[]getDocuments()voidsetUp()For subclasses to override.voidtearDown()For subclasses to override.-
Methods inherited from class org.apache.lucene.tests.util.LuceneTestCase
addVirusChecker, assertDeletedDocsEquals, assertDocsAndPositionsEnumEquals, assertDocsEnumEquals, assertDocsSkippingEquals, assertDocValuesEquals, assertDocValuesEquals, assertDoubleUlpEquals, assertFieldInfosEquals, assertFloatUlpEquals, assertNormsEquals, assertPointsEquals, assertPositionsSkippingEquals, assertReaderEquals, assertReaderStatisticsEquals, assertStoredFieldEquals, assertStoredFieldsEquals, assertTermsEnumEquals, assertTermsEquals, assertTermsEquals, assertTermsStatisticsEquals, assertTermStatsEquals, assertTermVectorsEquals, asSet, assumeFalse, assumeNoException, assumeTrue, assumeWorkingMMapOnWindows, atLeast, atLeast, callStackContains, callStackContains, callStackContainsAnyOf, closeAfterSuite, closeAfterTest, collate, createTempDir, createTempDir, createTempFile, createTempFile, dumpArray, dumpIterator, ensureSaneIWCOnNightly, expectThrows, expectThrows, expectThrows, expectThrowsAnyOf, expectThrowsAnyOf, getDataInputStream, getDataPath, getJvmForkArguments, getOnlyLeafReader, getTestClass, getTestName, hasWorkingMMapOnWindows, isTestThread, localeForLanguageTag, maybeChangeLiveIndexWriterConfig, maybeWrapReader, newAlcoholicMergePolicy, newAlcoholicMergePolicy, newBytesRef, newBytesRef, newBytesRef, newBytesRef, newBytesRef, newBytesRef, newDirectory, newDirectory, newDirectory, newDirectory, newDirectory, newField, newField, newFSDirectory, newFSDirectory, newIndexWriterConfig, newIndexWriterConfig, newIndexWriterConfig, newIOContext, newIOContext, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newMaybeVirusCheckingDirectory, newMaybeVirusCheckingFSDirectory, newMergePolicy, newMergePolicy, newMergePolicy, newMockDirectory, newMockDirectory, newMockDirectory, newMockFSDirectory, newMockFSDirectory, newSearcher, newSearcher, newSearcher, newSearcher, newSnapshotIndexWriterConfig, newStringField, newStringField, newStringField, newStringField, newTextField, newTextField, newTieredMergePolicy, newTieredMergePolicy, overrideDefaultQueryCache, overrideTestDefaultQueryCache, random, randomLocale, randomTimeZone, randomVectorFormat, rarely, rarely, replaceMaxFailureRule, resetDefaultQueryCache, restoreCPUCoreCount, restoreIndexWriterMaxDocs, runWithRestrictedPermissions, setIndexWriterMaxDocs, setupCPUCoreCount, setUpExecutorService, shutdownExecutorService, slowFileExists, usually, usually, wrapReader
-
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, assertEquals, assertEquals, assertFalse, assertFalse, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertThat, assertThat, assertThrows, assertThrows, assertTrue, assertTrue, fail, fail
-
-
-
-
Field Detail
-
searcher
protected IndexSearcher searcher
-
directory
protected Directory directory
-
reader
protected IndexReader reader
-
FIELD_WITH_OFFSETS
protected static final String FIELD_WITH_OFFSETS
- See Also:
- Constant Field Values
-
FIELD_NO_OFFSETS
protected static final String FIELD_NO_OFFSETS
- See Also:
- Constant Field Values
-
FIELD_DOCS_ONLY
protected static final String FIELD_DOCS_ONLY
- See Also:
- Constant Field Values
-
FIELD_FREQS
protected static final String FIELD_FREQS
- See Also:
- Constant Field Values
-
FIELD_POINT
protected static final String FIELD_POINT
- See Also:
- Constant Field Values
-
-
Method Detail
-
getDocuments
protected abstract String[] getDocuments()
- Returns:
- an array of documents to be indexed
-
tearDown
public void tearDown() throws ExceptionDescription copied from class:LuceneTestCaseFor subclasses to override. Overrides must callsuper.tearDown().- Overrides:
tearDownin classLuceneTestCase- Throws:
Exception
-
setUp
public void setUp() throws ExceptionDescription copied from class:LuceneTestCaseFor subclasses to override. Overrides must callsuper.setUp().- Overrides:
setUpin classLuceneTestCase- Throws:
Exception
-
checkMatches
protected void checkMatches(Query q, String field, int[][] expected) throws IOException
For a given query and field, check that expected matches are retrieved- Parameters:
q- the queryfield- the field to pull matches fromexpected- an array of arrays of ints; for each entry, the first int is the expected docid, followed by pairs of start and end positions- Throws:
IOException
-
checkLabelCount
protected void checkLabelCount(Query q, String field, int[] expected) throws IOException
For a given query and field, check that the expected numbers of query labels were found- Parameters:
q- the queryfield- the field to pull matches fromexpected- an array of expected label counts, one entry per document- Throws:
IOException
-
checkFieldMatches
protected void checkFieldMatches(MatchesIterator it, int[] expected) throws IOException
Given a MatchesIterator, check that it has the expected set of start and end positions- Parameters:
it- an iteratorexpected- an array of expected start and end pairs and start and end offsets; the entry at position 0 is ignored- Throws:
IOException
-
checkNoPositionsMatches
protected void checkNoPositionsMatches(Query q, String field, boolean[] expected) throws IOException
Given a query and field, check that matches are returned from expected documents and that they return -1 for start and end positions- Parameters:
q- the queryfield- the field to pull matches fromexpected- an array of booleans indicating if matches are expected from each document- Throws:
IOException
-
checkSubMatches
protected void checkSubMatches(Query q, String[][] expectedNames) throws IOException
Given a query, check that matches contain the expected NamedQuery wrapper names- Parameters:
q- the queryexpectedNames- an array of arrays of Strings; for each document, an array of expected query names that match- Throws:
IOException
-
assertIsLeafMatch
protected void assertIsLeafMatch(Query q, String field) throws IOException
Assert that query matches from a field are all leaf matches and do not contain sub matches- Parameters:
q- the queryfield- the field- Throws:
IOException
-
checkTermMatches
protected void checkTermMatches(Query q, String field, MatchesTestBase.TermMatch[][][] expected) throws IOException
For a query and field, check that each document's submatches conform to an expected TermMatch- Parameters:
q- the queryfield- the field to pull matches forexpected- an array per doc of arrays per match of an array of expected submatches- Throws:
IOException
-
-