| java.lang.Object org.apache.solr.util.TestHarness
TestHarness | public class TestHarness (Code) | | 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.
author: hossman version: $Id:$ |
Inner Class :public class LocalRequestFactory | |
Method Summary | |
public 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. | public String | checkUpdateStatus(String xml, String code) Validates that an "update" (add, commit or optimize) results in success. | public void | close() | public static String | commit(String... args) Helper that returns an <commit> String with
optional key/val pairs. | public static String | deleteById(String id) | public static String | deleteByQuery(String q) | public SolrCore | getCore() | public LocalRequestFactory | getRequestFactory(String qtype, int start, int limit) | public LocalRequestFactory | getRequestFactory(String qtype, int start, int limit, String... args) 0 and Even numbered args are keys, Odd numbered args are values. | public LocalRequestFactory | getRequestFactory(String qtype, int start, int limit, Map<String, String> args) | public static StringBuffer | makeSimpleDoc(String... fieldsAndValues) | public static String | optimize(String... args) Helper that returns an <optimize> String with
optional key/val pairs. | public String | query(SolrQueryRequest req) Processes a "query" using a user constructed SolrQueryRequest
Parameters: req - the Query to process, will be closed. | public String | query(String handler, SolrQueryRequest req) Processes a "query" using a user constructed SolrQueryRequest
Parameters: handler - the name of the request handler to process the request Parameters: req - the Query to process, will be closed. | public String | update(String xml) Processes an "update" (add, commit or optimize) and
returns the response as a String. | public String | validateAddDoc(String... fieldsAndValues) Validates that an add of a single document results in success. | public String | validateErrorUpdate(String xml) Validates that an "update" (add, commit or optimize) results in success. | public String | validateQuery(SolrQueryRequest req, String... tests) | public String | validateUpdate(String xml) Validates that an "update" (add, commit or optimize) results in success. | public String | validateXPath(String xml, String... tests) A helper method which valides a String against an array of XPath test
strings. |
TestHarness | public TestHarness(String dataDirectory)(Code) | | Assumes "solrconfig.xml" is the config file to use, and
"schema.xml" is the schema path to use.
Parameters: dataDirectory - path for index data, will not be cleaned up |
TestHarness | public TestHarness(String dataDirectory, String schemaFile)(Code) | | Assumes "solrconfig.xml" is the config file to use.
Parameters: dataDirectory - path for index data, will not be cleaned up Parameters: schemaFile - path of schema file |
TestHarness | public TestHarness(String dataDirectory, String confFile, String schemaFile)(Code) | | Parameters: dataDirectory - path for index data, will not be cleaned up Parameters: confFile - solrconfig filename Parameters: schemaFile - schema filename |
appendSimpleDoc | public void appendSimpleDoc(StringBuffer buf, String... fieldsAndValues) throws IOException(Code) | | A helper that adds an xml <doc> containing all of the
fields and values specified (odds are fields, evens are values)
to a StringBuffer.
|
checkUpdateStatus | public String checkUpdateStatus(String xml, String code) throws SAXException(Code) | | Validates that an "update" (add, commit or optimize) results in success.
:TODO: currently only deals with one add/doc at a time, this will need changed if/when SOLR-2 is resolved
Parameters: xml - The XML of the update null if succesful, otherwise the XML response to the update |
close | public void close()(Code) | | Shuts down and frees any resources
|
commit | public static String commit(String... args)(Code) | | Helper that returns an <commit> String with
optional key/val pairs.
Parameters: args - 0 and Even numbered args are params, Odd numbered args are values. |
deleteById | public static String deleteById(String id)(Code) | | Generates a delete by id xml string
Parameters: id - ID that has not already been xml escaped |
deleteByQuery | public static String deleteByQuery(String q)(Code) | | Generates a delete by query xml string
Parameters: q - Query that has not already been xml escaped |
getRequestFactory | public LocalRequestFactory getRequestFactory(String qtype, int start, int limit)(Code) | | |
getRequestFactory | public LocalRequestFactory getRequestFactory(String qtype, int start, int limit, String... args)(Code) | | 0 and Even numbered args are keys, Odd numbered args are values.
|
makeSimpleDoc | public static StringBuffer makeSimpleDoc(String... fieldsAndValues)(Code) | | A helper that creates an xml <doc> containing all of the
fields and values specified
Parameters: fieldsAndValues - 0 and Even numbered args are fields names odds are field values. |
optimize | public static String optimize(String... args)(Code) | | Helper that returns an <optimize> String with
optional key/val pairs.
Parameters: args - 0 and Even numbered args are params, Odd numbered args are values. |
update | public String update(String xml)(Code) | | Processes an "update" (add, commit or optimize) and
returns the response as a String.
The better approach is to instanciate a Updatehandler directly
Parameters: xml - The XML of the update The XML response to the update |
validateErrorUpdate | public String validateErrorUpdate(String xml) throws SAXException(Code) | | Validates that an "update" (add, commit or optimize) results in success.
:TODO: currently only deals with one add/doc at a time, this will need changed if/when SOLR-2 is resolved
Parameters: xml - The XML of the update null if succesful, otherwise the XML response to the update |
validateUpdate | public String validateUpdate(String xml) throws SAXException(Code) | | Validates that an "update" (add, commit or optimize) results in success.
:TODO: currently only deals with one add/doc at a time, this will need changed if/when SOLR-2 is resolved
Parameters: xml - The XML of the update null if succesful, otherwise the XML response to the update |
validateXPath | public String validateXPath(String xml, String... tests) throws XPathExpressionException, SAXException(Code) | | A helper method which valides a String against an array of XPath test
strings.
Parameters: xml - The xml String to validate Parameters: tests - Array of XPath strings to test (in boolean mode) on the xml null if all good, otherwise the first test that fails. |
|
|