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 Summary
Constructors Constructor Description BaseTestHarness()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description String
checkUpdateStatus(String xml, String code)
Validates that an "update" (add, commit or optimize) results in success.static String
commit(String... args)
Helper that returns an <commit> String with optional key/val pairs.static String
deleteById(String id, String... args)
Generates a delete by id xml stringstatic String
deleteByQuery(String q, String... args)
Generates a delete by query xml stringstatic Object
evaluateXPath(String xml, String xpath, QName returnType)
static DocumentBuilder
getXmlDocumentBuilder()
static XPath
getXpath()
static String
makeSimpleDoc(String... fieldsAndValues)
A helper that creates an xml <doc> containing all of the fields and values specifiedstatic String
optimize(String... args)
Helper that returns an <optimize> String with optional key/val pairs.abstract void
reload()
Reloads the corestatic String
simpleTag(String tag, String... args)
abstract String
update(String xml)
Processes an "update" (add, commit or optimize) and returns the response as a String.String
validateErrorUpdate(String xml)
Validates that an "update" (add, commit or optimize) results in success.String
validateUpdate(String xml)
Validates that an "update" (add, commit or optimize) results in success.static String
validateXPath(String xml, String... tests)
A helper method which validates a String against an array of XPath test strings.
-
-
-
Method Detail
-
getXmlDocumentBuilder
public static DocumentBuilder getXmlDocumentBuilder()
-
getXpath
public static XPath 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:
XPathExpressionException
SAXException
-
evaluateXPath
public static Object evaluateXPath(String xml, String xpath, QName returnType) throws XPathExpressionException, SAXException
- Throws:
XPathExpressionException
SAXException
-
makeSimpleDoc
public 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.
-
deleteByQuery
public static String deleteByQuery(String q, String... args)
Generates a delete by query xml string- Parameters:
q
- Query that has not already been xml escapedargs
- The attributes of the delete tag
-
deleteById
public static String deleteById(String id, String... args)
Generates a delete by id xml string- Parameters:
id
- ID that has not already been xml escapedargs
- The attributes of the delete tag
-
optimize
public 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.
-
commit
public 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.
-
update
public 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
-
validateUpdate
public 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
-
validateErrorUpdate
public 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
-
checkUpdateStatus
public 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
-
-