@Test public void beanNameUrlHandlerMapping() { loadBeanDefinitions("mvc-config.xml"); BeanNameUrlHandlerMapping mapping = appContext.getBean(BeanNameUrlHandlerMapping.class); assertNotNull(mapping); assertEquals(2, mapping.getOrder()); }
@Test public void beanNameHandlerMapping() throws Exception { StaticWebApplicationContext cxt = new StaticWebApplicationContext(); cxt.registerSingleton("/controller", TestController.class); HttpServletRequest request = new MockHttpServletRequest("GET", "/controller"); BeanNameUrlHandlerMapping handlerMapping = mvcConfiguration.beanNameHandlerMapping(); assertEquals(2, handlerMapping.getOrder()); handlerMapping.setApplicationContext(cxt); HandlerExecutionChain chain = handlerMapping.getHandler(request); assertNotNull(chain.getInterceptors()); assertEquals(2, chain.getInterceptors().length); assertEquals(ConversionServiceExposingInterceptor.class, chain.getInterceptors()[1].getClass()); }