|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.solr.util.TestHarness
public class TestHarness
This class provides a simple harness that may be useful when writing testcases.
This class lives in the tests-framework source tree (and not in the test source tree), so that it will be included with even the most minimal solr distribution, in order to encourage plugin writers to create unit tests for their plugins.
Nested Class Summary | |
---|---|
class |
TestHarness.LocalRequestFactory
A Factory that generates LocalSolrQueryRequest objects using a specified set of default options. |
Field Summary | |
---|---|
protected org.apache.solr.core.CoreContainer |
container
|
org.apache.solr.handler.UpdateRequestHandler |
updater
|
Constructor Summary | |
---|---|
TestHarness(String dataDirectory)
Assumes "solrconfig.xml" is the config file to use, and "schema.xml" is the schema path to use. |
|
TestHarness(String coreName,
org.apache.solr.core.CoreContainer.Initializer init)
|
|
TestHarness(String dataDirectory,
org.apache.solr.core.SolrConfig solrConfig,
org.apache.solr.schema.IndexSchema indexSchema)
|
|
TestHarness(String dataDirectory,
org.apache.solr.core.SolrConfig solrConfig,
String schemaFile)
|
|
TestHarness(String dataDirectory,
String schemaFile)
Assumes "solrconfig.xml" is the config file to use. |
|
TestHarness(String dataDirectory,
String configFile,
String schemaFile)
|
Method Summary | |
---|---|
String |
checkUpdateStatus(String xml,
String code)
Validates that an "update" (add, commit or optimize) results in success. |
void |
close()
Shuts down and frees any resources |
static String |
commit(String... args)
Helper that returns an <commit> String with optional key/val pairs. |
static org.apache.solr.core.SolrConfig |
createConfig(String confFile)
|
static String |
deleteById(String id,
String... args)
Generates a delete by id xml string |
static String |
deleteByQuery(String q,
String... args)
Generates a delete by query xml string |
org.apache.solr.core.SolrCore |
getCore()
|
org.apache.solr.core.CoreContainer |
getCoreContainer()
|
TestHarness.LocalRequestFactory |
getRequestFactory(String qtype,
int start,
int limit)
|
TestHarness.LocalRequestFactory |
getRequestFactory(String qtype,
int start,
int limit,
Map<String,String> args)
|
TestHarness.LocalRequestFactory |
getRequestFactory(String qtype,
int start,
int limit,
String... args)
0 and Even numbered args are keys, Odd numbered args are values. |
static StringBuffer |
makeSimpleDoc(String... fieldsAndValues)
A helper that creates an xml <doc> containing all of the fields and values specified |
static String |
optimize(String... args)
Helper that returns an <optimize> String with optional key/val pairs. |
String |
query(org.apache.solr.request.SolrQueryRequest req)
Processes a "query" using a user constructed SolrQueryRequest |
String |
query(String handler,
org.apache.solr.request.SolrQueryRequest req)
Processes a "query" using a user constructed SolrQueryRequest, and closes the request at the end. |
org.apache.solr.response.SolrQueryResponse |
queryAndResponse(String handler,
org.apache.solr.request.SolrQueryRequest req)
It is the users responsibility to close the request object when done with it. |
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 |
validateQuery(org.apache.solr.request.SolrQueryRequest req,
String... tests)
Validates a "query" response against an array of XPath test strings |
String |
validateUpdate(String xml)
Validates that an "update" (add, commit or optimize) results in success. |
String |
validateXPath(String xml,
String... tests)
A helper method which valides a String against an array of XPath test strings. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected org.apache.solr.core.CoreContainer container
public org.apache.solr.handler.UpdateRequestHandler updater
Constructor Detail |
---|
public TestHarness(String dataDirectory)
dataDirectory
- path for index data, will not be cleaned uppublic TestHarness(String dataDirectory, String schemaFile)
dataDirectory
- path for index data, will not be cleaned upschemaFile
- path of schema filepublic TestHarness(String dataDirectory, String configFile, String schemaFile)
dataDirectory
- path for index data, will not be cleaned upconfigFile
- solrconfig filenameschemaFile
- schema filenamepublic TestHarness(String dataDirectory, org.apache.solr.core.SolrConfig solrConfig, String schemaFile)
dataDirectory
- path for index data, will not be cleaned upsolrConfig
- solronfig instanceschemaFile
- schema filenamepublic TestHarness(String dataDirectory, org.apache.solr.core.SolrConfig solrConfig, org.apache.solr.schema.IndexSchema indexSchema)
dataDirectory
- path for index data, will not be cleaned upsolrConfig
- solrconfig instanceindexSchema
- schema instancepublic TestHarness(String coreName, org.apache.solr.core.CoreContainer.Initializer init)
Method Detail |
---|
public static org.apache.solr.core.SolrConfig createConfig(String confFile)
public org.apache.solr.core.CoreContainer getCoreContainer()
public org.apache.solr.core.SolrCore getCore()
public String update(String xml)
xml
- The XML of the update
public String validateUpdate(String xml) throws SAXException
xml
- The XML of the update
SAXException
public String validateErrorUpdate(String xml) throws SAXException
xml
- The XML of the update
SAXException
public String checkUpdateStatus(String xml, String code) throws SAXException
xml
- The XML of the update
SAXException
public String validateQuery(org.apache.solr.request.SolrQueryRequest req, String... tests) throws IOException, Exception
req
- the Query to process
Exception
- any exception in the response.
IOException
- if there is a problem writing the XMLLocalSolrQueryRequest
public String query(org.apache.solr.request.SolrQueryRequest req) throws IOException, Exception
req
- the Query to process, will be closed.
Exception
- any exception in the response.
IOException
- if there is a problem writing the XMLLocalSolrQueryRequest
public String query(String handler, org.apache.solr.request.SolrQueryRequest req) throws IOException, Exception
handler
- the name of the request handler to process the requestreq
- the Query to process, will be closed.
Exception
- any exception in the response.
IOException
- if there is a problem writing the XMLLocalSolrQueryRequest
public org.apache.solr.response.SolrQueryResponse queryAndResponse(String handler, org.apache.solr.request.SolrQueryRequest req) throws Exception
Exception
public String validateXPath(String xml, String... tests) throws XPathExpressionException, SAXException
xml
- The xml String to validatetests
- Array of XPath strings to test (in boolean mode) on the xml
XPathExpressionException
SAXException
public void close()
public static StringBuffer makeSimpleDoc(String... fieldsAndValues)
fieldsAndValues
- 0 and Even numbered args are fields names odds are field values.public static String deleteByQuery(String q, String... args)
q
- Query that has not already been xml escapedargs
- The attributes of the delete tagpublic static String deleteById(String id, String... args)
id
- ID that has not already been xml escapedargs
- The attributes of the delete tagpublic static String optimize(String... args)
args
- 0 and Even numbered args are params, Odd numbered args are values.public static String commit(String... args)
args
- 0 and Even numbered args are params, Odd numbered args are values.public TestHarness.LocalRequestFactory getRequestFactory(String qtype, int start, int limit)
public TestHarness.LocalRequestFactory getRequestFactory(String qtype, int start, int limit, String... args)
public TestHarness.LocalRequestFactory getRequestFactory(String qtype, int start, int limit, Map<String,String> args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |