commit
4670226a3c
|
|
@ -32,7 +32,7 @@ import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Actual ElasticSearch health indicator configurations imported by
|
* Actual Elasticsearch health indicator configurations imported by
|
||||||
* {@link HealthIndicatorAutoConfiguration}.
|
* {@link HealthIndicatorAutoConfiguration}.
|
||||||
*
|
*
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
|
|
|
||||||
|
|
@ -427,7 +427,7 @@ public class HealthIndicatorAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void notElasticSearchHealthIndicator() {
|
public void notElasticsearchHealthIndicator() {
|
||||||
EnvironmentTestUtils.addEnvironment(this.context,
|
EnvironmentTestUtils.addEnvironment(this.context,
|
||||||
"management.health.elasticsearch.enabled:false",
|
"management.health.elasticsearch.enabled:false",
|
||||||
"spring.data.elasticsearch.properties.path.home:target",
|
"spring.data.elasticsearch.properties.path.home:target",
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
public class JestProperties {
|
public class JestProperties {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Comma-separated list of the elasticsearch instances to use.
|
* Comma-separated list of the Elasticsearch instances to use.
|
||||||
*/
|
*/
|
||||||
private List<String> uris = Collections.singletonList("http://localhost:9200");
|
private List<String> uris = Collections.singletonList("http://localhost:9200");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -629,11 +629,11 @@ content into your application; rather pick only the properties that you need.
|
||||||
spring.datasource.url= # JDBC url of the database.
|
spring.datasource.url= # JDBC url of the database.
|
||||||
spring.datasource.username=
|
spring.datasource.username=
|
||||||
|
|
||||||
# JEST (ElasticSearch HTTP client) ({sc-spring-boot-autoconfigure}/jest/JestProperties.{sc-ext}[JestProperties])
|
# JEST (Elasticsearch HTTP client) ({sc-spring-boot-autoconfigure}/jest/JestProperties.{sc-ext}[JestProperties])
|
||||||
spring.elasticsearch.jest.connection-timeout=3000 # Connection timeout in milliseconds.
|
spring.elasticsearch.jest.connection-timeout=3000 # Connection timeout in milliseconds.
|
||||||
spring.elasticsearch.jest.password= # Login password.
|
spring.elasticsearch.jest.password= # Login password.
|
||||||
spring.elasticsearch.jest.read-timeout=3000 # Read timeout in milliseconds.
|
spring.elasticsearch.jest.read-timeout=3000 # Read timeout in milliseconds.
|
||||||
spring.elasticsearch.jest.uris=http://localhost:9200 # Comma-separated list of the elasticsearch instances to use.
|
spring.elasticsearch.jest.uris=http://localhost:9200 # Comma-separated list of the Elasticsearch instances to use.
|
||||||
spring.elasticsearch.jest.username= # Login user.
|
spring.elasticsearch.jest.username= # Login user.
|
||||||
|
|
||||||
# H2 Web Console ({sc-spring-boot-autoconfigure}/h2/H2ConsoleProperties.{sc-ext}[H2ConsoleProperties])
|
# H2 Web Console ({sc-spring-boot-autoconfigure}/h2/H2ConsoleProperties.{sc-ext}[H2ConsoleProperties])
|
||||||
|
|
|
||||||
|
|
@ -292,7 +292,7 @@ The following `HealthIndicators` are auto-configured by Spring Boot when appropr
|
||||||
|Checks that a connection to `DataSource` can be obtained.
|
|Checks that a connection to `DataSource` can be obtained.
|
||||||
|
|
||||||
|{sc-spring-boot-actuator}/health/ElasticsearchHealthIndicator.{sc-ext}[`ElasticsearchHealthIndicator`]
|
|{sc-spring-boot-actuator}/health/ElasticsearchHealthIndicator.{sc-ext}[`ElasticsearchHealthIndicator`]
|
||||||
|Checks that an ElasticSearch cluster is up.
|
|Checks that an Elasticsearch cluster is up.
|
||||||
|
|
||||||
|{sc-spring-boot-actuator}/health/JmsHealthIndicator.{sc-ext}[`JmsHealthIndicator`]
|
|{sc-spring-boot-actuator}/health/JmsHealthIndicator.{sc-ext}[`JmsHealthIndicator`]
|
||||||
|Checks that a JMS broker is up.
|
|Checks that a JMS broker is up.
|
||||||
|
|
|
||||||
|
|
@ -3335,7 +3335,7 @@ https://github.com/searchbox-io/Jest[Jest].
|
||||||
|
|
||||||
|
|
||||||
[[boot-features-connecting-to-elasticsearch-jest]]
|
[[boot-features-connecting-to-elasticsearch-jest]]
|
||||||
==== Connecting to Elasticsearch using Spring Data
|
==== Connecting to Elasticsearch using Jest
|
||||||
If you have `Jest` on the classpath, you can inject an auto-configured `JestClient`
|
If you have `Jest` on the classpath, you can inject an auto-configured `JestClient`
|
||||||
targeting `http://localhost:9200` by default. You can further tune how the client is
|
targeting `http://localhost:9200` by default. You can further tune how the client is
|
||||||
configured:
|
configured:
|
||||||
|
|
@ -3352,14 +3352,13 @@ To take full control over the registration, define a `JestClient` bean.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[boot-features-connecting-to-elasticsearch]]
|
|
||||||
[[boot-features-connecting-to-elasticsearch-spring-data]]
|
[[boot-features-connecting-to-elasticsearch-spring-data]]
|
||||||
==== Connecting to Elasticsearch using Spring Data
|
==== Connecting to Elasticsearch using Spring Data
|
||||||
You can inject an auto-configured `ElasticsearchTemplate` or Elasticsearch `Client`
|
You can inject an auto-configured `ElasticsearchTemplate` or Elasticsearch `Client`
|
||||||
instance as you would any other Spring Bean. By default the instance will embed a
|
instance as you would any other Spring Bean. By default the instance will embed a
|
||||||
local in-memory server (a `Node` in ElasticSearch terms) and use the current working
|
local in-memory server (a `Node` in Elasticsearch terms) and use the current working
|
||||||
directory as the home directory for the server. In this setup, the first thing to do
|
directory as the home directory for the server. In this setup, the first thing to do
|
||||||
is to tell ElasticSearch where to store its files:
|
is to tell Elasticsearch where to store its files:
|
||||||
|
|
||||||
[source,properties,indent=0]
|
[source,properties,indent=0]
|
||||||
----
|
----
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ import org.springframework.web.client.RestTemplate;
|
||||||
import org.springframework.web.util.UriTemplateHandler;
|
import org.springframework.web.util.UriTemplateHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link RequestExpectationManager} that strips any the specified root URI from the
|
* {@link RequestExpectationManager} that strips the specified root URI from the
|
||||||
* request before verification. Can be used to simply test declarations when all REST
|
* request before verification. Can be used to simply test declarations when all REST
|
||||||
* calls start the same way. For example: <pre class="code">
|
* calls start the same way. For example: <pre class="code">
|
||||||
* RestTemplate restTemplate = new RestTemplateBuilder().rootUri("http://example.com").build();
|
* RestTemplate restTemplate = new RestTemplateBuilder().rootUri("http://example.com").build();
|
||||||
|
|
@ -107,7 +107,7 @@ public class RootUriRequestExpectationManager implements RequestExpectationManag
|
||||||
/**
|
/**
|
||||||
* Return a bound {@link MockRestServiceServer} for the given {@link RestTemplate},
|
* Return a bound {@link MockRestServiceServer} for the given {@link RestTemplate},
|
||||||
* configured with {@link RootUriRequestExpectationManager} when possible.
|
* configured with {@link RootUriRequestExpectationManager} when possible.
|
||||||
* @param restTemplate the source reset template
|
* @param restTemplate the source REST template
|
||||||
* @return a configured {@link MockRestServiceServer}
|
* @return a configured {@link MockRestServiceServer}
|
||||||
*/
|
*/
|
||||||
public static MockRestServiceServer bindTo(RestTemplate restTemplate) {
|
public static MockRestServiceServer bindTo(RestTemplate restTemplate) {
|
||||||
|
|
@ -117,7 +117,7 @@ public class RootUriRequestExpectationManager implements RequestExpectationManag
|
||||||
/**
|
/**
|
||||||
* Return a bound {@link MockRestServiceServer} for the given {@link RestTemplate},
|
* Return a bound {@link MockRestServiceServer} for the given {@link RestTemplate},
|
||||||
* configured with {@link RootUriRequestExpectationManager} when possible.
|
* configured with {@link RootUriRequestExpectationManager} when possible.
|
||||||
* @param restTemplate the source reset template
|
* @param restTemplate the source REST template
|
||||||
* @param expectationManager the source {@link RequestExpectationManager}
|
* @param expectationManager the source {@link RequestExpectationManager}
|
||||||
* @return a configured {@link MockRestServiceServer}
|
* @return a configured {@link MockRestServiceServer}
|
||||||
*/
|
*/
|
||||||
|
|
@ -132,7 +132,7 @@ public class RootUriRequestExpectationManager implements RequestExpectationManag
|
||||||
* {@link RestTemplate}. If the {@link RestTemplate} is using a
|
* {@link RestTemplate}. If the {@link RestTemplate} is using a
|
||||||
* {@link RootUriTemplateHandler} then a {@link RootUriRequestExpectationManager} is
|
* {@link RootUriTemplateHandler} then a {@link RootUriRequestExpectationManager} is
|
||||||
* returned, otherwise the source manager is returned unchanged.
|
* returned, otherwise the source manager is returned unchanged.
|
||||||
* @param restTemplate the source reset template
|
* @param restTemplate the source REST template
|
||||||
* @param expectationManager the source {@link RequestExpectationManager}
|
* @param expectationManager the source {@link RequestExpectationManager}
|
||||||
* @return a {@link RequestExpectationManager} to be bound to the template
|
* @return a {@link RequestExpectationManager} to be bound to the template
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ public class RootUriRequestExpectationManagerTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void bindToShouldReturnMockResetServiceServer() throws Exception {
|
public void bindToShouldReturnMockRestServiceServer() throws Exception {
|
||||||
RestTemplate restTemplate = new RestTemplateBuilder().build();
|
RestTemplate restTemplate = new RestTemplateBuilder().build();
|
||||||
MockRestServiceServer bound = RootUriRequestExpectationManager
|
MockRestServiceServer bound = RootUriRequestExpectationManager
|
||||||
.bindTo(restTemplate);
|
.bindTo(restTemplate);
|
||||||
|
|
@ -142,7 +142,7 @@ public class RootUriRequestExpectationManagerTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void bindToWithExpectationManagerShouldReturnMockResetServiceServer()
|
public void bindToWithExpectationManagerShouldReturnMockRestServiceServer()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
RestTemplate restTemplate = new RestTemplateBuilder().build();
|
RestTemplate restTemplate = new RestTemplateBuilder().build();
|
||||||
MockRestServiceServer bound = RootUriRequestExpectationManager
|
MockRestServiceServer bound = RootUriRequestExpectationManager
|
||||||
|
|
@ -161,7 +161,7 @@ public class RootUriRequestExpectationManagerTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void forRestTemplateWhenNotUsingRootUriTemplateHandlerShouldReturnOriginalUriRequestExpectationManager()
|
public void forRestTemplateWhenNotUsingRootUriTemplateHandlerShouldReturnOriginalRequestExpectationManager()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
RestTemplate restTemplate = new RestTemplateBuilder().build();
|
RestTemplate restTemplate = new RestTemplateBuilder().build();
|
||||||
RequestExpectationManager actual = RootUriRequestExpectationManager
|
RequestExpectationManager actual = RootUriRequestExpectationManager
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue