From 5f2106046ccded1df2dc92821a6d12a06e26f949 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Sat, 11 Jan 2014 10:19:09 -0500 Subject: [PATCH] Add UpgradeRequestStrategy for WildFly/Undertow Issue: SPR-11237 --- build.gradle | 7 + .../AbstractStandardUpgradeStrategy.java | 12 ++ .../GlassFishRequestUpgradeStrategy.java | 12 +- .../TomcatRequestUpgradeStrategy.java | 12 +- .../UndertowRequestUpgradeStrategy.java | 161 ++++++++++++++++++ .../support/DefaultHandshakeHandler.java | 10 +- .../AbstractWebSocketIntegrationTests.java | 12 ++ .../web/socket/UndertowTestServer.java | 125 ++++++++++++++ .../web/socket/WebSocketIntegrationTests.java | 5 +- .../WebSocketConfigurationTests.java | 10 +- .../SimpAnnotationMethodIntegrationTests.java | 13 +- 11 files changed, 342 insertions(+), 37 deletions(-) create mode 100644 spring-websocket/src/main/java/org/springframework/web/socket/server/standard/UndertowRequestUpgradeStrategy.java create mode 100644 spring-websocket/src/test/java/org/springframework/web/socket/UndertowTestServer.java diff --git a/build.gradle b/build.gradle index 69ef8757cf3..77e698cd643 100644 --- a/build.gradle +++ b/build.gradle @@ -593,6 +593,13 @@ project("spring-websocket") { exclude group: "javax.servlet", module: "javax.servlet" } optional("org.eclipse.jetty.websocket:websocket-client:${jettyVersion}") + optional("io.undertow:undertow-core:1.0.0.Beta31") + optional("io.undertow:undertow-servlet:1.0.0.Beta31") { + exclude group: "org.jboss.spec.javax.servlet", module: "jboss-servlet-api_3.1_spec" + } + optional("io.undertow:undertow-websockets-jsr:1.0.0.Beta31") { + exclude group: "org.jboss.spec.javax.websocket", module: "jboss-websocket-api_1.0_spec" + } optional("com.fasterxml.jackson.core:jackson-databind:2.3.0") testCompile("org.apache.tomcat.embed:tomcat-embed-core:8.0.0-RC10") testCompile("org.slf4j:slf4j-jcl:${slf4jVersion}") diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/AbstractStandardUpgradeStrategy.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/AbstractStandardUpgradeStrategy.java index d0e29957cc4..35c072fcd21 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/AbstractStandardUpgradeStrategy.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/AbstractStandardUpgradeStrategy.java @@ -23,6 +23,7 @@ import java.util.List; import java.util.Map; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import javax.websocket.Endpoint; import javax.websocket.Extension; import javax.websocket.WebSocketContainer; @@ -35,6 +36,7 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.server.ServerHttpRequest; import org.springframework.http.server.ServerHttpResponse; import org.springframework.http.server.ServletServerHttpRequest; +import org.springframework.http.server.ServletServerHttpResponse; import org.springframework.util.Assert; import org.springframework.web.socket.WebSocketExtension; import org.springframework.web.socket.WebSocketHandler; @@ -85,6 +87,16 @@ public abstract class AbstractStandardUpgradeStrategy implements RequestUpgradeS return result; } + protected final HttpServletResponse getHttpServletResponse(ServerHttpResponse response) { + Assert.isTrue(response instanceof ServletServerHttpResponse); + return ((ServletServerHttpResponse) response).getServletResponse(); + } + + protected final HttpServletRequest getHttpServletRequest(ServerHttpRequest request) { + Assert.isTrue(request instanceof ServletServerHttpRequest); + return ((ServletServerHttpRequest) request).getServletRequest(); + } + @Override public void upgrade(ServerHttpRequest request, ServerHttpResponse response, String selectedProtocol, List selectedExtensions, Principal user, diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/GlassFishRequestUpgradeStrategy.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/GlassFishRequestUpgradeStrategy.java index 9f6e5f70740..065936805ec 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/GlassFishRequestUpgradeStrategy.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/GlassFishRequestUpgradeStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,9 +45,6 @@ import org.glassfish.tyrus.websockets.WebSocketEngine; import org.springframework.http.HttpHeaders; import org.springframework.http.server.ServerHttpRequest; import org.springframework.http.server.ServerHttpResponse; -import org.springframework.http.server.ServletServerHttpRequest; -import org.springframework.http.server.ServletServerHttpResponse; -import org.springframework.util.Assert; import org.springframework.util.ReflectionUtils; import org.springframework.util.StringUtils; import org.springframework.web.socket.WebSocketExtension; @@ -120,11 +117,8 @@ public class GlassFishRequestUpgradeStrategy extends AbstractStandardUpgradeStra String selectedProtocol, List selectedExtensions, Endpoint endpoint) throws HandshakeFailureException { - Assert.isTrue(request instanceof ServletServerHttpRequest); - HttpServletRequest servletRequest = ((ServletServerHttpRequest) request).getServletRequest(); - - Assert.isTrue(response instanceof ServletServerHttpResponse); - HttpServletResponse servletResponse = ((ServletServerHttpResponse) response).getServletResponse(); + HttpServletRequest servletRequest = getHttpServletRequest(request); + HttpServletResponse servletResponse = getHttpServletResponse(response); WebSocketApplication webSocketApplication = createTyrusEndpoint(endpoint, selectedProtocol, selectedExtensions); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/TomcatRequestUpgradeStrategy.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/TomcatRequestUpgradeStrategy.java index 157079e79f9..95358efcf0b 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/TomcatRequestUpgradeStrategy.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/TomcatRequestUpgradeStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,9 +31,6 @@ import org.apache.tomcat.websocket.server.WsServerContainer; import org.springframework.http.server.ServerHttpRequest; import org.springframework.http.server.ServerHttpResponse; -import org.springframework.http.server.ServletServerHttpRequest; -import org.springframework.http.server.ServletServerHttpResponse; -import org.springframework.util.Assert; import org.springframework.web.socket.server.HandshakeFailureException; /** @@ -60,11 +57,8 @@ public class TomcatRequestUpgradeStrategy extends AbstractStandardUpgradeStrateg String selectedProtocol, List selectedExtensions, Endpoint endpoint) throws HandshakeFailureException { - Assert.isTrue(request instanceof ServletServerHttpRequest); - HttpServletRequest servletRequest = ((ServletServerHttpRequest) request).getServletRequest(); - - Assert.isTrue(response instanceof ServletServerHttpResponse); - HttpServletResponse servletResponse = ((ServletServerHttpResponse) response).getServletResponse(); + HttpServletRequest servletRequest = getHttpServletRequest(request); + HttpServletResponse servletResponse = getHttpServletResponse(response); StringBuffer requestUrl = servletRequest.getRequestURL(); String path = servletRequest.getRequestURI(); // shouldn't matter diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/UndertowRequestUpgradeStrategy.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/UndertowRequestUpgradeStrategy.java new file mode 100644 index 00000000000..546d146fc73 --- /dev/null +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/UndertowRequestUpgradeStrategy.java @@ -0,0 +1,161 @@ +/* + * Copyright 2002-2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.web.socket.server.standard; + +import io.undertow.server.HttpServerExchange; +import io.undertow.server.HttpUpgradeListener; +import io.undertow.servlet.api.InstanceFactory; +import io.undertow.servlet.api.InstanceHandle; +import io.undertow.servlet.websockets.ServletWebSocketHttpExchange; +import io.undertow.websockets.core.WebSocketChannel; +import io.undertow.websockets.core.protocol.Handshake; +import io.undertow.websockets.core.protocol.version07.Hybi07Handshake; +import io.undertow.websockets.core.protocol.version08.Hybi08Handshake; +import io.undertow.websockets.core.protocol.version13.Hybi13Handshake; +import io.undertow.websockets.jsr.ConfiguredServerEndpoint; +import io.undertow.websockets.jsr.EncodingFactory; +import io.undertow.websockets.jsr.EndpointSessionHandler; +import io.undertow.websockets.jsr.ServerWebSocketContainer; +import io.undertow.websockets.jsr.handshake.HandshakeUtil; +import org.springframework.http.server.ServerHttpRequest; +import org.springframework.http.server.ServerHttpResponse; +import org.springframework.web.socket.server.HandshakeFailureException; +import org.xnio.StreamConnection; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.websocket.Decoder; +import javax.websocket.Encoder; +import javax.websocket.Endpoint; +import javax.websocket.Extension; +import java.util.*; + + +/** + * A {@link org.springframework.web.socket.server.RequestUpgradeStrategy} for use + * with WildFly and its underlying Undertow web server. + * + * @author Rossen Stoyanchev + * @since 4.0.1 + */ +public class UndertowRequestUpgradeStrategy extends AbstractStandardUpgradeStrategy { + + private final Handshake[] handshakes; + + private final String[] supportedVersions; + + + public UndertowRequestUpgradeStrategy() { + this.handshakes = new Handshake[] { new Hybi13Handshake(), new Hybi08Handshake(), new Hybi07Handshake() }; + this.supportedVersions = initSupportedVersions(this.handshakes); + } + + private String[] initSupportedVersions(Handshake[] handshakes) { + String[] versions = new String[handshakes.length]; + for (int i=0; i < versions.length; i++) { + versions[i] = handshakes[i].getVersion().toHttpHeaderValue(); + } + return versions; + } + + @Override + public String[] getSupportedVersions() { + return this.supportedVersions; + } + + @Override + protected void upgradeInternal(ServerHttpRequest request, ServerHttpResponse response, String selectedProtocol, + List selectedExtensions, final Endpoint endpoint) throws HandshakeFailureException { + + HttpServletRequest servletRequest = getHttpServletRequest(request); + HttpServletResponse servletResponse = getHttpServletResponse(response); + + final ServletWebSocketHttpExchange exchange = new ServletWebSocketHttpExchange(servletRequest, servletResponse); + exchange.putAttachment(HandshakeUtil.PATH_PARAMS, Collections.emptyMap()); + + ServerWebSocketContainer wsContainer = (ServerWebSocketContainer) getContainer(servletRequest); + final EndpointSessionHandler endpointSessionHandler = new EndpointSessionHandler(wsContainer); + + final Handshake handshake = getHandshakeToUse(exchange); + + final ConfiguredServerEndpoint configuredServerEndpoint = createConfiguredServerEndpoint( + selectedProtocol, selectedExtensions, endpoint, servletRequest); + + exchange.upgradeChannel(new HttpUpgradeListener() { + @Override + public void handleUpgrade(StreamConnection connection, HttpServerExchange serverExchange) { + WebSocketChannel channel = handshake.createChannel(exchange, connection, exchange.getBufferPool()); + HandshakeUtil.setConfig(channel, configuredServerEndpoint); + endpointSessionHandler.onConnect(exchange, channel); + } + }); + + handshake.handshake(exchange); + } + + private Handshake getHandshakeToUse(ServletWebSocketHttpExchange exchange) { + for (Handshake handshake : this.handshakes) { + if (handshake.matches(exchange)) { + return handshake; + } + } + // Should never occur + throw new HandshakeFailureException("No matching Undertow Handshake found: " + exchange.getRequestHeaders()); + } + + private ConfiguredServerEndpoint createConfiguredServerEndpoint(String selectedProtocol, + List selectedExtensions, Endpoint endpoint, HttpServletRequest servletRequest) { + + String path = servletRequest.getRequestURI(); // shouldn't matter + ServerEndpointRegistration endpointRegistration = new ServerEndpointRegistration(path, endpoint); + endpointRegistration.setSubprotocols(Arrays.asList(selectedProtocol)); + endpointRegistration.setExtensions(selectedExtensions); + + return new ConfiguredServerEndpoint(endpointRegistration, + new EndpointInstanceFactory(endpoint), null, + new EncodingFactory( + Collections., List>>emptyMap(), + Collections., List>>emptyMap(), + Collections., List>>emptyMap(), + Collections., List>>emptyMap())); + } + + + private static class EndpointInstanceFactory implements InstanceFactory { + + private final Endpoint endpoint; + + public EndpointInstanceFactory(Endpoint endpoint) { + this.endpoint = endpoint; + } + + @Override + public InstanceHandle createInstance() throws InstantiationException { + + return new InstanceHandle() { + @Override + public Endpoint getInstance() { + return endpoint; + } + @Override + public void release() { + } + }; + } + } + +} diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/DefaultHandshakeHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/DefaultHandshakeHandler.java index 0eca7eec5eb..4f785939f91 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/DefaultHandshakeHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/DefaultHandshakeHandler.java @@ -62,14 +62,17 @@ public class DefaultHandshakeHandler implements HandshakeHandler { protected Log logger = LogFactory.getLog(getClass()); + private static final boolean glassFishWsPresent = ClassUtils.isPresent( + "org.glassfish.tyrus.servlet.TyrusHttpUpgradeHandler", DefaultHandshakeHandler.class.getClassLoader()); + private static final boolean jettyWsPresent = ClassUtils.isPresent( "org.eclipse.jetty.websocket.server.WebSocketServerFactory", DefaultHandshakeHandler.class.getClassLoader()); private static final boolean tomcatWsPresent = ClassUtils.isPresent( "org.apache.tomcat.websocket.server.WsHttpUpgradeHandler", DefaultHandshakeHandler.class.getClassLoader()); - private static final boolean glassFishWsPresent = ClassUtils.isPresent( - "org.glassfish.tyrus.servlet.TyrusHttpUpgradeHandler", DefaultHandshakeHandler.class.getClassLoader()); + private static final boolean undertowWsPresent = ClassUtils.isPresent( + "io.undertow.websockets.jsr.ServerWebSocketContainer", DefaultHandshakeHandler.class.getClassLoader()); private final RequestUpgradeStrategy requestUpgradeStrategy; @@ -97,6 +100,9 @@ public class DefaultHandshakeHandler implements HandshakeHandler { else if (glassFishWsPresent) { className = "org.springframework.web.socket.server.standard.GlassFishRequestUpgradeStrategy"; } + else if (undertowWsPresent) { + className = "org.springframework.web.socket.server.standard.UndertowRequestUpgradeStrategy"; + } else { throw new IllegalStateException("No suitable default RequestUpgradeStrategy found"); } diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/AbstractWebSocketIntegrationTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/AbstractWebSocketIntegrationTests.java index 29dcc584ba5..73468289373 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/AbstractWebSocketIntegrationTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/AbstractWebSocketIntegrationTests.java @@ -1,4 +1,5 @@ /* + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +30,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.util.concurrent.ListenableFuture; import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; import org.springframework.web.socket.client.WebSocketClient; +import org.springframework.web.socket.server.standard.UndertowRequestUpgradeStrategy; import org.springframework.web.socket.server.support.DefaultHandshakeHandler; import org.springframework.web.socket.server.RequestUpgradeStrategy; import org.springframework.web.socket.server.jetty.JettyRequestUpgradeStrategy; @@ -48,6 +50,7 @@ public abstract class AbstractWebSocketIntegrationTests { static { upgradeStrategyConfigTypes.put(JettyWebSocketTestServer.class, JettyUpgradeStrategyConfig.class); upgradeStrategyConfigTypes.put(TomcatWebSocketTestServer.class, TomcatUpgradeStrategyConfig.class); + upgradeStrategyConfigTypes.put(UndertowTestServer.class, UndertowUpgradeStrategyConfig.class); } @Parameter(0) @@ -141,4 +144,13 @@ public abstract class AbstractWebSocketIntegrationTests { } } + @Configuration + static class UndertowUpgradeStrategyConfig extends AbstractRequestUpgradeStrategyConfig { + + @Bean + public RequestUpgradeStrategy requestUpgradeStrategy() { + return new UndertowRequestUpgradeStrategy(); + } + } + } diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/UndertowTestServer.java b/spring-websocket/src/test/java/org/springframework/web/socket/UndertowTestServer.java new file mode 100644 index 00000000000..385e000720a --- /dev/null +++ b/spring-websocket/src/test/java/org/springframework/web/socket/UndertowTestServer.java @@ -0,0 +1,125 @@ +/* + * Copyright 2002-2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.web.socket; + +import io.undertow.Undertow; +import io.undertow.servlet.api.DeploymentInfo; +import io.undertow.servlet.api.DeploymentManager; +import io.undertow.servlet.api.InstanceFactory; +import io.undertow.servlet.api.InstanceHandle; +import io.undertow.websockets.jsr.ServerWebSocketContainer; +import io.undertow.websockets.jsr.WebSocketDeploymentInfo; +import org.springframework.util.SocketUtils; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.servlet.DispatcherServlet; +import org.xnio.ByteBufferSlicePool; + +import javax.servlet.Servlet; +import javax.servlet.ServletException; + +import static io.undertow.servlet.Servlets.defaultContainer; +import static io.undertow.servlet.Servlets.deployment; +import static io.undertow.servlet.Servlets.servlet; + +/** + * Undertow-based {@link WebSocketTestServer}. + * + * @author Rossen Stoyanchev + */ +public class UndertowTestServer implements WebSocketTestServer { + + private Undertow server; + + private DeploymentManager manager; + + private final int port; + + + public UndertowTestServer() { + this.port = SocketUtils.findAvailableTcpPort(); + } + + @Override + public int getPort() { + return this.port; + } + + @Override + public void deployConfig(WebApplicationContext cxt) { + + DispatcherServletInstanceFactory servletFactory = new DispatcherServletInstanceFactory(cxt); + + DeploymentInfo servletBuilder = deployment() + .setClassLoader(UndertowTestServer.class.getClassLoader()) + .setDeploymentName("underow-websocket-test") + .setContextPath("/") + .addServlet(servlet("DispatcherServlet", DispatcherServlet.class, servletFactory).addMapping("/")) + .addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME, new WebSocketDeploymentInfo()); + + + this.manager = defaultContainer().addDeployment(servletBuilder); + this.manager.deploy(); + + try { + this.server = Undertow.builder() + .addListener(this.port, "localhost") + .setHandler(this.manager.start()).build(); + } + catch (ServletException e) { + throw new IllegalStateException(e); + } + } + + @Override + public void undeployConfig() { + this.manager.undeploy(); + } + + @Override + public void start() throws Exception { + this.server.start(); + } + + @Override + public void stop() throws Exception { + this.server.stop(); + } + + + private static class DispatcherServletInstanceFactory implements InstanceFactory { + + private final WebApplicationContext wac; + + + private DispatcherServletInstanceFactory(WebApplicationContext wac) { + this.wac = wac; + } + + @Override + public InstanceHandle createInstance() throws InstantiationException { + return new InstanceHandle() { + @Override + public Servlet getInstance() { + return new DispatcherServlet(wac); + } + @Override + public void release() { + } + }; + } + } +} diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/WebSocketIntegrationTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/WebSocketIntegrationTests.java index a2d5ec37121..b5b35c4c8a1 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/WebSocketIntegrationTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/WebSocketIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +49,8 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTest public static Iterable arguments() { return Arrays.asList(new Object[][]{ {new JettyWebSocketTestServer(), new JettyWebSocketClient()}, - {new TomcatWebSocketTestServer(), new StandardWebSocketClient()} + {new TomcatWebSocketTestServer(), new StandardWebSocketClient()}, + {new UndertowTestServer(), new JettyWebSocketClient()} }); }; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketConfigurationTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketConfigurationTests.java index 24949e432a5..1af7832b88b 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketConfigurationTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,10 +27,7 @@ import org.junit.runners.Parameterized.Parameters; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.web.socket.AbstractWebSocketIntegrationTests; -import org.springframework.web.socket.JettyWebSocketTestServer; -import org.springframework.web.socket.TomcatWebSocketTestServer; -import org.springframework.web.socket.WebSocketSession; +import org.springframework.web.socket.*; import org.springframework.web.socket.handler.AbstractWebSocketHandler; import org.springframework.web.socket.client.standard.StandardWebSocketClient; import org.springframework.web.socket.client.jetty.JettyWebSocketClient; @@ -51,7 +48,8 @@ public class WebSocketConfigurationTests extends AbstractWebSocketIntegrationTes public static Iterable arguments() { return Arrays.asList(new Object[][] { {new JettyWebSocketTestServer(), new JettyWebSocketClient()}, - {new TomcatWebSocketTestServer(), new StandardWebSocketClient()} + {new TomcatWebSocketTestServer(), new StandardWebSocketClient()}, + {new UndertowTestServer(), new StandardWebSocketClient()} }); }; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/SimpAnnotationMethodIntegrationTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/SimpAnnotationMethodIntegrationTests.java index 6f3b34a4669..066c94843ae 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/SimpAnnotationMethodIntegrationTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/SimpAnnotationMethodIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,24 +36,18 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.messaging.handler.annotation.MessageExceptionHandler; import org.springframework.messaging.handler.annotation.MessageMapping; -import org.springframework.messaging.simp.config.ChannelRegistration; import org.springframework.messaging.simp.config.MessageBrokerRegistry; import org.springframework.messaging.simp.stomp.StompCommand; import org.springframework.messaging.support.AbstractSubscribableChannel; import org.springframework.messaging.support.ExecutorSubscribableChannel; import org.springframework.stereotype.Controller; -import org.springframework.web.socket.AbstractWebSocketIntegrationTests; -import org.springframework.web.socket.JettyWebSocketTestServer; -import org.springframework.web.socket.TextMessage; -import org.springframework.web.socket.TomcatWebSocketTestServer; -import org.springframework.web.socket.WebSocketSession; +import org.springframework.web.socket.*; import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer; import org.springframework.web.socket.handler.TextWebSocketHandler; import org.springframework.web.socket.client.standard.StandardWebSocketClient; import org.springframework.web.socket.client.jetty.JettyWebSocketClient; import org.springframework.web.socket.config.annotation.DelegatingWebSocketMessageBrokerConfiguration; import org.springframework.web.socket.config.annotation.StompEndpointRegistry; -import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer; import org.springframework.web.socket.server.HandshakeHandler; import static org.junit.Assert.*; @@ -70,7 +64,8 @@ public class SimpAnnotationMethodIntegrationTests extends AbstractWebSocketInteg public static Iterable arguments() { return Arrays.asList(new Object[][] { {new JettyWebSocketTestServer(), new JettyWebSocketClient()}, - {new TomcatWebSocketTestServer(), new StandardWebSocketClient()} + {new TomcatWebSocketTestServer(), new StandardWebSocketClient()}, + {new UndertowTestServer(), new StandardWebSocketClient()} }); }