org.springframework.web.servlet.handler.UserRoleAuthorizationInterceptor Java Examples
The following examples show how to use
org.springframework.web.servlet.handler.UserRoleAuthorizationInterceptor.
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: MvcNamespaceTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testInterceptors() throws Exception { loadBeanDefinitions("mvc-config-interceptors.xml"); RequestMappingHandlerMapping mapping = appContext.getBean(RequestMappingHandlerMapping.class); assertNotNull(mapping); mapping.setDefaultHandler(handlerMethod); MockHttpServletRequest request = new MockHttpServletRequest("GET", "/"); request.setRequestURI("/accounts/12345"); request.addParameter("locale", "en"); request.addParameter("theme", "green"); HandlerExecutionChain chain = mapping.getHandler(request); assertEquals(4, chain.getInterceptors().length); assertTrue(chain.getInterceptors()[0] instanceof ConversionServiceExposingInterceptor); assertTrue(chain.getInterceptors()[1] instanceof LocaleChangeInterceptor); assertTrue(chain.getInterceptors()[2] instanceof ThemeChangeInterceptor); assertTrue(chain.getInterceptors()[3] instanceof UserRoleAuthorizationInterceptor); request.setRequestURI("/admin/users"); chain = mapping.getHandler(request); assertEquals(2, chain.getInterceptors().length); request.setRequestURI("/logged/accounts/12345"); chain = mapping.getHandler(request); assertEquals(3, chain.getInterceptors().length); request.setRequestURI("/foo/logged"); chain = mapping.getHandler(request); assertEquals(3, chain.getInterceptors().length); }
Example #2
Source File: MvcNamespaceTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testInterceptors() throws Exception { loadBeanDefinitions("mvc-config-interceptors.xml"); RequestMappingHandlerMapping mapping = appContext.getBean(RequestMappingHandlerMapping.class); assertNotNull(mapping); mapping.setDefaultHandler(handlerMethod); MockHttpServletRequest request = new MockHttpServletRequest("GET", "/"); request.setRequestURI("/accounts/12345"); request.addParameter("locale", "en"); request.addParameter("theme", "green"); HandlerExecutionChain chain = mapping.getHandler(request); assertEquals(4, chain.getInterceptors().length); assertTrue(chain.getInterceptors()[0] instanceof ConversionServiceExposingInterceptor); assertTrue(chain.getInterceptors()[1] instanceof LocaleChangeInterceptor); assertTrue(chain.getInterceptors()[2] instanceof ThemeChangeInterceptor); assertTrue(chain.getInterceptors()[3] instanceof UserRoleAuthorizationInterceptor); request.setRequestURI("/admin/users"); chain = mapping.getHandler(request); assertEquals(2, chain.getInterceptors().length); request.setRequestURI("/logged/accounts/12345"); chain = mapping.getHandler(request); assertEquals(3, chain.getInterceptors().length); request.setRequestURI("/foo/logged"); chain = mapping.getHandler(request); assertEquals(3, chain.getInterceptors().length); }
Example #3
Source File: MvcNamespaceTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testInterceptors() throws Exception { loadBeanDefinitions("mvc-config-interceptors.xml", 21); RequestMappingHandlerMapping mapping = appContext.getBean(RequestMappingHandlerMapping.class); assertNotNull(mapping); mapping.setDefaultHandler(handlerMethod); MockHttpServletRequest request = new MockHttpServletRequest("GET", "/"); request.setRequestURI("/accounts/12345"); request.addParameter("locale", "en"); request.addParameter("theme", "green"); HandlerExecutionChain chain = mapping.getHandler(request); assertEquals(5, chain.getInterceptors().length); assertTrue(chain.getInterceptors()[0] instanceof ConversionServiceExposingInterceptor); assertTrue(chain.getInterceptors()[1] instanceof LocaleChangeInterceptor); assertTrue(chain.getInterceptors()[2] instanceof WebRequestHandlerInterceptorAdapter); assertTrue(chain.getInterceptors()[3] instanceof ThemeChangeInterceptor); assertTrue(chain.getInterceptors()[4] instanceof UserRoleAuthorizationInterceptor); request.setRequestURI("/admin/users"); chain = mapping.getHandler(request); assertEquals(3, chain.getInterceptors().length); request.setRequestURI("/logged/accounts/12345"); chain = mapping.getHandler(request); assertEquals(5, chain.getInterceptors().length); assertTrue(chain.getInterceptors()[4] instanceof WebRequestHandlerInterceptorAdapter); request.setRequestURI("/foo/logged"); chain = mapping.getHandler(request); assertEquals(5, chain.getInterceptors().length); assertTrue(chain.getInterceptors()[4] instanceof WebRequestHandlerInterceptorAdapter); }