Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Erdfelt2012-08-02 13:13:07 -0400
committerJoakim Erdfelt2012-08-02 13:13:07 -0400
commite2dd62a3af198fbcfaf49e566dda6aff96514774 (patch)
treea6da0793a3fc03bdd9870b8def32dceee5b18449 /jetty-websocket
parenta638bbb850de68a5705feec5b5782c3b725fce03 (diff)
downloadorg.eclipse.jetty.project-e2dd62a3af198fbcfaf49e566dda6aff96514774.tar.gz
org.eclipse.jetty.project-e2dd62a3af198fbcfaf49e566dda6aff96514774.tar.xz
org.eclipse.jetty.project-e2dd62a3af198fbcfaf49e566dda6aff96514774.zip
Trying to work out masking issue with parser
Diffstat (limited to 'jetty-websocket')
-rw-r--r--jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/protocol/Parser.java2
-rw-r--r--jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/protocol/GeneratorTest.java14
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/AbstractABCase.java5
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/Fuzzer.java8
-rw-r--r--jetty-websocket/websocket-server/src/test/resources/jetty-logging.properties2
5 files changed, 25 insertions, 6 deletions
diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/protocol/Parser.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/protocol/Parser.java
index 7e9e5c94df..fa49a5e705 100644
--- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/protocol/Parser.java
+++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/protocol/Parser.java
@@ -164,7 +164,7 @@ public class Parser
incomingFramesHandler.incoming(e);
}
- public void parse(ByteBuffer buffer)
+ public synchronized void parse(ByteBuffer buffer)
{
if (buffer.remaining() <= 0)
{
diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/protocol/GeneratorTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/protocol/GeneratorTest.java
index c903f0548a..3b1b0e60c8 100644
--- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/protocol/GeneratorTest.java
+++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/protocol/GeneratorTest.java
@@ -25,7 +25,7 @@ public class GeneratorTest
{
byte[] MASK =
{ 0x11, 0x22, 0x33, 0x44 };
- int pingCount = 10;
+ int pingCount = 1000;
// the generator
Generator generator = new UnitGenerator();
@@ -58,13 +58,21 @@ public class GeneratorTest
}
BufferUtil.flipToFlush(completeBuf,0);
- // Parse complete buffer.
+ // Parse complete buffer (5 bytes at a time)
WebSocketPolicy policy = WebSocketPolicy.newServerPolicy();
Parser parser = new Parser(policy);
IncomingFramesCapture capture = new IncomingFramesCapture();
parser.setIncomingFramesHandler(capture);
- parser.parse(completeBuf);
+ int segmentSize = 5;
+ while (completeBuf.remaining() > 0)
+ {
+ ByteBuffer part = completeBuf.slice();
+ int len = Math.min(segmentSize,part.remaining());
+ part.limit(part.position() + len);
+ parser.parse(part);
+ completeBuf.position(completeBuf.position() + len);
+ }
// Assert validity of frame
int frameCount = send.size();
diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/AbstractABCase.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/AbstractABCase.java
index 2393808996..258ef27091 100644
--- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/AbstractABCase.java
+++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/AbstractABCase.java
@@ -10,6 +10,8 @@ import org.eclipse.jetty.websocket.protocol.Generator;
import org.eclipse.jetty.websocket.server.SimpleServletServer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.rules.TestName;
public abstract class AbstractABCase
{
@@ -65,6 +67,9 @@ public abstract class AbstractABCase
return ret.toString();
}
+ @Rule
+ public TestName testname = new TestName();
+
public Generator getLaxGenerator()
{
return laxGenerator;
diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/Fuzzer.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/Fuzzer.java
index 82b5e13ac2..fcf9a7f516 100644
--- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/Fuzzer.java
+++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/Fuzzer.java
@@ -41,6 +41,7 @@ public class Fuzzer
private final BlockheadClient client;
private final Generator generator;
+ private final String testname;
private SendMode sendMode = SendMode.BULK;
private int slowSendSegmentSize = 5;
@@ -48,6 +49,7 @@ public class Fuzzer
{
this.client = new BlockheadClient(testcase.getServer().getServerUri());
this.generator = testcase.getLaxGenerator();
+ this.testname = testcase.testname.getMethodName();
}
public ByteBuffer asNetworkBuffer(List<WebSocketFrame> send)
@@ -158,7 +160,7 @@ public class Fuzzer
public void send(List<WebSocketFrame> send) throws IOException
{
Assert.assertThat("Client connected",client.isConnected(),is(true));
- LOG.debug("Sending {} frames (mode {})",send.size(),sendMode);
+ LOG.debug("[{}] Sending {} frames (mode {})",testname,send.size(),sendMode);
if ((sendMode == SendMode.BULK) || (sendMode == SendMode.SLOW))
{
int buflen = 0;
@@ -173,6 +175,10 @@ public class Fuzzer
for (WebSocketFrame f : send)
{
f.setMask(MASK); // make sure we have mask set
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("payload: {}",BufferUtil.toDetailString(f.getPayload()));
+ }
BufferUtil.put(generator.generate(f),buf);
}
BufferUtil.flipToFlush(buf,0);
diff --git a/jetty-websocket/websocket-server/src/test/resources/jetty-logging.properties b/jetty-websocket/websocket-server/src/test/resources/jetty-logging.properties
index 27aa8f1f22..1610750775 100644
--- a/jetty-websocket/websocket-server/src/test/resources/jetty-logging.properties
+++ b/jetty-websocket/websocket-server/src/test/resources/jetty-logging.properties
@@ -14,5 +14,5 @@ org.eclipse.jetty.websocket.server.helper.RFCSocket.LEVEL=OFF
# org.eclipse.jetty.websocket.extensions.LEVEL=DEBUG
# org.eclipse.jetty.websocket.protocol.Generator.LEVEL=INFO
# org.eclipse.jetty.websocket.protocol.Parser.LEVEL=DEBUG
-org.eclipse.jetty.websocket.server.ab.LEVEL=DEBUG
+# org.eclipse.jetty.websocket.server.ab.LEVEL=DEBUG
# org.eclipse.jetty.websocket.server.blockhead.LEVEL=DEBUG \ No newline at end of file

Back to the top