|
||||||||||
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(String dataDirectory)
Assumes "solrconfig.xml" is the config file to use, and "schema.xml" is the schema path to use. |
|
TestHarness(String dataDirectory,
String schemaFile)
Assumes "solrconfig.xml" is the config file to use. |
|
TestHarness(String dataDirectory,
String confFile,
String schemaFile)
|
Method Summary | |
---|---|
void |
appendSimpleDoc(StringBuffer buf,
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. |
String |
checkUpdateStatus(String xml,
String code)
Validates that an "update" (add, commit or optimize) results in success. |
void |
close()
Shuts down and frees any resources |
static String |
commit(String... args)
Helper that returns an <commit> String with optional key/val pairs. |
static String |
deleteById(String id)
Generates a delete by id xml string |
static String |
deleteByQuery(String q)
Generates a delete by query xml string |
SolrCore |
getCore()
|
TestHarness.LocalRequestFactory |
getRequestFactory(String qtype,
int start,
int limit)
|
TestHarness.LocalRequestFactory |
getRequestFactory(String qtype,
int start,
int limit,
Map<String,String> args)
|
TestHarness.LocalRequestFactory |
getRequestFactory(String qtype,
int start,
int limit,
String... args)
0 and Even numbered args are keys, Odd numbered args are values. |
static StringBuffer |
makeSimpleDoc(String... fieldsAndValues)
A helper that creates an xml <doc> containing all of the fields and values specified |
static String |
optimize(String... args)
Helper that returns an <optimize> String with optional key/val pairs. |
String |
query(SolrQueryRequest req)
Processes a "query" using a user constructed SolrQueryRequest |
String |
query(String handler,
SolrQueryRequest req)
Processes a "query" using a user constructed SolrQueryRequest |
String |
update(String xml)
Deprecated. |
String |
validateAddDoc(String... fieldsAndValues)
Validates that an add of a single document results in success. |
String |
validateErrorUpdate(String xml)
Validates that an "update" (add, commit or optimize) results in success. |
String |
validateQuery(SolrQueryRequest req,
String... tests)
Validates a "query" response against an array of XPath test strings |
String |
validateUpdate(String xml)
Validates that an "update" (add, commit or optimize) results in success. |
String |
validateXPath(String xml,
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(String dataDirectory)
dataDirectory
- path for index data, will not be cleaned uppublic TestHarness(String dataDirectory, String schemaFile)
dataDirectory
- path for index data, will not be cleaned upschemaFile
- path of schema filepublic TestHarness(String dataDirectory, String confFile, String schemaFile)
dataDirectory
- path for index data, will not be cleaned upconfFile
- solrconfig filenameschemaFile
- schema filenameMethod Detail |
---|
@Deprecated public String update(String xml)
xml
- The XML of the update
public String validateUpdate(String xml) throws SAXException
xml
- The XML of the update
SAXException
public String validateErrorUpdate(String xml) throws SAXException
xml
- The XML of the update
SAXException
public String checkUpdateStatus(String xml, String code) throws SAXException
xml
- The XML of the update
SAXException
public String validateAddDoc(String... fieldsAndValues) throws XPathExpressionException, SAXException, IOException
fieldsAndValues
- Odds are field names, Evens are values
XPathExpressionException
SAXException
IOException
appendSimpleDoc(java.lang.StringBuffer, java.lang.String...)
public String validateQuery(SolrQueryRequest req, String... tests) throws IOException, Exception
req
- the Query to process
Exception
- any exception in the response.
IOException
- if there is a problem writing the XMLLocalSolrQueryRequest
public String query(SolrQueryRequest req) throws IOException, Exception
req
- the Query to process, will be closed.
Exception
- any exception in the response.
IOException
- if there is a problem writing the XMLLocalSolrQueryRequest
public String query(String handler, SolrQueryRequest req) throws IOException, Exception
handler
- the name of the request handler to process the requestreq
- the Query to process, will be closed.
Exception
- any exception in the response.
IOException
- if there is a problem writing the XMLLocalSolrQueryRequest
public String validateXPath(String xml, String... tests) throws XPathExpressionException, SAXException
xml
- The xml String to validatetests
- Array of XPath strings to test (in boolean mode) on the xml
XPathExpressionException
SAXException
public SolrCore getCore()
public void close()
public void appendSimpleDoc(StringBuffer buf, String... fieldsAndValues) throws IOException
IOException
public static StringBuffer makeSimpleDoc(String... fieldsAndValues)
fieldsAndValues
- 0 and Even numbered args are fields names odds are field values.public static String deleteByQuery(String q)
q
- Query that has not already been xml escapedpublic static String deleteById(String id)
id
- ID that has not already been xml escapedpublic static String optimize(String... args)
args
- 0 and Even numbered args are params, Odd numbered args are values.public static String commit(String... args)
args
- 0 and Even numbered args are params, Odd numbered args are values.public TestHarness.LocalRequestFactory getRequestFactory(String qtype, int start, int limit)
public TestHarness.LocalRequestFactory getRequestFactory(String qtype, int start, int limit, String... args)
public TestHarness.LocalRequestFactory getRequestFactory(String qtype, int start, int limit, Map<String,String> args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |