Search in sources :

Example 1 with AbstractHandlerMethodAdapter

use of org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter in project spring-boot by spring-projects.

the class WebMvcAutoConfigurationTests method testLogResolvedExceptionCustomization.

private void testLogResolvedExceptionCustomization(final boolean expected) {
    HandlerExceptionResolver exceptionResolver = this.context.getBean(HandlerExceptionResolver.class);
    assertThat(exceptionResolver).isInstanceOf(HandlerExceptionResolverComposite.class);
    List<HandlerExceptionResolver> delegates = ((HandlerExceptionResolverComposite) exceptionResolver).getExceptionResolvers();
    for (HandlerExceptionResolver delegate : delegates) {
        if (delegate instanceof AbstractHandlerMethodAdapter) {
            assertThat(new DirectFieldAccessor(delegate).getPropertyValue("warnLogger")).is(new Condition<Object>() {

                @Override
                public boolean matches(Object value) {
                    return (expected ? value != null : value == null);
                }
            });
        }
    }
}
Also used : HandlerExceptionResolver(org.springframework.web.servlet.HandlerExceptionResolver) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) HandlerExceptionResolverComposite(org.springframework.web.servlet.handler.HandlerExceptionResolverComposite) AbstractHandlerMethodAdapter(org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter)

Aggregations

DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)1 HandlerExceptionResolver (org.springframework.web.servlet.HandlerExceptionResolver)1 HandlerExceptionResolverComposite (org.springframework.web.servlet.handler.HandlerExceptionResolverComposite)1 AbstractHandlerMethodAdapter (org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter)1