Package org.apache.solr.util
Class BaseTestHarness
java.lang.Object
org.apache.solr.util.BaseTestHarness
- Direct Known Subclasses:
RestTestHarness,TestHarness
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncheckUpdateStatus(String xml, String code) Validates that an "update" (add, commit or optimize) results in success.static StringHelper that returns an <commit> String with optional key/val pairs.static StringdeleteById(String id, String... args) Generates a delete by id xml stringstatic StringdeleteByQuery(String q, String... args) Generates a delete by query xml stringstatic ObjectevaluateXPath(String xml, String xpath, QName returnType) static DocumentBuilderstatic XPathgetXpath()static StringmakeSimpleDoc(String... fieldsAndValues) A helper that creates an xml <doc> containing all of the fields and values specifiedstatic StringHelper that returns an <optimize> String with optional key/val pairs.abstract voidreload()Reloads the corestatic Stringabstract StringProcesses an "update" (add, commit or optimize) and returns the response as a String.Validates that an "update" (add, commit or optimize) results in success.validateUpdate(String xml) Validates that an "update" (add, commit or optimize) results in success.static StringvalidateXPath(String xml, String... tests) A helper method which validates a String against an array of XPath test strings.
-
Constructor Details
-
BaseTestHarness
public BaseTestHarness()
-
-
Method Details
-
getXmlDocumentBuilder
-
getXpath
-
validateXPath
public static String validateXPath(String xml, String... tests) throws XPathExpressionException, SAXException A helper method which validates a String against an array of XPath test strings.- Parameters:
xml- The xml String to validatetests- Array of XPath strings to test (in boolean mode) on the xml- Returns:
- null if all good, otherwise the first test that fails.
- Throws:
XPathExpressionExceptionSAXException
-
evaluateXPath
public static Object evaluateXPath(String xml, String xpath, QName returnType) throws XPathExpressionException, SAXException - Throws:
XPathExpressionExceptionSAXException
-
makeSimpleDoc
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.
-
deleteByQuery
Generates a delete by query xml string- Parameters:
q- Query that has not already been xml escapedargs- The attributes of the delete tag
-
deleteById
Generates a delete by id xml string- Parameters:
id- ID that has not already been xml escapedargs- The attributes of the delete tag
-
optimize
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.
-
simpleTag
-
commit
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.
-
reload
Reloads the core- Throws:
Exception
-
update
Processes an "update" (add, commit or optimize) and returns the response as a String.This method does NOT commit after the request.
- Parameters:
xml- The XML of the update- Returns:
- The XML response to the update
-
validateUpdate
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- Returns:
- null if successful, otherwise the XML response to the update
- Throws:
SAXException
-
validateErrorUpdate
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- Returns:
- null if successful, otherwise the XML response to the update
- Throws:
SAXException
-
checkUpdateStatus
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- Returns:
- null if successful, otherwise the XML response to the update
- Throws:
SAXException
-