@Test public void readMessagesBadContent() throws Exception { this.servletRequest.setContent("".getBytes("UTF-8")); handleRequestAndExpectFailure(); this.servletRequest.setContent("[\"x]".getBytes("UTF-8")); handleRequestAndExpectFailure(); }
@Test public void readMessagesXhr() throws Exception { this.servletRequest.setContent("[\"x\"]".getBytes("UTF-8")); handleRequest(new XhrReceivingTransportHandler()); assertEquals(204, this.servletResponse.getStatus()); }
private void handleRequestAndExpectFailure() throws Exception { resetResponse(); WebSocketHandler wsHandler = mock(WebSocketHandler.class); AbstractSockJsSession session = new TestHttpSockJsSession("1", new StubSockJsServiceConfig(), wsHandler, null); new XhrReceivingTransportHandler().handleRequest(this.request, this.response, wsHandler, session); assertEquals(500, this.servletResponse.getStatus()); verifyNoMoreInteractions(wsHandler); }