title: How can I do integration testing in elasticsearch with spring-data-elasticsearch?
body: <p>I am using spring-data-elasticsearch v3.2.4.RELEASE which is available via spring-boot-starter-data-elasticsearch v2.2.4.RELEASE. 
  I want to do the integration tests for this but the available option which is this:
  <a href="https://github.com/allegro/embedded-elasticsearch" rel="nofollow noreferrer">https://github.com/allegro/embedded-elasticsearch</a> not working.</p>
  
  <p>The part which I tried to get started as POC is below and it is throwing exception:</p>
  
  <pre><code>    public class EmbeddedElasticConfiguration {
  
      public static final String VERSION = "6.8.4";
      public static final String DOWNLOAD_DIRECTORY = "&lt;path&gt;\\test-elasticsearch";
      public static final String INSTALLATION_DIRECTORY = "&lt;path&gt;\test-elasticsearch";
      public static final String NAME = "elasticsearch";
      public static final String TRANSPORT_PORT = "9300";
      public static final String HTTP_CLIENT_PORT = "9200";
      public static final String TEST_INDEX = "salesorder";
      public static final String TEST_TYPE = "salesorder";
      public static final String RESOURCE_LOCATION = "src/test/resources/salesorder-mapping.json";
      private ObjectMapper objectMapper = new ObjectMapper();
      EmbeddedElastic embeddedElastic;
  
      @Test
      public void configure() throws IOException, InterruptedException {
          embeddedElastic = EmbeddedElastic.builder()
                  .withElasticVersion(VERSION)
                  .withSetting(TRANSPORT_TCP_PORT, 9300)
                  .withSetting(CLUSTER_NAME, "my-cluster")
                  //.withPlugin("analysis-stempel")
                  .withDownloadDirectory(new File(DOWNLOAD_DIRECTORY))
                  .withInstallationDirectory(new File(INSTALLATION_DIRECTORY))
                  .withSetting(HTTP_PORT, 9200)
                  .withIndex(TEST_INDEX, IndexSettings.builder()
                         .withType(TEST_TYPE, readMappingFromJson())
                       .build())
                  .build();
  
          embeddedElastic.start();
      }
  
      private String readMappingFromJson() throws IOException {
          final File file = ResourceUtils.getFile(RESOURCE_LOCATION);
          String mapping = new String(Files.readAllBytes(file.toPath()));
          System.out.println("mapping: "+ mapping);
          return mapping;
      }
  
      @After
      public void stopServer() {
          embeddedElastic.stop();
      }
  }
  </code></pre>
  
  <p>I am below getting below exception:</p>
  
  <pre><code>pl.allegro.tech.embeddedelasticsearch.EmbeddedElasticsearchStartupException: Failed to start elasticsearch within time-out
  
      at pl.allegro.tech.embeddedelasticsearch.ElasticServer.waitForElasticToStart(ElasticServer.java:127)
      at pl.allegro.tech.embeddedelasticsearch.ElasticServer.start(ElasticServer.java:50)
      at pl.allegro.tech.embeddedelasticsearch.EmbeddedElastic.startElastic(EmbeddedElastic.java:82)
      at pl.allegro.tech.embeddedelasticsearch.EmbeddedElastic.start(EmbeddedElastic.java:63)
      at com.xxx.elasticsearch.adapter.configuration.EmbeddedElasticConfiguration.configure(EmbeddedElasticConfiguration.java:50)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  </code></pre>
  
  <p>Can someone help with any other options for integration tests in elasticsearch with spring-data or How should I write integration tests for elasticsearch.</p>
  
  <p>I know there are other answers on stackoverflow and other portals for embedded-elasticsearch but those are not working with my current elasticsearch version.</p>