From fb76491ea0c616c42d778da5772743ca39df33c9 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Tue, 14 Jun 2016 11:04:01 +0200 Subject: [PATCH 1/2] Code cleanups. --- .../server/PerMessageDeflateExtensionTest.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/PerMessageDeflateExtensionTest.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/PerMessageDeflateExtensionTest.java index 5ada833bca1..8905999503c 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/PerMessageDeflateExtensionTest.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/PerMessageDeflateExtensionTest.java @@ -57,7 +57,7 @@ public class PerMessageDeflateExtensionTest MEDIUM(10*1024), LARGE(100*1024), HUGE(1024*1024); - + private int size; private TestCaseMessageSize(int size) @@ -65,12 +65,12 @@ public class PerMessageDeflateExtensionTest this.size = size; } } - + @Parameters(name = "{0} ({3}) (Input Buffer Size: {4} bytes)") public static List modes() { List modes = new ArrayList<>(); - + for(TestCaseMessageSize size: TestCaseMessageSize.values()) { modes.add(new Object[] { "Normal HTTP/WS", false, "ws", size, -1 }); @@ -79,7 +79,7 @@ public class PerMessageDeflateExtensionTest modes.add(new Object[] { "Normal HTTP/WS", false, "ws", size, altInputBufSize }); modes.add(new Object[] { "Encrypted HTTPS/WSS", true, "wss", size, altInputBufSize }); } - + return modes; } @@ -121,9 +121,9 @@ public class PerMessageDeflateExtensionTest Assert.assertThat("server scheme",server.getServerUri().getScheme(),is(scheme)); int binBufferSize = (int) (msgSize * 1.5); - + WebSocketPolicy serverPolicy = server.getWebSocketServletFactory().getPolicy(); - + // Ensure binBufferSize is sane (not smaller then other buffers) binBufferSize = Math.max(binBufferSize,serverPolicy.getMaxBinaryMessageSize()); binBufferSize = Math.max(binBufferSize,serverPolicy.getMaxBinaryMessageBufferSize()); @@ -140,7 +140,7 @@ public class PerMessageDeflateExtensionTest { clientPolicy.setInputBufferSize(inputBufferSize); } - + try { client.start(); @@ -164,10 +164,10 @@ public class PerMessageDeflateExtensionTest Random rand = new Random(); rand.setSeed(8080); rand.nextBytes(msg); - + // Calculate sha1 String sha1 = Sha1Sum.calculate(msg); - + // Client sends first message session.getRemote().sendBytes(ByteBuffer.wrap(msg)); From dc7bd636d0163322b061339d02d3fdbcf15c715f Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Tue, 14 Jun 2016 11:04:18 +0200 Subject: [PATCH 2/2] Increased timeouts to avoid failures on slower machines. --- .../server/PerMessageDeflateExtensionTest.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/PerMessageDeflateExtensionTest.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/PerMessageDeflateExtensionTest.java index 8905999503c..6eb97ff7b60 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/PerMessageDeflateExtensionTest.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/PerMessageDeflateExtensionTest.java @@ -18,10 +18,6 @@ package org.eclipse.jetty.websocket.server; -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; - import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; @@ -47,6 +43,10 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + @RunWith(Parameterized.class) public class PerMessageDeflateExtensionTest { @@ -145,7 +145,7 @@ public class PerMessageDeflateExtensionTest { client.start(); // Make sure the read times out if there are problems with the implementation - client.setMaxIdleTimeout(TimeUnit.SECONDS.toMillis(1)); + client.setMaxIdleTimeout(TimeUnit.SECONDS.toMillis(15)); CaptureSocket clientSocket = new CaptureSocket(); ClientUpgradeRequest request = new ClientUpgradeRequest(); @@ -155,7 +155,7 @@ public class PerMessageDeflateExtensionTest Future fut = client.connect(clientSocket,server.getServerUri(),request); // Wait for connect - Session session = fut.get(3,TimeUnit.SECONDS); + Session session = fut.get(5,TimeUnit.SECONDS); assertThat("Response.extensions",getNegotiatedExtensionList(session),containsString("permessage-deflate")); @@ -171,7 +171,7 @@ public class PerMessageDeflateExtensionTest // Client sends first message session.getRemote().sendBytes(ByteBuffer.wrap(msg)); - clientSocket.messages.awaitEventCount(1,1,TimeUnit.SECONDS); + clientSocket.messages.awaitEventCount(1,5,TimeUnit.SECONDS); String echoMsg = clientSocket.messages.poll(); Assert.assertThat("Echo'd Message",echoMsg,is("binary[sha1="+sha1+"]")); }