Search in sources :

Example 1 with EndpointMvcAdapter

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

the class RequestMappingEndpointTests method beanMethodMappings.

@Test
public void beanMethodMappings() {
    StaticApplicationContext context = new StaticApplicationContext();
    EndpointHandlerMapping mapping = new EndpointHandlerMapping(Arrays.asList(new EndpointMvcAdapter(new DumpEndpoint())));
    mapping.setApplicationContext(new StaticApplicationContext());
    mapping.afterPropertiesSet();
    context.getDefaultListableBeanFactory().registerSingleton("mapping", mapping);
    this.endpoint.setApplicationContext(context);
    Map<String, Object> result = this.endpoint.invoke();
    assertThat(result).hasSize(1);
    assertThat(result.keySet().iterator().next().contains("/dump")).isTrue();
    @SuppressWarnings("unchecked") Map<String, Object> handler = (Map<String, Object>) result.values().iterator().next();
    assertThat(handler.containsKey("method")).isTrue();
}
Also used : StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) EndpointMvcAdapter(org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter) EndpointHandlerMapping(org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping) Map(java.util.Map) Test(org.junit.Test)

Example 2 with EndpointMvcAdapter

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

the class RequestMappingEndpointTests method concreteMethodMappings.

@Test
public void concreteMethodMappings() {
    EndpointHandlerMapping mapping = new EndpointHandlerMapping(Arrays.asList(new EndpointMvcAdapter(new DumpEndpoint())));
    mapping.setApplicationContext(new StaticApplicationContext());
    mapping.afterPropertiesSet();
    this.endpoint.setMethodMappings(Collections.<AbstractHandlerMethodMapping<?>>singletonList(mapping));
    Map<String, Object> result = this.endpoint.invoke();
    assertThat(result).hasSize(1);
    assertThat(result.keySet().iterator().next().contains("/dump")).isTrue();
    @SuppressWarnings("unchecked") Map<String, Object> handler = (Map<String, Object>) result.values().iterator().next();
    assertThat(handler.containsKey("method")).isTrue();
}
Also used : StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) EndpointMvcAdapter(org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter) EndpointHandlerMapping(org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping) Map(java.util.Map) Test(org.junit.Test)

Aggregations

Map (java.util.Map)2 Test (org.junit.Test)2 EndpointHandlerMapping (org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping)2 EndpointMvcAdapter (org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter)2 StaticApplicationContext (org.springframework.context.support.StaticApplicationContext)2