Search in sources :

Example 1 with ContextMappings

use of org.springframework.boot.actuate.web.mappings.MappingsEndpoint.ContextMappings in project spring-boot by spring-projects.

the class MappingsEndpointTests method servletWebMappingsWithPathPatternParser.

@Test
void servletWebMappingsWithPathPatternParser() {
    Supplier<ConfigurableWebApplicationContext> contextSupplier = prepareContextSupplier();
    new WebApplicationContextRunner(contextSupplier).withUserConfiguration(EndpointConfiguration.class, ServletWebConfiguration.class, PathPatternParserConfiguration.class).run((context) -> {
        ContextMappings contextMappings = contextMappings(context);
        assertThat(contextMappings.getParentId()).isNull();
        assertThat(contextMappings.getMappings()).containsOnlyKeys("dispatcherServlets", "servletFilters", "servlets");
        Map<String, List<DispatcherServletMappingDescription>> dispatcherServlets = mappings(contextMappings, "dispatcherServlets");
        assertThat(dispatcherServlets).containsOnlyKeys("dispatcherServlet");
        List<DispatcherServletMappingDescription> handlerMappings = dispatcherServlets.get("dispatcherServlet");
        assertThat(handlerMappings).hasSize(1);
        List<ServletRegistrationMappingDescription> servlets = mappings(contextMappings, "servlets");
        assertThat(servlets).hasSize(1);
        List<FilterRegistrationMappingDescription> filters = mappings(contextMappings, "servletFilters");
        assertThat(filters).hasSize(1);
    });
}
Also used : ConfigurableWebApplicationContext(org.springframework.web.context.ConfigurableWebApplicationContext) ReactiveWebApplicationContextRunner(org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner) WebApplicationContextRunner(org.springframework.boot.test.context.runner.WebApplicationContextRunner) FilterRegistrationMappingDescription(org.springframework.boot.actuate.web.mappings.servlet.FilterRegistrationMappingDescription) DispatcherServletMappingDescription(org.springframework.boot.actuate.web.mappings.servlet.DispatcherServletMappingDescription) ContextMappings(org.springframework.boot.actuate.web.mappings.MappingsEndpoint.ContextMappings) ServletRegistrationMappingDescription(org.springframework.boot.actuate.web.mappings.servlet.ServletRegistrationMappingDescription) List(java.util.List) Test(org.junit.jupiter.api.Test)

Example 2 with ContextMappings

use of org.springframework.boot.actuate.web.mappings.MappingsEndpoint.ContextMappings in project spring-boot by spring-projects.

the class MappingsEndpointTests method reactiveWebMappings.

@Test
void reactiveWebMappings() {
    new ReactiveWebApplicationContextRunner().withUserConfiguration(EndpointConfiguration.class, ReactiveWebConfiguration.class).run((context) -> {
        ContextMappings contextMappings = contextMappings(context);
        assertThat(contextMappings.getParentId()).isNull();
        assertThat(contextMappings.getMappings()).containsOnlyKeys("dispatcherHandlers");
        Map<String, List<DispatcherHandlerMappingDescription>> dispatcherHandlers = mappings(contextMappings, "dispatcherHandlers");
        assertThat(dispatcherHandlers).containsOnlyKeys("webHandler");
        List<DispatcherHandlerMappingDescription> handlerMappings = dispatcherHandlers.get("webHandler");
        assertThat(handlerMappings).hasSize(3);
    });
}
Also used : DispatcherHandlerMappingDescription(org.springframework.boot.actuate.web.mappings.reactive.DispatcherHandlerMappingDescription) ContextMappings(org.springframework.boot.actuate.web.mappings.MappingsEndpoint.ContextMappings) List(java.util.List) ReactiveWebApplicationContextRunner(org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner) Test(org.junit.jupiter.api.Test)

Example 3 with ContextMappings

use of org.springframework.boot.actuate.web.mappings.MappingsEndpoint.ContextMappings in project spring-boot by spring-projects.

the class MappingsEndpointTests method servletWebMappings.

@Test
void servletWebMappings() {
    Supplier<ConfigurableWebApplicationContext> contextSupplier = prepareContextSupplier();
    new WebApplicationContextRunner(contextSupplier).withUserConfiguration(EndpointConfiguration.class, ServletWebConfiguration.class).run((context) -> {
        ContextMappings contextMappings = contextMappings(context);
        assertThat(contextMappings.getParentId()).isNull();
        assertThat(contextMappings.getMappings()).containsOnlyKeys("dispatcherServlets", "servletFilters", "servlets");
        Map<String, List<DispatcherServletMappingDescription>> dispatcherServlets = mappings(contextMappings, "dispatcherServlets");
        assertThat(dispatcherServlets).containsOnlyKeys("dispatcherServlet");
        List<DispatcherServletMappingDescription> handlerMappings = dispatcherServlets.get("dispatcherServlet");
        assertThat(handlerMappings).hasSize(1);
        List<ServletRegistrationMappingDescription> servlets = mappings(contextMappings, "servlets");
        assertThat(servlets).hasSize(1);
        List<FilterRegistrationMappingDescription> filters = mappings(contextMappings, "servletFilters");
        assertThat(filters).hasSize(1);
    });
}
Also used : ConfigurableWebApplicationContext(org.springframework.web.context.ConfigurableWebApplicationContext) ReactiveWebApplicationContextRunner(org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner) WebApplicationContextRunner(org.springframework.boot.test.context.runner.WebApplicationContextRunner) FilterRegistrationMappingDescription(org.springframework.boot.actuate.web.mappings.servlet.FilterRegistrationMappingDescription) DispatcherServletMappingDescription(org.springframework.boot.actuate.web.mappings.servlet.DispatcherServletMappingDescription) ContextMappings(org.springframework.boot.actuate.web.mappings.MappingsEndpoint.ContextMappings) ServletRegistrationMappingDescription(org.springframework.boot.actuate.web.mappings.servlet.ServletRegistrationMappingDescription) List(java.util.List) Test(org.junit.jupiter.api.Test)

Example 4 with ContextMappings

use of org.springframework.boot.actuate.web.mappings.MappingsEndpoint.ContextMappings in project spring-boot by spring-projects.

the class MappingsEndpointTests method servletWebMappingsWithAdditionalDispatcherServlets.

@Test
void servletWebMappingsWithAdditionalDispatcherServlets() {
    Supplier<ConfigurableWebApplicationContext> contextSupplier = prepareContextSupplier();
    new WebApplicationContextRunner(contextSupplier).withUserConfiguration(EndpointConfiguration.class, ServletWebConfiguration.class, CustomDispatcherServletConfiguration.class).run((context) -> {
        ContextMappings contextMappings = contextMappings(context);
        Map<String, List<DispatcherServletMappingDescription>> dispatcherServlets = mappings(contextMappings, "dispatcherServlets");
        assertThat(dispatcherServlets).containsOnlyKeys("dispatcherServlet", "customDispatcherServletRegistration", "anotherDispatcherServletRegistration");
        assertThat(dispatcherServlets.get("dispatcherServlet")).hasSize(1);
        assertThat(dispatcherServlets.get("customDispatcherServletRegistration")).hasSize(1);
        assertThat(dispatcherServlets.get("anotherDispatcherServletRegistration")).hasSize(1);
    });
}
Also used : ConfigurableWebApplicationContext(org.springframework.web.context.ConfigurableWebApplicationContext) ReactiveWebApplicationContextRunner(org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner) WebApplicationContextRunner(org.springframework.boot.test.context.runner.WebApplicationContextRunner) ContextMappings(org.springframework.boot.actuate.web.mappings.MappingsEndpoint.ContextMappings) List(java.util.List) Test(org.junit.jupiter.api.Test)

Aggregations

List (java.util.List)4 Test (org.junit.jupiter.api.Test)4 ContextMappings (org.springframework.boot.actuate.web.mappings.MappingsEndpoint.ContextMappings)4 ReactiveWebApplicationContextRunner (org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner)4 WebApplicationContextRunner (org.springframework.boot.test.context.runner.WebApplicationContextRunner)3 ConfigurableWebApplicationContext (org.springframework.web.context.ConfigurableWebApplicationContext)3 DispatcherServletMappingDescription (org.springframework.boot.actuate.web.mappings.servlet.DispatcherServletMappingDescription)2 FilterRegistrationMappingDescription (org.springframework.boot.actuate.web.mappings.servlet.FilterRegistrationMappingDescription)2 ServletRegistrationMappingDescription (org.springframework.boot.actuate.web.mappings.servlet.ServletRegistrationMappingDescription)2 DispatcherHandlerMappingDescription (org.springframework.boot.actuate.web.mappings.reactive.DispatcherHandlerMappingDescription)1