CitrusWebSocketDispatcherServlet extends CitrusDispatcherServlet { @Override protected void initStrategies(ApplicationContext context) { super.initStrategies(context); configureWebSockerHandler(context); } CitrusWebSocketDispatcherServlet(WebSocketServer webSocketServer);   }
@Test public void testNoBeansInContext() throws Exception { reset(httpServer); when(httpServer.getWebSockets()).thenReturn(new ArrayList<WebSocketEndpoint>()); GenericApplicationContext applicationContext = new GenericApplicationContext(); applicationContext.refresh(); servlet.initStrategies(applicationContext); }
@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.getMessageConverter()).thenReturn(new HttpMessageConverter()); when(httpServer.getWebSockets()).thenReturn(new ArrayList<>()); servlet.initStrategies(applicationContext); Assert.assertEquals(handlerInterceptor.getInterceptors().size(), 1L); Assert.assertEquals(handlerInterceptor.getInterceptors().get(0), interceptors.get(0)); Assert.assertNotNull(httpMessageController.getEndpointConfiguration().getMessageConverter()); Assert.assertEquals(httpMessageController.getEndpointAdapter().getClass(), EmptyResponseEndpointAdapter.class); }
@Test public void testConfigureMessageController() throws Exception { reset(httpServer); when(httpServer.getInterceptors()).thenReturn(null); when(httpServer.getEndpointAdapter()).thenReturn(new TimeoutProducingEndpointAdapter()); when(httpServer.getMessageConverter()).thenReturn(new HttpMessageConverter()); when(httpServer.getWebSockets()).thenReturn(new ArrayList<WebSocketEndpoint>()); servlet.initStrategies(applicationContext); Assert.assertEquals(handlerInterceptor.getInterceptors().size(), 0L); Assert.assertEquals(httpMessageController.getEndpointAdapter().getClass(), TimeoutProducingEndpointAdapter.class); Assert.assertNotNull(httpMessageController.getEndpointConfiguration().getMessageConverter()); }