Search in sources :

Example 1 with TestWebSocketServerSockJsSession

use of org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSessionTests.TestWebSocketServerSockJsSession in project spring-framework by spring-projects.

the class WebSocketServerSockJsSessionTests method afterSessionInitializedOpenFrameFirst.

@Test
@SuppressWarnings("resource")
public void afterSessionInitializedOpenFrameFirst() throws Exception {
    TextWebSocketHandler handler = new TextWebSocketHandler() {

        @Override
        public void afterConnectionEstablished(WebSocketSession session) throws Exception {
            session.sendMessage(new TextMessage("go go"));
        }
    };
    TestWebSocketServerSockJsSession session = new TestWebSocketServerSockJsSession(this.sockJsConfig, handler, null);
    session.initializeDelegateSession(this.webSocketSession);
    List<TextMessage> expected = Arrays.asList(new TextMessage("o"), new TextMessage("a[\"go go\"]"));
    assertEquals(expected, this.webSocketSession.getSentMessages());
}
Also used : TextWebSocketHandler(org.springframework.web.socket.handler.TextWebSocketHandler) TextMessage(org.springframework.web.socket.TextMessage) WebSocketSession(org.springframework.web.socket.WebSocketSession) TestWebSocketSession(org.springframework.web.socket.handler.TestWebSocketSession) TestWebSocketServerSockJsSession(org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSessionTests.TestWebSocketServerSockJsSession) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 TextMessage (org.springframework.web.socket.TextMessage)1 WebSocketSession (org.springframework.web.socket.WebSocketSession)1 TestWebSocketSession (org.springframework.web.socket.handler.TestWebSocketSession)1 TextWebSocketHandler (org.springframework.web.socket.handler.TextWebSocketHandler)1 TestWebSocketServerSockJsSession (org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSessionTests.TestWebSocketServerSockJsSession)1