From ce0435e0992c3640cc4f717eaf9f1a7b247f1369 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Thu, 9 May 2013 14:29:59 -0700 Subject: [PATCH] Cleaning up test output --- .../test/resources/jetty-logging.properties | 4 +- .../jsr356/server/BasicAnnotatedTest.java | 2 +- .../server/pathmap/PathMappingsTest.java | 18 ++-- .../test/resources/jetty-logging.properties | 2 +- .../client/TomcatServerQuirksTest.java | 6 +- .../client/blockhead/BlockheadServer.java | 2 +- .../server/WebSocketServletRFCTest.java | 92 ++----------------- .../server/pathmap/PathMappingsTest.java | 18 ++-- 8 files changed, 35 insertions(+), 109 deletions(-) diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/resources/jetty-logging.properties b/jetty-websocket/javax-websocket-client-impl/src/test/resources/jetty-logging.properties index 52538e27d83..ff1a47be4d2 100644 --- a/jetty-websocket/javax-websocket-client-impl/src/test/resources/jetty-logging.properties +++ b/jetty-websocket/javax-websocket-client-impl/src/test/resources/jetty-logging.properties @@ -1,4 +1,4 @@ org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog -org.eclipse.jetty.websocket.LEVEL=DEBUG -org.eclipse.jetty.websocket.jsr356.LEVEL=DEBUG +# org.eclipse.jetty.websocket.LEVEL=DEBUG +# org.eclipse.jetty.websocket.jsr356.LEVEL=DEBUG diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/BasicAnnotatedTest.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/BasicAnnotatedTest.java index 13da6b782b2..1b5f535392a 100644 --- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/BasicAnnotatedTest.java +++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/BasicAnnotatedTest.java @@ -54,7 +54,7 @@ public class BasicAnnotatedTest WebAppContext webapp = wsb.createWebAppContext(); wsb.deployWebapp(webapp); - wsb.dump(); + // wsb.dump(); WebSocketClient client = new WebSocketClient(); try diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/pathmap/PathMappingsTest.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/pathmap/PathMappingsTest.java index 2ba15abe9d6..247b738f903 100644 --- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/pathmap/PathMappingsTest.java +++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/pathmap/PathMappingsTest.java @@ -37,6 +37,14 @@ public class PathMappingsTest Assert.assertEquals(msg,expectedValue,actualMatch); } + public void dumpMappings(PathMappings p) + { + for (MappedResource res : p) + { + System.out.printf(" %s%n",res); + } + } + /** * Test the match order rules with a mixed Servlet and WebSocket path specs *

@@ -59,10 +67,7 @@ public class PathMappingsTest p.put(new WebSocketPathSpec("/animal/{type}/{name}/cam"),"animalCam"); p.put(new WebSocketPathSpec("/entrance/cam"),"entranceCam"); - for (MappedResource res : p) - { - System.out.printf(" %s%n",res); - } + // dumpMappings(p); assertMatch(p,"/animal/bird/eagle","birds"); assertMatch(p,"/animal/fish/bass/sea","fishes"); @@ -94,10 +99,7 @@ public class PathMappingsTest p.put(new WebSocketPathSpec("/{var1}/d"),"endpointD"); p.put(new WebSocketPathSpec("/b/{var2}"),"endpointE"); - for (MappedResource res : p) - { - System.out.printf(" %s%n",res); - } + // dumpMappings(p); assertMatch(p,"/a/b/c","endpointB"); assertMatch(p,"/a/d/c","endpointA"); diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/resources/jetty-logging.properties b/jetty-websocket/javax-websocket-server-impl/src/test/resources/jetty-logging.properties index 95a7e3fbed1..7ec9b882b32 100644 --- a/jetty-websocket/javax-websocket-server-impl/src/test/resources/jetty-logging.properties +++ b/jetty-websocket/javax-websocket-server-impl/src/test/resources/jetty-logging.properties @@ -1,7 +1,7 @@ org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog org.eclipse.jetty.LEVEL=WARN -org.eclipse.jetty.websocket.LEVEL=DEBUG +# org.eclipse.jetty.websocket.LEVEL=DEBUG # org.eclipse.jetty.websocket.LEVEL=WARN # org.eclipse.jetty.websocket.common.io.LEVEL=DEBUG diff --git a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/TomcatServerQuirksTest.java b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/TomcatServerQuirksTest.java index a97c255572c..a2db61f4cfd 100644 --- a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/TomcatServerQuirksTest.java +++ b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/TomcatServerQuirksTest.java @@ -24,6 +24,7 @@ import java.nio.ByteBuffer; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.WebSocketAdapter; import org.eclipse.jetty.websocket.client.blockhead.BlockheadServer; @@ -104,6 +105,7 @@ public class TomcatServerQuirksTest // Have server write frame. int length = bufferSize / 2; ByteBuffer serverFrame = ByteBuffer.allocate(bufferSize); + // BufferUtil.flipToFill(serverFrame); serverFrame.put((byte)(0x80 | 0x01)); // FIN + TEXT serverFrame.put((byte)0x7E); // No MASK and 2 bytes length serverFrame.put((byte)(length >> 8)); // first length byte @@ -112,8 +114,8 @@ public class TomcatServerQuirksTest { serverFrame.put((byte)'x'); } - serverFrame.flip(); - byte buf[] = serverFrame.array(); + BufferUtil.flipToFlush(serverFrame,0); + byte buf[] = BufferUtil.toArray(serverFrame); socket.write(buf,0,buf.length); socket.flush(); diff --git a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/blockhead/BlockheadServer.java b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/blockhead/BlockheadServer.java index 6e7acf30c0d..4e2bc37f718 100644 --- a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/blockhead/BlockheadServer.java +++ b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/blockhead/BlockheadServer.java @@ -510,7 +510,7 @@ public class BlockheadServer resp.append("Connection: upgrade\r\n"); resp.append("Sec-WebSocket-Accept: "); resp.append(AcceptHash.hashKey(key)).append("\r\n"); - if (!extensionStack.hasNegotiatedExtensions()) + if (extensionStack.hasNegotiatedExtensions()) { // Respond to used extensions resp.append("Sec-WebSocket-Extensions: "); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketServletRFCTest.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketServletRFCTest.java index 8ca6db30d5e..e1e31b91eb8 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketServletRFCTest.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketServletRFCTest.java @@ -20,7 +20,6 @@ package org.eclipse.jetty.websocket.server; import static org.hamcrest.Matchers.*; -import java.net.SocketException; import java.nio.ByteBuffer; import java.util.Arrays; import java.util.concurrent.TimeUnit; @@ -36,6 +35,7 @@ import org.eclipse.jetty.websocket.common.Generator; import org.eclipse.jetty.websocket.common.OpCode; import org.eclipse.jetty.websocket.common.Parser; import org.eclipse.jetty.websocket.common.WebSocketFrame; +import org.eclipse.jetty.websocket.common.events.EventDriver; import org.eclipse.jetty.websocket.server.blockhead.BlockheadClient; import org.eclipse.jetty.websocket.server.helper.IncomingFramesCapture; import org.eclipse.jetty.websocket.server.helper.RFCServlet; @@ -43,7 +43,6 @@ import org.eclipse.jetty.websocket.servlet.WebSocketServlet; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; @@ -197,6 +196,9 @@ public class WebSocketServletRFCTest @Test public void testInternalError() throws Exception { + // Disable Long Stacks from EventDriver (we know this test will throw an exception) + enableStacks(EventDriver.class,false); + BlockheadClient client = new BlockheadClient(server.getServerUri()); try { @@ -215,6 +217,8 @@ public class WebSocketServletRFCTest } finally { + // Reenable Long Stacks from EventDriver + enableStacks(EventDriver.class,true); client.close(); } } @@ -261,90 +265,6 @@ public class WebSocketServletRFCTest } } - @Test - @Ignore("Should be moved to Fuzzer") - public void testMaxBinarySize() throws Exception - { - BlockheadClient client = new BlockheadClient(server.getServerUri()); - client.setProtocols("other"); - try - { - client.connect(); - client.sendStandardRequest(); - client.expectUpgradeResponse(); - - // Choose a size for a single frame larger than the - // server side policy - int dataSize = 1024 * 100; - byte buf[] = new byte[dataSize]; - Arrays.fill(buf,(byte)0x44); - - WebSocketFrame bin = WebSocketFrame.binary(buf).setFin(true); - ByteBuffer bb = generator.generate(bin); - try - { - client.writeRaw(bb); - Assert.fail("Write should have failed due to terminated connection"); - } - catch (SocketException e) - { - Assert.assertThat("Exception",e.getMessage(),containsString("Broken pipe")); - } - - IncomingFramesCapture capture = client.readFrames(1,TimeUnit.SECONDS,1); - WebSocketFrame frame = capture.getFrames().poll(); - Assert.assertThat("frames[0].opcode",frame.getOpCode(),is(OpCode.CLOSE)); - CloseInfo close = new CloseInfo(frame); - Assert.assertThat("Close Status Code",close.getStatusCode(),is(StatusCode.MESSAGE_TOO_LARGE)); - } - finally - { - client.close(); - } - } - - @Test - @Ignore("Should be moved to Fuzzer") - public void testMaxTextSize() throws Exception - { - BlockheadClient client = new BlockheadClient(server.getServerUri()); - client.setProtocols("other"); - try - { - client.connect(); - client.sendStandardRequest(); - client.expectUpgradeResponse(); - - // Choose a size for a single frame larger than the - // server side policy - int dataSize = 1024 * 100; - byte buf[] = new byte[dataSize]; - Arrays.fill(buf,(byte)'z'); - - WebSocketFrame text = WebSocketFrame.text().setPayload(buf).setFin(true); - ByteBuffer bb = generator.generate(text); - try - { - client.writeRaw(bb); - Assert.fail("Write should have failed due to terminated connection"); - } - catch (SocketException e) - { - Assert.assertThat("Exception",e.getMessage(),containsString("Broken pipe")); - } - - IncomingFramesCapture capture = client.readFrames(1,TimeUnit.SECONDS,1); - WebSocketFrame frame = capture.getFrames().poll(); - Assert.assertThat("frames[0].opcode",frame.getOpCode(),is(OpCode.CLOSE)); - CloseInfo close = new CloseInfo(frame); - Assert.assertThat("Close Status Code",close.getStatusCode(),is(StatusCode.MESSAGE_TOO_LARGE)); - } - finally - { - client.close(); - } - } - @Test public void testTextNotUTF8() throws Exception { diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/pathmap/PathMappingsTest.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/pathmap/PathMappingsTest.java index cb5f7019bb4..807b1686714 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/pathmap/PathMappingsTest.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/pathmap/PathMappingsTest.java @@ -35,6 +35,14 @@ public class PathMappingsTest Assert.assertEquals(msg,expectedValue,actualMatch); } + public void dumpMappings(PathMappings p) + { + for (MappedResource res : p) + { + System.out.printf(" %s%n",res); + } + } + /** * Test the match order rules with a mixed Servlet and WebSocket path specs *

@@ -57,10 +65,7 @@ public class PathMappingsTest p.put(new RegexPathSpec("^/animal/.*/cam$"),"animalCam"); p.put(new RegexPathSpec("^/entrance/cam$"),"entranceCam"); - for (MappedResource res : p) - { - System.out.printf(" %s%n",res); - } + // dumpMappings(p); assertMatch(p,"/animal/bird/eagle","birds"); assertMatch(p,"/animal/fish/bass/sea","fishes"); @@ -96,10 +101,7 @@ public class PathMappingsTest p.put(new ServletPathSpec("*.gz"),"gzipped"); p.put(new ServletPathSpec("/"),"default"); - for (MappedResource res : p) - { - System.out.printf(" %s%n",res); - } + // dumpMappings(p); assertMatch(p,"/abs/path","path"); assertMatch(p,"/abs/path/longer","longpath");