Search in sources :

Example 1 with HealthMvcEndpoint

use of org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint in project spring-boot by spring-projects.

the class HealthMvcEndpointAutoConfigurationTests method testSetRoles.

@Test
public void testSetRoles() throws Exception {
    // gh-8314
    this.context = new AnnotationConfigWebApplicationContext();
    this.context.setServletContext(new MockServletContext());
    this.context.register(TestConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context, "management.security.roles[0]=super");
    this.context.refresh();
    HealthMvcEndpoint health = this.context.getBean(HealthMvcEndpoint.class);
    assertThat(ReflectionTestUtils.getField(health, "roles")).isEqualTo(Arrays.asList("super"));
}
Also used : AnnotationConfigWebApplicationContext(org.springframework.web.context.support.AnnotationConfigWebApplicationContext) MockServletContext(org.springframework.mock.web.MockServletContext) HealthMvcEndpoint(org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint) Test(org.junit.Test)

Example 2 with HealthMvcEndpoint

use of org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint in project spring-boot by spring-projects.

the class CloudFoundryEndpointHandlerMapping method postProcessEndpoints.

@Override
protected void postProcessEndpoints(Set<NamedMvcEndpoint> endpoints) {
    super.postProcessEndpoints(endpoints);
    Iterator<NamedMvcEndpoint> iterator = endpoints.iterator();
    HealthMvcEndpoint healthMvcEndpoint = null;
    while (iterator.hasNext()) {
        NamedMvcEndpoint endpoint = iterator.next();
        if (endpoint instanceof HalJsonMvcEndpoint) {
            iterator.remove();
        } else if (endpoint instanceof HealthMvcEndpoint) {
            iterator.remove();
            healthMvcEndpoint = (HealthMvcEndpoint) endpoint;
        }
    }
    if (healthMvcEndpoint != null) {
        endpoints.add(new CloudFoundryHealthMvcEndpoint(healthMvcEndpoint.getDelegate()));
    }
}
Also used : NamedMvcEndpoint(org.springframework.boot.actuate.endpoint.mvc.NamedMvcEndpoint) HalJsonMvcEndpoint(org.springframework.boot.actuate.endpoint.mvc.HalJsonMvcEndpoint) HealthMvcEndpoint(org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint)

Aggregations

HealthMvcEndpoint (org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint)2 Test (org.junit.Test)1 HalJsonMvcEndpoint (org.springframework.boot.actuate.endpoint.mvc.HalJsonMvcEndpoint)1 NamedMvcEndpoint (org.springframework.boot.actuate.endpoint.mvc.NamedMvcEndpoint)1 MockServletContext (org.springframework.mock.web.MockServletContext)1 AnnotationConfigWebApplicationContext (org.springframework.web.context.support.AnnotationConfigWebApplicationContext)1