|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.solr.util.TestHarness
public class TestHarness
This class provides a simple harness that may be useful when writing testcases.
This class lives in the main source tree (and not in the test source tree), so that it will be included with even the most minimal solr distribution, in order to encourage plugin writers to create unit tests for their plugins.
Nested Class Summary | |
---|---|
class |
TestHarness.LocalRequestFactory
A Factory that generates LocalSolrQueryRequest objects using a specified set of default options. |
Constructor Summary | |
---|---|
TestHarness(java.lang.String dataDirectory)
Assumes "solrconfig.xml" is the config file to use, and "schema.xml" is the schema path to use. |
|
TestHarness(java.lang.String dataDirectory,
java.lang.String schemaFile)
Assumes "solrconfig.xml" is the config file to use. |
|
TestHarness(java.lang.String dataDirectory,
java.lang.String confFile,
java.lang.String schemaFile)
|
Method Summary | |
---|---|
void |
appendSimpleDoc(java.lang.StringBuffer buf,
java.lang.String... fieldsAndValues)
A helper that adds an xml <doc> containing all of the fields and values specified (odds are fields, evens are values) to a StringBuffer. |
java.lang.String |
checkUpdateStatus(java.lang.String xml,
java.lang.String code)
Validates that an "update" (add, commit or optimize) results in success. |
void |
close()
Shuts down and frees any resources |
static java.lang.String |
commit(java.lang.String... args)
Helper that returns an <commit> String with optional key/val pairs. |
static java.lang.String |
deleteById(java.lang.String id)
Generates a delete by id xml string |
static java.lang.String |
deleteByQuery(java.lang.String q)
Generates a delete by query xml string |
SolrCore |
getCore()
|
TestHarness.LocalRequestFactory |
getRequestFactory(java.lang.String qtype,
int start,
int limit)
|
TestHarness.LocalRequestFactory |
getRequestFactory(java.lang.String qtype,
int start,
int limit,
java.util.Map<java.lang.String,java.lang.String> args)
|
TestHarness.LocalRequestFactory |
getRequestFactory(java.lang.String qtype,
int start,
int limit,
java.lang.String... args)
0 and Even numbered args are keys, Odd numbered args are values. |
static java.lang.StringBuffer |
makeSimpleDoc(java.lang.String... fieldsAndValues)
A helper that creates an xml <doc> containing all of the fields and values specified |
static java.lang.String |
optimize(java.lang.String... args)
Helper that returns an <optimize> String with optional key/val pairs. |
java.lang.String |
query(SolrQueryRequest req)
Processes a "query" using a user constructed SolrQueryRequest |
java.lang.String |
query(java.lang.String handler,
SolrQueryRequest req)
Processes a "query" using a user constructed SolrQueryRequest |
java.lang.String |
update(java.lang.String xml)
Deprecated. |
java.lang.String |
validateAddDoc(java.lang.String... fieldsAndValues)
Validates that an add of a single document results in success. |
java.lang.String |
validateErrorUpdate(java.lang.String xml)
Validates that an "update" (add, commit or optimize) results in success. |
java.lang.String |
validateQuery(SolrQueryRequest req,
java.lang.String... tests)
Validates a "query" response against an array of XPath test strings |
java.lang.String |
validateUpdate(java.lang.String xml)
Validates that an "update" (add, commit or optimize) results in success. |
java.lang.String |
validateXPath(java.lang.String xml,
java.lang.String... tests)
A helper method which valides a String against an array of XPath test strings. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TestHarness(java.lang.String dataDirectory)
dataDirectory
- path for index data, will not be cleaned uppublic TestHarness(java.lang.String dataDirectory, java.lang.String schemaFile)
dataDirectory
- path for index data, will not be cleaned upschemaFile
- path of schema filepublic TestHarness(java.lang.String dataDirectory, java.lang.String confFile, java.lang.String schemaFile)
dataDirectory
- path for index data, will not be cleaned upconfFile
- solrconfig filenameschemaFile
- schema filenameMethod Detail |
---|
@Deprecated public java.lang.String update(java.lang.String xml)
xml
- The XML of the update
public java.lang.String validateUpdate(java.lang.String xml) throws org.xml.sax.SAXException
xml
- The XML of the update
org.xml.sax.SAXException
public java.lang.String validateErrorUpdate(java.lang.String xml) throws org.xml.sax.SAXException
xml
- The XML of the update
org.xml.sax.SAXException
public java.lang.String checkUpdateStatus(java.lang.String xml, java.lang.String code) throws org.xml.sax.SAXException
xml
- The XML of the update
org.xml.sax.SAXException
public java.lang.String validateAddDoc(java.lang.String... fieldsAndValues) throws javax.xml.xpath.XPathExpressionException, org.xml.sax.SAXException, java.io.IOException
fieldsAndValues
- Odds are field names, Evens are values
javax.xml.xpath.XPathExpressionException
org.xml.sax.SAXException
java.io.IOException
appendSimpleDoc(java.lang.StringBuffer, java.lang.String...)
public java.lang.String validateQuery(SolrQueryRequest req, java.lang.String... tests) throws java.io.IOException, java.lang.Exception
req
- the Query to process
java.lang.Exception
- any exception in the response.
java.io.IOException
- if there is a problem writing the XMLLocalSolrQueryRequest
public java.lang.String query(SolrQueryRequest req) throws java.io.IOException, java.lang.Exception
req
- the Query to process, will be closed.
java.lang.Exception
- any exception in the response.
java.io.IOException
- if there is a problem writing the XMLLocalSolrQueryRequest
public java.lang.String query(java.lang.String handler, SolrQueryRequest req) throws java.io.IOException, java.lang.Exception
handler
- the name of the request handler to process the requestreq
- the Query to process, will be closed.
java.lang.Exception
- any exception in the response.
java.io.IOException
- if there is a problem writing the XMLLocalSolrQueryRequest
public java.lang.String validateXPath(java.lang.String xml, java.lang.String... tests) throws javax.xml.xpath.XPathExpressionException, org.xml.sax.SAXException
xml
- The xml String to validatetests
- Array of XPath strings to test (in boolean mode) on the xml
javax.xml.xpath.XPathExpressionException
org.xml.sax.SAXException
public SolrCore getCore()
public void close()
public void appendSimpleDoc(java.lang.StringBuffer buf, java.lang.String... fieldsAndValues) throws java.io.IOException
java.io.IOException
public static java.lang.StringBuffer makeSimpleDoc(java.lang.String... fieldsAndValues)
fieldsAndValues
- 0 and Even numbered args are fields names odds are field values.public static java.lang.String deleteByQuery(java.lang.String q)
q
- Query that has not already been xml escapedpublic static java.lang.String deleteById(java.lang.String id)
id
- ID that has not already been xml escapedpublic static java.lang.String optimize(java.lang.String... args)
args
- 0 and Even numbered args are params, Odd numbered args are values.public static java.lang.String commit(java.lang.String... args)
args
- 0 and Even numbered args are params, Odd numbered args are values.public TestHarness.LocalRequestFactory getRequestFactory(java.lang.String qtype, int start, int limit)
public TestHarness.LocalRequestFactory getRequestFactory(java.lang.String qtype, int start, int limit, java.lang.String... args)
public TestHarness.LocalRequestFactory getRequestFactory(java.lang.String qtype, int start, int limit, java.util.Map<java.lang.String,java.lang.String> args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |