CitrusDispatcherServlet extends DispatcherServlet { protected void configureHandlerInterceptor(ApplicationContext context) { if (context.containsBean(HANDLER_INTERCEPTOR_BEAN_NAME)) { DelegatingHandlerInterceptor handlerInterceptor = context.getBean(HANDLER_INTERCEPTOR_BEAN_NAME, DelegatingHandlerInterceptor.class); handlerInterceptor.setInterceptors(adaptInterceptors(httpServer.getInterceptors(), context)); } } CitrusDispatcherServlet(HttpServer httpServer);   }
@Test public void testConfigureHandlerInterceptor() throws Exception { List<Object> interceptors = new ArrayList<>(); interceptors.add(new LoggingHandlerInterceptor()); reset(httpServer); when(httpServer.getInterceptors()).thenReturn(interceptors); when(httpServer.getEndpointAdapter()).thenReturn(null); when(httpServer.isHandleAttributeHeaders()).thenReturn(false); when(httpServer.isHandleCookies()).thenReturn(false); when(httpServer.getMessageConverter()).thenReturn(new HttpMessageConverter()); servlet.initStrategies(applicationContext); Assert.assertEquals(handlerInterceptor.getInterceptors().size(), 2L); Assert.assertEquals(handlerInterceptor.getInterceptors().get(0).getClass(), LoggingHandlerInterceptor.class); Assert.assertEquals(handlerInterceptor.getInterceptors().get(1), interceptors.get(0)); Assert.assertNotNull(httpMessageController.getEndpointConfiguration().getMessageConverter()); Assert.assertFalse(httpMessageController.getEndpointConfiguration().isHandleAttributeHeaders()); Assert.assertFalse(httpMessageController.getEndpointConfiguration().isHandleCookies()); Assert.assertEquals(httpMessageController.getEndpointAdapter().getClass(), EmptyResponseEndpointAdapter.class); }