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
public abstract class SolrClientTestRule extends org.junit.rules.ExternalResource
Provides access to aSolrClient
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 JUnitExternalResource
(aTestRule
), and thus closes the client and Solr itself when the test completes. 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 Modifier and Type Class Description class
SolrClientTestRule.NewCollectionBuilder
-
Constructor Summary
Constructors Constructor Description SolrClientTestRule()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
clearIndex()
protected void
create(SolrClientTestRule.NewCollectionBuilder b)
abstract org.apache.solr.client.solrj.SolrClient
getAdminClient()
Provides a SolrClient instance for administration actionsorg.apache.solr.client.solrj.SolrClient
getSolrClient()
Provides a SolrClient instance for collection1abstract org.apache.solr.client.solrj.SolrClient
getSolrClient(String name)
SolrClientTestRule.NewCollectionBuilder
newCollection()
SolrClientTestRule.NewCollectionBuilder
newCollection(String name)
void
startSolr()
Starts the Solr server with empty solrHome.abstract void
startSolr(Path solrHome)
Starts the Solr server with the given solrHome.
-
-
-
Method Detail
-
startSolr
public void startSolr()
Starts the Solr server with empty solrHome.
-
startSolr
public abstract void startSolr(Path solrHome)
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
public SolrClientTestRule.NewCollectionBuilder newCollection(String name)
-
newCollection
public SolrClientTestRule.NewCollectionBuilder newCollection()
-
create
protected void create(SolrClientTestRule.NewCollectionBuilder b) throws org.apache.solr.client.solrj.SolrServerException, IOException
- Throws:
org.apache.solr.client.solrj.SolrServerException
IOException
-
getAdminClient
public abstract org.apache.solr.client.solrj.SolrClient getAdminClient()
Provides a SolrClient instance for administration actions
-
getSolrClient
public org.apache.solr.client.solrj.SolrClient getSolrClient()
Provides a SolrClient instance for collection1
-
getSolrClient
public abstract org.apache.solr.client.solrj.SolrClient getSolrClient(String name)
-
clearIndex
public void clearIndex() throws org.apache.solr.client.solrj.SolrServerException, IOException
- Throws:
org.apache.solr.client.solrj.SolrServerException
IOException
-
-