Search in sources :

Example 1 with WebSocketClient

use of org.springframework.web.socket.client.WebSocketClient in project spring-framework by spring-projects.

the class WebSocketStompClientTests method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    WebSocketClient webSocketClient = mock(WebSocketClient.class);
    this.stompClient = new TestWebSocketStompClient(webSocketClient);
    this.stompClient.setTaskScheduler(this.taskScheduler);
    this.stompClient.setStompSession(this.stompSession);
    this.webSocketHandlerCaptor = ArgumentCaptor.forClass(WebSocketHandler.class);
    this.handshakeFuture = new SettableListenableFuture<>();
    when(webSocketClient.doHandshake(this.webSocketHandlerCaptor.capture(), any(), any(URI.class))).thenReturn(this.handshakeFuture);
}
Also used : WebSocketHandler(org.springframework.web.socket.WebSocketHandler) WebSocketClient(org.springframework.web.socket.client.WebSocketClient) URI(java.net.URI) Before(org.junit.Before)

Example 2 with WebSocketClient

use of org.springframework.web.socket.client.WebSocketClient in project spring-framework by spring-projects.

the class WebSocketStompClientIntegrationTests method setUp.

@Before
public void setUp() throws Exception {
    logger.debug("Setting up before '" + this.testName.getMethodName() + "'");
    this.wac = new AnnotationConfigWebApplicationContext();
    this.wac.register(TestConfig.class);
    this.wac.refresh();
    this.server = new TomcatWebSocketTestServer();
    this.server.setup();
    this.server.deployConfig(this.wac);
    this.server.start();
    WebSocketClient webSocketClient = new StandardWebSocketClient();
    this.stompClient = new WebSocketStompClient(webSocketClient);
    this.stompClient.setMessageConverter(new StringMessageConverter());
}
Also used : StringMessageConverter(org.springframework.messaging.converter.StringMessageConverter) TomcatWebSocketTestServer(org.springframework.web.socket.TomcatWebSocketTestServer) StandardWebSocketClient(org.springframework.web.socket.client.standard.StandardWebSocketClient) WebSocketClient(org.springframework.web.socket.client.WebSocketClient) StandardWebSocketClient(org.springframework.web.socket.client.standard.StandardWebSocketClient) AnnotationConfigWebApplicationContext(org.springframework.web.context.support.AnnotationConfigWebApplicationContext) Before(org.junit.Before)

Example 3 with WebSocketClient

use of org.springframework.web.socket.client.WebSocketClient in project spring-boot by spring-projects.

the class LiveReloadServerTests method connect.

private LiveReloadWebSocketHandler connect() throws Exception {
    WebSocketClient client = new StandardWebSocketClient(new WsWebSocketContainer());
    LiveReloadWebSocketHandler handler = new LiveReloadWebSocketHandler();
    client.doHandshake(handler, "ws://localhost:" + this.port + "/livereload");
    handler.awaitHello();
    return handler;
}
Also used : WsWebSocketContainer(org.apache.tomcat.websocket.WsWebSocketContainer) StandardWebSocketClient(org.springframework.web.socket.client.standard.StandardWebSocketClient) WebSocketClient(org.springframework.web.socket.client.WebSocketClient) StandardWebSocketClient(org.springframework.web.socket.client.standard.StandardWebSocketClient)

Aggregations

WebSocketClient (org.springframework.web.socket.client.WebSocketClient)3 Before (org.junit.Before)2 StandardWebSocketClient (org.springframework.web.socket.client.standard.StandardWebSocketClient)2 URI (java.net.URI)1 WsWebSocketContainer (org.apache.tomcat.websocket.WsWebSocketContainer)1 StringMessageConverter (org.springframework.messaging.converter.StringMessageConverter)1 AnnotationConfigWebApplicationContext (org.springframework.web.context.support.AnnotationConfigWebApplicationContext)1 TomcatWebSocketTestServer (org.springframework.web.socket.TomcatWebSocketTestServer)1 WebSocketHandler (org.springframework.web.socket.WebSocketHandler)1