From 1a190a176ef65c6883a1320eb91523de5468831c Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Mon, 24 Jun 2013 15:02:40 -0700 Subject: [PATCH] Making testcase more consistent --- .../websocket/server/WebSocketOverSSLTest.java | 13 ++++++++++--- .../websocket/server/helper/CaptureSocket.java | 9 ++++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketOverSSLTest.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketOverSSLTest.java index 89ea4155354..3502924b123 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketOverSSLTest.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketOverSSLTest.java @@ -25,6 +25,9 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import org.eclipse.jetty.toolchain.test.EventQueue; +import org.eclipse.jetty.toolchain.test.TestTracker; +import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.client.WebSocketClient; import org.eclipse.jetty.websocket.server.helper.CaptureSocket; @@ -32,10 +35,14 @@ import org.eclipse.jetty.websocket.server.helper.SessionServlet; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; +import org.junit.Rule; import org.junit.Test; public class WebSocketOverSSLTest { + @Rule + public TestTracker tracker = new TestTracker(); + private static SimpleServletServer server; @BeforeClass @@ -144,13 +151,13 @@ public class WebSocketOverSSLTest CaptureSocket clientSocket = new CaptureSocket(); URI requestUri = server.getServerUri().resolve("/deep?a=b"); System.err.printf("Request URI: %s%n",requestUri.toASCIIString()); - client.connect(clientSocket,requestUri); + Future fut = client.connect(clientSocket,requestUri); // wait for connect - clientSocket.awaitConnected(5000); + Session session = fut.get(5,TimeUnit.SECONDS); // Generate text frame - clientSocket.getRemote().sendString("session.upgradeRequest.requestURI"); + session.getRemote().sendString("session.upgradeRequest.requestURI"); // Read frame (hopefully text frame) clientSocket.messages.awaitEventCount(1,500,TimeUnit.MILLISECONDS); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/helper/CaptureSocket.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/helper/CaptureSocket.java index 847d9c85e8a..a1b597aa2b3 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/helper/CaptureSocket.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/helper/CaptureSocket.java @@ -24,6 +24,7 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import org.eclipse.jetty.toolchain.test.EventQueue; +import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.WebSocketAdapter; public class CaptureSocket extends WebSocketAdapter @@ -53,12 +54,10 @@ public class CaptureSocket extends WebSocketAdapter } } - public void onClose(int closeCode, String message) - { - } - - public void onOpen(Connection connection) + @Override + public void onWebSocketConnect(Session sess) { + super.onWebSocketConnect(sess); latch.countDown(); }