org.apache.solr.util
Class RestTestHarness

java.lang.Object
  extended by org.apache.solr.util.BaseTestHarness
      extended by org.apache.solr.util.RestTestHarness

public class RestTestHarness
extends BaseTestHarness

Facilitates testing Solr's REST API via a provided embedded Jetty


Constructor Summary
RestTestHarness(RESTfulServerProvider serverProvider)
           
 
Method Summary
 String checkQueryStatus(String xml, String code)
           
 String getBaseURL()
           
 String query(String request)
          Processes a "query" using a URL path (with no context path) + optional query params, e.g.
 void reload()
          Reloads the core
 String update(String xml)
          Processes an "update" (add, commit or optimize) and returns the response as a String.
 String validateQuery(String request, String... tests)
          Validates a "query" response against an array of XPath test strings
 
Methods inherited from class org.apache.solr.util.BaseTestHarness
checkUpdateStatus, commit, deleteById, deleteByQuery, getXmlDocumentBuilder, getXpath, makeSimpleDoc, optimize, simpleTag, validateErrorUpdate, validateUpdate, validateXPath
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RestTestHarness

public RestTestHarness(RESTfulServerProvider serverProvider)
Method Detail

getBaseURL

public String getBaseURL()

validateQuery

public String validateQuery(String request,
                            String... tests)
                     throws Exception
Validates a "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

query

public String query(String request)
             throws Exception
Processes a "query" using a URL path (with no context path) + optional query params, e.g. "/schema/fields?indent=on"

Parameters:
request - the URL path and optional query params
Returns:
The response to the query
Throws:
Exception - any exception in the response.

checkQueryStatus

public String checkQueryStatus(String xml,
                               String code)
                        throws Exception
Throws:
Exception

reload

public void reload()
            throws Exception
Description copied from class: BaseTestHarness
Reloads the core

Specified by:
reload in class BaseTestHarness
Throws:
Exception

update

public String update(String xml)
Processes an "update" (add, commit or optimize) and returns the response as a String.

Specified by:
update in class BaseTestHarness
Parameters:
xml - The XML of the update
Returns:
The XML response to the update


Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.