|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.junit.Assert
org.apache.lucene.util.LuceneTestCase
org.apache.solr.SolrTestCaseJ4
public abstract class SolrTestCaseJ4
A junit4 Solr test harness that extends LuceneTestCaseJ4. Unlike AbstractSolrTestCase, a new core is not created for each test method.
| Nested Class Summary | |
|---|---|
static class |
SolrTestCaseJ4.Doc
Neccessary to make method signatures un-ambiguous |
| Nested classes/interfaces inherited from class org.apache.lucene.util.LuceneTestCase |
|---|
org.apache.lucene.util.LuceneTestCase.LuceneTestCaseRunner, org.apache.lucene.util.LuceneTestCase.Nightly |
| Field Summary | |
|---|---|
protected static String |
configString
|
protected static File |
dataDir
The directory used to story the index managed by the TestHarness h |
protected static TestHarness |
h
Harness initialized by initTestHarness. |
static org.slf4j.Logger |
log
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. |
protected static TestHarness.LocalRequestFactory |
lrf
LocalRequestFactory initialized by initTestHarness using sensible defaults. |
protected static String |
schemaString
|
protected static org.apache.solr.core.SolrConfig |
solrConfig
|
| Fields inherited from class org.apache.lucene.util.LuceneTestCase |
|---|
intercept, random, RANDOM_MULTIPLIER, 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, VERBOSE |
| Constructor Summary | |
|---|---|
SolrTestCaseJ4()
|
|
| Method Summary | |
|---|---|
static String |
add(SolrTestCaseJ4.Doc doc,
String... args)
Generates an <add><doc>... |
static String |
adoc(org.apache.solr.common.SolrInputDocument sdoc)
Generates a simple <add><doc>... |
static String |
adoc(String... fieldsAndValues)
Generates a simple <add><doc>... |
static void |
afterClassSolrTestCase()
|
static void |
assertFailedU(String update)
Validates an update XML String failed |
static void |
assertFailedU(String message,
String update)
Validates an update XML String failed |
static void |
assertJQ(org.apache.solr.request.SolrQueryRequest req,
double delta,
String... tests)
Validates a query matches some JSON test expressions and closes the query. |
static void |
assertJQ(org.apache.solr.request.SolrQueryRequest req,
String... tests)
Validates a query matches some JSON test expressions using the default double delta tollerance. |
static void |
assertQ(org.apache.solr.request.SolrQueryRequest req,
String... tests)
Validates a query matches some XPath test expressions and closes the query |
static void |
assertQ(String message,
org.apache.solr.request.SolrQueryRequest req,
String... tests)
Validates a query matches some XPath test expressions and closes the query |
static void |
assertQEx(String message,
org.apache.solr.request.SolrQueryRequest req,
int code)
Makes sure a query throws a SolrException with the listed response code |
static void |
assertQEx(String message,
org.apache.solr.request.SolrQueryRequest req,
org.apache.solr.common.SolrException.ErrorCode code)
|
static void |
assertU(String update)
Validates an update XML String is successful |
static void |
assertU(String message,
String update)
Validates an update XML String is successful |
static void |
beforeClassSolrTestCase()
|
void |
clearIndex()
|
static String |
commit(String... args)
|
static void |
createTempDir()
|
static void |
deleteCore()
Shuts down the test harness, and makes the best attempt possible to delete dataDir, unless the system property "solr.test.leavedatadir" is set. |
static String |
delI(String id)
Generates a <delete>... |
static String |
delQ(String q)
Generates a <delete>... |
static SolrTestCaseJ4.Doc |
doc(String... fieldsAndValues)
Generates a simple <doc>... |
protected static void |
endTrackingSearchers()
|
protected static String |
getClassName()
|
static File |
getFile(String name)
Gets a resource from the context classloader as File. |
static Throwable |
getRootCause(Throwable t)
|
static String |
getSchemaFile()
Subclasses must define this method to return the name of the schema.xml they wish to use. |
protected static String |
getSimpleClassName()
|
static String |
getSolrConfigFile()
Subclasses must define this method to return the name of the solrconfig.xml they wish to use. |
static void |
ignoreException(String pattern)
Causes an exception matching the regex pattern to not be logged. |
static void |
initCore()
|
static void |
initCore(String config,
String schema)
Call initCore in @BeforeClass to instantiate a solr core in your test class. |
static void |
initCore(String config,
String schema,
String solrHome)
Call initCore in @BeforeClass to instantiate a solr core in your test class. |
static String |
optimize(String... args)
|
static org.apache.solr.common.params.ModifiableSolrParams |
params(String... params)
|
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)
|
static org.apache.solr.request.SolrQueryRequest |
req(org.apache.solr.common.params.SolrParams params,
String... moreParams)
Generates a SolrQueryRequest |
static org.apache.solr.request.SolrQueryRequest |
req(String... q)
Generates a SolrQueryRequest using the LocalRequestFactory |
static org.apache.solr.request.SolrQueryRequest |
req(String[] params,
String... moreParams)
Generates a SolrQueryRequest using the LocalRequestFactory |
static void |
resetExceptionIgnores()
|
void |
setUp()
|
protected static void |
startTrackingSearchers()
|
void |
tearDown()
|
static String |
TEST_HOME()
|
| Methods inherited from class org.apache.lucene.util.LuceneTestCase |
|---|
afterClassLuceneTestCaseJ4, alwaysIgnoredTestMethod, assertEquals, assertEquals, assertEquals, assertEquals, assertSaneFieldCaches, assumeFalse, assumeNoException, assumeTrue, beforeClassLuceneTestCaseJ4, dumpArray, dumpIterator, getDataFile, getName, getTestLabel, 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, registerTempFile, reportAdditionalFailureInfo, setMergeFactor, setUseCompoundFile |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static String configString
protected static String schemaString
protected static org.apache.solr.core.SolrConfig solrConfig
protected static TestHarness h
For use in test methods as needed.
protected static TestHarness.LocalRequestFactory lrf
For use in test methods as needed.
protected static File dataDir
public static org.slf4j.Logger log
| Constructor Detail |
|---|
public SolrTestCaseJ4()
| Method Detail |
|---|
public static void beforeClassSolrTestCase()
throws Exception
Exception
public static void afterClassSolrTestCase()
throws Exception
Exception
public void setUp()
throws Exception
setUp in class org.apache.lucene.util.LuceneTestCaseException
public void tearDown()
throws Exception
tearDown in class org.apache.lucene.util.LuceneTestCaseException
public static void initCore(String config,
String schema)
throws Exception
Exception
public static void initCore(String config,
String schema,
String solrHome)
throws Exception
Exceptionprotected static void startTrackingSearchers()
protected static void endTrackingSearchers()
public static void ignoreException(String pattern)
public static void resetExceptionIgnores()
protected static String getClassName()
protected static String getSimpleClassName()
public static String getSchemaFile()
public static String getSolrConfigFile()
public static void createTempDir()
public static void initCore()
throws Exception
Exceptionpublic void postSetUp()
public void preTearDown()
public static void deleteCore()
throws Exception
Exceptionpublic static void assertU(String update)
public static void assertU(String message,
String update)
public static void assertFailedU(String update)
public static void assertFailedU(String message,
String update)
public static void assertQ(org.apache.solr.request.SolrQueryRequest req,
String... tests)
public static void assertQ(String message,
org.apache.solr.request.SolrQueryRequest req,
String... tests)
public static void assertJQ(org.apache.solr.request.SolrQueryRequest req,
String... tests)
throws Exception
ExceptionJSONTestUtil.DEFAULT_DELTA,
assertJQ(SolrQueryRequest,double,String...)
public static void assertJQ(org.apache.solr.request.SolrQueryRequest req,
double delta,
String... tests)
throws Exception
Please use this with care: this makes it easy to match complete structures, but doing so can result in fragile tests if you are matching more than what you want to test.
req - Solr request to executedelta - tollerance allowed in comparing float/double valuestests - JSON path expression + '==' + expected value
Exception
public static void assertQEx(String message,
org.apache.solr.request.SolrQueryRequest req,
int code)
public static void assertQEx(String message,
org.apache.solr.request.SolrQueryRequest req,
org.apache.solr.common.SolrException.ErrorCode code)
public static String optimize(String... args)
TestHarness.optimize(java.lang.String...)public static String commit(String... args)
TestHarness.commit(java.lang.String...)public static String adoc(String... fieldsAndValues)
fieldsAndValues - 0th and Even numbered args are fields names odds are field values.add(org.apache.solr.SolrTestCaseJ4.Doc, java.lang.String...),
doc(java.lang.String...)public static String adoc(org.apache.solr.common.SolrInputDocument sdoc)
public static String add(SolrTestCaseJ4.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.SolrTestCaseJ4.Doc, java.lang.String...),
doc(java.lang.String...)public static String delI(String id)
TestHarness.deleteById(java.lang.String)public static String delQ(String q)
TestHarness.deleteByQuery(java.lang.String)public static SolrTestCaseJ4.Doc doc(String... fieldsAndValues)
fieldsAndValues - 0th and Even numbered args are fields names, Odds are field values.TestHarness.makeSimpleDoc(java.lang.String...)public static org.apache.solr.common.params.ModifiableSolrParams params(String... params)
public static org.apache.solr.request.SolrQueryRequest req(String... q)
lrf
public static org.apache.solr.request.SolrQueryRequest req(String[] params,
String... moreParams)
lrf
public static org.apache.solr.request.SolrQueryRequest req(org.apache.solr.common.params.SolrParams params,
String... moreParams)
public static boolean recurseDelete(File f)
public void clearIndex()
public static File getFile(String name)
File. This method should only be used,
if a real file is needed. To get a stream, code should prefer
Class.getResourceAsStream(java.lang.String) using this.getClass().
public static String TEST_HOME()
public static Throwable getRootCause(Throwable t)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||