@Test public void handleTextMessage() throws Exception { Message<String> message = new Message<>(0, 1L, 1, 1L, "a"); TextMessage textMessage = new TextMessage((new ObjectMapper()).writeValueAsString(message)); String refUtf8 = new String(textMessage.getPayload().getBytes(), UTF_8); String refUtf16 = new String(textMessage.getPayload().getBytes(), UTF_16); underTest.afterConnectionEstablished(session); underTest.handleTextMessage(session, textMessage); ArgumentCaptor<String> valueCapture = ArgumentCaptor.forClass(String.class); verify(service).onEvent(valueCapture.capture()); String out = valueCapture.getValue(); assertEquals(refUtf8, out); assertNotEquals(refUtf16, out); }
@Override protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception { if (message.getPayloadLength() == 0) { log.warn("Road: {}, stream: {}, sessionId: {} - Ignoring message with zero sized payload", roadName, streamName, sessionId); return; } service.onEvent(message.getPayload()); }
OfframpWebSocketHandler extends AbstractWebSocketHandler { @Override protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception { if (message.getPayloadLength() == 0) { log.warn("Road: {}, stream: {}, sessionId: {} - Ignoring message with zero sized payload", roadName, streamName, sessionId); return; } service.onEvent(message.getPayload()); } }
OfframpWebSocketHandler extends AbstractWebSocketHandler { @Override protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception { if (message.getPayloadLength() == 0) { log.warn("Road: {}, stream: {}, sessionId: {} - Ignoring message with zero sized payload", roadName, streamName, sessionId); return; } service.onEvent(message.getPayload()); }  }
OfframpWebSocketHandler extends AbstractWebSocketHandler { @Override protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception { if (message.getPayloadLength() == 0) { log.warn("Road: {}, stream: {}, sessionId: {} - Ignoring message with zero sized payload", roadName, streamName, sessionId); return; } service.onEvent(message.getPayload()); }  @Override void afterConnectionEstablished(WebSocketSession session); @Override void afterConnectionClosed(WebSocketSession session, CloseStatus status); @Override void handleTransportError(WebSocketSession session, Throwable exception); }
OfframpWebSocketHandler extends AbstractWebSocketHandler { @Override protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception { if (message.getPayloadLength() == 0) { log.warn("Road: {}, stream: {}, sessionId: {} - Ignoring message with zero sized payload", roadName, streamName, sessionId); return; } service.onEvent(message.getPayload()); }  @Override void afterConnectionEstablished(WebSocketSession session); @Override void afterConnectionClosed(WebSocketSession session, CloseStatus status); @Override void handleTransportError(WebSocketSession session, Throwable exception);  }