public class TestHarness extends BaseTestHarness
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.
Modifier and Type | Class and Description |
---|---|
class |
TestHarness.LocalRequestFactory
A Factory that generates LocalSolrQueryRequest objects using a
specified set of default options.
|
static class |
TestHarness.TestCoresLocator |
Modifier and Type | Field and Description |
---|---|
protected org.apache.solr.core.CoreContainer |
container |
String |
coreName |
org.apache.solr.handler.UpdateRequestHandler |
updater |
Constructor and Description |
---|
TestHarness(org.apache.solr.core.NodeConfig nodeConfig) |
TestHarness(org.apache.solr.core.NodeConfig config,
org.apache.solr.core.CoresLocator coresLocator)
Create a TestHarness using a specific config
|
TestHarness(Path solrHome,
String solrXml)
Create a TestHarness using a specific solr home directory and solr xml
|
TestHarness(org.apache.solr.core.SolrResourceLoader loader,
String solrXml)
Create a TestHarness using a specific solr resource loader and solr xml
|
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 coreName,
String dataDir,
org.apache.solr.core.SolrConfig solrConfig,
org.apache.solr.schema.IndexSchema indexSchema) |
TestHarness(String coreName,
String dataDirectory,
org.apache.solr.core.SolrConfig solrConfig,
String schemaFile) |
TestHarness(String coreName,
String dataDir,
String solrConfig,
String indexSchema) |
Modifier and Type | Method and Description |
---|---|
static org.apache.solr.core.NodeConfig |
buildTestNodeConfig(org.apache.solr.core.SolrResourceLoader loader) |
void |
close()
Shuts down and frees any resources
|
static org.apache.solr.core.SolrConfig |
createConfig(Path solrHome,
String confFile)
Creates a SolrConfig object for the default test core using
createConfig(Path,String,String) |
static org.apache.solr.core.SolrConfig |
createConfig(Path solrHome,
String coreName,
String confFile)
Creates a SolrConfig object for the specified coreName assuming it
follows the basic conventions of being a relative path in the solrHome
dir.
|
org.apache.solr.core.SolrCore |
getCore()
Gets a core that does not have its refcount incremented (i.e.
|
org.apache.solr.core.CoreContainer |
getCoreContainer() |
org.apache.solr.core.SolrCore |
getCoreInc()
Gets the core with its reference count incremented.
|
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.
|
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.
|
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(org.apache.solr.request.SolrQueryRequest req,
String... tests)
Validates a "query" response against an array of XPath test strings
|
checkUpdateStatus, commit, deleteById, deleteByQuery, evaluateXPath, getXmlDocumentBuilder, getXpath, makeSimpleDoc, optimize, simpleTag, validateErrorUpdate, validateUpdate, validateXPath
public String coreName
protected volatile org.apache.solr.core.CoreContainer container
public org.apache.solr.handler.UpdateRequestHandler updater
public TestHarness(String coreName, String dataDirectory, org.apache.solr.core.SolrConfig solrConfig, String schemaFile)
coreName
- to initializedataDirectory
- path for index data, will not be cleaned upsolrConfig
- solronfig instanceschemaFile
- 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, String dataDir, String solrConfig, String indexSchema)
coreName
- to initializedataDir
- path for index data, will not be cleaned upsolrConfig
- solrconfig resource nameindexSchema
- schema resource namepublic TestHarness(String coreName, String dataDir, org.apache.solr.core.SolrConfig solrConfig, org.apache.solr.schema.IndexSchema indexSchema)
public TestHarness(Path solrHome, String solrXml)
solrHome
- the solr home directorysolrXml
- the text of a solrxmlpublic TestHarness(org.apache.solr.core.SolrResourceLoader loader, String solrXml)
loader
- the SolrResourceLoader to usesolrXml
- the text of a solrxmlpublic TestHarness(org.apache.solr.core.NodeConfig nodeConfig)
public TestHarness(org.apache.solr.core.NodeConfig config, org.apache.solr.core.CoresLocator coresLocator)
config
- the ConfigSolr to usepublic static org.apache.solr.core.SolrConfig createConfig(Path solrHome, String coreName, String confFile)
${solrHome}/${coreName}/conf/${confFile}
public static org.apache.solr.core.SolrConfig createConfig(Path solrHome, String confFile)
createConfig(Path,String,String)
public static org.apache.solr.core.NodeConfig buildTestNodeConfig(org.apache.solr.core.SolrResourceLoader loader)
public org.apache.solr.core.CoreContainer getCoreContainer()
public org.apache.solr.core.SolrCore getCore()
public org.apache.solr.core.SolrCore getCoreInc()
public void reload() throws Exception
BaseTestHarness
reload
in class BaseTestHarness
Exception
public String update(String xml)
update
in class BaseTestHarness
xml
- The XML of the updatepublic String validateQuery(org.apache.solr.request.SolrQueryRequest req, String... tests) throws Exception
req
- the Query to processException
- any exception in the response.IOException
- if there is a problem writing the XMLLocalSolrQueryRequest
public String query(org.apache.solr.request.SolrQueryRequest req) throws 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 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 void close()
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)
Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.