Package org.apache.solr.util
Class SolrClientTestRule
java.lang.Object
org.junit.rules.ExternalResource
org.apache.solr.util.SolrClientTestRule
- All Implemented Interfaces:
org.junit.rules.TestRule
- Direct Known Subclasses:
EmbeddedSolrServerTestRule,SolrJettyTestRule
public abstract class SolrClientTestRule
extends org.junit.rules.ExternalResource
Provides access to a
SolrClient instance and a running Solr in tests. Implementations
could run Solr in different ways (e.g. strictly embedded, adding HTTP/Jetty, adding SolrCloud, or
an external process). It's a JUnit ExternalResource (a TestRule), and thus closes
the client and Solr itself when the test completes. Wraps a SolrBackend. This test
utility is encouraged to be used by external projects that wish to test communicating with Solr,
especially for plugin providers.-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidafter()voidprotected abstract voidOverride to call eithercreateCollSolrCloud(NewCollectionBuilder)orcreateCollStandalone(NewCollectionBuilder)protected voidprotected voidorg.apache.solr.client.solrj.SolrClientProvides a SolrClient instance for administration actions.Returns the underlyingSolrBackend.getBaseUrl(Random r) org.apache.solr.core.CoreContainerorg.apache.solr.client.solrj.SolrClientProvides a SolrClient instance for collection1.abstract org.apache.solr.client.solrj.SolrClientgetSolrClient(String collection) Provides a SolrClient instance for caller defined collection name.Returns a builder for creating a collection/core.newCollection(String name) Returns a builder for creating a collection/core.voidStarts the Solr server with empty solrHome.abstract voidStarts the Solr server with the given solrHome.Methods inherited from class org.junit.rules.ExternalResource
apply, before
-
Field Details
-
backend
-
-
Constructor Details
-
SolrClientTestRule
public SolrClientTestRule()
-
-
Method Details
-
getBackend
Returns the underlyingSolrBackend. -
after
protected void after()- Overrides:
afterin classorg.junit.rules.ExternalResource
-
startSolr
public void startSolr()Starts the Solr server with empty solrHome. -
startSolr
Starts the Solr server with the given solrHome. If solrHome contains a solr.xml file, it is used. Otherwise, a default testing configuration is used. -
newCollection
Returns a builder for creating a collection/core. Not for testing collection creation itself. -
newCollection
Returns a builder for creating a collection/core. Not for testing collection creation itself. -
createColl
protected abstract void createColl(SolrClientTestRule.NewCollectionBuilder b) throws org.apache.solr.client.solrj.SolrServerException, IOException Override to call eithercreateCollSolrCloud(NewCollectionBuilder)orcreateCollStandalone(NewCollectionBuilder)- Throws:
org.apache.solr.client.solrj.SolrServerExceptionIOException
-
createCollSolrCloud
protected void createCollSolrCloud(SolrClientTestRule.NewCollectionBuilder b) throws org.apache.solr.client.solrj.SolrServerException, IOException - Throws:
org.apache.solr.client.solrj.SolrServerExceptionIOException
-
createCollStandalone
protected void createCollStandalone(SolrClientTestRule.NewCollectionBuilder b) throws org.apache.solr.client.solrj.SolrServerException, IOException - Throws:
org.apache.solr.client.solrj.SolrServerExceptionIOException
-
getAdminClient
public org.apache.solr.client.solrj.SolrClient getAdminClient()Provides a SolrClient instance for administration actions. The caller must not close it. -
getSolrClient
public org.apache.solr.client.solrj.SolrClient getSolrClient()Provides a SolrClient instance for collection1. The caller doesn't need to close it -
getSolrClient
Provides a SolrClient instance for caller defined collection name. The caller doesn't need to close it -
clearIndex
- Throws:
org.apache.solr.client.solrj.SolrServerExceptionIOException
-
getCoreContainer
public org.apache.solr.core.CoreContainer getCoreContainer()- See Also:
-
getBaseUrl
- See Also:
-