|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
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 |
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
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 TestHarness.LocalRequestFactory |
lrf
LocalRequestFactory initialized by initTestHarness using sensible defaults. |
protected SolrConfig |
solrConfig
|
Constructor Summary | |
---|---|
AbstractSolrTestCase()
|
Method Summary | |
---|---|
String |
add(AbstractSolrTestCase.Doc doc,
String... args)
Generates an <add><doc>... |
String |
adoc(SolrInputDocument sdoc)
Generates a simple <add><doc>... |
String |
adoc(String... fieldsAndValues)
Generates a simple <add><doc>... |
void |
assertFailedU(String update)
Validates an update XML String failed |
void |
assertFailedU(String message,
String update)
Validates an update XML String failed |
void |
assertQ(SolrQueryRequest req,
String... tests)
Validates a query matches some XPath test expressions and closes the query |
void |
assertQ(String message,
SolrQueryRequest req,
String... tests)
Validates a query matches some XPath test expressions and closes the query |
void |
assertQEx(String message,
SolrQueryRequest req,
int code)
Makes sure a query throws a SolrException with the listed response 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 |
String |
commit(String... args)
|
String |
delI(String id)
Generates a <delete>... |
String |
delQ(String q)
Generates a <delete>... |
AbstractSolrTestCase.Doc |
doc(String... fieldsAndValues)
Generates a simple <doc>... |
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 |
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)
|
SolrQueryRequest |
req(String... q)
Generates a SolrQueryRequest using the LocalRequestFactory |
SolrQueryRequest |
req(String[] params,
String... moreParams)
Generates a SolrQueryRequest using the LocalRequestFactory |
void |
setUp()
|
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 junit.framework.TestCase |
---|
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString |
Methods inherited from class junit.framework.Assert |
---|
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected SolrConfig solrConfig
protected TestHarness h
For use in test methods as needed.
protected TestHarness.LocalRequestFactory lrf
For use in test methods as needed.
protected File dataDir
public static org.slf4j.Logger log
Constructor Detail |
---|
public AbstractSolrTestCase()
Method Detail |
---|
public abstract String getSchemaFile()
public abstract String getSolrConfigFile()
public void setUp() throws Exception
setUp
in class junit.framework.TestCase
Exception
public void postSetUp()
public void preTearDown()
public void tearDown() throws Exception
tearDown
in class junit.framework.TestCase
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(SolrQueryRequest req, String... tests)
public void assertQ(String message, SolrQueryRequest req, String... tests)
public void assertQEx(String message, SolrQueryRequest req, int 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(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)
TestHarness.deleteById(java.lang.String)
public String delQ(String q)
TestHarness.deleteByQuery(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 SolrQueryRequest req(String... q)
lrf
public SolrQueryRequest req(String[] params, String... moreParams)
lrf
public static boolean recurseDelete(File f)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |