From ec9549f01fced7d10de19959daaf02efb88c1582 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 12 Aug 2016 11:49:29 +0100 Subject: [PATCH] =?UTF-8?q?Downgrade=20to=20Jackson=202.7.6=20and=20verify?= =?UTF-8?q?=20Elasticsearch=E2=80=99s=20compatibility?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes gh-6508 --- .../jest/JestAutoConfigurationTests.java | 33 ++++++++++++++++++- spring-boot-dependencies/pom.xml | 2 +- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/jest/JestAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/jest/JestAutoConfigurationTests.java index 3fb0d593052..66735a6df2b 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/jest/JestAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/jest/JestAutoConfigurationTests.java @@ -16,20 +16,30 @@ package org.springframework.boot.autoconfigure.elasticsearch.jest; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + import com.google.gson.Gson; import io.searchbox.client.JestClient; import io.searchbox.client.http.JestHttpClient; +import io.searchbox.core.Index; +import io.searchbox.core.Search; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.search.builder.SearchSourceBuilder; import org.junit.After; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.springframework.beans.factory.BeanCreationException; +import org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration; import org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration; import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.util.SocketUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; @@ -38,6 +48,7 @@ import static org.mockito.Mockito.mock; * Tests for {@link JestAutoConfiguration}. * * @author Stephane Nicoll + * @author Andy Wilkinson */ public class JestAutoConfigurationTests { @@ -61,7 +72,8 @@ public class JestAutoConfigurationTests { @Test public void customJestClient() { - load(CustomJestClient.class, "spring.elasticsearch.jest.uris=http://localhost:9200"); + load(CustomJestClient.class, + "spring.elasticsearch.jest.uris=http://localhost:9200"); assertThat(this.context.getBeansOfType(JestClient.class)).hasSize(1); } @@ -80,6 +92,25 @@ public class JestAutoConfigurationTests { "spring.elasticsearch.jest.proxy.host=proxy.example.com"); } + @Test + public void jestCanCommunicateWithElasticsearchInstance() throws IOException { + int port = SocketUtils.findAvailableTcpPort(); + load(ElasticsearchAutoConfiguration.class, + "spring.data.elasticsearch.properties.path.home:target/elastic", + "spring.data.elasticsearch.properties.http.enabled:true", + "spring.data.elasticsearch.properties.http.port:" + port, + "spring.elasticsearch.jest.uris:http://localhost:" + port); + JestClient client = this.context.getBean(JestClient.class); + Map source = new HashMap(); + source.put("a", "alpha"); + source.put("b", "bravo"); + Index index = new Index.Builder(source).index("foo").type("bar").build(); + client.execute(index); + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); + searchSourceBuilder.query(QueryBuilders.matchQuery("a", "alpha")); + assertThat(client.execute(new Search.Builder(searchSourceBuilder.toString()) + .addIndex("foo").build()).getResponseCode()).isEqualTo(200); + } private void load(String... environment) { load(null, environment); diff --git a/spring-boot-dependencies/pom.xml b/spring-boot-dependencies/pom.xml index 3dcec6d2ca4..27d7431c122 100644 --- a/spring-boot-dependencies/pom.xml +++ b/spring-boot-dependencies/pom.xml @@ -93,7 +93,7 @@ 4.5.2 4.4.5 8.2.2.Final - 2.8.1 + 2.7.6 2.7.8 3.20.0-GA 1.0.0