From ea67a637aea3e479d4f1d3c28f756162ec0c6de3 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 26 Jan 2017 06:10:31 -0500 Subject: [PATCH] Align setup of SockJS and WebSocket integration tests Failures in JettySockJsIntegrationTests after the upgrade to 9.4 were hidden due to the PERFORMANCE test group but were failing on the CI performance build with IllegalStateException inside Jetty on "Failure find the required ServletContext attribute org.eclipse.jetty.util.DecoratedObjectFactory". --- .../sockjs/client/AbstractSockJsIntegrationTests.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/AbstractSockJsIntegrationTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/AbstractSockJsIntegrationTests.java index 716c22a107..d7bf036ecb 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/AbstractSockJsIntegrationTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/AbstractSockJsIntegrationTests.java @@ -39,7 +39,6 @@ import javax.servlet.http.HttpServletResponse; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - import org.junit.After; import org.junit.Before; import org.junit.BeforeClass; @@ -111,16 +110,18 @@ public abstract class AbstractSockJsIntegrationTests { public void setup() throws Exception { logger.debug("Setting up '" + this.testName.getMethodName() + "'"); this.testFilter = new TestFilter(); + this.wac = new AnnotationConfigWebApplicationContext(); this.wac.register(TestConfig.class, upgradeStrategyConfigClass()); + this.server = createWebSocketTestServer(); this.server.setup(); this.server.deployConfig(this.wac, this.testFilter); - // Set ServletContext in WebApplicationContext after deployment but before - // starting the server. + this.server.start(); + this.wac.setServletContext(this.server.getServletContext()); this.wac.refresh(); - this.server.start(); + this.baseUrl = "http://localhost:" + this.server.getPort(); }