mvc namespace installation of handler mapping and handler adapter

This commit is contained in:
Keith Donald
2009-11-06 15:38:08 +00:00
parent d96bea9f6a
commit ee15bbb494
3 changed files with 85 additions and 6 deletions

View File

@@ -0,0 +1,36 @@
package org.springframework.web.servlet.config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.ClassPathResource;
import org.springframework.mock.web.MockServletContext;
import org.springframework.web.context.support.GenericWebApplicationContext;
import org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter;
import org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping;
public class MvcNamespaceTests {
private GenericWebApplicationContext container;
@Before
public void setUp() {
container = new GenericWebApplicationContext();
container.setServletContext(new MockServletContext());
}
@Test
public void testDefaultConfig() {
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(container);
reader.loadBeanDefinitions(new ClassPathResource("mvc-config.xml", getClass()));
assertEquals(2, container.getBeanDefinitionCount());
DefaultAnnotationHandlerMapping mapping = container.getBean("defaultAnnotationHandlerMapping", DefaultAnnotationHandlerMapping.class);
assertNotNull(mapping);
assertEquals(0, mapping.getOrder());
AnnotationMethodHandlerAdapter adapter = container.getBean("annotationMethodHandlerAdapter", AnnotationMethodHandlerAdapter.class);
assertNotNull(adapter);
}
}

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<mvc:annotated-controllers/>
</beans>