Solr Container

Note

This module is INCUBATING. While it is ready for use and operational in the current version of Testcontainers, it is possible that it may receive breaking changes in the future. See our contributing guidelines for more information on our incubating modules policy.

This module helps running solr using Testcontainers.

Note that it's based on the official Docker image.

Usage example

You can start a solr container instance from any Java application by using:

// Create the solr container.
SolrContainer container = new SolrContainer();

// Start the container. This step might take some time...
container.start();

// Do whatever you want with the client ...
SolrClient client = new Http2SolrClient.Builder("http://" + container.getContainerIpAddress() + ":" + container.getSolrPort() + "/solr").build();
SolrPingResponse response = client.ping("dummy");

// Stop the container.
container.stop();

Adding this module to your project dependencies

Add the following dependency to your pom.xml/build.gradle file:

testCompile "org.testcontainers:solr:1.14.3"
<dependency>
    <groupId>org.testcontainers</groupId>
    <artifactId>solr</artifactId>
    <version>1.14.3</version>
    <scope>test</scope>
</dependency>