Commit bf8a8167 authored by Stephane Nicoll's avatar Stephane Nicoll

Merge pull request #6374 from izeye:polish-20160712

* pr/6374:
  Polish
parents 43afc149 a9f6ae44
...@@ -28,8 +28,8 @@ import org.springframework.core.ResolvableType; ...@@ -28,8 +28,8 @@ import org.springframework.core.ResolvableType;
* Base class for configurations that can combine source beans using a * Base class for configurations that can combine source beans using a
* {@link CompositeHealthIndicator}. * {@link CompositeHealthIndicator}.
* *
* @param <H> The health indicator type * @param <H> the health indicator type
* @param <S> T he bean source type * @param <S> the bean source type
* @author Stephane Nicoll * @author Stephane Nicoll
* @since 1.4.0 * @since 1.4.0
*/ */
......
...@@ -43,14 +43,14 @@ class ElasticsearchHealthIndicatorConfiguration { ...@@ -43,14 +43,14 @@ class ElasticsearchHealthIndicatorConfiguration {
@ConditionalOnBean(Client.class) @ConditionalOnBean(Client.class)
@ConditionalOnEnabledHealthIndicator("elasticsearch") @ConditionalOnEnabledHealthIndicator("elasticsearch")
@EnableConfigurationProperties(ElasticsearchHealthIndicatorProperties.class) @EnableConfigurationProperties(ElasticsearchHealthIndicatorProperties.class)
static class ElasticsearchSpringDataHealthIndicatorConfiguration extends static class ElasticsearchClientHealthIndicatorConfiguration extends
CompositeHealthIndicatorConfiguration<ElasticsearchHealthIndicator, Client> { CompositeHealthIndicatorConfiguration<ElasticsearchHealthIndicator, Client> {
private final Map<String, Client> clients; private final Map<String, Client> clients;
private final ElasticsearchHealthIndicatorProperties properties; private final ElasticsearchHealthIndicatorProperties properties;
ElasticsearchSpringDataHealthIndicatorConfiguration(Map<String, Client> clients, ElasticsearchClientHealthIndicatorConfiguration(Map<String, Client> clients,
ElasticsearchHealthIndicatorProperties properties) { ElasticsearchHealthIndicatorProperties properties) {
this.clients = clients; this.clients = clients;
this.properties = properties; this.properties = properties;
......
...@@ -98,7 +98,7 @@ import org.springframework.mail.javamail.JavaMailSenderImpl; ...@@ -98,7 +98,7 @@ import org.springframework.mail.javamail.JavaMailSenderImpl;
MongoDataAutoConfiguration.class, RabbitAutoConfiguration.class, MongoDataAutoConfiguration.class, RabbitAutoConfiguration.class,
RedisAutoConfiguration.class, SolrAutoConfiguration.class }) RedisAutoConfiguration.class, SolrAutoConfiguration.class })
@EnableConfigurationProperties({ HealthIndicatorProperties.class }) @EnableConfigurationProperties({ HealthIndicatorProperties.class })
@Import({ ElasticsearchHealthIndicatorConfiguration.ElasticsearchSpringDataHealthIndicatorConfiguration.class, @Import({ ElasticsearchHealthIndicatorConfiguration.ElasticsearchClientHealthIndicatorConfiguration.class,
ElasticsearchHealthIndicatorConfiguration.ElasticsearchJestHealthIndicatorConfiguration.class }) ElasticsearchHealthIndicatorConfiguration.ElasticsearchJestHealthIndicatorConfiguration.class })
public class HealthIndicatorAutoConfiguration { public class HealthIndicatorAutoConfiguration {
......
...@@ -37,7 +37,7 @@ public class ElasticsearchHealthIndicatorProperties { ...@@ -37,7 +37,7 @@ public class ElasticsearchHealthIndicatorProperties {
private List<String> indices = new ArrayList<String>(); private List<String> indices = new ArrayList<String>();
/** /**
* The time, in milliseconds, to wait for a response from the cluster. * Time, in milliseconds, to wait for a response from the cluster.
*/ */
private long responseTimeout = 100L; private long responseTimeout = 100L;
......
...@@ -33,6 +33,8 @@ public class ElasticsearchJestHealthIndicator extends AbstractHealthIndicator { ...@@ -33,6 +33,8 @@ public class ElasticsearchJestHealthIndicator extends AbstractHealthIndicator {
private final JestClient jestClient; private final JestClient jestClient;
private final JsonParser jsonParser = new JsonParser();
public ElasticsearchJestHealthIndicator(JestClient jestClient) { public ElasticsearchJestHealthIndicator(JestClient jestClient) {
this.jestClient = jestClient; this.jestClient = jestClient;
} }
...@@ -40,8 +42,7 @@ public class ElasticsearchJestHealthIndicator extends AbstractHealthIndicator { ...@@ -40,8 +42,7 @@ public class ElasticsearchJestHealthIndicator extends AbstractHealthIndicator {
@Override @Override
protected void doHealthCheck(Health.Builder builder) throws Exception { protected void doHealthCheck(Health.Builder builder) throws Exception {
JestResult aliases = this.jestClient.execute(new Stats.Builder().build()); JestResult aliases = this.jestClient.execute(new Stats.Builder().build());
JsonParser jsonParser = new JsonParser(); JsonElement root = this.jsonParser.parse(aliases.getJsonString());
JsonElement root = jsonParser.parse(aliases.getJsonString());
JsonObject shards = root.getAsJsonObject().get("_shards").getAsJsonObject(); JsonObject shards = root.getAsJsonObject().get("_shards").getAsJsonObject();
int failedShards = shards.get("failed").getAsInt(); int failedShards = shards.get("failed").getAsInt();
if (failedShards != 0) { if (failedShards != 0) {
......
...@@ -394,7 +394,7 @@ public class HealthIndicatorAutoConfigurationTests { ...@@ -394,7 +394,7 @@ public class HealthIndicatorAutoConfigurationTests {
} }
@Test @Test
public void elasticSearchHealthIndicator() { public void elasticsearchHealthIndicator() {
EnvironmentTestUtils.addEnvironment(this.context, EnvironmentTestUtils.addEnvironment(this.context,
"spring.data.elasticsearch.properties.path.home:target", "spring.data.elasticsearch.properties.path.home:target",
"management.health.diskspace.enabled:false"); "management.health.diskspace.enabled:false");
...@@ -411,7 +411,7 @@ public class HealthIndicatorAutoConfigurationTests { ...@@ -411,7 +411,7 @@ public class HealthIndicatorAutoConfigurationTests {
} }
@Test @Test
public void elasticSearchJestHealthIndicator() { public void elasticsearchJestHealthIndicator() {
EnvironmentTestUtils.addEnvironment(this.context, EnvironmentTestUtils.addEnvironment(this.context,
"management.health.diskspace.enabled:false"); "management.health.diskspace.enabled:false");
this.context.register(JestClientConfiguration.class, this.context.register(JestClientConfiguration.class,
......
...@@ -46,7 +46,7 @@ public class ElasticsearchJestHealthIndicatorTests { ...@@ -46,7 +46,7 @@ public class ElasticsearchJestHealthIndicatorTests {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
public void elasticSearchIsUp() throws IOException { public void elasticsearchIsUp() throws IOException {
given(this.jestClient.execute(any(Action.class))) given(this.jestClient.execute(any(Action.class)))
.willReturn(createJestResult(4, 0)); .willReturn(createJestResult(4, 0));
...@@ -56,7 +56,7 @@ public class ElasticsearchJestHealthIndicatorTests { ...@@ -56,7 +56,7 @@ public class ElasticsearchJestHealthIndicatorTests {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
public void elasticSearchIsDown() throws IOException { public void elasticsearchIsDown() throws IOException {
given(this.jestClient.execute(any(Action.class))).willThrow( given(this.jestClient.execute(any(Action.class))).willThrow(
new CouldNotConnectException("http://localhost:9200", new IOException())); new CouldNotConnectException("http://localhost:9200", new IOException()));
Health health = this.healthIndicator.health(); Health health = this.healthIndicator.health();
...@@ -65,7 +65,7 @@ public class ElasticsearchJestHealthIndicatorTests { ...@@ -65,7 +65,7 @@ public class ElasticsearchJestHealthIndicatorTests {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
public void elasticSearchIsOutOfService() throws IOException { public void elasticsearchIsOutOfService() throws IOException {
given(this.jestClient.execute(any(Action.class))) given(this.jestClient.execute(any(Action.class)))
.willReturn(createJestResult(4, 1)); .willReturn(createJestResult(4, 1));
Health health = this.healthIndicator.health(); Health health = this.healthIndicator.health();
......
...@@ -18,9 +18,7 @@ package org.springframework.boot.autoconfigure.data.neo4j; ...@@ -18,9 +18,7 @@ package org.springframework.boot.autoconfigure.data.neo4j;
import org.assertj.core.api.Assertions; import org.assertj.core.api.Assertions;
import org.junit.After; import org.junit.After;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.neo4j.ogm.drivers.http.driver.HttpDriver; import org.neo4j.ogm.drivers.http.driver.HttpDriver;
import org.neo4j.ogm.session.Session; import org.neo4j.ogm.session.Session;
import org.neo4j.ogm.session.SessionFactory; import org.neo4j.ogm.session.SessionFactory;
...@@ -48,9 +46,6 @@ import static org.mockito.Mockito.mock; ...@@ -48,9 +46,6 @@ import static org.mockito.Mockito.mock;
*/ */
public class Neo4jDataAutoConfigurationTests { public class Neo4jDataAutoConfigurationTests {
@Rule
public final ExpectedException thrown = ExpectedException.none();
private AnnotationConfigApplicationContext context; private AnnotationConfigApplicationContext context;
@After @After
......
...@@ -86,7 +86,6 @@ public class Neo4jRepositoriesAutoConfigurationTests { ...@@ -86,7 +86,6 @@ public class Neo4jRepositoriesAutoConfigurationTests {
"spring.data.neo4j.uri=http://localhost:9797"); "spring.data.neo4j.uri=http://localhost:9797");
this.context.register(configurationClasses); this.context.register(configurationClasses);
this.context.register(Neo4jDataAutoConfiguration.class, this.context.register(Neo4jDataAutoConfiguration.class,
Neo4jDataAutoConfiguration.class,
Neo4jRepositoriesAutoConfiguration.class, Neo4jRepositoriesAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class);
this.context.refresh(); this.context.refresh();
......
...@@ -78,7 +78,7 @@ class SpringBootTestContextCustomizer implements ContextCustomizer { ...@@ -78,7 +78,7 @@ class SpringBootTestContextCustomizer implements ContextCustomizer {
} }
/** /**
* {@link FactoryBean} used to create a configure a {@link TestRestTemplate}. * {@link FactoryBean} used to create and configure a {@link TestRestTemplate}.
*/ */
public static class TestRestTemplateFactory public static class TestRestTemplateFactory
implements FactoryBean<TestRestTemplate>, ApplicationContextAware { implements FactoryBean<TestRestTemplate>, ApplicationContextAware {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment