Package org.apache.solr.util
Class RestTestHarness
java.lang.Object
org.apache.solr.util.BaseTestHarness
org.apache.solr.util.RestTestHarness
- All Implemented Interfaces:
Closeable,AutoCloseable
Facilitates testing Solr's REST API via a provided embedded Jetty
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadminQuery(String request) checkAdminResponseStatus(String xml, String code) checkResponseStatus(String xml, String code) voidclose()Processes a DELETE request using a URL path (with no context path) + optional query params, e.g.Processes a HEAD request using a URL path (with no context path) + optional query params and returns the response content.Processes a POST request using a URL path (with no context path) + optional query params, e.g.Processes a PUT request using a URL path (with no context path) + optional query params, e.g.Processes a "query" using a URL path (with no context path) + optional query params, e.g.voidreload()Reloads the first core listed in the response to the core admin handler STATUS commandvoidsetServerProvider(RESTfulServerProvider serverProvider) Processes an "update" (add, commit or optimize) and returns the response as a String.validatePut(String request, String content, String... tests) Validates an XML PUT response against an array of XPath test stringsvalidateQuery(String request, String... tests) Validates an XML "query" response against an array of XPath test stringsMethods inherited from class org.apache.solr.util.BaseTestHarness
checkUpdateStatus, commit, deleteById, deleteByQuery, evaluateXPath, getXmlDocumentBuilder, getXpath, makeSimpleDoc, optimize, simpleTag, validateErrorUpdate, validateUpdate, validateXPath
-
Constructor Details
-
RestTestHarness
-
-
Method Details
-
getBaseURL
-
setServerProvider
-
getServerProvider
-
getAdminURL
-
validateQuery
Validates an XML "query" response against an array of XPath test strings- Parameters:
request- the Query to process- Returns:
- null if all good, otherwise the first test that fails.
- Throws:
Exception- any exception in the response.IOException- if there is a problem writing the XML
-
validatePut
Validates an XML PUT response against an array of XPath test strings- Parameters:
request- the PUT request to processcontent- the content to send with the PUT requesttests- the validating XPath tests- Returns:
- null if all good, otherwise the first test that fails.
- Throws:
Exception- any exception in the response.IOException- if there is a problem writing the XML
-
query
Processes a "query" using a URL path (with no context path) + optional query params, e.g. "/schema/fields?indent=off"- Parameters:
request- the URL path and optional query params- Returns:
- The response to the query
- Throws:
IOException- any exception in the response.
-
adminQuery
- Throws:
IOException
-
head
Processes a HEAD request using a URL path (with no context path) + optional query params and returns the response content.- Parameters:
request- The URL path and optional query params- Returns:
- The response to the HEAD request
- Throws:
IOException
-
put
Processes a PUT request using a URL path (with no context path) + optional query params, e.g. "/schema/fields/newfield", PUTs the given content, and returns the response content.- Parameters:
request- The URL path and optional query paramscontent- The content to include with the PUT request- Returns:
- The response to the PUT request
- Throws:
IOException
-
delete
Processes a DELETE request using a URL path (with no context path) + optional query params, e.g. "/schema/analysis/protwords/english", and returns the response content.- Parameters:
request- the URL path and optional query params- Returns:
- The response to the DELETE request
- Throws:
IOException
-
post
Processes a POST request using a URL path (with no context path) + optional query params, e.g. "/schema/fields/newfield", PUTs the given content, and returns the response content.- Parameters:
request- The URL path and optional query paramscontent- The content to include with the POST request- Returns:
- The response to the POST request
- Throws:
IOException
-
checkResponseStatus
- Throws:
Exception
-
checkAdminResponseStatus
- Throws:
Exception
-
reload
Reloads the first core listed in the response to the core admin handler STATUS command- Specified by:
reloadin classBaseTestHarness- Throws:
Exception
-
update
Processes an "update" (add, commit or optimize) and returns the response as a String.- Specified by:
updatein classBaseTestHarness- Parameters:
xml- The XML of the update- Returns:
- The XML response to the update
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-