Rename RequestMapping types for concision

Remove 'Method' from RequestMappingHandlerMethodMapping and
RequestMappingHandlerMethodAdapter
This commit is contained in:
Chris Beams 2011-05-06 19:13:05 +00:00
parent 2092a31f9d
commit 1efb82d7cb
15 changed files with 140 additions and 140 deletions

View File

@ -49,8 +49,8 @@ import org.springframework.web.servlet.handler.ConversionServiceExposingIntercep
import org.springframework.web.servlet.handler.MappedInterceptor; import org.springframework.web.servlet.handler.MappedInterceptor;
import org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver; import org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver;
import org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver; import org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMethodAdapter; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMethodMapping; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
import org.springframework.web.servlet.mvc.method.annotation.support.ServletWebArgumentResolverAdapter; import org.springframework.web.servlet.mvc.method.annotation.support.ServletWebArgumentResolverAdapter;
import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver; import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver;
import org.w3c.dom.Element; import org.w3c.dom.Element;
@ -105,7 +105,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
CompositeComponentDefinition compDefinition = new CompositeComponentDefinition(element.getTagName(), source); CompositeComponentDefinition compDefinition = new CompositeComponentDefinition(element.getTagName(), source);
parserContext.pushContainingComponent(compDefinition); parserContext.pushContainingComponent(compDefinition);
RootBeanDefinition methodMappingDef = new RootBeanDefinition(RequestMappingHandlerMethodMapping.class); RootBeanDefinition methodMappingDef = new RootBeanDefinition(RequestMappingHandlerMapping.class);
methodMappingDef.setSource(source); methodMappingDef.setSource(source);
methodMappingDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); methodMappingDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
methodMappingDef.getPropertyValues().add("order", 0); methodMappingDef.getPropertyValues().add("order", 0);
@ -125,7 +125,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
ManagedList<?> messageConverters = getMessageConverters(element, source, parserContext); ManagedList<?> messageConverters = getMessageConverters(element, source, parserContext);
ManagedList<?> argumentResolvers = getArgumentResolvers(element, source, parserContext); ManagedList<?> argumentResolvers = getArgumentResolvers(element, source, parserContext);
RootBeanDefinition methodAdapterDef = new RootBeanDefinition(RequestMappingHandlerMethodAdapter.class); RootBeanDefinition methodAdapterDef = new RootBeanDefinition(RequestMappingHandlerAdapter.class);
methodAdapterDef.setSource(source); methodAdapterDef.setSource(source);
methodAdapterDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); methodAdapterDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
methodAdapterDef.getPropertyValues().add("webBindingInitializer", bindingDef); methodAdapterDef.getPropertyValues().add("webBindingInitializer", bindingDef);

View File

@ -65,8 +65,8 @@ import org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter;
import org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter; import org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter;
import org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver; import org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver;
import org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver; import org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMethodAdapter; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMethodMapping; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver; import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver;
/** /**
@ -79,7 +79,7 @@ import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolv
* *
* <p>Registers these handler mappings: * <p>Registers these handler mappings:
* <ul> * <ul>
* <li>{@link RequestMappingHandlerMethodMapping} ordered at 0 for mapping requests to annotated controller methods. * <li>{@link RequestMappingHandlerMapping} ordered at 0 for mapping requests to annotated controller methods.
* <li>{@link SimpleUrlHandlerMapping} ordered at 1 to map URL paths directly to view names. * <li>{@link SimpleUrlHandlerMapping} ordered at 1 to map URL paths directly to view names.
* <li>{@link BeanNameUrlHandlerMapping} ordered at 2 to map URL paths to controller bean names. * <li>{@link BeanNameUrlHandlerMapping} ordered at 2 to map URL paths to controller bean names.
* <li>{@link SimpleUrlHandlerMapping} ordered at {@code Integer.MAX_VALUE-1} to serve static resource requests. * <li>{@link SimpleUrlHandlerMapping} ordered at {@code Integer.MAX_VALUE-1} to serve static resource requests.
@ -91,7 +91,7 @@ import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolv
* *
* <p>Registers these handler adapters: * <p>Registers these handler adapters:
* <ul> * <ul>
* <li>{@link RequestMappingHandlerMethodAdapter} for processing requests using annotated controller methods. * <li>{@link RequestMappingHandlerAdapter} for processing requests using annotated controller methods.
* <li>{@link HttpRequestHandlerAdapter} for processing requests with {@link HttpRequestHandler}s. * <li>{@link HttpRequestHandlerAdapter} for processing requests with {@link HttpRequestHandler}s.
* <li>{@link SimpleControllerHandlerAdapter} for processing requests with interface-based {@link Controller}s. * <li>{@link SimpleControllerHandlerAdapter} for processing requests with interface-based {@link Controller}s.
* </ul> * </ul>
@ -139,8 +139,8 @@ class MvcConfiguration implements ApplicationContextAware, ServletContextAware {
} }
@Bean @Bean
RequestMappingHandlerMethodMapping requestMappingHandlerMapping() { RequestMappingHandlerMapping requestMappingHandlerMapping() {
RequestMappingHandlerMethodMapping mapping = new RequestMappingHandlerMethodMapping(); RequestMappingHandlerMapping mapping = new RequestMappingHandlerMapping();
mapping.setOrder(0); mapping.setOrder(0);
return mapping; return mapping;
} }
@ -176,8 +176,8 @@ class MvcConfiguration implements ApplicationContextAware, ServletContextAware {
} }
@Bean @Bean
RequestMappingHandlerMethodAdapter requestMappingHandlerAdapter() { RequestMappingHandlerAdapter requestMappingHandlerAdapter() {
RequestMappingHandlerMethodAdapter adapter = new RequestMappingHandlerMethodAdapter(); RequestMappingHandlerAdapter adapter = new RequestMappingHandlerAdapter();
ConfigurableWebBindingInitializer bindingInitializer = new ConfigurableWebBindingInitializer(); ConfigurableWebBindingInitializer bindingInitializer = new ConfigurableWebBindingInitializer();
bindingInitializer.setConversionService(conversionService()); bindingInitializer.setConversionService(conversionService());
@ -306,4 +306,4 @@ class MvcConfiguration implements ApplicationContextAware, ServletContextAware {
return configurer.getMappedInterceptors(); return configurer.getMappedInterceptors();
} }
} }

View File

@ -62,20 +62,20 @@ import org.springframework.web.servlet.mvc.method.annotation.support.ServletWebA
import org.springframework.web.servlet.mvc.method.annotation.support.ViewMethodReturnValueHandler; import org.springframework.web.servlet.mvc.method.annotation.support.ViewMethodReturnValueHandler;
/** /**
* An {@link AbstractHandlerMethodExceptionResolver} that looks for an {@link ExceptionHandler}-annotated method * An {@link AbstractHandlerMethodExceptionResolver} that looks for an {@link ExceptionHandler}-annotated method
* that can handle a thrown exception. If a match is found the exception-handling method is invoked to finish * that can handle a thrown exception. If a match is found the exception-handling method is invoked to finish
* processing the request. * processing the request.
* *
* <p>{@link ExceptionMethodMapping} is a key contributing class storing method-to-exception type mappings extracted * <p>{@link ExceptionMethodMapping} is a key contributing class storing method-to-exception type mappings extracted
* from {@link ExceptionHandler} annotations or from the list of method arguments on the exception-handling method. * from {@link ExceptionHandler} annotations or from the list of method arguments on the exception-handling method.
* {@link ExceptionMethodMapping} assists with actually locating a method for a thrown exception. * {@link ExceptionMethodMapping} assists with actually locating a method for a thrown exception.
* *
* <p>Once located the invocation of the exception-handling method is done using much of the same classes * <p>Once located the invocation of the exception-handling method is done using much of the same classes
* used for {@link RequestMapping} methods, which is described under {@link RequestMappingHandlerMethodAdapter}. * used for {@link RequestMapping} methods, which is described under {@link RequestMappingHandlerAdapter}.
* *
* <p>See {@link ExceptionHandler} for information on supported method arguments and return values for * <p>See {@link ExceptionHandler} for information on supported method arguments and return values for
* exception-handling methods. * exception-handling methods.
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 3.1 * @since 3.1
*/ */
@ -88,7 +88,7 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce
private List<HttpMessageConverter<?>> messageConverters; private List<HttpMessageConverter<?>> messageConverters;
private final Map<Class<?>, ExceptionMethodMapping> exceptionMethodMappingCache = private final Map<Class<?>, ExceptionMethodMapping> exceptionMethodMappingCache =
new ConcurrentHashMap<Class<?>, ExceptionMethodMapping>(); new ConcurrentHashMap<Class<?>, ExceptionMethodMapping>();
private HandlerMethodArgumentResolverComposite argumentResolvers; private HandlerMethodArgumentResolverComposite argumentResolvers;
@ -113,16 +113,16 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce
/** /**
* Set one or more custom argument resolvers to use with {@link ExceptionHandler} methods. Custom argument resolvers * Set one or more custom argument resolvers to use with {@link ExceptionHandler} methods. Custom argument resolvers
* are given a chance to resolve argument values ahead of the standard argument resolvers registered by default. * are given a chance to resolve argument values ahead of the standard argument resolvers registered by default.
* <p>An existing {@link WebArgumentResolver} can either adapted with {@link ServletWebArgumentResolverAdapter} * <p>An existing {@link WebArgumentResolver} can either adapted with {@link ServletWebArgumentResolverAdapter}
* or preferably converted to a {@link HandlerMethodArgumentResolver} instead. * or preferably converted to a {@link HandlerMethodArgumentResolver} instead.
*/ */
public void setCustomArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) { public void setCustomArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
this.customArgumentResolvers= argumentResolvers; this.customArgumentResolvers= argumentResolvers;
} }
/** /**
* Set the argument resolvers to use with {@link ExceptionHandler} methods. * Set the argument resolvers to use with {@link ExceptionHandler} methods.
* This is an optional property providing full control over all argument resolvers in contrast to * This is an optional property providing full control over all argument resolvers in contrast to
* {@link #setCustomArgumentResolvers(List)}, which does not override default registrations. * {@link #setCustomArgumentResolvers(List)}, which does not override default registrations.
* @param argumentResolvers argument resolvers for {@link ExceptionHandler} methods * @param argumentResolvers argument resolvers for {@link ExceptionHandler} methods
*/ */
@ -134,19 +134,19 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce
} }
/** /**
* Set custom return value handlers to use to handle the return values of {@link ExceptionHandler} methods. * Set custom return value handlers to use to handle the return values of {@link ExceptionHandler} methods.
* Custom return value handlers are given a chance to handle a return value before the standard * Custom return value handlers are given a chance to handle a return value before the standard
* return value handlers registered by default. * return value handlers registered by default.
* @param returnValueHandlers custom return value handlers for {@link ExceptionHandler} methods * @param returnValueHandlers custom return value handlers for {@link ExceptionHandler} methods
*/ */
public void setCustomReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) { public void setCustomReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) {
this.customReturnValueHandlers = returnValueHandlers; this.customReturnValueHandlers = returnValueHandlers;
} }
/** /**
* Set the {@link HandlerMethodReturnValueHandler}s to use to use with {@link ExceptionHandler} methods. * Set the {@link HandlerMethodReturnValueHandler}s to use to use with {@link ExceptionHandler} methods.
* This is an optional property providing full control over all return value handlers in contrast to * This is an optional property providing full control over all return value handlers in contrast to
* {@link #setCustomReturnValueHandlers(List)}, which does not override default registrations. * {@link #setCustomReturnValueHandlers(List)}, which does not override default registrations.
* @param returnValueHandlers the return value handlers for {@link ExceptionHandler} methods * @param returnValueHandlers the return value handlers for {@link ExceptionHandler} methods
*/ */
public void setReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) { public void setReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) {
@ -211,9 +211,9 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce
* @return a {@link ModelAndView} if a matching exception-handling method was found, or {@code null} otherwise * @return a {@link ModelAndView} if a matching exception-handling method was found, or {@code null} otherwise
*/ */
@Override @Override
protected ModelAndView doResolveHandlerMethodException(HttpServletRequest request, protected ModelAndView doResolveHandlerMethodException(HttpServletRequest request,
HttpServletResponse response, HttpServletResponse response,
HandlerMethod handlerMethod, HandlerMethod handlerMethod,
Exception ex) { Exception ex) {
if (handlerMethod != null) { if (handlerMethod != null) {
ExceptionMethodMapping mapping = getExceptionMethodMapping(handlerMethod); ExceptionMethodMapping mapping = getExceptionMethodMapping(handlerMethod);
@ -242,12 +242,12 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce
mav.setViewName(mavContainer.getViewName()); mav.setViewName(mavContainer.getViewName());
if (mavContainer.getView() != null) { if (mavContainer.getView() != null) {
mav.setView((View) mavContainer.getView()); mav.setView((View) mavContainer.getView());
} }
return mav; return mav;
} }
} }
catch (Exception invocationEx) { catch (Exception invocationEx) {
logger.error("Invoking exception-handling method resulted in exception : " + logger.error("Invoking exception-handling method resulted in exception : " +
exceptionHandler, invocationEx); exceptionHandler, invocationEx);
} }
} }
@ -257,7 +257,7 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce
} }
/** /**
* @return an {@link ExceptionMethodMapping} for the the given handler method, never {@code null} * @return an {@link ExceptionMethodMapping} for the the given handler method, never {@code null}
*/ */
private ExceptionMethodMapping getExceptionMethodMapping(HandlerMethod handlerMethod) { private ExceptionMethodMapping getExceptionMethodMapping(HandlerMethod handlerMethod) {
Class<?> handlerType = handlerMethod.getBeanType(); Class<?> handlerType = handlerMethod.getBeanType();

View File

@ -118,7 +118,7 @@ import org.springframework.web.util.WebUtils;
* @see HandlerMethodArgumentResolver * @see HandlerMethodArgumentResolver
* @see HandlerMethodReturnValueHandler * @see HandlerMethodReturnValueHandler
*/ */
public class RequestMappingHandlerMethodAdapter extends AbstractHandlerMethodAdapter implements BeanFactoryAware, public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter implements BeanFactoryAware,
InitializingBean { InitializingBean {
private List<HandlerMethodArgumentResolver> customArgumentResolvers; private List<HandlerMethodArgumentResolver> customArgumentResolvers;
@ -155,9 +155,9 @@ public class RequestMappingHandlerMethodAdapter extends AbstractHandlerMethodAda
private HandlerMethodArgumentResolverComposite initBinderArgumentResolvers; private HandlerMethodArgumentResolverComposite initBinderArgumentResolvers;
/** /**
* Create a {@link RequestMappingHandlerMethodAdapter} instance. * Create a {@link RequestMappingHandlerAdapter} instance.
*/ */
public RequestMappingHandlerMethodAdapter() { public RequestMappingHandlerAdapter() {
StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter(); StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter();
stringHttpMessageConverter.setWriteAcceptCharset(false); // See SPR-7316 stringHttpMessageConverter.setWriteAcceptCharset(false); // See SPR-7316

View File

@ -46,14 +46,14 @@ import org.springframework.web.servlet.handler.MappedInterceptors;
import org.springframework.web.servlet.mvc.method.condition.RequestConditionFactory; import org.springframework.web.servlet.mvc.method.condition.RequestConditionFactory;
/** /**
* An {@link AbstractHandlerMethodMapping} variant that uses {@link RequestMappingInfo}s for the registration and * An {@link AbstractHandlerMethodMapping} variant that uses {@link RequestMappingInfo}s for the registration and
* the lookup of {@link HandlerMethod}s. * the lookup of {@link HandlerMethod}s.
* *
* @author Arjen Poutsma * @author Arjen Poutsma
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 3.1.0 * @since 3.1
*/ */
public class RequestMappingHandlerMethodMapping extends AbstractHandlerMethodMapping<RequestMappingInfo> { public class RequestMappingHandlerMapping extends AbstractHandlerMethodMapping<RequestMappingInfo> {
private PathMatcher pathMatcher = new AntPathMatcher(); private PathMatcher pathMatcher = new AntPathMatcher();
@ -87,7 +87,7 @@ public class RequestMappingHandlerMethodMapping extends AbstractHandlerMethodMap
/** /**
* {@inheritDoc} * {@inheritDoc}
* The handler determination is made based on the presence of a type-level {@link Controller} or * The handler determination is made based on the presence of a type-level {@link Controller} or
* a type-level {@link RequestMapping} annotation. * a type-level {@link RequestMapping} annotation.
*/ */
@Override @Override
@ -97,9 +97,9 @@ public class RequestMappingHandlerMethodMapping extends AbstractHandlerMethodMap
} }
/** /**
* Provides a {@link RequestMappingInfo} for the given method. * Provides a {@link RequestMappingInfo} for the given method.
* <p>Only {@link RequestMapping @RequestMapping}-annotated methods are considered. * <p>Only {@link RequestMapping @RequestMapping}-annotated methods are considered.
* Type-level {@link RequestMapping @RequestMapping} annotations are also detected and their * Type-level {@link RequestMapping @RequestMapping} annotations are also detected and their
* attributes combined with method-level {@link RequestMapping @RequestMapping} attributes. * attributes combined with method-level {@link RequestMapping @RequestMapping} attributes.
* *
* @param beanName the name of the bean the method belongs to * @param beanName the name of the bean the method belongs to
@ -206,15 +206,15 @@ public class RequestMappingHandlerMethodMapping extends AbstractHandlerMethodMap
} }
/** /**
* A comparator for {@link RequestMappingInfo}s. Effective comparison can only be done in the context of a * A comparator for {@link RequestMappingInfo}s. Effective comparison can only be done in the context of a
* specific request. For example not all {@link RequestMappingInfo} patterns may apply to the current request. * specific request. For example not all {@link RequestMappingInfo} patterns may apply to the current request.
* Therefore an HttpServletRequest is required as input. * Therefore an HttpServletRequest is required as input.
* *
* <p>Furthermore, the following assumptions are made about the input RequestMappings: * <p>Furthermore, the following assumptions are made about the input RequestMappings:
* <ul><li>Each RequestMappingInfo has been fully matched to the request <li>The RequestMappingInfo contains * <ul><li>Each RequestMappingInfo has been fully matched to the request <li>The RequestMappingInfo contains
* matched patterns only <li>Patterns are ordered with the best matching pattern at the top </ul> * matched patterns only <li>Patterns are ordered with the best matching pattern at the top </ul>
* *
* @see RequestMappingHandlerMethodMapping#getMatchingMapping(RequestMappingInfo, String, HttpServletRequest) * @see RequestMappingHandlerMapping#getMatchingMapping(RequestMappingInfo, String, HttpServletRequest)
*/ */
private class RequestMappingInfoComparator implements Comparator<RequestMappingInfo> { private class RequestMappingInfoComparator implements Comparator<RequestMappingInfo> {

View File

@ -38,7 +38,7 @@ import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.context.support.GenericWebApplicationContext; import org.springframework.web.context.support.GenericWebApplicationContext;
import org.springframework.web.method.support.HandlerMethodArgumentResolver; import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.ModelAndViewContainer; import org.springframework.web.method.support.ModelAndViewContainer;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMethodAdapter; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
import org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver; import org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver;
import org.springframework.web.servlet.mvc.method.annotation.support.ServletWebArgumentResolverAdapter; import org.springframework.web.servlet.mvc.method.annotation.support.ServletWebArgumentResolverAdapter;
@ -58,7 +58,7 @@ public class AnnotationDrivenBeanDefinitionParserTests {
@Test @Test
public void testMessageCodesResolver() { public void testMessageCodesResolver() {
loadBeanDefinitions("mvc-config-message-codes-resolver.xml"); loadBeanDefinitions("mvc-config-message-codes-resolver.xml");
RequestMappingHandlerMethodAdapter adapter = appContext.getBean(RequestMappingHandlerMethodAdapter.class); RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.class);
assertNotNull(adapter); assertNotNull(adapter);
Object initializer = new DirectFieldAccessor(adapter).getPropertyValue("webBindingInitializer"); Object initializer = new DirectFieldAccessor(adapter).getPropertyValue("webBindingInitializer");
assertNotNull(initializer); assertNotNull(initializer);
@ -70,14 +70,14 @@ public class AnnotationDrivenBeanDefinitionParserTests {
@Test @Test
public void testMessageConverters() { public void testMessageConverters() {
loadBeanDefinitions("mvc-config-message-converters.xml"); loadBeanDefinitions("mvc-config-message-converters.xml");
verifyMessageConverters(appContext.getBean(RequestMappingHandlerMethodAdapter.class), true); verifyMessageConverters(appContext.getBean(RequestMappingHandlerAdapter.class), true);
verifyMessageConverters(appContext.getBean(ExceptionHandlerExceptionResolver.class), true); verifyMessageConverters(appContext.getBean(ExceptionHandlerExceptionResolver.class), true);
} }
@Test @Test
public void testMessageConvertersWithoutDefaultRegistrations() { public void testMessageConvertersWithoutDefaultRegistrations() {
loadBeanDefinitions("mvc-config-message-converters-defaults-off.xml"); loadBeanDefinitions("mvc-config-message-converters-defaults-off.xml");
verifyMessageConverters(appContext.getBean(RequestMappingHandlerMethodAdapter.class), false); verifyMessageConverters(appContext.getBean(RequestMappingHandlerAdapter.class), false);
verifyMessageConverters(appContext.getBean(ExceptionHandlerExceptionResolver.class), false); verifyMessageConverters(appContext.getBean(ExceptionHandlerExceptionResolver.class), false);
} }
@ -85,7 +85,7 @@ public class AnnotationDrivenBeanDefinitionParserTests {
@Test @Test
public void testArgumentResolvers() { public void testArgumentResolvers() {
loadBeanDefinitions("mvc-config-argument-resolvers.xml"); loadBeanDefinitions("mvc-config-argument-resolvers.xml");
RequestMappingHandlerMethodAdapter adapter = appContext.getBean(RequestMappingHandlerMethodAdapter.class); RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.class);
assertNotNull(adapter); assertNotNull(adapter);
Object value = new DirectFieldAccessor(adapter).getPropertyValue("customArgumentResolvers"); Object value = new DirectFieldAccessor(adapter).getPropertyValue("customArgumentResolvers");
assertNotNull(value); assertNotNull(value);
@ -109,7 +109,7 @@ public class AnnotationDrivenBeanDefinitionParserTests {
Object value = new DirectFieldAccessor(bean).getPropertyValue("messageConverters"); Object value = new DirectFieldAccessor(bean).getPropertyValue("messageConverters");
assertNotNull(value); assertNotNull(value);
assertTrue(value instanceof List); assertTrue(value instanceof List);
List<HttpMessageConverter<?>> converters = (List<HttpMessageConverter<?>>) value; List<HttpMessageConverter<?>> converters = (List<HttpMessageConverter<?>>) value;
if (hasDefaultRegistrations) { if (hasDefaultRegistrations) {
assertTrue("Default converters are registered in addition to custom ones", converters.size() > 2); assertTrue("Default converters are registered in addition to custom ones", converters.size() > 2);
} else { } else {

View File

@ -67,15 +67,15 @@ import org.springframework.web.servlet.handler.WebRequestHandlerInterceptorAdapt
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor; import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
import org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter; import org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter;
import org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter; import org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMethodAdapter; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMethodMapping; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
import org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler; import org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler;
import org.springframework.web.servlet.resource.ResourceHttpRequestHandler; import org.springframework.web.servlet.resource.ResourceHttpRequestHandler;
import org.springframework.web.servlet.theme.ThemeChangeInterceptor; import org.springframework.web.servlet.theme.ThemeChangeInterceptor;
/** /**
* @author Keith Donald * @author Keith Donald
* @author Arjen Poutsma * @author Arjen Poutsma
* @author Jeremy Grelle * @author Jeremy Grelle
*/ */
public class MvcNamespaceTests { public class MvcNamespaceTests {
@ -104,12 +104,12 @@ public class MvcNamespaceTests {
assertEquals(8, appContext.getBeanDefinitionCount()); assertEquals(8, appContext.getBeanDefinitionCount());
appContext.refresh(); appContext.refresh();
RequestMappingHandlerMethodMapping mapping = appContext.getBean(RequestMappingHandlerMethodMapping.class); RequestMappingHandlerMapping mapping = appContext.getBean(RequestMappingHandlerMapping.class);
assertNotNull(mapping); assertNotNull(mapping);
assertEquals(0, mapping.getOrder()); assertEquals(0, mapping.getOrder());
mapping.setDefaultHandler(handlerMethod); mapping.setDefaultHandler(handlerMethod);
RequestMappingHandlerMethodAdapter adapter = appContext.getBean(RequestMappingHandlerMethodAdapter.class); RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.class);
assertNotNull(adapter); assertNotNull(adapter);
List<HttpMessageConverter<?>> messageConverters = adapter.getMessageConverters(); List<HttpMessageConverter<?>> messageConverters = adapter.getMessageConverters();
@ -143,7 +143,7 @@ public class MvcNamespaceTests {
assertEquals(8, appContext.getBeanDefinitionCount()); assertEquals(8, appContext.getBeanDefinitionCount());
appContext.refresh(); appContext.refresh();
RequestMappingHandlerMethodMapping mapping = appContext.getBean(RequestMappingHandlerMethodMapping.class); RequestMappingHandlerMapping mapping = appContext.getBean(RequestMappingHandlerMapping.class);
assertNotNull(mapping); assertNotNull(mapping);
mapping.setDefaultHandler(handlerMethod); mapping.setDefaultHandler(handlerMethod);
@ -160,7 +160,7 @@ public class MvcNamespaceTests {
interceptor.preHandle(request, response, handler); interceptor.preHandle(request, response, handler);
assertSame(appContext.getBean("conversionService"), request.getAttribute(ConversionService.class.getName())); assertSame(appContext.getBean("conversionService"), request.getAttribute(ConversionService.class.getName()));
RequestMappingHandlerMethodAdapter adapter = appContext.getBean(RequestMappingHandlerMethodAdapter.class); RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.class);
assertNotNull(adapter); assertNotNull(adapter);
adapter.handle(request, response, handlerMethod); adapter.handle(request, response, handlerMethod);
} }
@ -172,7 +172,7 @@ public class MvcNamespaceTests {
assertEquals(8, appContext.getBeanDefinitionCount()); assertEquals(8, appContext.getBeanDefinitionCount());
appContext.refresh(); appContext.refresh();
RequestMappingHandlerMethodAdapter adapter = appContext.getBean(RequestMappingHandlerMethodAdapter.class); RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.class);
assertNotNull(adapter); assertNotNull(adapter);
// default web binding initializer behavior test // default web binding initializer behavior test
@ -192,7 +192,7 @@ public class MvcNamespaceTests {
assertEquals(11, appContext.getBeanDefinitionCount()); assertEquals(11, appContext.getBeanDefinitionCount());
appContext.refresh(); appContext.refresh();
RequestMappingHandlerMethodMapping mapping = appContext.getBean(RequestMappingHandlerMethodMapping.class); RequestMappingHandlerMapping mapping = appContext.getBean(RequestMappingHandlerMapping.class);
assertNotNull(mapping); assertNotNull(mapping);
mapping.setDefaultHandler(handlerMethod); mapping.setDefaultHandler(handlerMethod);
@ -327,7 +327,7 @@ public class MvcNamespaceTests {
assertEquals(10, appContext.getBeanDefinitionCount()); assertEquals(10, appContext.getBeanDefinitionCount());
appContext.refresh(); appContext.refresh();
RequestMappingHandlerMethodMapping mapping = appContext.getBean(RequestMappingHandlerMethodMapping.class); RequestMappingHandlerMapping mapping = appContext.getBean(RequestMappingHandlerMapping.class);
assertNotNull(mapping); assertNotNull(mapping);
mapping.setDefaultHandler(handlerMethod); mapping.setDefaultHandler(handlerMethod);
@ -351,7 +351,7 @@ public class MvcNamespaceTests {
assertEquals(12, appContext.getBeanDefinitionCount()); assertEquals(12, appContext.getBeanDefinitionCount());
appContext.refresh(); appContext.refresh();
RequestMappingHandlerMethodMapping mapping = appContext.getBean(RequestMappingHandlerMethodMapping.class); RequestMappingHandlerMapping mapping = appContext.getBean(RequestMappingHandlerMapping.class);
assertNotNull(mapping); assertNotNull(mapping);
mapping.setDefaultHandler(handlerMethod); mapping.setDefaultHandler(handlerMethod);

View File

@ -40,7 +40,7 @@ import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
import org.springframework.web.servlet.HandlerExceptionResolver; import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver; import org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver;
import org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver; import org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMethodAdapter; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver; import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver;
/** /**
@ -75,7 +75,7 @@ public class MvcConfigurationTests {
configurer.configureMessageConverters(capture(converters)); configurer.configureMessageConverters(capture(converters));
replay(configurer); replay(configurer);
RequestMappingHandlerMethodAdapter adapter = mvcConfiguration.requestMappingHandlerAdapter(); RequestMappingHandlerAdapter adapter = mvcConfiguration.requestMappingHandlerAdapter();
ConfigurableWebBindingInitializer initializer = (ConfigurableWebBindingInitializer) adapter.getWebBindingInitializer(); ConfigurableWebBindingInitializer initializer = (ConfigurableWebBindingInitializer) adapter.getWebBindingInitializer();
assertSame(conversionService.getValue(), initializer.getConversionService()); assertSame(conversionService.getValue(), initializer.getConversionService());

View File

@ -38,17 +38,17 @@ import org.springframework.web.context.support.GenericWebApplicationContext;
import org.springframework.web.method.HandlerMethod; import org.springframework.web.method.HandlerMethod;
/** /**
* Test various scenarios for detecting handler methods depending on where @RequestMapping annotations * Test various scenarios for detecting handler methods depending on where @RequestMapping annotations
* are located -- super types, parameterized methods, or in combination with proxies. * are located -- super types, parameterized methods, or in combination with proxies.
* *
* Note the following: * Note the following:
* <ul> * <ul>
* <li>Parameterized methods cannot be used in combination with JDK dynamic proxies since the * <li>Parameterized methods cannot be used in combination with JDK dynamic proxies since the
* proxy interface does not contain the bridged methods that need to be invoked. * proxy interface does not contain the bridged methods that need to be invoked.
* <li>When using JDK dynamic proxies, the proxied interface must contain all required annotations. * <li>When using JDK dynamic proxies, the proxied interface must contain all required annotations.
* <li>Method-level annotations can be placed on parent classes or interfaces. * <li>Method-level annotations can be placed on parent classes or interfaces.
* </ul> * </ul>
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
*/ */
@RunWith(Parameterized.class) @RunWith(Parameterized.class)
@ -56,13 +56,13 @@ public class HandlerMethodMappingAnnotationDetectionTests {
@Parameters @Parameters
public static Collection<Object[]> handlerTypes() { public static Collection<Object[]> handlerTypes() {
return Arrays.asList(new Object[][] { return Arrays.asList(new Object[][] {
{ new MappingInterfaceController(), false}, { new MappingInterfaceController(), false},
{ new MappingAbstractClassController(), false}, { new MappingAbstractClassController(), false},
{ new ParameterizedInterfaceController(), false }, { new ParameterizedInterfaceController(), false },
{ new MappingParameterizedInterfaceController(), false }, { new MappingParameterizedInterfaceController(), false },
{ new MappingClassController(), false }, { new MappingClassController(), false },
{ new MappingAbstractClassController(), true}, { new MappingAbstractClassController(), true},
{ new PlainController(), true} { new PlainController(), true}
}); });
} }
@ -80,13 +80,13 @@ public class HandlerMethodMappingAnnotationDetectionTests {
public void detectAndMapHandlerMethod() throws Exception { public void detectAndMapHandlerMethod() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/type/handle"); MockHttpServletRequest request = new MockHttpServletRequest("GET", "/type/handle");
RequestMappingHandlerMethodMapping mapping = createHandlerMapping(handler.getClass(), useAutoProxy); RequestMappingHandlerMapping mapping = createHandlerMapping(handler.getClass(), useAutoProxy);
HandlerMethod handlerMethod = (HandlerMethod) mapping.getHandler(request).getHandler(); HandlerMethod handlerMethod = (HandlerMethod) mapping.getHandler(request).getHandler();
assertNotNull("Failed to detect and map @RequestMapping handler method", handlerMethod); assertNotNull("Failed to detect and map @RequestMapping handler method", handlerMethod);
} }
private RequestMappingHandlerMethodMapping createHandlerMapping(Class<?> controllerType, boolean useAutoProxy) { private RequestMappingHandlerMapping createHandlerMapping(Class<?> controllerType, boolean useAutoProxy) {
GenericWebApplicationContext wac = new GenericWebApplicationContext(); GenericWebApplicationContext wac = new GenericWebApplicationContext();
wac.registerBeanDefinition("controller", new RootBeanDefinition(controllerType)); wac.registerBeanDefinition("controller", new RootBeanDefinition(controllerType));
if (useAutoProxy) { if (useAutoProxy) {
@ -96,7 +96,7 @@ public class HandlerMethodMappingAnnotationDetectionTests {
wac.getBeanFactory().registerSingleton("advsr", new DefaultPointcutAdvisor(new SimpleTraceInterceptor())); wac.getBeanFactory().registerSingleton("advsr", new DefaultPointcutAdvisor(new SimpleTraceInterceptor()));
} }
RequestMappingHandlerMethodMapping mapping = new RequestMappingHandlerMethodMapping(); RequestMappingHandlerMapping mapping = new RequestMappingHandlerMapping();
mapping.setApplicationContext(wac); mapping.setApplicationContext(wac);
return mapping; return mapping;
} }

View File

@ -33,20 +33,20 @@ import static java.util.Arrays.*;
import static org.junit.Assert.*; import static org.junit.Assert.*;
/** /**
* Test fixture with {@link RequestMappingHandlerMethodMapping} testing its {@link RequestMappingInfo} comparator. * Test fixture with {@link RequestMappingHandlerMapping} testing its {@link RequestMappingInfo} comparator.
* *
* @author Arjen Poutsma * @author Arjen Poutsma
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
*/ */
public class RequestKeyComparatorTests { public class RequestKeyComparatorTests {
private RequestMappingHandlerMethodMapping handlerMapping; private RequestMappingHandlerMapping handlerMapping;
private MockHttpServletRequest request; private MockHttpServletRequest request;
@Before @Before
public void setup() { public void setup() {
this.handlerMapping = new RequestMappingHandlerMethodMapping(); this.handlerMapping = new RequestMappingHandlerMapping();
this.request = new MockHttpServletRequest(); this.request = new MockHttpServletRequest();
} }
@ -110,7 +110,7 @@ public class RequestKeyComparatorTests {
assertEquals(empty, list.get(2)); assertEquals(empty, list.get(2));
} }
@Test @Test
@Ignore // TODO : remove ignore @Ignore // TODO : remove ignore
public void acceptHeaders() { public void acceptHeaders() {
RequestMappingInfo html = new RequestMappingInfo(null, null, null, RequestConditionFactory.parseHeaders("accept=text/html"), null); RequestMappingInfo html = new RequestMappingInfo(null, null, null, RequestConditionFactory.parseHeaders("accept=text/html"), null);

View File

@ -82,24 +82,24 @@ import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.method.annotation.support.ServletWebArgumentResolverAdapter; import org.springframework.web.servlet.mvc.method.annotation.support.ServletWebArgumentResolverAdapter;
/** /**
* Serves as a sandbox to invoke all types of controller methods using all features except for the kitchen sink. * Serves as a sandbox to invoke all types of controller methods using all features except for the kitchen sink.
* Once a problem has been debugged and understood, tests demonstrating the issue are preferably added to the * Once a problem has been debugged and understood, tests demonstrating the issue are preferably added to the
* appropriate, more fine-grained test fixture. * appropriate, more fine-grained test fixture.
* *
* <p>If you wish to add high-level tests, consider the following other "integration"-style tests: * <p>If you wish to add high-level tests, consider the following other "integration"-style tests:
* <ul> * <ul>
* <li>{@link HandlerMethodAdapterAnnotationDetectionTests} * <li>{@link HandlerMethodAdapterAnnotationDetectionTests}
* <li>{@link HandlerMethodMappingAnnotationDetectionTests} * <li>{@link HandlerMethodMappingAnnotationDetectionTests}
* <li>{@link ServletHandlerMethodTests} * <li>{@link ServletHandlerMethodTests}
* </ul> * </ul>
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
*/ */
public class RequestMappingHandlerMethodAdapterIntegrationTests { public class RequestMappingHandlerAdapterIntegrationTests {
private final Object handler = new Handler(); private final Object handler = new Handler();
private RequestMappingHandlerMethodAdapter handlerAdapter; private RequestMappingHandlerAdapter handlerAdapter;
private MockHttpServletRequest request; private MockHttpServletRequest request;
@ -116,7 +116,7 @@ public class RequestMappingHandlerMethodAdapterIntegrationTests {
GenericWebApplicationContext context = new GenericWebApplicationContext(); GenericWebApplicationContext context = new GenericWebApplicationContext();
context.refresh(); context.refresh();
handlerAdapter = new RequestMappingHandlerMethodAdapter(); handlerAdapter = new RequestMappingHandlerAdapter();
handlerAdapter.setWebBindingInitializer(bindingInitializer); handlerAdapter.setWebBindingInitializer(bindingInitializer);
handlerAdapter.setCustomArgumentResolvers(customResolvers); handlerAdapter.setCustomArgumentResolvers(customResolvers);
handlerAdapter.setApplicationContext(context); handlerAdapter.setApplicationContext(context);
@ -161,7 +161,7 @@ public class RequestMappingHandlerMethodAdapterIntegrationTests {
System.setProperty("systemHeader", "systemHeaderValue"); System.setProperty("systemHeader", "systemHeaderValue");
/* Set up path variables as RequestMappingHandlerMethodMapping would... */ /* Set up path variables as RequestMappingHandlerMapping would... */
Map<String, String> uriTemplateVars = new HashMap<String, String>(); Map<String, String> uriTemplateVars = new HashMap<String, String>();
uriTemplateVars.put("pathvar", "pathvarValue"); uriTemplateVars.put("pathvar", "pathvarValue");
request.setAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriTemplateVars); request.setAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriTemplateVars);
@ -274,14 +274,14 @@ public class RequestMappingHandlerMethodAdapterIntegrationTests {
} }
public String handleMvc( public String handleMvc(
@CookieValue("cookie") int cookie, @CookieValue("cookie") int cookie,
@PathVariable("pathvar") String pathvar, @PathVariable("pathvar") String pathvar,
@RequestHeader("header") String header, @RequestHeader("header") String header,
@RequestHeader(defaultValue="#{systemProperties.systemHeader}") String systemHeader, @RequestHeader(defaultValue="#{systemProperties.systemHeader}") String systemHeader,
@RequestHeader Map<String, Object> headerMap, @RequestHeader Map<String, Object> headerMap,
@RequestParam("dateParam") Date dateParam, @RequestParam("dateParam") Date dateParam,
@RequestParam Map<String, Object> paramMap, @RequestParam Map<String, Object> paramMap,
String paramByConvention, String paramByConvention,
@Value("#{request.contextPath}") String value, @Value("#{request.contextPath}") String value,
@ModelAttribute("modelAttr") @Valid TestBean modelAttr, @ModelAttribute("modelAttr") @Valid TestBean modelAttr,
Errors errors, Errors errors,

View File

@ -31,20 +31,20 @@ import org.springframework.web.method.HandlerMethod;
import org.springframework.web.method.support.InvocableHandlerMethod; import org.springframework.web.method.support.InvocableHandlerMethod;
/** /**
* Fine-grained {@link RequestMappingHandlerMethodAdapter} unit tests. * Fine-grained {@link RequestMappingHandlerAdapter} unit tests.
* *
* <p>For higher-level adapter tests see: * <p>For higher-level adapter tests see:
* <ul> * <ul>
* <li>{@link ServletHandlerMethodTests} * <li>{@link ServletHandlerMethodTests}
* <li>{@link RequestMappingHandlerMethodAdapterIntegrationTests} * <li>{@link RequestMappingHandlerAdapterIntegrationTests}
* <li>{@link HandlerMethodAdapterAnnotationDetectionTests} * <li>{@link HandlerMethodAdapterAnnotationDetectionTests}
* </ul> * </ul>
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
*/ */
public class RequestMappingHandlerMethodAdapterTests { public class RequestMappingHandlerAdapterTests {
private RequestMappingHandlerMethodAdapter handlerAdapter; private RequestMappingHandlerAdapter handlerAdapter;
private MockHttpServletRequest request; private MockHttpServletRequest request;
@ -52,7 +52,7 @@ public class RequestMappingHandlerMethodAdapterTests {
@Before @Before
public void setup() throws Exception { public void setup() throws Exception {
this.handlerAdapter = new RequestMappingHandlerMethodAdapter(); this.handlerAdapter = new RequestMappingHandlerAdapter();
this.handlerAdapter.setApplicationContext(new GenericWebApplicationContext()); this.handlerAdapter.setApplicationContext(new GenericWebApplicationContext());
this.handlerAdapter.afterPropertiesSet(); this.handlerAdapter.afterPropertiesSet();

View File

@ -43,14 +43,14 @@ import org.springframework.web.servlet.handler.MappedInterceptor;
import org.springframework.web.util.UrlPathHelper; import org.springframework.web.util.UrlPathHelper;
/** /**
* Test fixture with {@link RequestMappingHandlerMethodMapping}. * Test fixture with {@link RequestMappingHandlerMapping}.
* *
* @author Arjen Poutsma * @author Arjen Poutsma
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
*/ */
public class RequestMappingHandlerMethodMappingTests { public class RequestMappingHandlerMappingTests {
private RequestMappingHandlerMethodMapping mapping; private RequestMappingHandlerMapping mapping;
private Handler handler; private Handler handler;
@ -73,7 +73,7 @@ public class RequestMappingHandlerMethodMappingTests {
StaticApplicationContext context = new StaticApplicationContext(); StaticApplicationContext context = new StaticApplicationContext();
context.registerSingleton("handler", handler.getClass()); context.registerSingleton("handler", handler.getClass());
mapping = new RequestMappingHandlerMethodMapping(); mapping = new RequestMappingHandlerMapping();
mapping.setApplicationContext(context); mapping.setApplicationContext(context);
} }

View File

@ -143,11 +143,11 @@ import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolv
import org.springframework.web.servlet.view.InternalResourceViewResolver; import org.springframework.web.servlet.view.InternalResourceViewResolver;
/** /**
* The origin of this test fixture is {@link ServletHandlerMethodTests} with tests in this class adapted to run * The origin of this test fixture is {@link ServletHandlerMethodTests} with tests in this class adapted to run
* against the HandlerMethod infrastructure rather than against the DefaultAnnotationHandlerMapping, the * against the HandlerMethod infrastructure rather than against the DefaultAnnotationHandlerMapping, the
* AnnotationMethodHandlerAdapter, and the AnnotationMethodHandlerExceptionResolver. Tests that are not * AnnotationMethodHandlerAdapter, and the AnnotationMethodHandlerExceptionResolver. Tests that are not
* supported are listed at the bottom. * supported are listed at the bottom.
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 3.1 * @since 3.1
*/ */
@ -263,7 +263,7 @@ public class ServletHandlerMethodTests {
csDef.getPropertyValues().add("converters", new TestBeanConverter()); csDef.getPropertyValues().add("converters", new TestBeanConverter());
RootBeanDefinition wbiDef = new RootBeanDefinition(ConfigurableWebBindingInitializer.class); RootBeanDefinition wbiDef = new RootBeanDefinition(ConfigurableWebBindingInitializer.class);
wbiDef.getPropertyValues().add("conversionService", csDef); wbiDef.getPropertyValues().add("conversionService", csDef);
RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerMethodAdapter.class); RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerAdapter.class);
adapterDef.getPropertyValues().add("webBindingInitializer", wbiDef); adapterDef.getPropertyValues().add("webBindingInitializer", wbiDef);
context.registerBeanDefinition("handlerAdapter", adapterDef); context.registerBeanDefinition("handlerAdapter", adapterDef);
} }
@ -555,7 +555,7 @@ public class ServletHandlerMethodTests {
initDispatcherServlet(MyCommandProvidingFormController.class, new BeanDefinitionRegistrar() { initDispatcherServlet(MyCommandProvidingFormController.class, new BeanDefinitionRegistrar() {
public void register(GenericWebApplicationContext wac) { public void register(GenericWebApplicationContext wac) {
wac.registerBeanDefinition("viewResolver", new RootBeanDefinition(TestViewResolver.class)); wac.registerBeanDefinition("viewResolver", new RootBeanDefinition(TestViewResolver.class));
RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerMethodAdapter.class); RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerAdapter.class);
adapterDef.getPropertyValues().add("webBindingInitializer", new MyWebBindingInitializer()); adapterDef.getPropertyValues().add("webBindingInitializer", new MyWebBindingInitializer());
wac.registerBeanDefinition("handlerAdapter", adapterDef); wac.registerBeanDefinition("handlerAdapter", adapterDef);
} }
@ -575,7 +575,7 @@ public class ServletHandlerMethodTests {
initDispatcherServlet(MyTypedCommandProvidingFormController.class, new BeanDefinitionRegistrar() { initDispatcherServlet(MyTypedCommandProvidingFormController.class, new BeanDefinitionRegistrar() {
public void register(GenericWebApplicationContext wac) { public void register(GenericWebApplicationContext wac) {
wac.registerBeanDefinition("viewResolver", new RootBeanDefinition(TestViewResolver.class)); wac.registerBeanDefinition("viewResolver", new RootBeanDefinition(TestViewResolver.class));
RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerMethodAdapter.class); RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerAdapter.class);
adapterDef.getPropertyValues().add("webBindingInitializer", new MyWebBindingInitializer()); adapterDef.getPropertyValues().add("webBindingInitializer", new MyWebBindingInitializer());
List<HandlerMethodArgumentResolver> argumentResolvers = new ArrayList<HandlerMethodArgumentResolver>(); List<HandlerMethodArgumentResolver> argumentResolvers = new ArrayList<HandlerMethodArgumentResolver>();
argumentResolvers.add(new ServletWebArgumentResolverAdapter(new MySpecialArgumentResolver())); argumentResolvers.add(new ServletWebArgumentResolverAdapter(new MySpecialArgumentResolver()));
@ -817,7 +817,7 @@ public class ServletHandlerMethodTests {
public void register(GenericWebApplicationContext wac) { public void register(GenericWebApplicationContext wac) {
RootBeanDefinition converterDef = new RootBeanDefinition(StringHttpMessageConverter.class); RootBeanDefinition converterDef = new RootBeanDefinition(StringHttpMessageConverter.class);
converterDef.getPropertyValues().add("supportedMediaTypes", new MediaType("text", "plain")); converterDef.getPropertyValues().add("supportedMediaTypes", new MediaType("text", "plain"));
RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerMethodAdapter.class); RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerAdapter.class);
StringHttpMessageConverter converter = new StringHttpMessageConverter(); StringHttpMessageConverter converter = new StringHttpMessageConverter();
converter.setSupportedMediaTypes(Collections.singletonList(new MediaType("text", "plain"))); converter.setSupportedMediaTypes(Collections.singletonList(new MediaType("text", "plain")));
adapterDef.getPropertyValues().add("messageConverters", converter); adapterDef.getPropertyValues().add("messageConverters", converter);
@ -853,7 +853,7 @@ public class ServletHandlerMethodTests {
public void unsupportedRequestBody() throws ServletException, IOException { public void unsupportedRequestBody() throws ServletException, IOException {
initDispatcherServlet(RequestResponseBodyController.class, new BeanDefinitionRegistrar() { initDispatcherServlet(RequestResponseBodyController.class, new BeanDefinitionRegistrar() {
public void register(GenericWebApplicationContext wac) { public void register(GenericWebApplicationContext wac) {
RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerMethodAdapter.class); RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerAdapter.class);
adapterDef.getPropertyValues().add("messageConverters", new ByteArrayHttpMessageConverter()); adapterDef.getPropertyValues().add("messageConverters", new ByteArrayHttpMessageConverter());
wac.registerBeanDefinition("handlerAdapter", adapterDef); wac.registerBeanDefinition("handlerAdapter", adapterDef);
} }
@ -887,7 +887,7 @@ public class ServletHandlerMethodTests {
public void badRequestRequestBody() throws ServletException, IOException { public void badRequestRequestBody() throws ServletException, IOException {
initDispatcherServlet(RequestResponseBodyController.class, new BeanDefinitionRegistrar() { initDispatcherServlet(RequestResponseBodyController.class, new BeanDefinitionRegistrar() {
public void register(GenericWebApplicationContext wac) { public void register(GenericWebApplicationContext wac) {
RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerMethodAdapter.class); RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerAdapter.class);
adapterDef.getPropertyValues().add("messageConverters", new NotReadableMessageConverter()); adapterDef.getPropertyValues().add("messageConverters", new NotReadableMessageConverter());
wac.registerBeanDefinition("handlerAdapter", adapterDef); wac.registerBeanDefinition("handlerAdapter", adapterDef);
} }
@ -933,7 +933,7 @@ public class ServletHandlerMethodTests {
public void overlappingMesssageConvertersRequestBody() throws ServletException, IOException { public void overlappingMesssageConvertersRequestBody() throws ServletException, IOException {
initDispatcherServlet(RequestResponseBodyController.class, new BeanDefinitionRegistrar() { initDispatcherServlet(RequestResponseBodyController.class, new BeanDefinitionRegistrar() {
public void register(GenericWebApplicationContext wac) { public void register(GenericWebApplicationContext wac) {
RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerMethodAdapter.class); RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerAdapter.class);
List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>(); List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>();
messageConverters.add(new StringHttpMessageConverter()); messageConverters.add(new StringHttpMessageConverter());
messageConverters messageConverters
@ -977,7 +977,7 @@ public class ServletHandlerMethodTests {
} }
MarshallingHttpMessageConverter messageConverter = new MarshallingHttpMessageConverter(marshaller); MarshallingHttpMessageConverter messageConverter = new MarshallingHttpMessageConverter(marshaller);
RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerMethodAdapter.class); RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerAdapter.class);
adapterDef.getPropertyValues().add("messageConverters", messageConverter); adapterDef.getPropertyValues().add("messageConverters", messageConverter);
wac.registerBeanDefinition("handlerAdapter", adapterDef); wac.registerBeanDefinition("handlerAdapter", adapterDef);
} }
@ -1080,7 +1080,7 @@ public class ServletHandlerMethodTests {
public void mavResolver() throws ServletException, IOException { public void mavResolver() throws ServletException, IOException {
initDispatcherServlet(ModelAndViewResolverController.class, new BeanDefinitionRegistrar() { initDispatcherServlet(ModelAndViewResolverController.class, new BeanDefinitionRegistrar() {
public void register(GenericWebApplicationContext wac) { public void register(GenericWebApplicationContext wac) {
RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerMethodAdapter.class); RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerAdapter.class);
ModelAndViewResolver[] mavResolvers = new ModelAndViewResolver[] {new MyModelAndViewResolver()}; ModelAndViewResolver[] mavResolvers = new ModelAndViewResolver[] {new MyModelAndViewResolver()};
adapterDef.getPropertyValues().add("modelAndViewResolvers", mavResolvers); adapterDef.getPropertyValues().add("modelAndViewResolvers", mavResolvers);
wac.registerBeanDefinition("handlerAdapter", adapterDef); wac.registerBeanDefinition("handlerAdapter", adapterDef);
@ -1335,7 +1335,7 @@ public class ServletHandlerMethodTests {
RootBeanDefinition csDef = new RootBeanDefinition(FormattingConversionServiceFactoryBean.class); RootBeanDefinition csDef = new RootBeanDefinition(FormattingConversionServiceFactoryBean.class);
RootBeanDefinition wbiDef = new RootBeanDefinition(ConfigurableWebBindingInitializer.class); RootBeanDefinition wbiDef = new RootBeanDefinition(ConfigurableWebBindingInitializer.class);
wbiDef.getPropertyValues().add("conversionService", csDef); wbiDef.getPropertyValues().add("conversionService", csDef);
RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerMethodAdapter.class); RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerAdapter.class);
adapterDef.getPropertyValues().add("webBindingInitializer", wbiDef); adapterDef.getPropertyValues().add("webBindingInitializer", wbiDef);
wac.registerBeanDefinition("handlerAdapter", adapterDef); wac.registerBeanDefinition("handlerAdapter", adapterDef);
} }
@ -1735,7 +1735,7 @@ public class ServletHandlerMethodTests {
} }
@Controller @Controller
static class MyBinderInitializingCommandProvidingFormController static class MyBinderInitializingCommandProvidingFormController
extends MyCommandProvidingFormController<String, TestBean, ITestBean> { extends MyCommandProvidingFormController<String, TestBean, ITestBean> {
@SuppressWarnings("unused") @SuppressWarnings("unused")
@ -2621,7 +2621,7 @@ public class ServletHandlerMethodTests {
} }
@SuppressWarnings("serial") @SuppressWarnings("serial")
private void initDispatcherServlet(final Class<?> controllerClass, final BeanDefinitionRegistrar registrar) private void initDispatcherServlet(final Class<?> controllerClass, final BeanDefinitionRegistrar registrar)
throws ServletException { throws ServletException {
servlet = new DispatcherServlet() { servlet = new DispatcherServlet() {
@ -2630,10 +2630,10 @@ public class ServletHandlerMethodTests {
GenericWebApplicationContext wac = new GenericWebApplicationContext(); GenericWebApplicationContext wac = new GenericWebApplicationContext();
wac.registerBeanDefinition("controller", new RootBeanDefinition(controllerClass)); wac.registerBeanDefinition("controller", new RootBeanDefinition(controllerClass));
Class<?> mappingType = RequestMappingHandlerMethodMapping.class; Class<?> mappingType = RequestMappingHandlerMapping.class;
wac.registerBeanDefinition("handlerMapping", new RootBeanDefinition(mappingType)); wac.registerBeanDefinition("handlerMapping", new RootBeanDefinition(mappingType));
Class<?> adapterType = RequestMappingHandlerMethodAdapter.class; Class<?> adapterType = RequestMappingHandlerAdapter.class;
wac.registerBeanDefinition("handlerAdapter", new RootBeanDefinition(adapterType)); wac.registerBeanDefinition("handlerAdapter", new RootBeanDefinition(adapterType));
Class<?> resolverType = ExceptionHandlerExceptionResolver.class; Class<?> resolverType = ExceptionHandlerExceptionResolver.class;

View File

@ -46,9 +46,9 @@ import org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionRes
import org.springframework.web.servlet.mvc.annotation.UriTemplateServletAnnotationControllerTests; import org.springframework.web.servlet.mvc.annotation.UriTemplateServletAnnotationControllerTests;
import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver; import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver;
/** /**
* The origin of this test class is {@link UriTemplateServletAnnotationControllerTests} with the tests in this class * The origin of this test class is {@link UriTemplateServletAnnotationControllerTests} with the tests in this class
* adapted to run against the HandlerMethod infrastructure rather than against the DefaultAnnotationHandlerMapping, * adapted to run against the HandlerMethod infrastructure rather than against the DefaultAnnotationHandlerMapping,
* the AnnotationMethodHandlerAdapter, and the AnnotationMethodHandlerExceptionResolver. Tests that are not supported * the AnnotationMethodHandlerAdapter, and the AnnotationMethodHandlerExceptionResolver. Tests that are not supported
* are listed at the bottom. * are listed at the bottom.
* *
@ -259,7 +259,7 @@ public class UriTemplateServletHandlerMethodTests {
} }
/* /*
* See SPR-6640 * See SPR-6640
*/ */
@Test @Test
public void menuTree() throws Exception { public void menuTree() throws Exception {
@ -592,7 +592,7 @@ public class UriTemplateServletHandlerMethodTests {
} }
@SuppressWarnings("serial") @SuppressWarnings("serial")
private void initDispatcherServlet(final Class<?> controllerClass, final BeanDefinitionRegistrar registrar) private void initDispatcherServlet(final Class<?> controllerClass, final BeanDefinitionRegistrar registrar)
throws ServletException { throws ServletException {
servlet = new DispatcherServlet() { servlet = new DispatcherServlet() {
@ -601,10 +601,10 @@ public class UriTemplateServletHandlerMethodTests {
GenericWebApplicationContext wac = new GenericWebApplicationContext(); GenericWebApplicationContext wac = new GenericWebApplicationContext();
wac.registerBeanDefinition("controller", new RootBeanDefinition(controllerClass)); wac.registerBeanDefinition("controller", new RootBeanDefinition(controllerClass));
Class<?> mappingType = RequestMappingHandlerMethodMapping.class; Class<?> mappingType = RequestMappingHandlerMapping.class;
wac.registerBeanDefinition("handlerMapping", new RootBeanDefinition(mappingType)); wac.registerBeanDefinition("handlerMapping", new RootBeanDefinition(mappingType));
Class<?> adapterType = RequestMappingHandlerMethodAdapter.class; Class<?> adapterType = RequestMappingHandlerAdapter.class;
wac.registerBeanDefinition("handlerAdapter", new RootBeanDefinition(adapterType)); wac.registerBeanDefinition("handlerAdapter", new RootBeanDefinition(adapterType));
Class<?> resolverType = ExceptionHandlerExceptionResolver.class; Class<?> resolverType = ExceptionHandlerExceptionResolver.class;