org.springframework.web.socket.sockjs.transport.session.StubSockJsServiceConfig Java Examples
The following examples show how to use
org.springframework.web.socket.sockjs.transport.session.StubSockJsServiceConfig.
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: HttpReceivingTransportHandlerTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void delegateMessageException() throws Exception { StubSockJsServiceConfig sockJsConfig = new StubSockJsServiceConfig(); this.servletRequest.setContent("[\"x\"]".getBytes("UTF-8")); WebSocketHandler wsHandler = mock(WebSocketHandler.class); TestHttpSockJsSession session = new TestHttpSockJsSession("1", sockJsConfig, wsHandler, null); session.delegateConnectionEstablished(); willThrow(new Exception()).given(wsHandler).handleMessage(session, new TextMessage("x")); try { XhrReceivingTransportHandler transportHandler = new XhrReceivingTransportHandler(); transportHandler.initialize(sockJsConfig); transportHandler.handleRequest(this.request, this.response, wsHandler, session); fail("Expected exception"); } catch (SockJsMessageDeliveryException ex) { assertNull(session.getCloseStatus()); } }
Example #2
Source File: HttpReceivingTransportHandlerTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void delegateMessageException() throws Exception { StubSockJsServiceConfig sockJsConfig = new StubSockJsServiceConfig(); this.servletRequest.setContent("[\"x\"]".getBytes("UTF-8")); WebSocketHandler wsHandler = mock(WebSocketHandler.class); TestHttpSockJsSession session = new TestHttpSockJsSession("1", sockJsConfig, wsHandler, null); session.delegateConnectionEstablished(); willThrow(new Exception()).given(wsHandler).handleMessage(session, new TextMessage("x")); try { XhrReceivingTransportHandler transportHandler = new XhrReceivingTransportHandler(); transportHandler.initialize(sockJsConfig); transportHandler.handleRequest(this.request, this.response, wsHandler, session); fail("Expected exception"); } catch (SockJsMessageDeliveryException ex) { assertNull(session.getCloseStatus()); } }
Example #3
Source File: HttpReceivingTransportHandlerTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void delegateMessageException() throws Exception { StubSockJsServiceConfig sockJsConfig = new StubSockJsServiceConfig(); this.servletRequest.setContent("[\"x\"]".getBytes("UTF-8")); WebSocketHandler wsHandler = mock(WebSocketHandler.class); TestHttpSockJsSession session = new TestHttpSockJsSession("1", sockJsConfig, wsHandler, null); session.delegateConnectionEstablished(); willThrow(new Exception()).given(wsHandler).handleMessage(session, new TextMessage("x")); try { XhrReceivingTransportHandler transportHandler = new XhrReceivingTransportHandler(); transportHandler.initialize(sockJsConfig); transportHandler.handleRequest(this.request, this.response, wsHandler, session); fail("Expected exception"); } catch (SockJsMessageDeliveryException ex) { assertNull(session.getCloseStatus()); } }
Example #4
Source File: DefaultSockJsServiceTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Before public void setup() { super.setUp(); MockitoAnnotations.initMocks(this); Map<String, Object> attributes = Collections.emptyMap(); this.session = new TestSockJsSession(sessionId, new StubSockJsServiceConfig(), this.wsHandler, attributes); given(this.xhrHandler.getTransportType()).willReturn(TransportType.XHR); given(this.xhrHandler.createSession(sessionId, this.wsHandler, attributes)).willReturn(this.session); given(this.xhrSendHandler.getTransportType()).willReturn(TransportType.XHR_SEND); given(this.jsonpHandler.getTransportType()).willReturn(TransportType.JSONP); given(this.jsonpHandler.createSession(sessionId, this.wsHandler, attributes)).willReturn(this.session); given(this.jsonpSendHandler.getTransportType()).willReturn(TransportType.JSONP_SEND); given(this.wsTransportHandler.getTransportType()).willReturn(TransportType.WEBSOCKET); this.service = new TransportHandlingSockJsService(this.taskScheduler, this.xhrHandler, this.xhrSendHandler); }
Example #5
Source File: HttpSendingTransportHandlerTests.java From spring-analysis-note with MIT License | 5 votes |
@Override @Before public void setup() { super.setup(); this.webSocketHandler = mock(WebSocketHandler.class); this.taskScheduler = mock(TaskScheduler.class); this.sockJsConfig = new StubSockJsServiceConfig(); this.sockJsConfig.setTaskScheduler(this.taskScheduler); setRequest("POST", "/"); }
Example #6
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 #7
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 #8
Source File: DefaultSockJsServiceTests.java From spring-analysis-note with MIT License | 5 votes |
@Before public void setup() { super.setup(); MockitoAnnotations.initMocks(this); Map<String, Object> attributes = Collections.emptyMap(); this.session = new TestSockJsSession(sessionId, new StubSockJsServiceConfig(), this.wsHandler, attributes); given(this.xhrHandler.getTransportType()).willReturn(TransportType.XHR); given(this.xhrHandler.createSession(sessionId, this.wsHandler, attributes)).willReturn(this.session); given(this.xhrSendHandler.getTransportType()).willReturn(TransportType.XHR_SEND); given(this.wsTransportHandler.getTransportType()).willReturn(TransportType.WEBSOCKET); this.service = new TransportHandlingSockJsService(this.taskScheduler, this.xhrHandler, this.xhrSendHandler); }
Example #9
Source File: HttpSendingTransportHandlerTests.java From java-technology-stack with MIT License | 5 votes |
@Override @Before public void setup() { super.setup(); this.webSocketHandler = mock(WebSocketHandler.class); this.taskScheduler = mock(TaskScheduler.class); this.sockJsConfig = new StubSockJsServiceConfig(); this.sockJsConfig.setTaskScheduler(this.taskScheduler); setRequest("POST", "/"); }
Example #10
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 #11
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 #12
Source File: DefaultSockJsServiceTests.java From java-technology-stack with MIT License | 5 votes |
@Before public void setup() { super.setup(); MockitoAnnotations.initMocks(this); Map<String, Object> attributes = Collections.emptyMap(); this.session = new TestSockJsSession(sessionId, new StubSockJsServiceConfig(), this.wsHandler, attributes); given(this.xhrHandler.getTransportType()).willReturn(TransportType.XHR); given(this.xhrHandler.createSession(sessionId, this.wsHandler, attributes)).willReturn(this.session); given(this.xhrSendHandler.getTransportType()).willReturn(TransportType.XHR_SEND); given(this.wsTransportHandler.getTransportType()).willReturn(TransportType.WEBSOCKET); this.service = new TransportHandlingSockJsService(this.taskScheduler, this.xhrHandler, this.xhrSendHandler); }
Example #13
Source File: HttpSendingTransportHandlerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override @Before public void setUp() { super.setUp(); this.webSocketHandler = mock(WebSocketHandler.class); this.taskScheduler = mock(TaskScheduler.class); this.sockJsConfig = new StubSockJsServiceConfig(); this.sockJsConfig.setTaskScheduler(this.taskScheduler); setRequest("POST", "/"); }
Example #14
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 #15
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); }