Search in sources :

Example 16 with TextWebSocketHandler

use of org.springframework.web.socket.handler.TextWebSocketHandler in project spring-framework by spring-projects.

the class DefaultHandshakeHandlerTests method supportedExtensions.

@Test
public void supportedExtensions() throws Exception {
    WebSocketExtension extension1 = new WebSocketExtension("ext1");
    WebSocketExtension extension2 = new WebSocketExtension("ext2");
    given(this.upgradeStrategy.getSupportedVersions()).willReturn(new String[] { "13" });
    given(this.upgradeStrategy.getSupportedExtensions(this.request)).willReturn(Arrays.asList(extension1));
    this.servletRequest.setMethod("GET");
    WebSocketHttpHeaders headers = new WebSocketHttpHeaders(this.request.getHeaders());
    headers.setUpgrade("WebSocket");
    headers.setConnection("Upgrade");
    headers.setSecWebSocketVersion("13");
    headers.setSecWebSocketKey("82/ZS2YHjEnUN97HLL8tbw==");
    headers.setSecWebSocketExtensions(Arrays.asList(extension1, extension2));
    WebSocketHandler handler = new TextWebSocketHandler();
    Map<String, Object> attributes = Collections.<String, Object>emptyMap();
    this.handshakeHandler.doHandshake(this.request, this.response, handler, attributes);
    verify(this.upgradeStrategy).upgrade(this.request, this.response, null, Arrays.asList(extension1), null, handler, attributes);
}
Also used : WebSocketExtension(org.springframework.web.socket.WebSocketExtension) WebSocketHttpHeaders(org.springframework.web.socket.WebSocketHttpHeaders) WebSocketHandler(org.springframework.web.socket.WebSocketHandler) TextWebSocketHandler(org.springframework.web.socket.handler.TextWebSocketHandler) TextWebSocketHandler(org.springframework.web.socket.handler.TextWebSocketHandler) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)16 TextWebSocketHandler (org.springframework.web.socket.handler.TextWebSocketHandler)16 WebSocketHandler (org.springframework.web.socket.WebSocketHandler)12 WebSocketHttpHeaders (org.springframework.web.socket.WebSocketHttpHeaders)5 URI (java.net.URI)4 HttpSessionHandshakeInterceptor (org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor)4 HandshakeHandler (org.springframework.web.socket.server.HandshakeHandler)2 DefaultHandshakeHandler (org.springframework.web.socket.server.support.DefaultHandshakeHandler)2 SimpleAsyncTaskExecutor (org.springframework.core.task.SimpleAsyncTaskExecutor)1 TaskScheduler (org.springframework.scheduling.TaskScheduler)1 TextMessage (org.springframework.web.socket.TextMessage)1 WebSocketExtension (org.springframework.web.socket.WebSocketExtension)1 WebSocketSession (org.springframework.web.socket.WebSocketSession)1 LoggingWebSocketHandlerDecorator (org.springframework.web.socket.handler.LoggingWebSocketHandlerDecorator)1 TestWebSocketSession (org.springframework.web.socket.handler.TestWebSocketSession)1 WebSocketHandlerDecorator (org.springframework.web.socket.handler.WebSocketHandlerDecorator)1 SubProtocolWebSocketHandler (org.springframework.web.socket.messaging.SubProtocolWebSocketHandler)1 HandshakeInterceptor (org.springframework.web.socket.server.HandshakeInterceptor)1 OriginHandshakeInterceptor (org.springframework.web.socket.server.support.OriginHandshakeInterceptor)1 WebSocketTransportHandler (org.springframework.web.socket.sockjs.transport.handler.WebSocketTransportHandler)1