use of org.springframework.web.socket.WebSocketSession in project spring-framework by spring-projects.
the class WebSocketConfigurationTests method registerWebSocketHandlerWithSockJS.
@Test
public void registerWebSocketHandlerWithSockJS() throws Exception {
WebSocketSession session = this.webSocketClient.doHandshake(new AbstractWebSocketHandler() {
}, getWsBaseUrl() + "/sockjs/websocket").get();
TestHandler serverHandler = this.wac.getBean(TestHandler.class);
assertTrue(serverHandler.connectLatch.await(2, TimeUnit.SECONDS));
session.close();
}
use of org.springframework.web.socket.WebSocketSession in project spring-framework by spring-projects.
the class WebSocketMessageBrokerConfigurationSupportTests method webSocketHandlerDecorator.
@Test
public void webSocketHandlerDecorator() throws Exception {
ApplicationContext config = createConfig(WebSocketHandlerDecoratorConfig.class);
WebSocketHandler handler = config.getBean(SubProtocolWebSocketHandler.class);
assertNotNull(handler);
SimpleUrlHandlerMapping mapping = (SimpleUrlHandlerMapping) config.getBean("stompWebSocketHandlerMapping");
WebSocketHttpRequestHandler httpHandler = (WebSocketHttpRequestHandler) mapping.getHandlerMap().get("/test");
handler = httpHandler.getWebSocketHandler();
WebSocketSession session = new TestWebSocketSession("id");
handler.afterConnectionEstablished(session);
assertEquals(true, session.getAttributes().get("decorated"));
}
Aggregations