Class EmbeddedSolrServerTestRule

java.lang.Object
org.junit.rules.ExternalResource
org.apache.solr.util.SolrClientTestRule
org.apache.solr.util.EmbeddedSolrServerTestRule
All Implemented Interfaces:
org.junit.rules.TestRule

public class EmbeddedSolrServerTestRule extends SolrClientTestRule
Provides an EmbeddedSolrServer for tests. It starts and stops the server and provides methods for creating collections and interacting with the server.
  • Constructor Details

    • EmbeddedSolrServerTestRule

      public EmbeddedSolrServerTestRule()
  • Method Details

    • after

      protected void after()
      Shuts down the EmbeddedSolrServer instance and clears the coreRootDirectory system property if necessary
      Overrides:
      after in class org.junit.rules.ExternalResource
    • startSolr

      public void startSolr(Path solrHome)
      Starts the Solr server with the given solrHome. If solrHome contains a solr.xml file, it is used to configure the server. If not, a new NodeConfig is built with default settings for configuration.
      Specified by:
      startSolr in class SolrClientTestRule
    • startSolr

      public void startSolr(org.apache.solr.core.NodeConfig nodeConfig)
      Starts Solr with custom NodeConfig
    • newNodeConfigBuilder

      public org.apache.solr.core.NodeConfig.NodeConfigBuilder newNodeConfigBuilder(Path solrHome)
      Returns a NodeConfigBuilder with default settings for test configuration
    • getAdminClient

      public org.apache.solr.client.solrj.embedded.EmbeddedSolrServer getAdminClient()
      Provides an EmbeddedSolrServer instance for administration actions
      Overrides:
      getAdminClient in class SolrClientTestRule
    • getSolrClient

      public org.apache.solr.client.solrj.embedded.EmbeddedSolrServer getSolrClient(String collection)
      Description copied from class: SolrClientTestRule
      Provides a SolrClient instance for caller defined collection name. The caller doesn't need to close it
      Specified by:
      getSolrClient in class SolrClientTestRule
    • getCoreContainer

      public org.apache.solr.core.CoreContainer getCoreContainer()