本文整理汇总了Java中org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.getHandler方法的典型用法代码示例。如果您正苦于以下问题:Java RequestMappingHandlerMapping.getHandler方法的具体用法?Java RequestMappingHandlerMapping.getHandler怎么用?Java RequestMappingHandlerMapping.getHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping
的用法示例。
在下文中一共展示了RequestMappingHandlerMapping.getHandler方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCustomConversionService
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; //导入方法依赖的package包/类
@Test(expected = TypeMismatchException.class)
public void testCustomConversionService() throws Exception {
loadBeanDefinitions("mvc-config-custom-conversion-service.xml", 14);
RequestMappingHandlerMapping mapping = appContext.getBean(RequestMappingHandlerMapping.class);
assertNotNull(mapping);
mapping.setDefaultHandler(handlerMethod);
// default web binding initializer behavior test
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/");
request.setRequestURI("/accounts/12345");
request.addParameter("date", "2009-10-31");
MockHttpServletResponse response = new MockHttpServletResponse();
HandlerExecutionChain chain = mapping.getHandler(request);
assertEquals(1, chain.getInterceptors().length);
assertTrue(chain.getInterceptors()[0] instanceof ConversionServiceExposingInterceptor);
ConversionServiceExposingInterceptor interceptor = (ConversionServiceExposingInterceptor) chain.getInterceptors()[0];
interceptor.preHandle(request, response, handler);
assertSame(appContext.getBean("conversionService"), request.getAttribute(ConversionService.class.getName()));
RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.class);
assertNotNull(adapter);
adapter.handle(request, response, handlerMethod);
}
示例2: testBeanDecoration
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; //导入方法依赖的package包/类
@Test
public void testBeanDecoration() throws Exception {
loadBeanDefinitions("mvc-config-bean-decoration.xml", 16);
RequestMappingHandlerMapping mapping = appContext.getBean(RequestMappingHandlerMapping.class);
assertNotNull(mapping);
mapping.setDefaultHandler(handlerMethod);
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/");
HandlerExecutionChain chain = mapping.getHandler(request);
assertEquals(3, chain.getInterceptors().length);
assertTrue(chain.getInterceptors()[0] instanceof ConversionServiceExposingInterceptor);
assertTrue(chain.getInterceptors()[1] instanceof LocaleChangeInterceptor);
assertTrue(chain.getInterceptors()[2] instanceof ThemeChangeInterceptor);
LocaleChangeInterceptor interceptor = (LocaleChangeInterceptor) chain.getInterceptors()[1];
assertEquals("lang", interceptor.getParamName());
ThemeChangeInterceptor interceptor2 = (ThemeChangeInterceptor) chain.getInterceptors()[2];
assertEquals("style", interceptor2.getParamName());
}
示例3: requestMappingHandlerMapping
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; //导入方法依赖的package包/类
@Test
public void requestMappingHandlerMapping() throws Exception {
ApplicationContext context = initContext(WebConfig.class, ScopedController.class, ScopedProxyController.class);
RequestMappingHandlerMapping handlerMapping = context.getBean(RequestMappingHandlerMapping.class);
assertEquals(0, handlerMapping.getOrder());
HandlerExecutionChain chain = handlerMapping.getHandler(new MockHttpServletRequest("GET", "/"));
assertNotNull(chain);
assertNotNull(chain.getInterceptors());
assertEquals(ConversionServiceExposingInterceptor.class, chain.getInterceptors()[0].getClass());
chain = handlerMapping.getHandler(new MockHttpServletRequest("GET", "/scoped"));
assertNotNull("HandlerExecutionChain for '/scoped' mapping should not be null.", chain);
chain = handlerMapping.getHandler(new MockHttpServletRequest("GET", "/scopedProxy"));
assertNotNull("HandlerExecutionChain for '/scopedProxy' mapping should not be null.", chain);
}
示例4: suffixPatternMatch
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; //导入方法依赖的package包/类
@Test
public void suffixPatternMatch() throws Exception {
TestStandaloneMockMvcBuilder builder = new TestStandaloneMockMvcBuilder(new PersonController());
builder.setUseSuffixPatternMatch(false);
builder.build();
RequestMappingHandlerMapping hm = builder.wac.getBean(RequestMappingHandlerMapping.class);
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/persons");
HandlerExecutionChain chain = hm.getHandler(request);
assertNotNull(chain);
assertEquals("persons", ((HandlerMethod) chain.getHandler()).getMethod().getName());
request = new MockHttpServletRequest("GET", "/persons.xml");
chain = hm.getHandler(request);
assertNull(chain);
}
示例5: testCustomConversionService
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; //导入方法依赖的package包/类
@Test(expected=TypeMismatchException.class)
public void testCustomConversionService() throws Exception {
loadBeanDefinitions("mvc-config-custom-conversion-service.xml", 12);
RequestMappingHandlerMapping mapping = appContext.getBean(RequestMappingHandlerMapping.class);
assertNotNull(mapping);
mapping.setDefaultHandler(handlerMethod);
// default web binding initializer behavior test
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/");
request.setRequestURI("/accounts/12345");
request.addParameter("date", "2009-10-31");
MockHttpServletResponse response = new MockHttpServletResponse();
HandlerExecutionChain chain = mapping.getHandler(request);
assertEquals(1, chain.getInterceptors().length);
assertTrue(chain.getInterceptors()[0] instanceof ConversionServiceExposingInterceptor);
ConversionServiceExposingInterceptor interceptor = (ConversionServiceExposingInterceptor) chain.getInterceptors()[0];
interceptor.preHandle(request, response, handler);
assertSame(appContext.getBean("conversionService"), request.getAttribute(ConversionService.class.getName()));
RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.class);
assertNotNull(adapter);
adapter.handle(request, response, handlerMethod);
}
示例6: testBeanDecoration
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; //导入方法依赖的package包/类
@Test
public void testBeanDecoration() throws Exception {
loadBeanDefinitions("mvc-config-bean-decoration.xml", 14);
RequestMappingHandlerMapping mapping = appContext.getBean(RequestMappingHandlerMapping.class);
assertNotNull(mapping);
mapping.setDefaultHandler(handlerMethod);
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/");
HandlerExecutionChain chain = mapping.getHandler(request);
assertEquals(3, chain.getInterceptors().length);
assertTrue(chain.getInterceptors()[0] instanceof ConversionServiceExposingInterceptor);
assertTrue(chain.getInterceptors()[1] instanceof LocaleChangeInterceptor);
assertTrue(chain.getInterceptors()[2] instanceof ThemeChangeInterceptor);
LocaleChangeInterceptor interceptor = (LocaleChangeInterceptor) chain.getInterceptors()[1];
assertEquals("lang", interceptor.getParamName());
ThemeChangeInterceptor interceptor2 = (ThemeChangeInterceptor) chain.getInterceptors()[2];
assertEquals("style", interceptor2.getParamName());
}
示例7: testInterceptors
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; //导入方法依赖的package包/类
@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);
}
示例8: placeHoldersInRequestMapping
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; //导入方法依赖的package包/类
@Test
public void placeHoldersInRequestMapping() throws Exception {
TestStandaloneMockMvcBuilder builder = new TestStandaloneMockMvcBuilder(new PlaceholderController());
builder.addPlaceHolderValue("sys.login.ajax", "/foo");
builder.build();
RequestMappingHandlerMapping hm = builder.wac.getBean(RequestMappingHandlerMapping.class);
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo");
HandlerExecutionChain chain = hm.getHandler(request);
assertNotNull(chain);
assertEquals("handleWithPlaceholders", ((HandlerMethod) chain.getHandler()).getMethod().getName());
}
示例9: testInterceptors
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; //导入方法依赖的package包/类
@Test
public void testInterceptors() throws Exception {
loadBeanDefinitions("mvc-config-interceptors.xml", 17);
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 WebRequestHandlerInterceptorAdapter);
assertTrue(chain.getInterceptors()[3] instanceof ThemeChangeInterceptor);
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);
}
示例10: requestMappingHandlerMapping
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; //导入方法依赖的package包/类
@Test
public void requestMappingHandlerMapping() throws Exception {
this.wac.registerSingleton("controller", TestController.class);
RequestMappingHandlerMapping handlerMapping = mvcConfiguration.requestMappingHandlerMapping();
assertEquals(0, handlerMapping.getOrder());
handlerMapping.setApplicationContext(this.wac);
handlerMapping.afterPropertiesSet();
HandlerExecutionChain chain = handlerMapping.getHandler(new MockHttpServletRequest("GET", "/"));
assertNotNull(chain.getInterceptors());
assertEquals(ConversionServiceExposingInterceptor.class, chain.getInterceptors()[0].getClass());
}
示例11: testDefaultConfig
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; //导入方法依赖的package包/类
@Test
public void testDefaultConfig() throws Exception {
loadBeanDefinitions("mvc-config.xml", 14);
RequestMappingHandlerMapping mapping = appContext.getBean(RequestMappingHandlerMapping.class);
assertNotNull(mapping);
assertEquals(0, mapping.getOrder());
assertTrue(mapping.getUrlPathHelper().shouldRemoveSemicolonContent());
mapping.setDefaultHandler(handlerMethod);
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo.json");
NativeWebRequest webRequest = new ServletWebRequest(request);
ContentNegotiationManager manager = mapping.getContentNegotiationManager();
assertEquals(Arrays.asList(MediaType.APPLICATION_JSON), manager.resolveMediaTypes(webRequest));
RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.class);
assertNotNull(adapter);
assertEquals(false, new DirectFieldAccessor(adapter).getPropertyValue("ignoreDefaultModelOnRedirect"));
List<HttpMessageConverter<?>> converters = adapter.getMessageConverters();
assertTrue(converters.size() > 0);
for (HttpMessageConverter<?> converter : converters) {
if (converter instanceof AbstractJackson2HttpMessageConverter) {
ObjectMapper objectMapper = ((AbstractJackson2HttpMessageConverter) converter).getObjectMapper();
assertFalse(objectMapper.getDeserializationConfig().isEnabled(MapperFeature.DEFAULT_VIEW_INCLUSION));
assertFalse(objectMapper.getSerializationConfig().isEnabled(MapperFeature.DEFAULT_VIEW_INCLUSION));
assertFalse(objectMapper.getDeserializationConfig().isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
if (converter instanceof MappingJackson2XmlHttpMessageConverter) {
assertEquals(XmlMapper.class, objectMapper.getClass());
}
}
}
assertNotNull(appContext.getBean(FormattingConversionServiceFactoryBean.class));
assertNotNull(appContext.getBean(ConversionService.class));
assertNotNull(appContext.getBean(LocalValidatorFactoryBean.class));
assertNotNull(appContext.getBean(Validator.class));
// default web binding initializer behavior test
request = new MockHttpServletRequest("GET", "/");
request.addParameter("date", "2009-10-31");
request.addParameter("percent", "99.99%");
MockHttpServletResponse response = new MockHttpServletResponse();
HandlerExecutionChain chain = mapping.getHandler(request);
assertEquals(1, chain.getInterceptors().length);
assertTrue(chain.getInterceptors()[0] instanceof ConversionServiceExposingInterceptor);
ConversionServiceExposingInterceptor interceptor = (ConversionServiceExposingInterceptor) chain.getInterceptors()[0];
interceptor.preHandle(request, response, handlerMethod);
assertSame(appContext.getBean(ConversionService.class), request.getAttribute(ConversionService.class.getName()));
adapter.handle(request, response, handlerMethod);
assertTrue(handler.recordedValidationError);
assertEquals(LocalDate.parse("2009-10-31").toDate(), handler.date);
assertEquals(Double.valueOf(0.9999), handler.percent);
CompositeUriComponentsContributor uriComponentsContributor = this.appContext.getBean(
MvcUriComponentsBuilder.MVC_URI_COMPONENTS_CONTRIBUTOR_BEAN_NAME,
CompositeUriComponentsContributor.class);
assertNotNull(uriComponentsContributor);
}
示例12: testViewControllers
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; //导入方法依赖的package包/类
@Test
public void testViewControllers() throws Exception {
loadBeanDefinitions("mvc-config-view-controllers.xml", 19);
RequestMappingHandlerMapping mapping = appContext.getBean(RequestMappingHandlerMapping.class);
assertNotNull(mapping);
mapping.setDefaultHandler(handlerMethod);
BeanNameUrlHandlerMapping beanNameMapping = appContext.getBean(BeanNameUrlHandlerMapping.class);
assertNotNull(beanNameMapping);
assertEquals(2, beanNameMapping.getOrder());
MockHttpServletRequest request = new MockHttpServletRequest();
request.setMethod("GET");
HandlerExecutionChain chain = mapping.getHandler(request);
assertEquals(3, chain.getInterceptors().length);
assertTrue(chain.getInterceptors()[0] instanceof ConversionServiceExposingInterceptor);
assertTrue(chain.getInterceptors()[1] instanceof LocaleChangeInterceptor);
assertTrue(chain.getInterceptors()[2] instanceof ThemeChangeInterceptor);
SimpleUrlHandlerMapping mapping2 = appContext.getBean(SimpleUrlHandlerMapping.class);
assertNotNull(mapping2);
SimpleControllerHandlerAdapter adapter = appContext.getBean(SimpleControllerHandlerAdapter.class);
assertNotNull(adapter);
request = new MockHttpServletRequest("GET", "/foo");
chain = mapping2.getHandler(request);
assertEquals(4, chain.getInterceptors().length);
assertTrue(chain.getInterceptors()[1] instanceof ConversionServiceExposingInterceptor);
assertTrue(chain.getInterceptors()[2] instanceof LocaleChangeInterceptor);
assertTrue(chain.getInterceptors()[3] instanceof ThemeChangeInterceptor);
ModelAndView mv = adapter.handle(request, new MockHttpServletResponse(), chain.getHandler());
assertNull(mv.getViewName());
request = new MockHttpServletRequest("GET", "/myapp/app/bar");
request.setContextPath("/myapp");
request.setServletPath("/app");
chain = mapping2.getHandler(request);
assertEquals(4, chain.getInterceptors().length);
assertTrue(chain.getInterceptors()[1] instanceof ConversionServiceExposingInterceptor);
assertTrue(chain.getInterceptors()[2] instanceof LocaleChangeInterceptor);
assertTrue(chain.getInterceptors()[3] instanceof ThemeChangeInterceptor);
mv = adapter.handle(request, new MockHttpServletResponse(), chain.getHandler());
assertEquals("baz", mv.getViewName());
request = new MockHttpServletRequest("GET", "/myapp/app/");
request.setContextPath("/myapp");
request.setServletPath("/app");
chain = mapping2.getHandler(request);
assertEquals(4, chain.getInterceptors().length);
assertTrue(chain.getInterceptors()[1] instanceof ConversionServiceExposingInterceptor);
assertTrue(chain.getInterceptors()[2] instanceof LocaleChangeInterceptor);
assertTrue(chain.getInterceptors()[3] instanceof ThemeChangeInterceptor);
mv = adapter.handle(request, new MockHttpServletResponse(), chain.getHandler());
assertEquals("root", mv.getViewName());
request = new MockHttpServletRequest("GET", "/myapp/app/old");
request.setContextPath("/myapp");
request.setServletPath("/app");
request.setQueryString("a=b");
chain = mapping2.getHandler(request);
mv = adapter.handle(request, new MockHttpServletResponse(), chain.getHandler());
assertNotNull(mv.getView());
assertEquals(RedirectView.class, mv.getView().getClass());
RedirectView redirectView = (RedirectView) mv.getView();
MockHttpServletResponse response = new MockHttpServletResponse();
redirectView.render(Collections.emptyMap(), request, response);
assertEquals("/new?a=b", response.getRedirectedUrl());
assertEquals(308, response.getStatus());
request = new MockHttpServletRequest("GET", "/bad");
chain = mapping2.getHandler(request);
response = new MockHttpServletResponse();
mv = adapter.handle(request, response, chain.getHandler());
assertNull(mv);
assertEquals(404, response.getStatus());
}
示例13: testDefaultConfig
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; //导入方法依赖的package包/类
@Test
public void testDefaultConfig() throws Exception {
loadBeanDefinitions("mvc-config.xml", 12);
RequestMappingHandlerMapping mapping = appContext.getBean(RequestMappingHandlerMapping.class);
assertNotNull(mapping);
assertEquals(0, mapping.getOrder());
assertTrue(mapping.getUrlPathHelper().shouldRemoveSemicolonContent());
mapping.setDefaultHandler(handlerMethod);
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo.json");
NativeWebRequest webRequest = new ServletWebRequest(request);
ContentNegotiationManager manager = mapping.getContentNegotiationManager();
assertEquals(Arrays.asList(MediaType.APPLICATION_JSON), manager.resolveMediaTypes(webRequest));
RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.class);
assertNotNull(adapter);
assertEquals(false, new DirectFieldAccessor(adapter).getPropertyValue("ignoreDefaultModelOnRedirect"));
List<HttpMessageConverter<?>> messageConverters = adapter.getMessageConverters();
assertTrue(messageConverters.size() > 0);
assertNotNull(appContext.getBean(FormattingConversionServiceFactoryBean.class));
assertNotNull(appContext.getBean(ConversionService.class));
assertNotNull(appContext.getBean(LocalValidatorFactoryBean.class));
assertNotNull(appContext.getBean(Validator.class));
// default web binding initializer behavior test
request = new MockHttpServletRequest("GET", "/");
request.addParameter("date", "2009-10-31");
MockHttpServletResponse response = new MockHttpServletResponse();
HandlerExecutionChain chain = mapping.getHandler(request);
assertEquals(1, chain.getInterceptors().length);
assertTrue(chain.getInterceptors()[0] instanceof ConversionServiceExposingInterceptor);
ConversionServiceExposingInterceptor interceptor = (ConversionServiceExposingInterceptor) chain.getInterceptors()[0];
interceptor.preHandle(request, response, handlerMethod);
assertSame(appContext.getBean(ConversionService.class), request.getAttribute(ConversionService.class.getName()));
adapter.handle(request, response, handlerMethod);
assertTrue(handler.recordedValidationError);
}
示例14: testViewControllers
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; //导入方法依赖的package包/类
@Test
public void testViewControllers() throws Exception {
loadBeanDefinitions("mvc-config-view-controllers.xml", 15);
RequestMappingHandlerMapping mapping = appContext.getBean(RequestMappingHandlerMapping.class);
assertNotNull(mapping);
mapping.setDefaultHandler(handlerMethod);
BeanNameUrlHandlerMapping beanNameMapping = appContext.getBean(BeanNameUrlHandlerMapping.class);
assertNotNull(beanNameMapping);
assertEquals(2, beanNameMapping.getOrder());
MockHttpServletRequest request = new MockHttpServletRequest();
request.setMethod("GET");
HandlerExecutionChain chain = mapping.getHandler(request);
assertEquals(3, chain.getInterceptors().length);
assertTrue(chain.getInterceptors()[0] instanceof ConversionServiceExposingInterceptor);
assertTrue(chain.getInterceptors()[1] instanceof LocaleChangeInterceptor);
assertTrue(chain.getInterceptors()[2] instanceof ThemeChangeInterceptor);
SimpleUrlHandlerMapping mapping2 = appContext.getBean(SimpleUrlHandlerMapping.class);
assertNotNull(mapping2);
SimpleControllerHandlerAdapter adapter = appContext.getBean(SimpleControllerHandlerAdapter.class);
assertNotNull(adapter);
request.setRequestURI("/foo");
chain = mapping2.getHandler(request);
assertEquals(4, chain.getInterceptors().length);
assertTrue(chain.getInterceptors()[1] instanceof ConversionServiceExposingInterceptor);
assertTrue(chain.getInterceptors()[2] instanceof LocaleChangeInterceptor);
assertTrue(chain.getInterceptors()[3] instanceof ThemeChangeInterceptor);
ModelAndView mv = adapter.handle(request, new MockHttpServletResponse(), chain.getHandler());
assertNull(mv.getViewName());
request.setRequestURI("/myapp/app/bar");
request.setContextPath("/myapp");
request.setServletPath("/app");
chain = mapping2.getHandler(request);
assertEquals(4, chain.getInterceptors().length);
assertTrue(chain.getInterceptors()[1] instanceof ConversionServiceExposingInterceptor);
assertTrue(chain.getInterceptors()[2] instanceof LocaleChangeInterceptor);
assertTrue(chain.getInterceptors()[3] instanceof ThemeChangeInterceptor);
ModelAndView mv2 = adapter.handle(request, new MockHttpServletResponse(), chain.getHandler());
assertEquals("baz", mv2.getViewName());
request.setRequestURI("/myapp/app/");
request.setContextPath("/myapp");
request.setServletPath("/app");
chain = mapping2.getHandler(request);
assertEquals(4, chain.getInterceptors().length);
assertTrue(chain.getInterceptors()[1] instanceof ConversionServiceExposingInterceptor);
assertTrue(chain.getInterceptors()[2] instanceof LocaleChangeInterceptor);
assertTrue(chain.getInterceptors()[3] instanceof ThemeChangeInterceptor);
ModelAndView mv3 = adapter.handle(request, new MockHttpServletResponse(), chain.getHandler());
assertEquals("root", mv3.getViewName());
}