Rename RequestMapping types for concision
Remove 'Method' from RequestMappingHandlerMethodMapping and RequestMappingHandlerMethodAdapter
This commit is contained in:
parent
2092a31f9d
commit
1efb82d7cb
|
|
@ -49,8 +49,8 @@ import org.springframework.web.servlet.handler.ConversionServiceExposingIntercep
|
|||
import org.springframework.web.servlet.handler.MappedInterceptor;
|
||||
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.RequestMappingHandlerMethodAdapter;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMethodMapping;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
|
||||
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.support.DefaultHandlerExceptionResolver;
|
||||
import org.w3c.dom.Element;
|
||||
|
|
@ -105,7 +105,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
|
|||
CompositeComponentDefinition compDefinition = new CompositeComponentDefinition(element.getTagName(), source);
|
||||
parserContext.pushContainingComponent(compDefinition);
|
||||
|
||||
RootBeanDefinition methodMappingDef = new RootBeanDefinition(RequestMappingHandlerMethodMapping.class);
|
||||
RootBeanDefinition methodMappingDef = new RootBeanDefinition(RequestMappingHandlerMapping.class);
|
||||
methodMappingDef.setSource(source);
|
||||
methodMappingDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
methodMappingDef.getPropertyValues().add("order", 0);
|
||||
|
|
@ -125,7 +125,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
|
|||
ManagedList<?> messageConverters = getMessageConverters(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.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
methodAdapterDef.getPropertyValues().add("webBindingInitializer", bindingDef);
|
||||
|
|
|
|||
|
|
@ -65,8 +65,8 @@ import org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter;
|
|||
import org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter;
|
||||
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.RequestMappingHandlerMethodAdapter;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMethodMapping;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
|
||||
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:
|
||||
* <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 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.
|
||||
|
|
@ -91,7 +91,7 @@ import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolv
|
|||
*
|
||||
* <p>Registers these handler adapters:
|
||||
* <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 SimpleControllerHandlerAdapter} for processing requests with interface-based {@link Controller}s.
|
||||
* </ul>
|
||||
|
|
@ -139,8 +139,8 @@ class MvcConfiguration implements ApplicationContextAware, ServletContextAware {
|
|||
}
|
||||
|
||||
@Bean
|
||||
RequestMappingHandlerMethodMapping requestMappingHandlerMapping() {
|
||||
RequestMappingHandlerMethodMapping mapping = new RequestMappingHandlerMethodMapping();
|
||||
RequestMappingHandlerMapping requestMappingHandlerMapping() {
|
||||
RequestMappingHandlerMapping mapping = new RequestMappingHandlerMapping();
|
||||
mapping.setOrder(0);
|
||||
return mapping;
|
||||
}
|
||||
|
|
@ -176,8 +176,8 @@ class MvcConfiguration implements ApplicationContextAware, ServletContextAware {
|
|||
}
|
||||
|
||||
@Bean
|
||||
RequestMappingHandlerMethodAdapter requestMappingHandlerAdapter() {
|
||||
RequestMappingHandlerMethodAdapter adapter = new RequestMappingHandlerMethodAdapter();
|
||||
RequestMappingHandlerAdapter requestMappingHandlerAdapter() {
|
||||
RequestMappingHandlerAdapter adapter = new RequestMappingHandlerAdapter();
|
||||
|
||||
ConfigurableWebBindingInitializer bindingInitializer = new ConfigurableWebBindingInitializer();
|
||||
bindingInitializer.setConversionService(conversionService());
|
||||
|
|
@ -306,4 +306,4 @@ class MvcConfiguration implements ApplicationContextAware, ServletContextAware {
|
|||
return configurer.getMappedInterceptors();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,20 +62,20 @@ import org.springframework.web.servlet.mvc.method.annotation.support.ServletWebA
|
|||
import org.springframework.web.servlet.mvc.method.annotation.support.ViewMethodReturnValueHandler;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* 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
|
||||
* processing the request.
|
||||
*
|
||||
*
|
||||
* <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.
|
||||
* {@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
|
||||
* used for {@link RequestMapping} methods, which is described under {@link RequestMappingHandlerMethodAdapter}.
|
||||
*
|
||||
* <p>See {@link ExceptionHandler} for information on supported method arguments and return values for
|
||||
* exception-handling methods.
|
||||
*
|
||||
* 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
|
||||
* exception-handling methods.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 3.1
|
||||
*/
|
||||
|
|
@ -88,7 +88,7 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce
|
|||
|
||||
private List<HttpMessageConverter<?>> messageConverters;
|
||||
|
||||
private final Map<Class<?>, ExceptionMethodMapping> exceptionMethodMappingCache =
|
||||
private final Map<Class<?>, ExceptionMethodMapping> exceptionMethodMappingCache =
|
||||
new ConcurrentHashMap<Class<?>, ExceptionMethodMapping>();
|
||||
|
||||
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
|
||||
* 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}
|
||||
* or preferably converted to a {@link HandlerMethodArgumentResolver} instead.
|
||||
* <p>An existing {@link WebArgumentResolver} can either adapted with {@link ServletWebArgumentResolverAdapter}
|
||||
* or preferably converted to a {@link HandlerMethodArgumentResolver} instead.
|
||||
*/
|
||||
public void setCustomArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
|
||||
this.customArgumentResolvers= argumentResolvers;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* 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
|
||||
* {@link #setCustomArgumentResolvers(List)}, which does not override default registrations.
|
||||
* @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.
|
||||
* Custom return value handlers are given a chance to handle a return value before the standard
|
||||
* 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
|
||||
* 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) {
|
||||
this.customReturnValueHandlers = returnValueHandlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* {@link #setCustomReturnValueHandlers(List)}, which does not override default registrations.
|
||||
* 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
|
||||
* {@link #setCustomReturnValueHandlers(List)}, which does not override default registrations.
|
||||
* @param returnValueHandlers the return value handlers for {@link ExceptionHandler} methods
|
||||
*/
|
||||
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
|
||||
*/
|
||||
@Override
|
||||
protected ModelAndView doResolveHandlerMethodException(HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
HandlerMethod handlerMethod,
|
||||
protected ModelAndView doResolveHandlerMethodException(HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
HandlerMethod handlerMethod,
|
||||
Exception ex) {
|
||||
if (handlerMethod != null) {
|
||||
ExceptionMethodMapping mapping = getExceptionMethodMapping(handlerMethod);
|
||||
|
|
@ -242,12 +242,12 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce
|
|||
mav.setViewName(mavContainer.getViewName());
|
||||
if (mavContainer.getView() != null) {
|
||||
mav.setView((View) mavContainer.getView());
|
||||
}
|
||||
}
|
||||
return mav;
|
||||
}
|
||||
}
|
||||
catch (Exception invocationEx) {
|
||||
logger.error("Invoking exception-handling method resulted in exception : " +
|
||||
logger.error("Invoking exception-handling method resulted in exception : " +
|
||||
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) {
|
||||
Class<?> handlerType = handlerMethod.getBeanType();
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ import org.springframework.web.util.WebUtils;
|
|||
* @see HandlerMethodArgumentResolver
|
||||
* @see HandlerMethodReturnValueHandler
|
||||
*/
|
||||
public class RequestMappingHandlerMethodAdapter extends AbstractHandlerMethodAdapter implements BeanFactoryAware,
|
||||
public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter implements BeanFactoryAware,
|
||||
InitializingBean {
|
||||
|
||||
private List<HandlerMethodArgumentResolver> customArgumentResolvers;
|
||||
|
|
@ -155,9 +155,9 @@ public class RequestMappingHandlerMethodAdapter extends AbstractHandlerMethodAda
|
|||
private HandlerMethodArgumentResolverComposite initBinderArgumentResolvers;
|
||||
|
||||
/**
|
||||
* Create a {@link RequestMappingHandlerMethodAdapter} instance.
|
||||
* Create a {@link RequestMappingHandlerAdapter} instance.
|
||||
*/
|
||||
public RequestMappingHandlerMethodAdapter() {
|
||||
public RequestMappingHandlerAdapter() {
|
||||
|
||||
StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter();
|
||||
stringHttpMessageConverter.setWriteAcceptCharset(false); // See SPR-7316
|
||||
|
|
@ -46,14 +46,14 @@ import org.springframework.web.servlet.handler.MappedInterceptors;
|
|||
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.
|
||||
*
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @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();
|
||||
|
||||
|
|
@ -87,7 +87,7 @@ public class RequestMappingHandlerMethodMapping extends AbstractHandlerMethodMap
|
|||
|
||||
/**
|
||||
* {@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.
|
||||
*/
|
||||
@Override
|
||||
|
|
@ -97,9 +97,9 @@ public class RequestMappingHandlerMethodMapping extends AbstractHandlerMethodMap
|
|||
}
|
||||
|
||||
/**
|
||||
* Provides a {@link RequestMappingInfo} for the given method.
|
||||
* <p>Only {@link RequestMapping @RequestMapping}-annotated methods are considered.
|
||||
* Type-level {@link RequestMapping @RequestMapping} annotations are also detected and their
|
||||
* Provides a {@link RequestMappingInfo} for the given method.
|
||||
* <p>Only {@link RequestMapping @RequestMapping}-annotated methods are considered.
|
||||
* Type-level {@link RequestMapping @RequestMapping} annotations are also detected and their
|
||||
* attributes combined with method-level {@link RequestMapping @RequestMapping} attributes.
|
||||
*
|
||||
* @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
|
||||
* specific request. For example not all {@link RequestMappingInfo} patterns may apply to the current request.
|
||||
* 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.
|
||||
* Therefore an HttpServletRequest is required as input.
|
||||
*
|
||||
* <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
|
||||
* <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
|
||||
* 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> {
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ import org.springframework.web.context.request.NativeWebRequest;
|
|||
import org.springframework.web.context.support.GenericWebApplicationContext;
|
||||
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||
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.support.ServletWebArgumentResolverAdapter;
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ public class AnnotationDrivenBeanDefinitionParserTests {
|
|||
@Test
|
||||
public void testMessageCodesResolver() {
|
||||
loadBeanDefinitions("mvc-config-message-codes-resolver.xml");
|
||||
RequestMappingHandlerMethodAdapter adapter = appContext.getBean(RequestMappingHandlerMethodAdapter.class);
|
||||
RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.class);
|
||||
assertNotNull(adapter);
|
||||
Object initializer = new DirectFieldAccessor(adapter).getPropertyValue("webBindingInitializer");
|
||||
assertNotNull(initializer);
|
||||
|
|
@ -70,14 +70,14 @@ public class AnnotationDrivenBeanDefinitionParserTests {
|
|||
@Test
|
||||
public void testMessageConverters() {
|
||||
loadBeanDefinitions("mvc-config-message-converters.xml");
|
||||
verifyMessageConverters(appContext.getBean(RequestMappingHandlerMethodAdapter.class), true);
|
||||
verifyMessageConverters(appContext.getBean(RequestMappingHandlerAdapter.class), true);
|
||||
verifyMessageConverters(appContext.getBean(ExceptionHandlerExceptionResolver.class), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMessageConvertersWithoutDefaultRegistrations() {
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ public class AnnotationDrivenBeanDefinitionParserTests {
|
|||
@Test
|
||||
public void testArgumentResolvers() {
|
||||
loadBeanDefinitions("mvc-config-argument-resolvers.xml");
|
||||
RequestMappingHandlerMethodAdapter adapter = appContext.getBean(RequestMappingHandlerMethodAdapter.class);
|
||||
RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.class);
|
||||
assertNotNull(adapter);
|
||||
Object value = new DirectFieldAccessor(adapter).getPropertyValue("customArgumentResolvers");
|
||||
assertNotNull(value);
|
||||
|
|
@ -109,7 +109,7 @@ public class AnnotationDrivenBeanDefinitionParserTests {
|
|||
Object value = new DirectFieldAccessor(bean).getPropertyValue("messageConverters");
|
||||
assertNotNull(value);
|
||||
assertTrue(value instanceof List);
|
||||
List<HttpMessageConverter<?>> converters = (List<HttpMessageConverter<?>>) value;
|
||||
List<HttpMessageConverter<?>> converters = (List<HttpMessageConverter<?>>) value;
|
||||
if (hasDefaultRegistrations) {
|
||||
assertTrue("Default converters are registered in addition to custom ones", converters.size() > 2);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -67,15 +67,15 @@ import org.springframework.web.servlet.handler.WebRequestHandlerInterceptorAdapt
|
|||
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
|
||||
import org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter;
|
||||
import org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMethodAdapter;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMethodMapping;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
|
||||
import org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler;
|
||||
import org.springframework.web.servlet.resource.ResourceHttpRequestHandler;
|
||||
import org.springframework.web.servlet.theme.ThemeChangeInterceptor;
|
||||
|
||||
/**
|
||||
* @author Keith Donald
|
||||
* @author Arjen Poutsma
|
||||
* @author Arjen Poutsma
|
||||
* @author Jeremy Grelle
|
||||
*/
|
||||
public class MvcNamespaceTests {
|
||||
|
|
@ -104,12 +104,12 @@ public class MvcNamespaceTests {
|
|||
assertEquals(8, appContext.getBeanDefinitionCount());
|
||||
appContext.refresh();
|
||||
|
||||
RequestMappingHandlerMethodMapping mapping = appContext.getBean(RequestMappingHandlerMethodMapping.class);
|
||||
RequestMappingHandlerMapping mapping = appContext.getBean(RequestMappingHandlerMapping.class);
|
||||
assertNotNull(mapping);
|
||||
assertEquals(0, mapping.getOrder());
|
||||
mapping.setDefaultHandler(handlerMethod);
|
||||
|
||||
RequestMappingHandlerMethodAdapter adapter = appContext.getBean(RequestMappingHandlerMethodAdapter.class);
|
||||
RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.class);
|
||||
assertNotNull(adapter);
|
||||
|
||||
List<HttpMessageConverter<?>> messageConverters = adapter.getMessageConverters();
|
||||
|
|
@ -143,7 +143,7 @@ public class MvcNamespaceTests {
|
|||
assertEquals(8, appContext.getBeanDefinitionCount());
|
||||
appContext.refresh();
|
||||
|
||||
RequestMappingHandlerMethodMapping mapping = appContext.getBean(RequestMappingHandlerMethodMapping.class);
|
||||
RequestMappingHandlerMapping mapping = appContext.getBean(RequestMappingHandlerMapping.class);
|
||||
assertNotNull(mapping);
|
||||
mapping.setDefaultHandler(handlerMethod);
|
||||
|
||||
|
|
@ -160,7 +160,7 @@ public class MvcNamespaceTests {
|
|||
interceptor.preHandle(request, response, handler);
|
||||
assertSame(appContext.getBean("conversionService"), request.getAttribute(ConversionService.class.getName()));
|
||||
|
||||
RequestMappingHandlerMethodAdapter adapter = appContext.getBean(RequestMappingHandlerMethodAdapter.class);
|
||||
RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.class);
|
||||
assertNotNull(adapter);
|
||||
adapter.handle(request, response, handlerMethod);
|
||||
}
|
||||
|
|
@ -172,7 +172,7 @@ public class MvcNamespaceTests {
|
|||
assertEquals(8, appContext.getBeanDefinitionCount());
|
||||
appContext.refresh();
|
||||
|
||||
RequestMappingHandlerMethodAdapter adapter = appContext.getBean(RequestMappingHandlerMethodAdapter.class);
|
||||
RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.class);
|
||||
assertNotNull(adapter);
|
||||
|
||||
// default web binding initializer behavior test
|
||||
|
|
@ -192,7 +192,7 @@ public class MvcNamespaceTests {
|
|||
assertEquals(11, appContext.getBeanDefinitionCount());
|
||||
appContext.refresh();
|
||||
|
||||
RequestMappingHandlerMethodMapping mapping = appContext.getBean(RequestMappingHandlerMethodMapping.class);
|
||||
RequestMappingHandlerMapping mapping = appContext.getBean(RequestMappingHandlerMapping.class);
|
||||
assertNotNull(mapping);
|
||||
mapping.setDefaultHandler(handlerMethod);
|
||||
|
||||
|
|
@ -327,7 +327,7 @@ public class MvcNamespaceTests {
|
|||
assertEquals(10, appContext.getBeanDefinitionCount());
|
||||
appContext.refresh();
|
||||
|
||||
RequestMappingHandlerMethodMapping mapping = appContext.getBean(RequestMappingHandlerMethodMapping.class);
|
||||
RequestMappingHandlerMapping mapping = appContext.getBean(RequestMappingHandlerMapping.class);
|
||||
assertNotNull(mapping);
|
||||
mapping.setDefaultHandler(handlerMethod);
|
||||
|
||||
|
|
@ -351,7 +351,7 @@ public class MvcNamespaceTests {
|
|||
assertEquals(12, appContext.getBeanDefinitionCount());
|
||||
appContext.refresh();
|
||||
|
||||
RequestMappingHandlerMethodMapping mapping = appContext.getBean(RequestMappingHandlerMethodMapping.class);
|
||||
RequestMappingHandlerMapping mapping = appContext.getBean(RequestMappingHandlerMapping.class);
|
||||
assertNotNull(mapping);
|
||||
mapping.setDefaultHandler(handlerMethod);
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
|
|||
import org.springframework.web.servlet.HandlerExceptionResolver;
|
||||
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.RequestMappingHandlerMethodAdapter;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
|
||||
import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver;
|
||||
|
||||
/**
|
||||
|
|
@ -75,7 +75,7 @@ public class MvcConfigurationTests {
|
|||
configurer.configureMessageConverters(capture(converters));
|
||||
replay(configurer);
|
||||
|
||||
RequestMappingHandlerMethodAdapter adapter = mvcConfiguration.requestMappingHandlerAdapter();
|
||||
RequestMappingHandlerAdapter adapter = mvcConfiguration.requestMappingHandlerAdapter();
|
||||
|
||||
ConfigurableWebBindingInitializer initializer = (ConfigurableWebBindingInitializer) adapter.getWebBindingInitializer();
|
||||
assertSame(conversionService.getValue(), initializer.getConversionService());
|
||||
|
|
|
|||
|
|
@ -38,17 +38,17 @@ import org.springframework.web.context.support.GenericWebApplicationContext;
|
|||
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.
|
||||
*
|
||||
* Note the following:
|
||||
* <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.
|
||||
* <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.
|
||||
* </ul>
|
||||
*
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
@RunWith(Parameterized.class)
|
||||
|
|
@ -56,13 +56,13 @@ public class HandlerMethodMappingAnnotationDetectionTests {
|
|||
|
||||
@Parameters
|
||||
public static Collection<Object[]> handlerTypes() {
|
||||
return Arrays.asList(new Object[][] {
|
||||
{ new MappingInterfaceController(), false},
|
||||
{ new MappingAbstractClassController(), false},
|
||||
{ new ParameterizedInterfaceController(), false },
|
||||
return Arrays.asList(new Object[][] {
|
||||
{ new MappingInterfaceController(), false},
|
||||
{ new MappingAbstractClassController(), false},
|
||||
{ new ParameterizedInterfaceController(), false },
|
||||
{ new MappingParameterizedInterfaceController(), false },
|
||||
{ new MappingClassController(), false },
|
||||
{ new MappingAbstractClassController(), true},
|
||||
{ new MappingClassController(), false },
|
||||
{ new MappingAbstractClassController(), true},
|
||||
{ new PlainController(), true}
|
||||
});
|
||||
}
|
||||
|
|
@ -80,13 +80,13 @@ public class HandlerMethodMappingAnnotationDetectionTests {
|
|||
public void detectAndMapHandlerMethod() throws Exception {
|
||||
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();
|
||||
|
||||
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();
|
||||
wac.registerBeanDefinition("controller", new RootBeanDefinition(controllerType));
|
||||
if (useAutoProxy) {
|
||||
|
|
@ -96,7 +96,7 @@ public class HandlerMethodMappingAnnotationDetectionTests {
|
|||
wac.getBeanFactory().registerSingleton("advsr", new DefaultPointcutAdvisor(new SimpleTraceInterceptor()));
|
||||
}
|
||||
|
||||
RequestMappingHandlerMethodMapping mapping = new RequestMappingHandlerMethodMapping();
|
||||
RequestMappingHandlerMapping mapping = new RequestMappingHandlerMapping();
|
||||
mapping.setApplicationContext(wac);
|
||||
return mapping;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,20 +33,20 @@ import static java.util.Arrays.*;
|
|||
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 Rossen Stoyanchev
|
||||
*/
|
||||
public class RequestKeyComparatorTests {
|
||||
|
||||
private RequestMappingHandlerMethodMapping handlerMapping;
|
||||
private RequestMappingHandlerMapping handlerMapping;
|
||||
|
||||
private MockHttpServletRequest request;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.handlerMapping = new RequestMappingHandlerMethodMapping();
|
||||
this.handlerMapping = new RequestMappingHandlerMapping();
|
||||
this.request = new MockHttpServletRequest();
|
||||
}
|
||||
|
||||
|
|
@ -110,7 +110,7 @@ public class RequestKeyComparatorTests {
|
|||
assertEquals(empty, list.get(2));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test
|
||||
@Ignore // TODO : remove ignore
|
||||
public void acceptHeaders() {
|
||||
RequestMappingInfo html = new RequestMappingInfo(null, null, null, RequestConditionFactory.parseHeaders("accept=text/html"), null);
|
||||
|
|
|
|||
|
|
@ -82,24 +82,24 @@ import org.springframework.web.servlet.ModelAndView;
|
|||
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.
|
||||
* Once a problem has been debugged and understood, tests demonstrating the issue are preferably added to the
|
||||
* 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
|
||||
* appropriate, more fine-grained test fixture.
|
||||
*
|
||||
*
|
||||
* <p>If you wish to add high-level tests, consider the following other "integration"-style tests:
|
||||
* <ul>
|
||||
* <li>{@link HandlerMethodAdapterAnnotationDetectionTests}
|
||||
* <li>{@link HandlerMethodAdapterAnnotationDetectionTests}
|
||||
* <li>{@link HandlerMethodMappingAnnotationDetectionTests}
|
||||
* <li>{@link ServletHandlerMethodTests}
|
||||
* </ul>
|
||||
*
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class RequestMappingHandlerMethodAdapterIntegrationTests {
|
||||
public class RequestMappingHandlerAdapterIntegrationTests {
|
||||
|
||||
private final Object handler = new Handler();
|
||||
|
||||
private RequestMappingHandlerMethodAdapter handlerAdapter;
|
||||
private RequestMappingHandlerAdapter handlerAdapter;
|
||||
|
||||
private MockHttpServletRequest request;
|
||||
|
||||
|
|
@ -116,7 +116,7 @@ public class RequestMappingHandlerMethodAdapterIntegrationTests {
|
|||
GenericWebApplicationContext context = new GenericWebApplicationContext();
|
||||
context.refresh();
|
||||
|
||||
handlerAdapter = new RequestMappingHandlerMethodAdapter();
|
||||
handlerAdapter = new RequestMappingHandlerAdapter();
|
||||
handlerAdapter.setWebBindingInitializer(bindingInitializer);
|
||||
handlerAdapter.setCustomArgumentResolvers(customResolvers);
|
||||
handlerAdapter.setApplicationContext(context);
|
||||
|
|
@ -161,7 +161,7 @@ public class RequestMappingHandlerMethodAdapterIntegrationTests {
|
|||
|
||||
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>();
|
||||
uriTemplateVars.put("pathvar", "pathvarValue");
|
||||
request.setAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriTemplateVars);
|
||||
|
|
@ -274,14 +274,14 @@ public class RequestMappingHandlerMethodAdapterIntegrationTests {
|
|||
}
|
||||
|
||||
public String handleMvc(
|
||||
@CookieValue("cookie") int cookie,
|
||||
@CookieValue("cookie") int cookie,
|
||||
@PathVariable("pathvar") String pathvar,
|
||||
@RequestHeader("header") String header,
|
||||
@RequestHeader(defaultValue="#{systemProperties.systemHeader}") String systemHeader,
|
||||
@RequestHeader Map<String, Object> headerMap,
|
||||
@RequestParam("dateParam") Date dateParam,
|
||||
@RequestParam("dateParam") Date dateParam,
|
||||
@RequestParam Map<String, Object> paramMap,
|
||||
String paramByConvention,
|
||||
String paramByConvention,
|
||||
@Value("#{request.contextPath}") String value,
|
||||
@ModelAttribute("modelAttr") @Valid TestBean modelAttr,
|
||||
Errors errors,
|
||||
|
|
@ -31,20 +31,20 @@ import org.springframework.web.method.HandlerMethod;
|
|||
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:
|
||||
* <ul>
|
||||
* <li>{@link ServletHandlerMethodTests}
|
||||
* <li>{@link RequestMappingHandlerMethodAdapterIntegrationTests}
|
||||
* <li>{@link RequestMappingHandlerAdapterIntegrationTests}
|
||||
* <li>{@link HandlerMethodAdapterAnnotationDetectionTests}
|
||||
* </ul>
|
||||
*
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class RequestMappingHandlerMethodAdapterTests {
|
||||
public class RequestMappingHandlerAdapterTests {
|
||||
|
||||
private RequestMappingHandlerMethodAdapter handlerAdapter;
|
||||
private RequestMappingHandlerAdapter handlerAdapter;
|
||||
|
||||
private MockHttpServletRequest request;
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ public class RequestMappingHandlerMethodAdapterTests {
|
|||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
this.handlerAdapter = new RequestMappingHandlerMethodAdapter();
|
||||
this.handlerAdapter = new RequestMappingHandlerAdapter();
|
||||
this.handlerAdapter.setApplicationContext(new GenericWebApplicationContext());
|
||||
this.handlerAdapter.afterPropertiesSet();
|
||||
|
||||
|
|
@ -43,14 +43,14 @@ import org.springframework.web.servlet.handler.MappedInterceptor;
|
|||
import org.springframework.web.util.UrlPathHelper;
|
||||
|
||||
/**
|
||||
* Test fixture with {@link RequestMappingHandlerMethodMapping}.
|
||||
*
|
||||
* Test fixture with {@link RequestMappingHandlerMapping}.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class RequestMappingHandlerMethodMappingTests {
|
||||
public class RequestMappingHandlerMappingTests {
|
||||
|
||||
private RequestMappingHandlerMethodMapping mapping;
|
||||
private RequestMappingHandlerMapping mapping;
|
||||
|
||||
private Handler handler;
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ public class RequestMappingHandlerMethodMappingTests {
|
|||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
context.registerSingleton("handler", handler.getClass());
|
||||
|
||||
mapping = new RequestMappingHandlerMethodMapping();
|
||||
mapping = new RequestMappingHandlerMapping();
|
||||
mapping.setApplicationContext(context);
|
||||
}
|
||||
|
||||
|
|
@ -143,11 +143,11 @@ import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolv
|
|||
import org.springframework.web.servlet.view.InternalResourceViewResolver;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* AnnotationMethodHandlerAdapter, and the AnnotationMethodHandlerExceptionResolver. Tests that are not
|
||||
* 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
|
||||
* AnnotationMethodHandlerAdapter, and the AnnotationMethodHandlerExceptionResolver. Tests that are not
|
||||
* supported are listed at the bottom.
|
||||
*
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 3.1
|
||||
*/
|
||||
|
|
@ -263,7 +263,7 @@ public class ServletHandlerMethodTests {
|
|||
csDef.getPropertyValues().add("converters", new TestBeanConverter());
|
||||
RootBeanDefinition wbiDef = new RootBeanDefinition(ConfigurableWebBindingInitializer.class);
|
||||
wbiDef.getPropertyValues().add("conversionService", csDef);
|
||||
RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerMethodAdapter.class);
|
||||
RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerAdapter.class);
|
||||
adapterDef.getPropertyValues().add("webBindingInitializer", wbiDef);
|
||||
context.registerBeanDefinition("handlerAdapter", adapterDef);
|
||||
}
|
||||
|
|
@ -555,7 +555,7 @@ public class ServletHandlerMethodTests {
|
|||
initDispatcherServlet(MyCommandProvidingFormController.class, new BeanDefinitionRegistrar() {
|
||||
public void register(GenericWebApplicationContext wac) {
|
||||
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());
|
||||
wac.registerBeanDefinition("handlerAdapter", adapterDef);
|
||||
}
|
||||
|
|
@ -575,7 +575,7 @@ public class ServletHandlerMethodTests {
|
|||
initDispatcherServlet(MyTypedCommandProvidingFormController.class, new BeanDefinitionRegistrar() {
|
||||
public void register(GenericWebApplicationContext wac) {
|
||||
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());
|
||||
List<HandlerMethodArgumentResolver> argumentResolvers = new ArrayList<HandlerMethodArgumentResolver>();
|
||||
argumentResolvers.add(new ServletWebArgumentResolverAdapter(new MySpecialArgumentResolver()));
|
||||
|
|
@ -817,7 +817,7 @@ public class ServletHandlerMethodTests {
|
|||
public void register(GenericWebApplicationContext wac) {
|
||||
RootBeanDefinition converterDef = new RootBeanDefinition(StringHttpMessageConverter.class);
|
||||
converterDef.getPropertyValues().add("supportedMediaTypes", new MediaType("text", "plain"));
|
||||
RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerMethodAdapter.class);
|
||||
RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerAdapter.class);
|
||||
StringHttpMessageConverter converter = new StringHttpMessageConverter();
|
||||
converter.setSupportedMediaTypes(Collections.singletonList(new MediaType("text", "plain")));
|
||||
adapterDef.getPropertyValues().add("messageConverters", converter);
|
||||
|
|
@ -853,7 +853,7 @@ public class ServletHandlerMethodTests {
|
|||
public void unsupportedRequestBody() throws ServletException, IOException {
|
||||
initDispatcherServlet(RequestResponseBodyController.class, new BeanDefinitionRegistrar() {
|
||||
public void register(GenericWebApplicationContext wac) {
|
||||
RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerMethodAdapter.class);
|
||||
RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerAdapter.class);
|
||||
adapterDef.getPropertyValues().add("messageConverters", new ByteArrayHttpMessageConverter());
|
||||
wac.registerBeanDefinition("handlerAdapter", adapterDef);
|
||||
}
|
||||
|
|
@ -887,7 +887,7 @@ public class ServletHandlerMethodTests {
|
|||
public void badRequestRequestBody() throws ServletException, IOException {
|
||||
initDispatcherServlet(RequestResponseBodyController.class, new BeanDefinitionRegistrar() {
|
||||
public void register(GenericWebApplicationContext wac) {
|
||||
RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerMethodAdapter.class);
|
||||
RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerAdapter.class);
|
||||
adapterDef.getPropertyValues().add("messageConverters", new NotReadableMessageConverter());
|
||||
wac.registerBeanDefinition("handlerAdapter", adapterDef);
|
||||
}
|
||||
|
|
@ -933,7 +933,7 @@ public class ServletHandlerMethodTests {
|
|||
public void overlappingMesssageConvertersRequestBody() throws ServletException, IOException {
|
||||
initDispatcherServlet(RequestResponseBodyController.class, new BeanDefinitionRegistrar() {
|
||||
public void register(GenericWebApplicationContext wac) {
|
||||
RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerMethodAdapter.class);
|
||||
RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerAdapter.class);
|
||||
List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>();
|
||||
messageConverters.add(new StringHttpMessageConverter());
|
||||
messageConverters
|
||||
|
|
@ -977,7 +977,7 @@ public class ServletHandlerMethodTests {
|
|||
}
|
||||
MarshallingHttpMessageConverter messageConverter = new MarshallingHttpMessageConverter(marshaller);
|
||||
|
||||
RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerMethodAdapter.class);
|
||||
RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerAdapter.class);
|
||||
adapterDef.getPropertyValues().add("messageConverters", messageConverter);
|
||||
wac.registerBeanDefinition("handlerAdapter", adapterDef);
|
||||
}
|
||||
|
|
@ -1080,7 +1080,7 @@ public class ServletHandlerMethodTests {
|
|||
public void mavResolver() throws ServletException, IOException {
|
||||
initDispatcherServlet(ModelAndViewResolverController.class, new BeanDefinitionRegistrar() {
|
||||
public void register(GenericWebApplicationContext wac) {
|
||||
RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerMethodAdapter.class);
|
||||
RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerAdapter.class);
|
||||
ModelAndViewResolver[] mavResolvers = new ModelAndViewResolver[] {new MyModelAndViewResolver()};
|
||||
adapterDef.getPropertyValues().add("modelAndViewResolvers", mavResolvers);
|
||||
wac.registerBeanDefinition("handlerAdapter", adapterDef);
|
||||
|
|
@ -1335,7 +1335,7 @@ public class ServletHandlerMethodTests {
|
|||
RootBeanDefinition csDef = new RootBeanDefinition(FormattingConversionServiceFactoryBean.class);
|
||||
RootBeanDefinition wbiDef = new RootBeanDefinition(ConfigurableWebBindingInitializer.class);
|
||||
wbiDef.getPropertyValues().add("conversionService", csDef);
|
||||
RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerMethodAdapter.class);
|
||||
RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerAdapter.class);
|
||||
adapterDef.getPropertyValues().add("webBindingInitializer", wbiDef);
|
||||
wac.registerBeanDefinition("handlerAdapter", adapterDef);
|
||||
}
|
||||
|
|
@ -1735,7 +1735,7 @@ public class ServletHandlerMethodTests {
|
|||
}
|
||||
|
||||
@Controller
|
||||
static class MyBinderInitializingCommandProvidingFormController
|
||||
static class MyBinderInitializingCommandProvidingFormController
|
||||
extends MyCommandProvidingFormController<String, TestBean, ITestBean> {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
|
@ -2621,7 +2621,7 @@ public class ServletHandlerMethodTests {
|
|||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private void initDispatcherServlet(final Class<?> controllerClass, final BeanDefinitionRegistrar registrar)
|
||||
private void initDispatcherServlet(final Class<?> controllerClass, final BeanDefinitionRegistrar registrar)
|
||||
throws ServletException {
|
||||
|
||||
servlet = new DispatcherServlet() {
|
||||
|
|
@ -2630,10 +2630,10 @@ public class ServletHandlerMethodTests {
|
|||
GenericWebApplicationContext wac = new GenericWebApplicationContext();
|
||||
wac.registerBeanDefinition("controller", new RootBeanDefinition(controllerClass));
|
||||
|
||||
Class<?> mappingType = RequestMappingHandlerMethodMapping.class;
|
||||
Class<?> mappingType = RequestMappingHandlerMapping.class;
|
||||
wac.registerBeanDefinition("handlerMapping", new RootBeanDefinition(mappingType));
|
||||
|
||||
Class<?> adapterType = RequestMappingHandlerMethodAdapter.class;
|
||||
Class<?> adapterType = RequestMappingHandlerAdapter.class;
|
||||
wac.registerBeanDefinition("handlerAdapter", new RootBeanDefinition(adapterType));
|
||||
|
||||
Class<?> resolverType = ExceptionHandlerExceptionResolver.class;
|
||||
|
|
|
|||
|
|
@ -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.support.DefaultHandlerExceptionResolver;
|
||||
|
||||
/**
|
||||
/**
|
||||
* 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
|
||||
* are listed at the bottom.
|
||||
*
|
||||
|
|
@ -259,7 +259,7 @@ public class UriTemplateServletHandlerMethodTests {
|
|||
}
|
||||
|
||||
/*
|
||||
* See SPR-6640
|
||||
* See SPR-6640
|
||||
*/
|
||||
@Test
|
||||
public void menuTree() throws Exception {
|
||||
|
|
@ -592,7 +592,7 @@ public class UriTemplateServletHandlerMethodTests {
|
|||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private void initDispatcherServlet(final Class<?> controllerClass, final BeanDefinitionRegistrar registrar)
|
||||
private void initDispatcherServlet(final Class<?> controllerClass, final BeanDefinitionRegistrar registrar)
|
||||
throws ServletException {
|
||||
|
||||
servlet = new DispatcherServlet() {
|
||||
|
|
@ -601,10 +601,10 @@ public class UriTemplateServletHandlerMethodTests {
|
|||
GenericWebApplicationContext wac = new GenericWebApplicationContext();
|
||||
wac.registerBeanDefinition("controller", new RootBeanDefinition(controllerClass));
|
||||
|
||||
Class<?> mappingType = RequestMappingHandlerMethodMapping.class;
|
||||
Class<?> mappingType = RequestMappingHandlerMapping.class;
|
||||
wac.registerBeanDefinition("handlerMapping", new RootBeanDefinition(mappingType));
|
||||
|
||||
Class<?> adapterType = RequestMappingHandlerMethodAdapter.class;
|
||||
Class<?> adapterType = RequestMappingHandlerAdapter.class;
|
||||
wac.registerBeanDefinition("handlerAdapter", new RootBeanDefinition(adapterType));
|
||||
|
||||
Class<?> resolverType = ExceptionHandlerExceptionResolver.class;
|
||||
|
|
|
|||
Loading…
Reference in New Issue