Package org.apache.solr.util
Class BaseTestHarness
- java.lang.Object
- 
- org.apache.solr.util.BaseTestHarness
 
- 
- Direct Known Subclasses:
- RestTestHarness,- TestHarness
 
 public abstract class BaseTestHarness extends Object 
- 
- 
Constructor SummaryConstructors Constructor Description BaseTestHarness()
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description StringcheckUpdateStatus(String xml, String code)Validates that an "update" (add, commit or optimize) results in success.static Stringcommit(String... args)Helper 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 DocumentBuildergetXmlDocumentBuilder()static XPathgetXpath()static StringmakeSimpleDoc(String... fieldsAndValues)A helper that creates an xml <doc> containing all of the fields and values specifiedstatic Stringoptimize(String... args)Helper that returns an <optimize> String with optional key/val pairs.abstract voidreload()Reloads the corestatic StringsimpleTag(String tag, String... args)abstract Stringupdate(String xml)Processes an "update" (add, commit or optimize) and returns the response as a String.StringvalidateErrorUpdate(String xml)Validates that an "update" (add, commit or optimize) results in success.StringvalidateUpdate(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.
 
- 
- 
- 
Method Detail- 
getXmlDocumentBuilderpublic static DocumentBuilder getXmlDocumentBuilder() 
 - 
getXpathpublic static XPath getXpath() 
 - 
validateXPathpublic 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 validate
- tests- Array of XPath strings to test (in boolean mode) on the xml
- Returns:
- null if all good, otherwise the first test that fails.
- Throws:
- XPathExpressionException
- SAXException
 
 - 
evaluateXPathpublic static Object evaluateXPath(String xml, String xpath, QName returnType) throws XPathExpressionException, SAXException - Throws:
- XPathExpressionException
- SAXException
 
 - 
makeSimpleDocpublic static String makeSimpleDoc(String... fieldsAndValues) 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.
 
 - 
deleteByQuerypublic static String deleteByQuery(String q, String... args) Generates a delete by query xml string- Parameters:
- q- Query that has not already been xml escaped
- args- The attributes of the delete tag
 
 - 
deleteByIdpublic static String deleteById(String id, String... args) Generates a delete by id xml string- Parameters:
- id- ID that has not already been xml escaped
- args- The attributes of the delete tag
 
 - 
optimizepublic static String optimize(String... args) 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.
 
 - 
commitpublic static String commit(String... args) 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.
 
 - 
updatepublic abstract String update(String xml) 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
 
 - 
validateUpdatepublic String validateUpdate(String xml) throws SAXException 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
 
 - 
validateErrorUpdatepublic String validateErrorUpdate(String xml) throws SAXException 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
 
 - 
checkUpdateStatuspublic String checkUpdateStatus(String xml, String code) throws SAXException 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
 
 
- 
 
-