[ Web Proxy ]
URL:
Viewing: https://java.testcontainers.org/supported_docker_environment/../../../modules/solr/ [Back]  [Original]

Solr Container - Testcontainers for Java
Skip to content
Testcontainers [Testcontainers] Menu
testcontainers-java
Content

Solr Container

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:

Using a Solr container
// Create the solr container.
SolrContainer container = new SolrContainer(solrImage);

// 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.getHost() + ":" + 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:

GradleMaven
testImplementation "org.testcontainers:testcontainers-solr:2.0.5"
<dependency>
    <groupId>org.testcontainers</groupId>
    <artifactId>testcontainers-solr</artifactId>
    <version>2.0.5</version>
    <scope>test</scope>
</dependency>

Web Proxy Viewer  |  New URL  |  Original Page