Search in sources :

Example 16 with AbstractHandlerMapping

use of org.springframework.web.servlet.handler.AbstractHandlerMapping in project spring-framework by spring-projects.

the class DelegatingWebMvcConfigurationIntegrationTests method viewControllerHandlerMappingUsesMvcInfrastructureByDefault.

@Test
void viewControllerHandlerMappingUsesMvcInfrastructureByDefault() {
    load(context -> context.registerBean(ViewControllerConfiguration.class));
    AbstractHandlerMapping handlerMapping = this.context.getBean("viewControllerHandlerMapping", AbstractHandlerMapping.class);
    assertThat(handlerMapping.getPathMatcher()).isSameAs(this.context.getBean("mvcPathMatcher"));
    assertThat(handlerMapping.getUrlPathHelper()).isSameAs(this.context.getBean("mvcUrlPathHelper"));
}
Also used : AbstractHandlerMapping(org.springframework.web.servlet.handler.AbstractHandlerMapping) Test(org.junit.jupiter.api.Test)

Example 17 with AbstractHandlerMapping

use of org.springframework.web.servlet.handler.AbstractHandlerMapping in project spring-framework by spring-projects.

the class DelegatingWebMvcConfigurationIntegrationTests method resourceHandlerMappingWithPrimaryUsesQualifiedPathMatcher.

@Test
void resourceHandlerMappingWithPrimaryUsesQualifiedPathMatcher() {
    load(registerPrimaryBean("testPathMatcher", PathMatcher.class).andThen(context -> context.registerBean(ResourceHandlerConfiguration.class)));
    AbstractHandlerMapping handlerMapping = this.context.getBean("resourceHandlerMapping", AbstractHandlerMapping.class);
    assertThat(handlerMapping.getPathMatcher()).isSameAs(this.context.getBean("mvcPathMatcher"));
    assertThat(this.context.getBeansOfType(PathMatcher.class)).containsOnlyKeys("mvcPathMatcher", "testPathMatcher");
}
Also used : Validator(org.springframework.validation.Validator) PathMatcher(org.springframework.util.PathMatcher) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) AnnotationConfigUtils(org.springframework.context.annotation.AnnotationConfigUtils) AbstractHandlerMapping(org.springframework.web.servlet.handler.AbstractHandlerMapping) Consumer(java.util.function.Consumer) Test(org.junit.jupiter.api.Test) Configuration(org.springframework.context.annotation.Configuration) AfterEach(org.junit.jupiter.api.AfterEach) ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) UrlPathHelper(org.springframework.web.util.UrlPathHelper) GenericWebApplicationContext(org.springframework.web.context.support.GenericWebApplicationContext) ContentNegotiationManager(org.springframework.web.accept.ContentNegotiationManager) RequestMappingHandlerMapping(org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping) ConversionService(org.springframework.core.convert.ConversionService) RequestMappingHandlerAdapter(org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter) MockServletContext(org.springframework.web.testfixture.servlet.MockServletContext) Mockito.mock(org.mockito.Mockito.mock) AbstractHandlerMapping(org.springframework.web.servlet.handler.AbstractHandlerMapping) Test(org.junit.jupiter.api.Test)

Aggregations

AbstractHandlerMapping (org.springframework.web.servlet.handler.AbstractHandlerMapping)17 Test (org.junit.jupiter.api.Test)9 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)5 Mockito.mock (org.mockito.Mockito.mock)5 Bean (org.springframework.context.annotation.Bean)5 Consumer (java.util.function.Consumer)4 AfterEach (org.junit.jupiter.api.AfterEach)4 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)4 AnnotationConfigUtils (org.springframework.context.annotation.AnnotationConfigUtils)4 Configuration (org.springframework.context.annotation.Configuration)4 ConversionService (org.springframework.core.convert.ConversionService)4 PathMatcher (org.springframework.util.PathMatcher)4 Validator (org.springframework.validation.Validator)4 ContentNegotiationManager (org.springframework.web.accept.ContentNegotiationManager)4 GenericWebApplicationContext (org.springframework.web.context.support.GenericWebApplicationContext)4 RequestMappingHandlerAdapter (org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter)4 RequestMappingHandlerMapping (org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping)4 MockServletContext (org.springframework.web.testfixture.servlet.MockServletContext)4 UrlPathHelper (org.springframework.web.util.UrlPathHelper)4 Test (org.junit.Test)3