Drop support for auto-configuring an embedded Elasticsearch node
Elastic have announced [1] that embedded Elasticsearch is no longer supported. This commit brings us into line with that announcement by removing the auto-configuration that would create an Elasticsearch Node and NodeClient. To use the Elasticsearch auto-configuration, a user must now provide the address of one or more cluster nodes (via the spring.elastisearch.cluster-nodes property) which will then be used to create a TransportClient. See gh-9374 [1] https://www.elastic.co/blog/elasticsearch-the-server
This commit is contained in:
@@ -18,6 +18,8 @@ package sample.data.elasticsearch;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.elasticsearch.client.transport.NoNodeAvailableException;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -28,8 +30,6 @@ import org.junit.runners.model.Statement;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.test.rule.OutputCapture;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link SampleElasticsearchApplication}.
|
||||
*
|
||||
@@ -45,9 +45,28 @@ public class SampleElasticsearchApplicationTests {
|
||||
|
||||
@Test
|
||||
public void testDefaultSettings() throws Exception {
|
||||
new SpringApplicationBuilder(SampleElasticsearchApplication.class).run();
|
||||
try {
|
||||
new SpringApplicationBuilder(SampleElasticsearchApplication.class).run();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
if (!elasticsearchRunning(ex)) {
|
||||
return;
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
String output = this.outputCapture.toString();
|
||||
assertThat(output).contains("firstName='Alice', lastName='Smith'");
|
||||
Assertions.assertThat(output).contains("firstName='Alice', lastName='Smith'");
|
||||
}
|
||||
|
||||
private boolean elasticsearchRunning(Exception ex) {
|
||||
Throwable candidate = ex;
|
||||
while (candidate != null) {
|
||||
if (candidate instanceof NoNodeAvailableException) {
|
||||
return false;
|
||||
}
|
||||
candidate = candidate.getCause();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static class SkipOnWindows implements TestRule {
|
||||
|
||||
Reference in New Issue
Block a user