org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession Java Examples
The following examples show how to use
org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HttpSendingTransportHandlerTests.java From spring-analysis-note with MIT License | 6 votes |
@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()); }
Example #2
Source File: HttpSendingTransportHandlerTests.java From java-technology-stack with MIT License | 6 votes |
@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()); }
Example #3
Source File: HttpSendingTransportHandlerTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@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()); }
Example #4
Source File: HttpSendingTransportHandlerTests.java From spring-analysis-note with MIT License | 5 votes |
@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); }
Example #5
Source File: HttpReceivingTransportHandlerTests.java From spring-analysis-note with MIT License | 5 votes |
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")); }
Example #6
Source File: HttpReceivingTransportHandlerTests.java From spring-analysis-note with MIT License | 5 votes |
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); }
Example #7
Source File: HttpSendingTransportHandlerTests.java From java-technology-stack with MIT License | 5 votes |
@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); }
Example #8
Source File: HttpReceivingTransportHandlerTests.java From java-technology-stack with MIT License | 5 votes |
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")); }
Example #9
Source File: HttpReceivingTransportHandlerTests.java From java-technology-stack with MIT License | 5 votes |
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); }
Example #10
Source File: HttpSendingTransportHandlerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@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); }
Example #11
Source File: HttpReceivingTransportHandlerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
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")); }
Example #12
Source File: HttpReceivingTransportHandlerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
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); }
Example #13
Source File: WebSocketTransportHandler.java From spring-analysis-note with MIT License | 4 votes |
@Override public AbstractSockJsSession createSession(String id, WebSocketHandler handler, Map<String, Object> attrs) { return new WebSocketServerSockJsSession(id, getServiceConfig(), handler, attrs); }
Example #14
Source File: WebSocketTransportHandler.java From java-technology-stack with MIT License | 4 votes |
@Override public AbstractSockJsSession createSession(String id, WebSocketHandler handler, Map<String, Object> attrs) { return new WebSocketServerSockJsSession(id, getServiceConfig(), handler, attrs); }
Example #15
Source File: WebSocketTransportHandler.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override public AbstractSockJsSession createSession(String id, WebSocketHandler handler, Map<String, Object> attrs) { return new WebSocketServerSockJsSession(id, getServiceConfig(), handler, attrs); }