use of org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession in project spring-framework by spring-projects.
the class HttpReceivingTransportHandlerTests method handleRequestAndExpectFailure.
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);
}
use of org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession in project spring-framework by spring-projects.
the class HttpSendingTransportHandlerTests method handleRequestXhr.
@Test
public void handleRequestXhr() throws Exception {
XhrPollingTransportHandler transportHandler = new XhrPollingTransportHandler();
transportHandler.initialize(this.sockJsConfig);
AbstractSockJsSession session = transportHandler.createSession("1", this.webSocketHandler, null);
transportHandler.handleRequest(this.request, this.response, this.webSocketHandler, session);
assertEquals("application/javascript;charset=UTF-8", this.response.getHeaders().getContentType().toString());
assertEquals("o\n", this.servletResponse.getContentAsString());
assertFalse("Polling request should complete after open frame", this.servletRequest.isAsyncStarted());
verify(this.webSocketHandler).afterConnectionEstablished(session);
resetRequestAndResponse();
transportHandler.handleRequest(this.request, this.response, this.webSocketHandler, session);
assertTrue("Polling request should remain open", this.servletRequest.isAsyncStarted());
verify(this.taskScheduler).schedule(any(Runnable.class), any(Date.class));
resetRequestAndResponse();
transportHandler.handleRequest(this.request, this.response, this.webSocketHandler, session);
assertFalse("Request should have been rejected", this.servletRequest.isAsyncStarted());
assertEquals("c[2010,\"Another connection still open\"]\n", this.servletResponse.getContentAsString());
}
use of org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession in project spring-framework by spring-projects.
the class HttpSendingTransportHandlerTests method handleRequestXhrStreaming.
@Test
public void handleRequestXhrStreaming() throws Exception {
XhrStreamingTransportHandler transportHandler = new XhrStreamingTransportHandler();
transportHandler.initialize(this.sockJsConfig);
AbstractSockJsSession session = transportHandler.createSession("1", this.webSocketHandler, null);
transportHandler.handleRequest(this.request, this.response, this.webSocketHandler, session);
assertEquals("application/javascript;charset=UTF-8", this.response.getHeaders().getContentType().toString());
assertTrue("Streaming request not started", this.servletRequest.isAsyncStarted());
verify(this.webSocketHandler).afterConnectionEstablished(session);
}
use of org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession in project spring-framework by spring-projects.
the class HttpReceivingTransportHandlerTests method handleRequest.
private void handleRequest(AbstractHttpReceivingTransportHandler transportHandler) throws Exception {
WebSocketHandler wsHandler = mock(WebSocketHandler.class);
AbstractSockJsSession session = new TestHttpSockJsSession("1", new StubSockJsServiceConfig(), wsHandler, null);
transportHandler.initialize(new StubSockJsServiceConfig());
transportHandler.handleRequest(this.request, this.response, wsHandler, session);
assertEquals("text/plain;charset=UTF-8", this.response.getHeaders().getContentType().toString());
verify(wsHandler).handleMessage(session, new TextMessage("x"));
}
Aggregations