use of org.springframework.boot.actuate.endpoint.HealthEndpoint in project spring-boot by spring-projects.
the class CloudFoundryEndpointHandlerMappingTests method registersCloudFoundryHealthEndpoint.
@Test
public void registersCloudFoundryHealthEndpoint() throws Exception {
StaticApplicationContext context = new StaticApplicationContext();
HealthEndpoint delegate = new HealthEndpoint(new OrderedHealthAggregator(), Collections.<String, HealthIndicator>emptyMap());
CloudFoundryEndpointHandlerMapping handlerMapping = new CloudFoundryEndpointHandlerMapping(Collections.singleton(new TestHealthMvcEndpoint(delegate)), null, null);
handlerMapping.setPrefix("/test");
handlerMapping.setApplicationContext(context);
handlerMapping.afterPropertiesSet();
HandlerExecutionChain handler = handlerMapping.getHandler(new MockHttpServletRequest("GET", "/test/health"));
HandlerMethod handlerMethod = (HandlerMethod) handler.getHandler();
Object handlerMethodBean = handlerMethod.getBean();
assertThat(handlerMethodBean).isInstanceOf(CloudFoundryHealthMvcEndpoint.class);
}
use of org.springframework.boot.actuate.endpoint.HealthEndpoint in project spring-boot by spring-projects.
the class EndpointAutoConfigurationTests method healthEndpointWithDefaultHealthIndicator.
@Test
public void healthEndpointWithDefaultHealthIndicator() {
load(EndpointAutoConfiguration.class, HealthIndicatorAutoConfiguration.class);
HealthEndpoint bean = this.context.getBean(HealthEndpoint.class);
assertThat(bean).isNotNull();
Health result = bean.invoke();
assertThat(result).isNotNull();
}
use of org.springframework.boot.actuate.endpoint.HealthEndpoint in project spring-boot by spring-projects.
the class CloudFoundryHealthMvcEndpointTests method cloudFoundryHealthEndpointShouldAlwaysReturnAllHealthDetails.
@Test
public void cloudFoundryHealthEndpointShouldAlwaysReturnAllHealthDetails() throws Exception {
HealthEndpoint endpoint = mock(HealthEndpoint.class);
given(endpoint.isEnabled()).willReturn(true);
CloudFoundryHealthMvcEndpoint mvc = new CloudFoundryHealthMvcEndpoint(endpoint);
given(endpoint.invoke()).willReturn(new Health.Builder().up().withDetail("foo", "bar").build());
given(endpoint.isSensitive()).willReturn(false);
Object result = mvc.invoke(null, null);
assertThat(result instanceof Health).isTrue();
assertThat(((Health) result).getStatus() == Status.UP).isTrue();
assertThat(((Health) result).getDetails().get("foo")).isEqualTo("bar");
}
use of org.springframework.boot.actuate.endpoint.HealthEndpoint in project spring-boot by spring-projects.
the class EndpointAutoConfigurationTests method healthEndpoint.
@Test
public void healthEndpoint() {
load(EmbeddedDataSourceConfiguration.class, EndpointAutoConfiguration.class, HealthIndicatorAutoConfiguration.class);
HealthEndpoint bean = this.context.getBean(HealthEndpoint.class);
assertThat(bean).isNotNull();
Health result = bean.invoke();
assertThat(result).isNotNull();
assertThat(result.getDetails().containsKey("db")).isTrue();
}
Aggregations