|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.junit.Assert org.apache.lucene.util.LuceneTestCase org.apache.solr.util.AbstractSolrTestCase
public abstract class AbstractSolrTestCase
An Abstract base class that makes writing Solr JUnit tests "easier"
Test classes that subclass this need only specify the path to the schema.xml file (:TODO: the solrconfig.xml as well) and write some testMethods. This class takes care of creating/destroying the index, and provides several assert methods to assist you.
setUp()
,
tearDown()
Nested Class Summary | |
---|---|
static class |
AbstractSolrTestCase.Doc
Neccessary to make method signatures un-ambiguous |
Nested classes/interfaces inherited from class org.apache.lucene.util.LuceneTestCase |
---|
org.apache.lucene.util.LuceneTestCase.AwaitsFix, org.apache.lucene.util.LuceneTestCase.Nightly, org.apache.lucene.util.LuceneTestCase.Slow, org.apache.lucene.util.LuceneTestCase.SuppressCodecs, org.apache.lucene.util.LuceneTestCase.Weekly |
Field Summary | |
---|---|
protected File |
dataDir
The directory used to story the index managed by the TestHarness h |
protected TestHarness |
h
Harness initialized by initTestHarness. |
static org.slf4j.Logger |
log
|
protected TestHarness.LocalRequestFactory |
lrf
LocalRequestFactory initialized by initTestHarness using sensible defaults. |
static org.junit.rules.TestRule |
solrClassRules
|
protected org.apache.solr.core.SolrConfig |
solrConfig
|
org.junit.rules.TestRule |
solrTestRules
|
Fields inherited from class org.apache.lucene.util.LuceneTestCase |
---|
classRules, DEFAULT_LINE_DOCS_FILE, INFOSTREAM, JENKINS_LARGE_LINE_DOCS_FILE, PREFLEX_IMPERSONATION_IS_ACTIVE, RANDOM_MULTIPLIER, ruleChain, suiteFailureMarker, SYSPROP_AWAITSFIX, SYSPROP_NIGHTLY, SYSPROP_SLOW, SYSPROP_WEEKLY, TEMP_DIR, TEST_AWAITSFIX, TEST_CODEC, TEST_DIRECTORY, TEST_LINE_DOCS_FILE, TEST_NIGHTLY, TEST_POSTINGSFORMAT, TEST_SLOW, TEST_THROTTLING, TEST_VERSION_CURRENT, TEST_WEEKLY, VERBOSE |
Constructor Summary | |
---|---|
AbstractSolrTestCase()
|
Method Summary | |
---|---|
String |
add(AbstractSolrTestCase.Doc doc,
String... args)
Generates an <add><doc>... |
String |
adoc(int commitWithin,
String... fieldsAndValues)
Generates a simple <add><doc>... |
String |
adoc(org.apache.solr.common.SolrInputDocument sdoc)
Generates a simple <add><doc>... |
String |
adoc(String... fieldsAndValues)
Generates a simple <add><doc>... |
static void |
afterClassAbstractSolrTestCase()
|
void |
assertFailedU(String update)
Validates an update XML String failed |
void |
assertFailedU(String message,
String update)
Validates an update XML String failed |
void |
assertQ(org.apache.solr.request.SolrQueryRequest req,
String... tests)
Validates a query matches some XPath test expressions and closes the query |
void |
assertQ(String message,
org.apache.solr.request.SolrQueryRequest req,
String... tests)
Validates a query matches some XPath test expressions and closes the query |
void |
assertQEx(String message,
org.apache.solr.request.SolrQueryRequest req,
int code)
Makes sure a query throws a SolrException with the listed response code |
void |
assertQEx(String message,
org.apache.solr.request.SolrQueryRequest req,
org.apache.solr.common.SolrException.ErrorCode code)
|
void |
assertU(String update)
Validates an update XML String is successful |
void |
assertU(String message,
String update)
Validates an update XML String is successful |
static void |
beforeClassAbstractSolrTestCase()
|
String |
commit(String... args)
|
String |
delI(String id,
String... args)
Generates a <delete>... |
String |
delQ(String q,
String... args)
Generates a <delete>... |
AbstractSolrTestCase.Doc |
doc(String... fieldsAndValues)
Generates a simple <doc>... |
static File |
getFile(String name)
|
abstract String |
getSchemaFile()
Subclasses must define this method to return the name of the schema.xml they wish to use. |
abstract String |
getSolrConfigFile()
Subclasses must define this method to return the name of the solrconfig.xml they wish to use. |
String |
getSolrHome()
Subclasses can override this to change a test's solr home (default is in test-files) |
static void |
ignoreException(String pattern)
Causes an exception matching the regex pattern to not be logged. |
String |
optimize(String... args)
|
void |
postSetUp()
Subclasses that override setUp can optionally call this method to log the fact that their setUp process has ended. |
void |
preTearDown()
Subclasses that override tearDown can optionally call this method to log the fact that the tearDown process has started. |
static boolean |
recurseDelete(File f)
|
org.apache.solr.request.SolrQueryRequest |
req(String... q)
Generates a SolrQueryRequest using the LocalRequestFactory |
org.apache.solr.request.SolrQueryRequest |
req(String[] params,
String... moreParams)
Generates a SolrQueryRequest using the LocalRequestFactory |
static void |
resetExceptionIgnores()
|
void |
setUp()
Initializes things your test might need Creates a dataDir in the "java.io.tmpdir" initializes the TestHarness h using this data directory, and getSchemaPath() initializes the LocalRequestFactory lrf using sensible defaults. |
void |
tearDown()
Shuts down the test harness, and makes the best attempt possible to delete dataDir, unless the system property "solr.test.leavedatadir" is set. |
Methods inherited from class org.apache.lucene.util.LuceneTestCase |
---|
assertSaneFieldCaches, asSet, assumeFalse, assumeNoException, assumeTrue, atLeast, atLeast, closeAfterSuite, closeAfterTest, defaultCodecSupportsDocValues, dumpArray, dumpIterator, getDataFile, getOnlySegmentReader, getTestClass, getTestName, isTestThread, localeForName, maybeWrapReader, newAlcoholicMergePolicy, newAlcoholicMergePolicy, newDirectory, newDirectory, newDirectory, newDirectory, newField, newField, newFSDirectory, newFSDirectory, newIndexWriterConfig, newIndexWriterConfig, newIOContext, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newSearcher, newSearcher, newStringField, newStringField, newTextField, newTextField, newTieredMergePolicy, newTieredMergePolicy, random, randomLocale, randomTimeZone, rarely, rarely, usually, usually |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected org.apache.solr.core.SolrConfig solrConfig
protected TestHarness h
For use in test methods as needed.
protected TestHarness.LocalRequestFactory lrf
For use in test methods as needed.
public static org.junit.rules.TestRule solrClassRules
public org.junit.rules.TestRule solrTestRules
protected File dataDir
public static org.slf4j.Logger log
Constructor Detail |
---|
public AbstractSolrTestCase()
Method Detail |
---|
public abstract String getSchemaFile()
public abstract String getSolrConfigFile()
public String getSolrHome()
public static void beforeClassAbstractSolrTestCase() throws Exception
Exception
public static void afterClassAbstractSolrTestCase() throws Exception
Exception
public void setUp() throws Exception
setUp
in class org.apache.lucene.util.LuceneTestCase
Exception
public static void ignoreException(String pattern)
public static void resetExceptionIgnores()
public void postSetUp()
public void preTearDown()
public void tearDown() throws Exception
tearDown
in class org.apache.lucene.util.LuceneTestCase
Exception
public void assertU(String update)
public void assertU(String message, String update)
public void assertFailedU(String update)
public void assertFailedU(String message, String update)
public void assertQ(org.apache.solr.request.SolrQueryRequest req, String... tests)
public void assertQ(String message, org.apache.solr.request.SolrQueryRequest req, String... tests)
public void assertQEx(String message, org.apache.solr.request.SolrQueryRequest req, int code)
public void assertQEx(String message, org.apache.solr.request.SolrQueryRequest req, org.apache.solr.common.SolrException.ErrorCode code)
public String optimize(String... args)
TestHarness.optimize(java.lang.String...)
public String commit(String... args)
TestHarness.commit(java.lang.String...)
public String adoc(String... fieldsAndValues)
fieldsAndValues
- 0th and Even numbered args are fields names odds are field values.add(org.apache.solr.util.AbstractSolrTestCase.Doc, java.lang.String...)
,
doc(java.lang.String...)
public String adoc(int commitWithin, String... fieldsAndValues)
commitWithin
- the value of the commitWithin attributefieldsAndValues
- 0th and Even numbered args are fields names odds are field values.add(org.apache.solr.util.AbstractSolrTestCase.Doc, java.lang.String...)
,
doc(java.lang.String...)
public String adoc(org.apache.solr.common.SolrInputDocument sdoc)
public String add(AbstractSolrTestCase.Doc doc, String... args)
doc
- the Document to addargs
- 0th and Even numbered args are param names, Odds are param values.add(org.apache.solr.util.AbstractSolrTestCase.Doc, java.lang.String...)
,
doc(java.lang.String...)
public String delI(String id, String... args)
TestHarness.deleteById(java.lang.String, java.lang.String...)
public String delQ(String q, String... args)
TestHarness.deleteByQuery(java.lang.String, java.lang.String...)
public AbstractSolrTestCase.Doc doc(String... fieldsAndValues)
fieldsAndValues
- 0th and Even numbered args are fields names, Odds are field values.TestHarness.makeSimpleDoc(java.lang.String...)
public org.apache.solr.request.SolrQueryRequest req(String... q)
lrf
public org.apache.solr.request.SolrQueryRequest req(String[] params, String... moreParams)
lrf
public static boolean recurseDelete(File f)
public static File getFile(String name) throws IOException
IOException
SolrTestCaseJ4.getFile(java.lang.String)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |