From 12d373659a167086625d2659a7bd6b331f5bc268 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 5 Jul 2016 20:47:53 +0200 Subject: [PATCH] Upgrade to Undertow 1.4 CR3 (and Jackson 2.8 GA) This commit also renames WebSocketIntegrationTests to WebSocketHandshakeTests. Issue: SPR-14328 --- build.gradle | 14 ++++++++------ .../socket/sockjs/client/UndertowXhrTransport.java | 4 ++-- .../socket/AbstractWebSocketIntegrationTests.java | 9 +++++---- ...tionTests.java => WebSocketHandshakeTests.java} | 13 +++++-------- .../annotation/WebSocketConfigurationTests.java | 4 ++-- 5 files changed, 22 insertions(+), 22 deletions(-) rename spring-websocket/src/test/java/org/springframework/web/socket/{WebSocketIntegrationTests.java => WebSocketHandshakeTests.java} (95%) diff --git a/build.gradle b/build.gradle index 6c19d6c7cfd..67f7c1b0c54 100644 --- a/build.gradle +++ b/build.gradle @@ -49,7 +49,7 @@ configure(allprojects) { project -> ext.hsqldbVersion = "2.3.4" ext.httpasyncVersion = "4.1.2" ext.httpclientVersion = "4.5.2" - ext.jackson2Version = "2.8.0.rc2" + ext.jackson2Version = "2.8.0" ext.jasperreportsVersion = "6.2.1" // our tests fail with JR-internal NPEs against 6.2.2 and higher ext.javamailVersion = "1.5.5" ext.jettyVersion = "9.3.10.v20160621" @@ -58,7 +58,7 @@ configure(allprojects) { project -> ext.junitVersion = "4.12" ext.junitJupiterVersion = '5.0.0-SNAPSHOT' ext.junitPlatformVersion = '1.0.0-SNAPSHOT' - ext.log4JVersion = '2.6.1' + ext.log4jVersion = '2.6.1' ext.nettyVersion = "4.1.1.Final" ext.okhttpVersion = "2.7.5" ext.okhttp3Version = "3.3.1" @@ -72,7 +72,7 @@ configure(allprojects) { project -> ext.tiles3Version = "3.0.5" ext.tomcatVersion = "8.5.3" ext.tyrusVersion = "1.13" - ext.undertowVersion = "1.4.0.CR2" + ext.undertowVersion = "1.4.0.CR3" ext.xmlunitVersion = "1.6" ext.xstreamVersion = "1.4.9" @@ -139,9 +139,8 @@ configure(allprojects) { project -> exclude group:'org.hamcrest', module:'hamcrest-core' } testCompile("org.hamcrest:hamcrest-all:${hamcrestVersion}") - - testRuntime("org.apache.logging.log4j:log4j-core:${log4JVersion}") - testRuntime("org.apache.logging.log4j:log4j-jcl:${log4JVersion}") + testRuntime("org.apache.logging.log4j:log4j-core:${log4jVersion}") + testRuntime("org.apache.logging.log4j:log4j-jcl:${log4jVersion}") sniffer("org.codehaus.mojo:animal-sniffer-ant-tasks:${snifferVersion}") javaApiSignature("org.codehaus.mojo.signature:java18:1.0@signature") @@ -840,12 +839,15 @@ project("spring-websocket") { optional("io.undertow:undertow-websockets-jsr:${undertowVersion}") { exclude group: "org.jboss.spec.javax.websocket", module: "jboss-websocket-api_1.1_spec" } + optional("org.jboss.xnio:xnio-api:3.3.7.Final") optional("com.fasterxml.jackson.core:jackson-databind:${jackson2Version}") testCompile("org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}") testCompile("org.apache.tomcat.embed:tomcat-embed-websocket:${tomcatVersion}") testCompile("io.projectreactor:reactor-net:${reactorVersion}") testCompile("io.netty:netty-all:${nettyVersion}") testCompile("org.slf4j:slf4j-jcl:${slf4jVersion}") + testRuntime("org.jboss.xnio:xnio-nio:3.3.7.Final") + testRuntime("org.jboss.logging:jboss-logging:3.3.0.Final") } } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/UndertowXhrTransport.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/UndertowXhrTransport.java index e2b91295fdd..6621c4cf2ef 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/UndertowXhrTransport.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/UndertowXhrTransport.java @@ -64,7 +64,7 @@ import org.springframework.web.socket.sockjs.frame.SockJsFrame; /** * An XHR transport based on Undertow's {@link io.undertow.client.UndertowClient}. - * Requires Undertow 1.3 or higher, as of Spring Framework 5.0. + * Requires Undertow 1.3 or 1.4, including XNIO, as of Spring Framework 5.0. * *

When used for testing purposes (e.g. load testing) or for specific use cases * (like HTTPS configuration), a custom OptionMap should be provided: @@ -461,7 +461,7 @@ public class UndertowXhrTransport extends AbstractXhrTransport { public void onFailure(Throwable failure) { IoUtils.safeClose(this.connection); - if (connectFuture.setException(failure)) { + if (this.connectFuture.setException(failure)) { return; } if (this.session.isDisconnected()) { 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 142e4fb73f8..2309f74f853 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 @@ -21,7 +21,6 @@ import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -48,8 +47,6 @@ import org.springframework.web.socket.server.support.DefaultHandshakeHandler; */ public abstract class AbstractWebSocketIntegrationTests { - protected Log logger = LogFactory.getLog(getClass()); - private static Map, Class> upgradeStrategyConfigTypes = new HashMap<>(); static { @@ -58,6 +55,7 @@ public abstract class AbstractWebSocketIntegrationTests { upgradeStrategyConfigTypes.put(UndertowTestServer.class, UndertowUpgradeStrategyConfig.class); } + @Rule public final TestName testName = new TestName(); @@ -67,12 +65,13 @@ public abstract class AbstractWebSocketIntegrationTests { @Parameter(1) public WebSocketClient webSocketClient; + protected final Log logger = LogFactory.getLog(getClass()); + protected AnnotationConfigWebApplicationContext wac; @Before public void setup() throws Exception { - logger.debug("Setting up '" + this.testName.getMethodName() + "', client=" + this.webSocketClient.getClass().getSimpleName() + ", server=" + this.server.getClass().getSimpleName()); @@ -155,6 +154,7 @@ public abstract class AbstractWebSocketIntegrationTests { } } + @Configuration static class TomcatUpgradeStrategyConfig extends AbstractRequestUpgradeStrategyConfig { @@ -164,6 +164,7 @@ public abstract class AbstractWebSocketIntegrationTests { } } + @Configuration static class UndertowUpgradeStrategyConfig extends AbstractRequestUpgradeStrategyConfig { diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/WebSocketIntegrationTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/WebSocketHandshakeTests.java similarity index 95% rename from spring-websocket/src/test/java/org/springframework/web/socket/WebSocketIntegrationTests.java rename to spring-websocket/src/test/java/org/springframework/web/socket/WebSocketHandshakeTests.java index 1d86998daed..813b7b5fbf8 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/WebSocketIntegrationTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/WebSocketHandshakeTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -46,9 +46,10 @@ import static org.junit.Assert.*; * Client and server-side WebSocket integration tests. * * @author Rossen Stoyanchev + * @author Juergen Hoeller */ @RunWith(Parameterized.class) -public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests { +public class WebSocketHandshakeTests extends AbstractWebSocketIntegrationTests { @Parameters(name = "server [{0}], client [{1}]") public static Iterable arguments() { @@ -62,7 +63,7 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTest @Override protected Class[] getAnnotatedConfigClasses() { - return new Class[] { TestConfig.class }; + return new Class[] {TestConfig.class}; } @Test @@ -75,11 +76,8 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTest session.close(); } - // SPR-12727 - - @Test + @Test // SPR-12727 public void unsolicitedPongWithEmptyPayload() throws Exception { - String url = getWsBaseUrl() + "/ws"; WebSocketSession session = this.webSocketClient.doHandshake(new AbstractWebSocketHandler() {}, url).get(); @@ -126,7 +124,6 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTest private Throwable transportError; - public void setWaitMessageCount(int waitMessageCount) { this.waitMessageCount = waitMessageCount; } 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 1a66397b7b4..f4aa0460480 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-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -61,7 +61,7 @@ public class WebSocketConfigurationTests extends AbstractWebSocketIntegrationTes @Override protected Class[] getAnnotatedConfigClasses() { - return new Class[] { TestConfig.class }; + return new Class[] {TestConfig.class}; } @Test