Upgrade to Spring Data Hopper M1

Closes gh-5120
This commit is contained in:
Stephane Nicoll
2016-02-15 14:22:40 +01:00
parent 1c365662b0
commit b205e02e33
9 changed files with 63 additions and 65 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,7 +23,7 @@ import javax.jms.ConnectionFactory;
import javax.sql.DataSource;
import com.datastax.driver.core.Cluster;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrClient;
import org.elasticsearch.client.Client;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
@@ -269,18 +269,18 @@ public class HealthIndicatorAutoConfiguration {
}
@Configuration
@ConditionalOnBean(SolrServer.class)
@ConditionalOnBean(SolrClient.class)
@ConditionalOnEnabledHealthIndicator("solr")
public static class SolrHealthIndicatorConfiguration extends
CompositeHealthIndicatorConfiguration<SolrHealthIndicator, SolrServer> {
CompositeHealthIndicatorConfiguration<SolrHealthIndicator, SolrClient> {
@Autowired
private Map<String, SolrServer> solrServers;
private Map<String, SolrClient> solrClients;
@Bean
@ConditionalOnMissingBean(name = "solrHealthIndicator")
public HealthIndicator solrHealthIndicator() {
return createHealthIndicator(this.solrServers);
return createHealthIndicator(this.solrClients);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
package org.springframework.boot.actuate.health;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrClient;
/**
* {@link HealthIndicator} for Apache Solr.
@@ -26,15 +26,15 @@ import org.apache.solr.client.solrj.SolrServer;
*/
public class SolrHealthIndicator extends AbstractHealthIndicator {
private final SolrServer solrServer;
private final SolrClient solrClient;
public SolrHealthIndicator(SolrServer solrServer) {
this.solrServer = solrServer;
public SolrHealthIndicator(SolrClient solrClient) {
this.solrClient = solrClient;
}
@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
Object status = this.solrServer.ping().getResponse().get("status");
Object status = this.solrClient.ping().getResponse().get("status");
builder.up().withDetail("solrStatus", status);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@ package org.springframework.boot.actuate.health;
import java.io.IOException;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.response.SolrPingResponse;
import org.apache.solr.common.util.NamedList;
import org.junit.After;
@@ -55,7 +55,7 @@ public class SolrHealthIndicatorTests {
this.context = new AnnotationConfigApplicationContext(
PropertyPlaceholderAutoConfiguration.class, SolrAutoConfiguration.class,
EndpointAutoConfiguration.class, HealthIndicatorAutoConfiguration.class);
assertThat(this.context.getBeanNamesForType(SolrServer.class).length)
assertThat(this.context.getBeanNamesForType(SolrClient.class).length)
.isEqualTo(1);
SolrHealthIndicator healthIndicator = this.context
.getBean(SolrHealthIndicator.class);
@@ -64,13 +64,13 @@ public class SolrHealthIndicatorTests {
@Test
public void solrIsUp() throws Exception {
SolrServer solrServer = mock(SolrServer.class);
SolrClient solrClient = mock(SolrClient.class);
SolrPingResponse pingResponse = new SolrPingResponse();
NamedList<Object> response = new NamedList<Object>();
response.add("status", "OK");
pingResponse.setResponse(response);
given(solrServer.ping()).willReturn(pingResponse);
SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrServer);
given(solrClient.ping()).willReturn(pingResponse);
SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient);
Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails().get("solrStatus")).isEqualTo("OK");
@@ -78,9 +78,9 @@ public class SolrHealthIndicatorTests {
@Test
public void solrIsDown() throws Exception {
SolrServer solrServer = mock(SolrServer.class);
given(solrServer.ping()).willThrow(new IOException("Connection failed"));
SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrServer);
SolrClient solrClient = mock(SolrClient.class);
given(solrClient.ping()).willThrow(new IOException("Connection failed"));
SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient);
Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
assertThat(((String) health.getDetails().get("error"))