use of org.springframework.web.method.support.HandlerMethodArgumentResolver in project spring-framework by spring-projects.
the class ExceptionHandlerExceptionResolverTests method setArgumentResolvers.
@Test
void setArgumentResolvers() {
HandlerMethodArgumentResolver resolver = new ServletRequestMethodArgumentResolver();
this.resolver.setArgumentResolvers(Collections.singletonList(resolver));
this.resolver.afterPropertiesSet();
assertMethodProcessorCount(1, HANDLER_COUNT);
}
use of org.springframework.web.method.support.HandlerMethodArgumentResolver in project spring-framework by spring-projects.
the class ExceptionHandlerExceptionResolverTests method setCustomArgumentResolvers.
@Test
void setCustomArgumentResolvers() {
HandlerMethodArgumentResolver resolver = new ServletRequestMethodArgumentResolver();
this.resolver.setCustomArgumentResolvers(Collections.singletonList(resolver));
this.resolver.afterPropertiesSet();
assertThat(this.resolver.getArgumentResolvers().getResolvers().contains(resolver)).isTrue();
assertMethodProcessorCount(RESOLVER_COUNT + 1, HANDLER_COUNT);
}
use of org.springframework.web.method.support.HandlerMethodArgumentResolver in project spring-framework by spring-projects.
the class TestPathHelper method testArgumentResolvers.
private void testArgumentResolvers(Object bean) {
assertThat(bean).isNotNull();
Object value = new DirectFieldAccessor(bean).getPropertyValue("customArgumentResolvers");
assertThat(value).isNotNull();
assertThat(value instanceof List).isTrue();
@SuppressWarnings("unchecked") List<HandlerMethodArgumentResolver> resolvers = (List<HandlerMethodArgumentResolver>) value;
assertThat(resolvers.size()).isEqualTo(3);
assertThat(resolvers.get(0) instanceof ServletWebArgumentResolverAdapter).isTrue();
assertThat(resolvers.get(1) instanceof TestHandlerMethodArgumentResolver).isTrue();
assertThat(resolvers.get(2) instanceof TestHandlerMethodArgumentResolver).isTrue();
assertThat(resolvers.get(2)).isNotSameAs(resolvers.get(1));
}
use of org.springframework.web.method.support.HandlerMethodArgumentResolver in project spring-framework by spring-projects.
the class WebMvcConfigurationSupportExtensionTests method requestMappingHandlerAdapter.
@SuppressWarnings("unchecked")
@Test
public void requestMappingHandlerAdapter() throws Exception {
RequestMappingHandlerAdapter adapter = this.config.requestMappingHandlerAdapter(this.config.mvcContentNegotiationManager(), this.config.mvcConversionService(), this.config.mvcValidator());
// ConversionService
String actual = this.config.mvcConversionService().convert(new TestBean(), String.class);
assertThat(actual).isEqualTo("converted");
// Message converters
List<HttpMessageConverter<?>> converters = adapter.getMessageConverters();
assertThat(converters.size()).isEqualTo(2);
assertThat(converters.get(0).getClass()).isEqualTo(StringHttpMessageConverter.class);
assertThat(converters.get(1).getClass()).isEqualTo(MappingJackson2HttpMessageConverter.class);
ObjectMapper objectMapper = ((MappingJackson2HttpMessageConverter) converters.get(1)).getObjectMapper();
assertThat(objectMapper.getDeserializationConfig().isEnabled(DEFAULT_VIEW_INCLUSION)).isFalse();
assertThat(objectMapper.getSerializationConfig().isEnabled(DEFAULT_VIEW_INCLUSION)).isFalse();
assertThat(objectMapper.getDeserializationConfig().isEnabled(FAIL_ON_UNKNOWN_PROPERTIES)).isFalse();
DirectFieldAccessor fieldAccessor = new DirectFieldAccessor(adapter);
// Custom argument resolvers and return value handlers
List<HandlerMethodArgumentResolver> argResolvers = (List<HandlerMethodArgumentResolver>) fieldAccessor.getPropertyValue("customArgumentResolvers");
assertThat(argResolvers.size()).isEqualTo(1);
List<HandlerMethodReturnValueHandler> handlers = (List<HandlerMethodReturnValueHandler>) fieldAccessor.getPropertyValue("customReturnValueHandlers");
assertThat(handlers.size()).isEqualTo(1);
// Async support options
assertThat(fieldAccessor.getPropertyValue("taskExecutor").getClass()).isEqualTo(ConcurrentTaskExecutor.class);
assertThat(fieldAccessor.getPropertyValue("asyncRequestTimeout")).isEqualTo(2500L);
CallableProcessingInterceptor[] callableInterceptors = (CallableProcessingInterceptor[]) fieldAccessor.getPropertyValue("callableInterceptors");
assertThat(callableInterceptors.length).isEqualTo(1);
DeferredResultProcessingInterceptor[] deferredResultInterceptors = (DeferredResultProcessingInterceptor[]) fieldAccessor.getPropertyValue("deferredResultInterceptors");
assertThat(deferredResultInterceptors.length).isEqualTo(1);
assertThat(fieldAccessor.getPropertyValue("ignoreDefaultModelOnRedirect")).asInstanceOf(BOOLEAN).isFalse();
}
Aggregations