Rename VanillaHealthIndicator to Application...

Rename `VanillaHealthIndicator` to `ApplicationHealthIndicator` and
changed the exposed bean name from `statusHealthIndicator` to
`applicationHealthIndicator`.

This provides less confusing JSON output:

  {"status":"UP","application":{"status":"UP"}}

vs:

  {"status":"UP","status":{"status":"UP"}}

Fixes gh-1291
pull/1324/merge
Phillip Webb 10 years ago
parent d089685935
commit 7d0a3ddcce

@ -34,7 +34,7 @@ import org.springframework.boot.actuate.health.OrderedHealthAggregator;
import org.springframework.boot.actuate.health.RabbitHealthIndicator; import org.springframework.boot.actuate.health.RabbitHealthIndicator;
import org.springframework.boot.actuate.health.RedisHealthIndicator; import org.springframework.boot.actuate.health.RedisHealthIndicator;
import org.springframework.boot.actuate.health.SolrHealthIndicator; import org.springframework.boot.actuate.health.SolrHealthIndicator;
import org.springframework.boot.actuate.health.VanillaHealthIndicator; import org.springframework.boot.actuate.health.ApplicationHealthIndicator;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@ -81,8 +81,8 @@ public class HealthIndicatorAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean(HealthIndicator.class) @ConditionalOnMissingBean(HealthIndicator.class)
public HealthIndicator statusHealthIndicator() { public HealthIndicator applicationHealthIndicator() {
return new VanillaHealthIndicator(); return new ApplicationHealthIndicator();
} }
@Configuration @Configuration

@ -23,7 +23,7 @@ package org.springframework.boot.actuate.health;
* @author Christian Dupuis * @author Christian Dupuis
* @see Status#UP * @see Status#UP
*/ */
public class VanillaHealthIndicator extends AbstractHealthIndicator { public class ApplicationHealthIndicator extends AbstractHealthIndicator {
@Override @Override
protected void doHealthCheck(Health.Builder builder) throws Exception { protected void doHealthCheck(Health.Builder builder) throws Exception {

@ -20,7 +20,7 @@ package org.springframework.boot.actuate.health;
* Strategy interface used to provide an indication of application health. * Strategy interface used to provide an indication of application health.
* *
* @author Dave Syer * @author Dave Syer
* @see VanillaHealthIndicator * @see ApplicationHealthIndicator
*/ */
public interface HealthIndicator { public interface HealthIndicator {

@ -27,7 +27,7 @@ import org.springframework.boot.actuate.health.MongoHealthIndicator;
import org.springframework.boot.actuate.health.RabbitHealthIndicator; import org.springframework.boot.actuate.health.RabbitHealthIndicator;
import org.springframework.boot.actuate.health.RedisHealthIndicator; import org.springframework.boot.actuate.health.RedisHealthIndicator;
import org.springframework.boot.actuate.health.SolrHealthIndicator; import org.springframework.boot.actuate.health.SolrHealthIndicator;
import org.springframework.boot.actuate.health.VanillaHealthIndicator; import org.springframework.boot.actuate.health.ApplicationHealthIndicator;
import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration; import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
@ -70,7 +70,7 @@ public class HealthIndicatorAutoConfigurationTests {
Map<String, HealthIndicator> beans = this.context Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class); .getBeansOfType(HealthIndicator.class);
assertEquals(1, beans.size()); assertEquals(1, beans.size());
assertEquals(VanillaHealthIndicator.class, beans.values().iterator().next() assertEquals(ApplicationHealthIndicator.class, beans.values().iterator().next()
.getClass()); .getClass());
} }
@ -97,7 +97,7 @@ public class HealthIndicatorAutoConfigurationTests {
Map<String, HealthIndicator> beans = this.context Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class); .getBeansOfType(HealthIndicator.class);
assertEquals(1, beans.size()); assertEquals(1, beans.size());
assertEquals(VanillaHealthIndicator.class, beans.values().iterator().next() assertEquals(ApplicationHealthIndicator.class, beans.values().iterator().next()
.getClass()); .getClass());
} }
@ -124,7 +124,7 @@ public class HealthIndicatorAutoConfigurationTests {
Map<String, HealthIndicator> beans = this.context Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class); .getBeansOfType(HealthIndicator.class);
assertEquals(1, beans.size()); assertEquals(1, beans.size());
assertEquals(VanillaHealthIndicator.class, beans.values().iterator().next() assertEquals(ApplicationHealthIndicator.class, beans.values().iterator().next()
.getClass()); .getClass());
} }
@ -163,7 +163,7 @@ public class HealthIndicatorAutoConfigurationTests {
Map<String, HealthIndicator> beans = this.context Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class); .getBeansOfType(HealthIndicator.class);
assertEquals(1, beans.size()); assertEquals(1, beans.size());
assertEquals(VanillaHealthIndicator.class, beans.values().iterator().next() assertEquals(ApplicationHealthIndicator.class, beans.values().iterator().next()
.getClass()); .getClass());
} }
@ -190,7 +190,7 @@ public class HealthIndicatorAutoConfigurationTests {
Map<String, HealthIndicator> beans = this.context Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class); .getBeansOfType(HealthIndicator.class);
assertEquals(1, beans.size()); assertEquals(1, beans.size());
assertEquals(VanillaHealthIndicator.class, beans.values().iterator().next() assertEquals(ApplicationHealthIndicator.class, beans.values().iterator().next()
.getClass()); .getClass());
} }
@ -217,7 +217,7 @@ public class HealthIndicatorAutoConfigurationTests {
Map<String, HealthIndicator> beans = this.context Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class); .getBeansOfType(HealthIndicator.class);
assertEquals(1, beans.size()); assertEquals(1, beans.size());
assertEquals(VanillaHealthIndicator.class, beans.values().iterator().next() assertEquals(ApplicationHealthIndicator.class, beans.values().iterator().next()
.getClass()); .getClass());
} }
} }

@ -21,15 +21,15 @@ import org.junit.Test;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
/** /**
* Tests for {@link VanillaHealthIndicator}. * Tests for {@link ApplicationHealthIndicator}.
* *
* @author Phillip Webb * @author Phillip Webb
*/ */
public class VanillaHealthIndicatorTests { public class ApplicationHealthIndicatorTests {
@Test @Test
public void indicatesUp() throws Exception { public void indicatesUp() throws Exception {
VanillaHealthIndicator healthIndicator = new VanillaHealthIndicator(); ApplicationHealthIndicator healthIndicator = new ApplicationHealthIndicator();
assertEquals(Status.UP, healthIndicator.health().getStatus()); assertEquals(Status.UP, healthIndicator.health().getStatus());
} }

@ -75,7 +75,8 @@ public class SampleActuatorUiApplicationPortTests {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity( ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.managementPort + "/health", String.class); "http://localhost:" + this.managementPort + "/health", String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode()); assertEquals(HttpStatus.OK, entity.getStatusCode());
assertEquals("{\"status\":\"UP\"}", entity.getBody()); assertEquals("{\"status\":\"UP\",\"application\":{\"status\":\"UP\"}}",
entity.getBody());
} }
} }

Loading…
Cancel
Save