Package no.mnemonic.commons.junit.docker
Class ElasticSearchDockerResource
java.lang.Object
org.junit.rules.ExternalResource
no.mnemonic.commons.junit.docker.DockerResource
no.mnemonic.commons.junit.docker.ElasticSearchDockerResource
- All Implemented Interfaces:
org.junit.rules.TestRule
Deprecated.
Use jupiter-docker instead
ElasticSearchDockerResource is a JUnit resource which can be used to write integration tests against an ElasticSearch
server executed inside an isolated Docker container. It extends the basic
DockerResource and makes sure that
the container initialization waits until ElasticSearch is available. Data indexed into ElasticSearch by tests can be
truncated by providing the indices to delete when constructing the resource and calling deleteIndices().
Initialize ElasticSearchDockerResource in the following way as a ClassRule:
@ClassRule
public static ElasticSearchDockerResource elastic = ElasticSearchDockerResource.builder()
.setImageName("elasticsearch")
.addApplicationPort(9200)
.addApplicationPort(9300)
.addDeleteIndex("foo")
.addDeleteIndex("bar")
.addDeleteIndex("baz")
.build();
See DockerResource.Builder and ElasticSearchDockerResource.Builder for more information on the
configuration properties.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDeprecated.Builder to create an ElasticSearchDockerResource which extendsDockerResource.Builder. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Deprecated.Create builder for ElasticSearchDockerResource.voidDeprecated.Truncate data indexed into ElasticSearch by deleting the indices specified when constructing the resource.protected booleanDeprecated.Verifies that ElasticSearch is reachable by querying the cluster status from inside the Docker container.Methods inherited from class no.mnemonic.commons.junit.docker.DockerResource
additionalContainerConfig, additionalHostConfig, after, before, getContainerID, getDockerClient, getExposedHost, getExposedHostPort, prepareContainerMethods inherited from class org.junit.rules.ExternalResource
apply
-
Method Details
-
deleteIndices
public void deleteIndices()Deprecated.Truncate data indexed into ElasticSearch by deleting the indices specified when constructing the resource. If no indices were specified all indices will be deleted.- Throws:
IllegalStateException- If indices could not be deleted
-
builder
Deprecated.Create builder for ElasticSearchDockerResource.- Returns:
- Builder object
-
isContainerReachable
protected boolean isContainerReachable()Deprecated.Verifies that ElasticSearch is reachable by querying the cluster status from inside the Docker container.- Overrides:
isContainerReachablein classDockerResource- Returns:
- True if cluster status could be queried successfully
- Throws:
IllegalStateException- If cluster status could not be queried
-