Cleaning up test output

This commit is contained in:
Joakim Erdfelt 2013-05-09 14:29:59 -07:00
parent 9f82849900
commit ce0435e099
8 changed files with 35 additions and 109 deletions

View File

@ -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

View File

@ -54,7 +54,7 @@ public class BasicAnnotatedTest
WebAppContext webapp = wsb.createWebAppContext();
wsb.deployWebapp(webapp);
wsb.dump();
// wsb.dump();
WebSocketClient client = new WebSocketClient();
try

View File

@ -37,6 +37,14 @@ public class PathMappingsTest
Assert.assertEquals(msg,expectedValue,actualMatch);
}
public void dumpMappings(PathMappings<String> p)
{
for (MappedResource<String> res : p)
{
System.out.printf(" %s%n",res);
}
}
/**
* Test the match order rules with a mixed Servlet and WebSocket path specs
* <p>
@ -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<String> 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<String> res : p)
{
System.out.printf(" %s%n",res);
}
// dumpMappings(p);
assertMatch(p,"/a/b/c","endpointB");
assertMatch(p,"/a/d/c","endpointA");

View File

@ -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

View File

@ -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();

View File

@ -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: ");

View File

@ -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
{

View File

@ -35,6 +35,14 @@ public class PathMappingsTest
Assert.assertEquals(msg,expectedValue,actualMatch);
}
public void dumpMappings(PathMappings<String> p)
{
for (MappedResource<String> res : p)
{
System.out.printf(" %s%n",res);
}
}
/**
* Test the match order rules with a mixed Servlet and WebSocket path specs
* <p>
@ -57,10 +65,7 @@ public class PathMappingsTest
p.put(new RegexPathSpec("^/animal/.*/cam$"),"animalCam");
p.put(new RegexPathSpec("^/entrance/cam$"),"entranceCam");
for (MappedResource<String> 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<String> res : p)
{
System.out.printf(" %s%n",res);
}
// dumpMappings(p);
assertMatch(p,"/abs/path","path");
assertMatch(p,"/abs/path/longer","longpath");