use of org.springframework.web.method.support.HandlerMethodArgumentResolver in project spring-framework by spring-projects.
the class ExceptionHandlerExceptionResolverTests method setCustomArgumentResolvers.
@Test
public void setCustomArgumentResolvers() throws Exception {
HandlerMethodArgumentResolver resolver = new ServletRequestMethodArgumentResolver();
this.resolver.setCustomArgumentResolvers(Collections.singletonList(resolver));
this.resolver.afterPropertiesSet();
assertTrue(this.resolver.getArgumentResolvers().getResolvers().contains(resolver));
assertMethodProcessorCount(RESOLVER_COUNT + 1, HANDLER_COUNT);
}
use of org.springframework.web.method.support.HandlerMethodArgumentResolver in project spring-framework by spring-projects.
the class RequestMappingHandlerAdapterIntegrationTests method setup.
@Before
public void setup() throws Exception {
ConfigurableWebBindingInitializer bindingInitializer = new ConfigurableWebBindingInitializer();
bindingInitializer.setValidator(new StubValidator());
List<HandlerMethodArgumentResolver> customResolvers = new ArrayList<>();
customResolvers.add(new ServletWebArgumentResolverAdapter(new ColorArgumentResolver()));
GenericWebApplicationContext context = new GenericWebApplicationContext();
context.refresh();
handlerAdapter = new RequestMappingHandlerAdapter();
handlerAdapter.setWebBindingInitializer(bindingInitializer);
handlerAdapter.setCustomArgumentResolvers(customResolvers);
handlerAdapter.setApplicationContext(context);
handlerAdapter.setBeanFactory(context.getBeanFactory());
handlerAdapter.afterPropertiesSet();
request = new MockHttpServletRequest();
response = new MockHttpServletResponse();
request.setMethod("POST");
// Expose request to the current thread (for SpEL expressions)
RequestContextHolder.setRequestAttributes(new ServletWebRequest(request));
}
Aggregations