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 class
MatchesTestBase.TermMatch
Encapsulates 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 Directory
directory
protected static String
FIELD_DOCS_ONLY
protected static String
FIELD_FREQS
protected static String
FIELD_NO_OFFSETS
protected static String
FIELD_POINT
protected static String
FIELD_WITH_OFFSETS
protected IndexReader
reader
protected IndexSearcher
searcher
-
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 void
assertIsLeafMatch(Query q, String field)
Assert that query matches from a field are all leaf matches and do not contain sub matchesprotected void
checkFieldMatches(MatchesIterator it, int[] expected)
Given a MatchesIterator, check that it has the expected set of start and end positionsprotected void
checkLabelCount(Query q, String field, int[] expected)
For a given query and field, check that the expected numbers of query labels were foundprotected void
checkMatches(Query q, String field, int[][] expected)
For a given query and field, check that expected matches are retrievedprotected void
checkNoPositionsMatches(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 void
checkSubMatches(Query q, String[][] expectedNames)
Given a query, check that matches contain the expected NamedQuery wrapper namesprotected void
checkTermMatches(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()
void
setUp()
For subclasses to override.void
tearDown()
For subclasses to override.-
Methods inherited from class org.apache.lucene.tests.util.LuceneTestCase
addVirusChecker, assertDeletedDocsEquals, assertDocsAndPositionsEnumEquals, assertDocsEnumEquals, assertDocsSkippingEquals, assertDocValuesEquals, assertDocValuesEquals, assertFieldInfosEquals, 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 Exception
Description copied from class:LuceneTestCase
For subclasses to override. Overrides must callsuper.tearDown()
.- Overrides:
tearDown
in classLuceneTestCase
- Throws:
Exception
-
setUp
public void setUp() throws Exception
Description copied from class:LuceneTestCase
For subclasses to override. Overrides must callsuper.setUp()
.- Overrides:
setUp
in 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
-
-