public WebSocketHttpRequestHandler(WebSocketHandler wsHandler, HandshakeHandler handshakeHandler) { Assert.notNull(wsHandler, "wsHandler must not be null"); Assert.notNull(handshakeHandler, "handshakeHandler must not be null"); this.wsHandler = new ExceptionWebSocketHandlerDecorator(new LoggingWebSocketHandlerDecorator(wsHandler)); this.handshakeHandler = handshakeHandler; }
/** * Create a new SockJsHttpRequestHandler. * @param sockJsService the SockJS service * @param webSocketHandler the websocket handler */ public SockJsHttpRequestHandler(SockJsService sockJsService, WebSocketHandler webSocketHandler) { Assert.notNull(sockJsService, "SockJsService must not be null"); Assert.notNull(webSocketHandler, "WebSocketHandler must not be null"); this.sockJsService = sockJsService; this.webSocketHandler = new ExceptionWebSocketHandlerDecorator(new LoggingWebSocketHandlerDecorator(webSocketHandler)); }
@Before public void setup() { this.delegate = mock(WebSocketHandler.class); this.decorator = new ExceptionWebSocketHandlerDecorator(this.delegate); this.session = new TestWebSocketSession(); this.session.setOpen(true); }
@Test public void delegateMessagesWithErrorAndConnectionClosing() throws Exception { WebSocketHandler wsHandler = new ExceptionWebSocketHandlerDecorator(this.webSocketHandler); TestSockJsSession sockJsSession = new TestSockJsSession( "1", this.sockJsConfig, wsHandler, Collections.<String, Object>emptyMap()); String msg1 = "message 1"; String msg2 = "message 2"; String msg3 = "message 3"; willThrow(new IOException()).given(this.webSocketHandler).handleMessage(sockJsSession, new TextMessage(msg2)); sockJsSession.delegateConnectionEstablished(); try { sockJsSession.delegateMessages(msg1, msg2, msg3); fail("expected exception"); } catch (SockJsMessageDeliveryException ex) { assertEquals(Collections.singletonList(msg3), ex.getUndeliveredMessages()); verify(this.webSocketHandler).afterConnectionEstablished(sockJsSession); verify(this.webSocketHandler).handleMessage(sockJsSession, new TextMessage(msg1)); verify(this.webSocketHandler).handleMessage(sockJsSession, new TextMessage(msg2)); verify(this.webSocketHandler).afterConnectionClosed(sockJsSession, CloseStatus.SERVER_ERROR); verifyNoMoreInteractions(this.webSocketHandler); } }
/** * Create a new SockJsHttpRequestHandler. * @param sockJsService the SockJS service * @param webSocketHandler the websocket handler */ public SockJsHttpRequestHandler(SockJsService sockJsService, WebSocketHandler webSocketHandler) { Assert.notNull(sockJsService, "SockJsService must not be null"); Assert.notNull(webSocketHandler, "WebSocketHandler must not be null"); this.sockJsService = sockJsService; this.webSocketHandler = new ExceptionWebSocketHandlerDecorator(new LoggingWebSocketHandlerDecorator(webSocketHandler)); }
public WebSocketHttpRequestHandler(WebSocketHandler wsHandler, HandshakeHandler handshakeHandler) { Assert.notNull(wsHandler, "wsHandler must not be null"); Assert.notNull(handshakeHandler, "handshakeHandler must not be null"); this.wsHandler = new ExceptionWebSocketHandlerDecorator(new LoggingWebSocketHandlerDecorator(wsHandler)); this.handshakeHandler = handshakeHandler; }
public WebSocketHttpRequestHandler(WebSocketHandler wsHandler, HandshakeHandler handshakeHandler) { Assert.notNull(wsHandler, "wsHandler must not be null"); Assert.notNull(handshakeHandler, "handshakeHandler must not be null"); this.wsHandler = new ExceptionWebSocketHandlerDecorator(new LoggingWebSocketHandlerDecorator(wsHandler)); this.handshakeHandler = handshakeHandler; }
/** * Create a new SockJsHttpRequestHandler. * @param sockJsService the SockJS service * @param webSocketHandler the websocket handler */ public SockJsHttpRequestHandler(SockJsService sockJsService, WebSocketHandler webSocketHandler) { Assert.notNull(sockJsService, "SockJsService must not be null"); Assert.notNull(webSocketHandler, "WebSocketHandler must not be null"); this.sockJsService = sockJsService; this.webSocketHandler = new ExceptionWebSocketHandlerDecorator(new LoggingWebSocketHandlerDecorator(webSocketHandler)); }