Search in sources :

Example 1 with OrderedHealthAggregator

use of org.springframework.boot.actuate.health.OrderedHealthAggregator 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);
}
Also used : HealthEndpoint(org.springframework.boot.actuate.endpoint.HealthEndpoint) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) HandlerExecutionChain(org.springframework.web.servlet.HandlerExecutionChain) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) OrderedHealthAggregator(org.springframework.boot.actuate.health.OrderedHealthAggregator) HandlerMethod(org.springframework.web.method.HandlerMethod) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 HealthEndpoint (org.springframework.boot.actuate.endpoint.HealthEndpoint)1 OrderedHealthAggregator (org.springframework.boot.actuate.health.OrderedHealthAggregator)1 StaticApplicationContext (org.springframework.context.support.StaticApplicationContext)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1 HandlerMethod (org.springframework.web.method.HandlerMethod)1 HandlerExecutionChain (org.springframework.web.servlet.HandlerExecutionChain)1