org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration Java Examples

The following examples show how to use org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HandlerMethodResolverTest.java    From spring-webmvc-support with GNU General Public License v3.0 4 votes vote down vote up
@Before
public void init() {

    handlerMethodResolver = new HandlerMethodResolver();

    servletContext = new MockServletContext();

    request = new MockHttpServletRequest(servletContext);

    webApplicationContext = new AnnotationConfigWebApplicationContext();

    webApplicationContext.setServletContext(servletContext);

    request.setAttribute(WEB_APPLICATION_CONTEXT_ATTRIBUTE, webApplicationContext);

    servletContext.setAttribute(ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, webApplicationContext);

    webApplicationContext.register(TestController.class);
    webApplicationContext.register(DelegatingWebMvcConfiguration.class);
    webApplicationContext.register(TestWebMvcConfigurer.class);

    webApplicationContext.refresh();

    RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request), true);
}
 
Example #2
Source File: WebMvcUtilsTest.java    From spring-webmvc-support with GNU General Public License v3.0 3 votes vote down vote up
@Test
public void testGetRequestMappingHandlerMapping() {

    AnnotationConfigWebApplicationContext webApplicationContext = new AnnotationConfigWebApplicationContext();

    servletContext.setAttribute(ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, webApplicationContext);

    webApplicationContext.setServletContext(servletContext);

    webApplicationContext.register(TestController.class);
    webApplicationContext.register(DelegatingWebMvcConfiguration.class);
    webApplicationContext.register(TestWebMvcConfigurer.class);

    webApplicationContext.refresh();

    request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, webApplicationContext);

    RequestMappingHandlerMapping requestMappingHandlerMapping =
            WebMvcUtils.getRequestMappingHandlerMapping(request, servletContext);

    Assert.assertNotNull(requestMappingHandlerMapping);

    Assert.assertFalse(requestMappingHandlerMapping.getHandlerMethods().isEmpty());

    requestMappingHandlerMapping =
            WebMvcUtils.getRequestMappingHandlerMapping(request);

    Assert.assertNotNull(requestMappingHandlerMapping);

    Assert.assertFalse(requestMappingHandlerMapping.getHandlerMethods().isEmpty());

}