Elasticsearch for JUnits

We are using Elasticsearch and planning to have JUnits for our modules. These JUnits run during our product build infact as a first step... we are looking for a kind of embedded Elasticsearch which we can use for our JUnits as we don't want to have a running instance in a VM and use it... (or) are there any recommendations to mock Elasticsearch APIs?

One of the easiest thing to do ATM is to extend ESIntegTestCase and add this dependency in your project:


And something like this:

                <!-- we skip surefire to work with randomized testing above -->

                <!-- Defaults for all tests (ITs and Unit). -->
                    <assertions enableSystemAssertions="false">
                        <disable package="${tests.assertion.disabled}"/>
                        <!-- pass org.elasticsearch to run without assertions -->

                        <report-text showThrowable="true" showStackTraces="true" showOutput="${tests.output}" showStatusOk="true"
                                     showStatusError="true" showStatusFailure="true" showStatusIgnored="true" showSuiteSummary="true" />
                    <systemProperties combine.children="append">


Hope this helps

Thanks for the reply. I haven't understood the usage of what you have said.

Where do the Elasticsearch run?
How do I use it in my JUnit class?

We are looking for something like the one below ,

Endpoint.publish("http://localhost:9292/ws/milli", new HelloWorld()); which opens up a http port on 9292..

similar thing for Elasticsearch... !!!
start the Elasticsearch
Run the junits
shutdown the Elasticsearch

The test framework will start an embedded cluster for you if you extend the class I mentioned.