WebSocket - more code cleanup

This commit is contained in:
Joakim Erdfelt 2013-08-20 16:28:51 -07:00
parent c6a4af4f78
commit 975d9870d2
49 changed files with 232 additions and 241 deletions

View File

@ -32,6 +32,8 @@ import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.BinaryFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.common.message.MessageOutputStream;
import org.eclipse.jetty.websocket.common.message.MessageWriter;
import org.eclipse.jetty.websocket.common.util.TextUtil;
@ -73,7 +75,7 @@ public class JsrAsyncRemote extends AbstractJsrRemote implements RemoteEndpoint.
{
LOG.debug("sendBinary({},{})",BufferUtil.toDetailString(data),handler);
}
WebSocketFrame frame = WebSocketFrame.binary().setPayload(data).setFin(true);
WebSocketFrame frame = new BinaryFrame().setPayload(data).setFin(true);
jettyRemote.sendFrame(frame,new SendHandlerWriteCallback(handler));
}
@ -183,7 +185,7 @@ public class JsrAsyncRemote extends AbstractJsrRemote implements RemoteEndpoint.
{
LOG.debug("sendText({},{})",TextUtil.hint(text),handler);
}
WebSocketFrame frame = WebSocketFrame.text(text).setFin(true);
WebSocketFrame frame = new TextFrame().setPayload(text).setFin(true);
jettyRemote.sendFrame(frame,new SendHandlerWriteCallback(handler));
}

View File

@ -27,6 +27,7 @@ import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.client.blockhead.BlockheadServer.ServerConnection;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
public class ServerWriteThread extends Thread
{
@ -71,7 +72,7 @@ public class ServerWriteThread extends Thread
{
while (m.get() < messageCount)
{
conn.write(WebSocketFrame.text(message));
conn.write(new TextFrame().setPayload(message));
if (exchanger != null)
{

View File

@ -34,6 +34,7 @@ import org.eclipse.jetty.websocket.api.UpgradeRequest;
import org.eclipse.jetty.websocket.client.blockhead.BlockheadServer;
import org.eclipse.jetty.websocket.client.blockhead.BlockheadServer.ServerConnection;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.common.io.FutureWriteCallback;
import org.junit.After;
import org.junit.Assert;
@ -179,7 +180,7 @@ public class WebSocketClientTest
Assert.assertThat("Session.upgradeResponse",sess.getUpgradeResponse(),notNullValue());
// Have server send initial message
srvSock.write(WebSocketFrame.text("Hello World"));
srvSock.write(new TextFrame().setPayload("Hello World"));
// Verify connect
future.get(500,TimeUnit.MILLISECONDS);

View File

@ -53,7 +53,6 @@ import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.api.WriteCallback;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.api.extensions.Frame.Type;
import org.eclipse.jetty.websocket.api.extensions.IncomingFrames;
import org.eclipse.jetty.websocket.api.extensions.OutgoingFrames;
import org.eclipse.jetty.websocket.common.AcceptHash;
@ -220,7 +219,7 @@ public class BlockheadServer
}
incomingFrames.incomingFrame(WebSocketFrame.copy(frame));
if (frame.getType() == Type.CLOSE)
if (frame.getOpCode() == OpCode.CLOSE)
{
CloseInfo close = new CloseInfo(frame);
LOG.debug("Close frame: {}",close);
@ -246,7 +245,7 @@ public class BlockheadServer
callback.writeSuccess();
}
if (frame.getType().getOpCode() == OpCode.CLOSE)
if (frame.getOpCode() == OpCode.CLOSE)
{
disconnect();
}

View File

@ -129,7 +129,7 @@ public class Generator
throw new ProtocolException("RSV3 not allowed to be set");
}
if (frame.getType().isControl())
if (OpCode.isControlFrame(frame.getOpCode()))
{
/*
* RFC 6455 Section 5.5
@ -151,7 +151,7 @@ public class Generator
*
* close frame payload is specially formatted which is checked in CloseInfo
*/
if (frame.getType().getOpCode() == OpCode.CLOSE)
if (frame.getOpCode() == OpCode.CLOSE)
{
ByteBuffer payload = frame.getPayload();

View File

@ -56,21 +56,6 @@ import org.eclipse.jetty.websocket.common.frames.TextFrame;
*/
public abstract class WebSocketFrame implements Frame
{
public static BinaryFrame binary()
{
return new BinaryFrame();
}
public static BinaryFrame binary(byte buf[])
{
return new BinaryFrame(buf);
}
public static BinaryFrame binary(ByteBuffer buf)
{
return new BinaryFrame(buf);
}
public static WebSocketFrame copy(Frame copy)
{
WebSocketFrame frame = null;
@ -104,26 +89,6 @@ public abstract class WebSocketFrame implements Frame
return frame;
}
public static PingFrame ping()
{
return new PingFrame();
}
public static PongFrame pong()
{
return new PongFrame();
}
public static TextFrame text()
{
return new TextFrame();
}
public static TextFrame text(String msg)
{
return new TextFrame(msg);
}
/**
* Combined FIN + RSV1 + RSV2 + RSV3 + OpCode byte.
* <p>
@ -149,9 +114,6 @@ public abstract class WebSocketFrame implements Frame
protected int payloadLength = 0;
// FIXME: Remove
private Type type;
/**
* Construct form opcode
*/
@ -178,7 +140,6 @@ public abstract class WebSocketFrame implements Frame
finRsvOp |= frame.isRsv3()?0x10:0x00;
finRsvOp |= frame.getOpCode() & 0x0F;
type = frame.getType();
masked = frame.isMasked();
if (masked)
{
@ -193,7 +154,6 @@ public abstract class WebSocketFrame implements Frame
protected void copyHeaders(WebSocketFrame copy)
{
finRsvOp = copy.finRsvOp;
type = copy.type;
masked = copy.masked;
mask = null;
if (copy.mask != null)
@ -289,7 +249,7 @@ public abstract class WebSocketFrame implements Frame
@Override
public Type getType()
{
return type;
return Type.from(getOpCode());
}
@Override
@ -414,15 +374,6 @@ public abstract class WebSocketFrame implements Frame
protected WebSocketFrame setOpCode(byte op)
{
this.finRsvOp = (byte)((finRsvOp & 0xF0) | (op & 0x0F));
if (op == OpCode.UNDEFINED)
{
this.type = null;
}
else
{
this.type = Frame.Type.from(op);
}
return this;
}

View File

@ -110,7 +110,7 @@ public abstract class AbstractEventDriver implements IncomingFrames, EventDriver
{
onFrame(frame);
byte opcode = frame.getType().getOpCode();
byte opcode = frame.getOpCode();
switch (opcode)
{
case OpCode.CLOSE:

View File

@ -24,6 +24,7 @@ import java.nio.ByteBuffer;
import org.eclipse.jetty.websocket.api.WriteCallback;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.common.OpCode;
import org.eclipse.jetty.websocket.common.extensions.AbstractExtension;
import org.eclipse.jetty.websocket.common.frames.DataFrame;
@ -44,7 +45,7 @@ public class FrameCompressionExtension extends AbstractExtension
@Override
public synchronized void incomingFrame(Frame frame)
{
if (frame.getType().isControl() || !frame.isRsv1())
if (OpCode.isControlFrame(frame.getOpCode()) || !frame.isRsv1())
{
// Cannot modify incoming control frames or ones with RSV1 set.
nextIncomingFrame(frame);
@ -84,7 +85,7 @@ public class FrameCompressionExtension extends AbstractExtension
@Override
public synchronized void outgoingFrame(Frame frame, WriteCallback callback)
{
if (frame.getType().isControl())
if (OpCode.isControlFrame(frame.getOpCode()))
{
// skip, cannot compress control frames.
nextOutgoingFrame(frame,callback);

View File

@ -23,6 +23,7 @@ import java.nio.ByteBuffer;
import org.eclipse.jetty.websocket.api.WriteCallback;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.common.OpCode;
import org.eclipse.jetty.websocket.common.extensions.AbstractExtension;
import org.eclipse.jetty.websocket.common.frames.DataFrame;
@ -44,7 +45,7 @@ public class MessageDeflateCompressionExtension extends AbstractExtension
@Override
public void incomingFrame(Frame frame)
{
if (frame.getType().isControl() || !frame.isRsv1())
if (OpCode.isControlFrame(frame.getOpCode()) || !frame.isRsv1())
{
// Cannot modify incoming control frames or ones with RSV1 set.
nextIncomingFrame(frame);
@ -90,7 +91,7 @@ public class MessageDeflateCompressionExtension extends AbstractExtension
@Override
public void outgoingFrame(Frame frame, WriteCallback callback)
{
if (frame.getType().isControl())
if (OpCode.isControlFrame(frame.getOpCode()))
{
// skip, cannot compress control frames.
nextOutgoingFrame(frame,callback);

View File

@ -24,6 +24,7 @@ import java.nio.ByteBuffer;
import org.eclipse.jetty.websocket.api.WriteCallback;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.common.OpCode;
import org.eclipse.jetty.websocket.common.extensions.AbstractExtension;
import org.eclipse.jetty.websocket.common.frames.DataFrame;
@ -57,7 +58,7 @@ public class FragmentExtension extends AbstractExtension
@Override
public void outgoingFrame(Frame frame, WriteCallback callback)
{
if (frame.getType().isControl())
if (OpCode.isControlFrame(frame.getOpCode()))
{
// Cannot fragment Control Frames
nextOutgoingFrame(frame,callback);

View File

@ -28,6 +28,12 @@ public class CloseFrame extends ControlFrame
super(OpCode.CLOSE);
}
@Override
public Type getType()
{
return Type.CLOSE;
}
/**
* Truncate arbitrary reason into something that will fit into the CloseFrame limits.
*

View File

@ -34,6 +34,7 @@ import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.common.Generator;
import org.eclipse.jetty.websocket.common.OpCode;
/**
* Interface for working with bytes destined for {@link EndPoint#write(Callback, ByteBuffer...)}
@ -190,12 +191,12 @@ public class WriteBytesProvider implements Callback
FrameEntry entry = new FrameEntry(frame,callback);
switch (frame.getType())
switch (frame.getOpCode())
{
case PING:
case OpCode.PING:
queue.addFirst(entry);
break;
case CLOSE:
case OpCode.CLOSE:
closed.set(true);
// drop the rest of the queue?
queue.addLast(entry);

View File

@ -50,7 +50,7 @@ public class GeneratorParserRoundtripTest
{
// Generate Buffer
BufferUtil.flipToFill(out);
WebSocketFrame frame = WebSocketFrame.text(message);
WebSocketFrame frame = new TextFrame().setPayload(message);
ByteBuffer header = gen.generateHeaderBytes(frame);
ByteBuffer payload = gen.getPayloadWindow(frame.getPayloadLength(),frame);
out.put(header);
@ -90,7 +90,7 @@ public class GeneratorParserRoundtripTest
try
{
// Setup Frame
WebSocketFrame frame = WebSocketFrame.text(message);
WebSocketFrame frame = new TextFrame().setPayload(message);
// Add masking
byte mask[] = new byte[4];

View File

@ -30,8 +30,10 @@ import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.api.StatusCode;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.common.frames.BinaryFrame;
import org.eclipse.jetty.websocket.common.frames.CloseFrame;
import org.eclipse.jetty.websocket.common.frames.PingFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.junit.Assert;
import org.junit.Test;
@ -155,7 +157,7 @@ public class GeneratorTest
@Test
public void testText_Hello()
{
WebSocketFrame frame = WebSocketFrame.text("Hello");
WebSocketFrame frame = new TextFrame().setPayload("Hello");
byte utf[] = StringUtil.getUtf8Bytes("Hello");
assertGeneratedBytes("8105" + Hex.asHex(utf),frame);
}
@ -163,7 +165,7 @@ public class GeneratorTest
@Test
public void testText_Masked()
{
WebSocketFrame frame = WebSocketFrame.text("Hello");
WebSocketFrame frame = new TextFrame().setPayload("Hello");
byte maskingKey[] = Hex.asByteArray("11223344");
frame.setMask(maskingKey);
@ -189,7 +191,7 @@ public class GeneratorTest
// we are testing that masking works as intended, even if the provided
// payload does not start at position 0.
LOG.debug("Payload = {}",BufferUtil.toDetailString(payload));
WebSocketFrame frame = WebSocketFrame.text().setPayload(payload);
WebSocketFrame frame = new TextFrame().setPayload(payload);
byte maskingKey[] = Hex.asByteArray("11223344");
frame.setMask(maskingKey);
@ -249,7 +251,7 @@ public class GeneratorTest
byte payload[] = new byte[10240];
Arrays.fill(payload,(byte)0x44);
WebSocketFrame frame = WebSocketFrame.binary(payload);
WebSocketFrame frame = new BinaryFrame(payload);
// Generate
int windowSize = 1024;
@ -277,7 +279,7 @@ public class GeneratorTest
byte mask[] = new byte[]
{ 0x2A, (byte)0xF0, 0x0F, 0x00 };
WebSocketFrame frame = WebSocketFrame.binary(payload);
WebSocketFrame frame = new BinaryFrame(payload);
frame.setMask(mask); // masking!
// Generate

View File

@ -80,7 +80,7 @@ public class RFC6455ExamplesGeneratorTest
@Test
public void testSingleMaskedTextMessage()
{
WebSocketFrame text = WebSocketFrame.text("Hello");
WebSocketFrame text = new TextFrame().setPayload("Hello");
text.setMask(new byte[]
{ 0x37, (byte)0xfa, 0x21, 0x3d });
@ -173,7 +173,7 @@ public class RFC6455ExamplesGeneratorTest
@Test
public void testSingleUnmaskedTextMessage()
{
WebSocketFrame text = WebSocketFrame.text("Hello");
WebSocketFrame text = new TextFrame().setPayload("Hello");
ByteBuffer actual = UnitGenerator.generate(text);

View File

@ -35,6 +35,7 @@ import org.eclipse.jetty.websocket.common.Parser;
import org.eclipse.jetty.websocket.common.UnitGenerator;
import org.eclipse.jetty.websocket.common.UnitParser;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.junit.Assert;
import org.junit.Test;
@ -53,7 +54,7 @@ public class TestABCase1_1
Arrays.fill(buf,(byte)'*');
String text = new String(buf,StringUtil.__UTF8_CHARSET);
Frame textFrame = WebSocketFrame.text(text);
Frame textFrame = new TextFrame().setPayload(text);
ByteBuffer actual = UnitGenerator.generate(textFrame);
@ -88,7 +89,7 @@ public class TestABCase1_1
builder.append("*");
}
WebSocketFrame textFrame = WebSocketFrame.text(builder.toString());
WebSocketFrame textFrame = new TextFrame().setPayload(builder.toString());
ByteBuffer actual = UnitGenerator.generate(textFrame);
@ -127,7 +128,7 @@ public class TestABCase1_1
builder.append("*");
}
WebSocketFrame textFrame = WebSocketFrame.text(builder.toString());
WebSocketFrame textFrame = new TextFrame().setPayload(builder.toString());
ByteBuffer actual = UnitGenerator.generate(textFrame);
@ -166,7 +167,7 @@ public class TestABCase1_1
builder.append("*");
}
WebSocketFrame textFrame = WebSocketFrame.text(builder.toString());
WebSocketFrame textFrame = new TextFrame().setPayload(builder.toString());
ByteBuffer actual = UnitGenerator.generate(textFrame);
@ -205,7 +206,7 @@ public class TestABCase1_1
builder.append("*");
}
WebSocketFrame textFrame = WebSocketFrame.text(builder.toString());
WebSocketFrame textFrame = new TextFrame().setPayload(builder.toString());
ByteBuffer actual = UnitGenerator.generate(textFrame);
@ -242,7 +243,7 @@ public class TestABCase1_1
builder.append("*");
}
WebSocketFrame textFrame = WebSocketFrame.text(builder.toString());
WebSocketFrame textFrame = new TextFrame().setPayload(builder.toString());
ByteBuffer actual = UnitGenerator.generate(textFrame);
@ -270,7 +271,7 @@ public class TestABCase1_1
@Test
public void testGenerateEmptyTextCase1_1_1()
{
WebSocketFrame textFrame = WebSocketFrame.text("");
WebSocketFrame textFrame = new TextFrame().setPayload("");
ByteBuffer actual = UnitGenerator.generate(textFrame);

View File

@ -34,6 +34,7 @@ import org.eclipse.jetty.websocket.common.Parser;
import org.eclipse.jetty.websocket.common.UnitGenerator;
import org.eclipse.jetty.websocket.common.UnitParser;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.BinaryFrame;
import org.junit.Assert;
import org.junit.Test;
@ -58,7 +59,7 @@ public class TestABCase1_2
bb.flip();
WebSocketFrame binaryFrame = WebSocketFrame.binary().setPayload(bb);
WebSocketFrame binaryFrame = new BinaryFrame().setPayload(bb);
ByteBuffer actual = UnitGenerator.generate(binaryFrame);
@ -96,7 +97,7 @@ public class TestABCase1_2
bb.flip();
WebSocketFrame binaryFrame = WebSocketFrame.binary().setPayload(bb);
WebSocketFrame binaryFrame = new BinaryFrame().setPayload(bb);
ByteBuffer actual = UnitGenerator.generate(binaryFrame);
@ -138,7 +139,7 @@ public class TestABCase1_2
bb.flip();
WebSocketFrame binaryFrame = WebSocketFrame.binary().setPayload(bb);
WebSocketFrame binaryFrame = new BinaryFrame().setPayload(bb);
ByteBuffer actual = UnitGenerator.generate(binaryFrame);
@ -179,7 +180,7 @@ public class TestABCase1_2
}
bb.flip();
WebSocketFrame binaryFrame = WebSocketFrame.binary().setPayload(bb);
WebSocketFrame binaryFrame = new BinaryFrame().setPayload(bb);
ByteBuffer actual = UnitGenerator.generate(binaryFrame);
@ -222,7 +223,7 @@ public class TestABCase1_2
bb.flip();
WebSocketFrame binaryFrame = WebSocketFrame.binary().setPayload(bb);
WebSocketFrame binaryFrame = new BinaryFrame().setPayload(bb);
ByteBuffer actual = UnitGenerator.generate(binaryFrame);
@ -261,7 +262,7 @@ public class TestABCase1_2
bb.flip();
WebSocketFrame binaryFrame = WebSocketFrame.binary().setPayload(bb);
WebSocketFrame binaryFrame = new BinaryFrame().setPayload(bb);
ByteBuffer actual = UnitGenerator.generate(binaryFrame);
@ -289,7 +290,7 @@ public class TestABCase1_2
@Test
public void testGenerateEmptyBinaryCase1_2_1()
{
WebSocketFrame binaryFrame = WebSocketFrame.binary(new byte[] {});
WebSocketFrame binaryFrame = new BinaryFrame(new byte[] {});
ByteBuffer actual = UnitGenerator.generate(binaryFrame);

View File

@ -102,7 +102,7 @@ public class TestABCase2
@Test
public void testGenerateEmptyPingCase2_1()
{
WebSocketFrame pingFrame = WebSocketFrame.ping();
WebSocketFrame pingFrame = new PingFrame();
ByteBuffer actual = UnitGenerator.generate(pingFrame);

View File

@ -27,6 +27,8 @@ import org.eclipse.jetty.websocket.api.ProtocolException;
import org.eclipse.jetty.websocket.common.CloseInfo;
import org.eclipse.jetty.websocket.common.UnitGenerator;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.PingFrame;
import org.eclipse.jetty.websocket.common.frames.PongFrame;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -45,21 +47,21 @@ public class TestABCase3
List<WebSocketFrame[]> data = new ArrayList<>();
// @formatter:off
data.add(new WebSocketFrame[]
{ WebSocketFrame.ping().setFin(false) });
{ new PingFrame().setFin(false) });
data.add(new WebSocketFrame[]
{ WebSocketFrame.ping().setRsv1(true) });
{ new PingFrame().setRsv1(true) });
data.add(new WebSocketFrame[]
{ WebSocketFrame.ping().setRsv2(true) });
{ new PingFrame().setRsv2(true) });
data.add(new WebSocketFrame[]
{ WebSocketFrame.ping().setRsv3(true) });
{ new PingFrame().setRsv3(true) });
data.add(new WebSocketFrame[]
{ WebSocketFrame.pong().setFin(false) });
{ new PongFrame().setFin(false) });
data.add(new WebSocketFrame[]
{ WebSocketFrame.ping().setRsv1(true) });
{ new PingFrame().setRsv1(true) });
data.add(new WebSocketFrame[]
{ WebSocketFrame.pong().setRsv2(true) });
{ new PongFrame().setRsv2(true) });
data.add(new WebSocketFrame[]
{ WebSocketFrame.pong().setRsv3(true) });
{ new PongFrame().setRsv3(true) });
data.add(new WebSocketFrame[]
{ new CloseInfo().asFrame().setFin(false) });
data.add(new WebSocketFrame[]

View File

@ -160,7 +160,7 @@ public class EventDriverTest
{
conn.start();
conn.open();
driver.incomingFrame(WebSocketFrame.text("Hello World"));
driver.incomingFrame(new TextFrame().setPayload("Hello World"));
driver.incomingFrame(new CloseInfo(StatusCode.NORMAL).asFrame());
socket.capture.assertEventCount(3);

View File

@ -71,7 +71,7 @@ public class FragmentExtensionTest
// Manually create frame and pass into extension
for (String q : quote)
{
Frame frame = WebSocketFrame.text(q);
Frame frame = new TextFrame().setPayload(q);
ext.incomingFrame(frame);
}
@ -158,7 +158,7 @@ public class FragmentExtensionTest
// Write quote as separate frames
for (String section : quote)
{
Frame frame = WebSocketFrame.text(section);
Frame frame = new TextFrame().setPayload(section);
ext.outgoingFrame(frame,null);
}
@ -230,7 +230,7 @@ public class FragmentExtensionTest
// Write quote as separate frames
for (String section : quote)
{
Frame frame = WebSocketFrame.text(section);
Frame frame = new TextFrame().setPayload(section);
ext.outgoingFrame(frame,null);
}

View File

@ -33,6 +33,7 @@ import org.eclipse.jetty.websocket.common.OpCode;
import org.eclipse.jetty.websocket.common.OutgoingFramesCapture;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.extensions.identity.IdentityExtension;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.junit.Assert;
import org.junit.Test;
@ -49,7 +50,7 @@ public class IdentityExtensionTest
Extension ext = new IdentityExtension();
ext.setNextIncomingFrames(capture);
Frame frame = WebSocketFrame.text("hello");
Frame frame = new TextFrame().setPayload("hello");
ext.incomingFrame(frame);
capture.assertFrameCount(1);
@ -78,7 +79,7 @@ public class IdentityExtensionTest
Extension ext = new IdentityExtension();
ext.setNextOutgoingFrames(capture);
Frame frame = WebSocketFrame.text("hello");
Frame frame = new TextFrame().setPayload("hello");
ext.outgoingFrame(frame,null);
capture.assertFrameCount(1);

View File

@ -42,6 +42,7 @@ import org.eclipse.jetty.websocket.common.OutgoingNetworkBytesCapture;
import org.eclipse.jetty.websocket.common.Parser;
import org.eclipse.jetty.websocket.common.UnitParser;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.junit.Assert;
import org.junit.Test;
@ -109,7 +110,7 @@ public class FrameCompressionExtensionTest
OutgoingNetworkBytesCapture capture = new OutgoingNetworkBytesCapture(generator);
ext.setNextOutgoingFrames(capture);
Frame frame = WebSocketFrame.text(text);
Frame frame = new TextFrame().setPayload(text);
ext.outgoingFrame(frame,null);
capture.assertBytes(0,expectedHex);
@ -228,8 +229,8 @@ public class FrameCompressionExtensionTest
OutgoingNetworkBytesCapture capture = new OutgoingNetworkBytesCapture(generator);
ext.setNextOutgoingFrames(capture);
ext.outgoingFrame(WebSocketFrame.text("Hello"),null);
ext.outgoingFrame(WebSocketFrame.text("There"),null);
ext.outgoingFrame(new TextFrame().setPayload("Hello"),null);
ext.outgoingFrame(new TextFrame().setPayload("There"),null);
capture.assertBytes(0,"c107f248cdc9c90700");
capture.assertBytes(1,"c1070ac9482d4a0500");

View File

@ -288,7 +288,7 @@ public class MessageCompressionExtensionTest
// Write quote as separate frames
for (String section : quote)
{
Frame frame = WebSocketFrame.text(section);
Frame frame = new TextFrame().setPayload(section);
ext.outgoingFrame(frame,null);
}

View File

@ -33,6 +33,7 @@ import org.eclipse.jetty.websocket.common.Hex;
import org.eclipse.jetty.websocket.common.UnitGenerator;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.BinaryFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.junit.Assert;
import org.junit.Test;
@ -56,7 +57,7 @@ public class WriteBytesProviderTest
bytesProvider = new WriteBytesProvider(generator,flushCallback);
TrackingCallback frameCallback = new TrackingCallback();
Frame frame = WebSocketFrame.text("Test");
Frame frame = new TextFrame().setPayload("Test");
// place in to bytes provider
bytesProvider.enqueue(frame,frameCallback);
@ -86,7 +87,7 @@ public class WriteBytesProviderTest
// Create frames for provider
TrackingCallback textCallback = new TrackingCallback();
TrackingCallback closeCallback = new TrackingCallback();
bytesProvider.enqueue(WebSocketFrame.text("Bye"),textCallback);
bytesProvider.enqueue(new TextFrame().setPayload("Bye"),textCallback);
bytesProvider.enqueue(new CloseInfo().asFrame(),closeCallback);
// get bytes out

View File

@ -45,7 +45,7 @@ public class DeMaskProcessorTest
// Use a string that is not multiple of 4 in length to test if/else branches in DeMaskProcessor
String message = "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF01";
WebSocketFrame frame = WebSocketFrame.text(message);
WebSocketFrame frame = new TextFrame().setPayload(message);
frame.setMask(TypeUtil.fromHexString("11223344"));
ByteBuffer buf = UnitGenerator.generate(frame);

View File

@ -28,6 +28,7 @@ import org.eclipse.jetty.websocket.api.WriteCallback;
import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.api.extensions.OutgoingFrames;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.BinaryFrame;
import org.eclipse.jetty.websocket.mux.op.MuxAddChannelRequest;
import org.eclipse.jetty.websocket.mux.op.MuxAddChannelResponse;
import org.eclipse.jetty.websocket.mux.op.MuxDropChannel;
@ -66,12 +67,12 @@ public class MuxGenerator
b |= (byte)(frame.isRsv1()?0x40:0x00); // rsv1
b |= (byte)(frame.isRsv2()?0x20:0x00); // rsv2
b |= (byte)(frame.isRsv3()?0x10:0x00); // rsv3
b |= (byte)(frame.getType().getOpCode() & 0x0F); // opcode
b |= (byte)(frame.getOpCode() & 0x0F); // opcode
muxPayload.put(b);
BufferUtil.put(frame.getPayload(),muxPayload);
// build muxed frame
WebSocketFrame muxFrame = WebSocketFrame.binary();
WebSocketFrame muxFrame = new BinaryFrame();
BufferUtil.flipToFlush(muxPayload,0);
muxFrame.setPayload(muxPayload);
// NOTE: the physical connection will handle masking rules for this frame.
@ -164,7 +165,7 @@ public class MuxGenerator
}
}
BufferUtil.flipToFlush(payload,0);
WebSocketFrame frame = WebSocketFrame.binary();
WebSocketFrame frame = new BinaryFrame();
frame.setPayload(payload);
outgoing.outgoingFrame(frame,callback);
}

View File

@ -81,7 +81,7 @@ public class MuxParser
return; // nothing to parse
}
if (frame.getType().getOpCode() != OpCode.BINARY)
if (frame.getOpCode() != OpCode.BINARY)
{
LOG.debug("Not a binary opcode (base frame), skipping");
return; // not a binary opcode

View File

@ -23,6 +23,7 @@ import static org.hamcrest.Matchers.*;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.common.OpCode;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.mux.MuxDecoder;
import org.eclipse.jetty.websocket.mux.MuxEncoder;
import org.eclipse.jetty.websocket.mux.MuxOp;
@ -97,7 +98,7 @@ public class MuxerAddServerTest
clientRead.reset();
// Send simple echo request
clientWrite.frame(1,WebSocketFrame.text("Hello World"));
clientWrite.frame(1,new TextFrame().setPayload("Hello World"));
// Test for echo response (is there a user echo websocket connected to the sub-channel?)
clientRead.assertHasFrame(OpCode.TEXT,1L,1);

View File

@ -27,6 +27,7 @@ import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.server.blockhead.BlockheadClient;
import org.eclipse.jetty.websocket.server.examples.echo.BigEchoSocket;
import org.eclipse.jetty.websocket.server.helper.IncomingFramesCapture;
@ -89,7 +90,7 @@ public class AnnotatedMaxMessageSizeTest
// Generate text frame
String msg = "this is an echo ... cho ... ho ... o";
client.write(WebSocketFrame.text(msg));
client.write(new TextFrame().setPayload(msg));
// Read frame (hopefully text frame)
IncomingFramesCapture capture = client.readFrames(1,TimeUnit.MILLISECONDS,500);

View File

@ -23,6 +23,7 @@ import static org.hamcrest.Matchers.*;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.server.blockhead.BlockheadClient;
import org.eclipse.jetty.websocket.server.blockhead.HttpResponse;
import org.eclipse.jetty.websocket.server.examples.MyEchoServlet;
@ -66,7 +67,7 @@ public class ChromeTest
// Generate text frame
String msg = "this is an echo ... cho ... ho ... o";
client.write(WebSocketFrame.text(msg));
client.write(new TextFrame().setPayload(msg));
// Read frame (hopefully text frame)
IncomingFramesCapture capture = client.readFrames(1,TimeUnit.MILLISECONDS,500);

View File

@ -23,6 +23,7 @@ import static org.hamcrest.Matchers.*;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.server.blockhead.BlockheadClient;
import org.eclipse.jetty.websocket.server.examples.MyEchoServlet;
import org.eclipse.jetty.websocket.server.helper.IncomingFramesCapture;
@ -62,7 +63,7 @@ public class FirefoxTest
// Generate text frame
String msg = "this is an echo ... cho ... ho ... o";
client.write(WebSocketFrame.text(msg));
client.write(new TextFrame().setPayload(msg));
// Read frame (hopefully text frame)
IncomingFramesCapture capture = client.readFrames(1,TimeUnit.MILLISECONDS,500);

View File

@ -23,6 +23,7 @@ import static org.hamcrest.Matchers.*;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.server.blockhead.BlockheadClient;
import org.eclipse.jetty.websocket.server.blockhead.HttpResponse;
import org.eclipse.jetty.websocket.server.helper.EchoServlet;
@ -86,7 +87,7 @@ public class FragmentExtensionTest
Assert.assertThat("Response",resp.getExtensionsHeader(),containsString("fragment"));
String msg = "Sent as a long message that should be split";
client.write(WebSocketFrame.text(msg));
client.write(new TextFrame().setPayload(msg));
String parts[] = split(msg,fragSize);
IncomingFramesCapture capture = client.readFrames(parts.length,TimeUnit.MILLISECONDS,1000);

View File

@ -23,6 +23,7 @@ import static org.hamcrest.Matchers.*;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.server.blockhead.BlockheadClient;
import org.eclipse.jetty.websocket.server.blockhead.HttpResponse;
import org.eclipse.jetty.websocket.server.helper.EchoServlet;
@ -72,7 +73,7 @@ public class FrameCompressionExtensionTest
String msg = "Hello";
// Client sends first message
client.write(WebSocketFrame.text(msg));
client.write(new TextFrame().setPayload(msg));
IncomingFramesCapture capture = client.readFrames(1,TimeUnit.MILLISECONDS,1000);
WebSocketFrame frame = capture.getFrames().poll();
@ -81,7 +82,7 @@ public class FrameCompressionExtensionTest
// Client sends second message
client.clearCaptured();
msg = "There";
client.write(WebSocketFrame.text(msg));
client.write(new TextFrame().setPayload(msg));
capture = client.readFrames(1,TimeUnit.SECONDS,1);
frame = capture.getFrames().poll();

View File

@ -23,6 +23,7 @@ import static org.hamcrest.Matchers.*;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.server.blockhead.BlockheadClient;
import org.eclipse.jetty.websocket.server.blockhead.HttpResponse;
import org.eclipse.jetty.websocket.server.helper.EchoServlet;
@ -70,7 +71,7 @@ public class IdentityExtensionTest
Assert.assertThat("Response",resp.getExtensionsHeader(),containsString("identity"));
client.write(WebSocketFrame.text("Hello"));
client.write(new TextFrame().setPayload("Hello"));
IncomingFramesCapture capture = client.readFrames(1,TimeUnit.MILLISECONDS,1000);
WebSocketFrame frame = capture.getFrames().poll();

View File

@ -21,6 +21,7 @@ package org.eclipse.jetty.websocket.server;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.server.blockhead.BlockheadClient;
import org.eclipse.jetty.websocket.server.helper.RFCSocket;
import org.eclipse.jetty.websocket.servlet.WebSocketServlet;
@ -81,7 +82,7 @@ public class IdleTimeoutTest
// Server could be in a half-closed state at this point.
// Where the server read is closed (due to timeout), but the server write is still open.
// The server could not read this frame, if it is in this half closed state
client.write(WebSocketFrame.text("Hello"));
client.write(new TextFrame().setPayload("Hello"));
// Expect server to be disconnected at this point
client.expectServerDisconnect();

View File

@ -32,6 +32,7 @@ import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect;
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage;
import org.eclipse.jetty.websocket.api.annotations.WebSocket;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.server.blockhead.BlockheadClient;
import org.eclipse.jetty.websocket.servlet.WebSocketServlet;
import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory;
@ -98,7 +99,7 @@ public class LoadTest
{
for (int i = 0; i < iterations; i++)
{
client.write(WebSocketFrame.text("msg-" + i));
client.write(new TextFrame().setPayload("msg-" + i));
if ((i % 100) == 0)
{
LOG.info("Client Wrote {} msgs",i);

View File

@ -27,6 +27,7 @@ import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.toolchain.test.AdvancedRunner;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.server.blockhead.BlockheadClient;
import org.eclipse.jetty.websocket.server.helper.IncomingFramesCapture;
import org.eclipse.jetty.websocket.server.helper.SessionServlet;
@ -68,7 +69,7 @@ public class WebSocketServerSessionTest
client.sendStandardRequest();
client.expectUpgradeResponse();
client.write(WebSocketFrame.text("harsh-disconnect"));
client.write(new TextFrame().setPayload("harsh-disconnect"));
client.awaitDisconnect(1,TimeUnit.SECONDS);
}
@ -90,10 +91,10 @@ public class WebSocketServerSessionTest
client.expectUpgradeResponse();
// Ask the server socket for specific parameter map info
client.write(WebSocketFrame.text("getParameterMap|snack"));
client.write(WebSocketFrame.text("getParameterMap|amount"));
client.write(WebSocketFrame.text("getParameterMap|brand"));
client.write(WebSocketFrame.text("getParameterMap|cost")); // intentionall invalid
client.write(new TextFrame().setPayload("getParameterMap|snack"));
client.write(new TextFrame().setPayload("getParameterMap|amount"));
client.write(new TextFrame().setPayload("getParameterMap|brand"));
client.write(new TextFrame().setPayload("getParameterMap|cost")); // intentionall invalid
// Read frame (hopefully text frame)
IncomingFramesCapture capture = client.readFrames(4,TimeUnit.MILLISECONDS,500);

View File

@ -179,7 +179,7 @@ public class WebSocketServletRFCTest
// Generate text frame
String msg = "this is an echo ... cho ... ho ... o";
client.write(WebSocketFrame.text(msg));
client.write(new TextFrame().setPayload(msg));
// Read frame (hopefully text frame)
IncomingFramesCapture capture = client.readFrames(1,TimeUnit.MILLISECONDS,500);
@ -212,7 +212,7 @@ public class WebSocketServletRFCTest
try (StacklessLogging context = new StacklessLogging(EventDriver.class))
{
// Generate text frame
client.write(WebSocketFrame.text("CRASH"));
client.write(new TextFrame().setPayload("CRASH"));
// Read frame (hopefully close frame)
IncomingFramesCapture capture = client.readFrames(1,TimeUnit.MILLISECONDS,500);
@ -258,7 +258,7 @@ public class WebSocketServletRFCTest
// Generate text frame
String msg = "this is an echo ... cho ... ho ... o";
client.write(WebSocketFrame.text(msg));
client.write(new TextFrame().setPayload(msg));
// Read frame (hopefully text frame)
IncomingFramesCapture capture = client.readFrames(1,TimeUnit.MILLISECONDS,500);
@ -337,7 +337,7 @@ public class WebSocketServletRFCTest
// Generate text frame
String msg = "this is an echo ... cho ... ho ... o";
client.write(WebSocketFrame.text(msg));
client.write(new TextFrame().setPayload(msg));
// Read frame (hopefully text frame)
IncomingFramesCapture capture = client.readFrames(1,TimeUnit.MILLISECONDS,500);

View File

@ -26,6 +26,7 @@ import java.util.List;
import org.eclipse.jetty.websocket.api.StatusCode;
import org.eclipse.jetty.websocket.common.CloseInfo;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.BinaryFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.server.ab.Fuzzer.SendMode;
import org.junit.Test;
@ -39,11 +40,11 @@ public class TestABCase1 extends AbstractABCase
public void testCase1_1_1() throws Exception
{
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.text());
send.add(new TextFrame());
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.text());
expect.add(new TextFrame());
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -72,11 +73,11 @@ public class TestABCase1 extends AbstractABCase
ByteBuffer buf = ByteBuffer.wrap(payload);
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.text().setPayload(buf));
send.add(new TextFrame().setPayload(buf));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.text().setPayload(clone(buf)));
expect.add(new TextFrame().setPayload(clone(buf)));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -105,11 +106,11 @@ public class TestABCase1 extends AbstractABCase
ByteBuffer buf = ByteBuffer.wrap(payload);
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.text().setPayload(buf));
send.add(new TextFrame().setPayload(buf));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.text().setPayload(clone(buf)));
expect.add(new TextFrame().setPayload(clone(buf)));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -138,11 +139,11 @@ public class TestABCase1 extends AbstractABCase
ByteBuffer buf = ByteBuffer.wrap(payload);
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.text().setPayload(buf));
send.add(new TextFrame().setPayload(buf));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.text().setPayload(clone(buf)));
expect.add(new TextFrame().setPayload(clone(buf)));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -171,11 +172,11 @@ public class TestABCase1 extends AbstractABCase
ByteBuffer buf = ByteBuffer.wrap(payload);
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.text().setPayload(buf));
send.add(new TextFrame().setPayload(buf));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.text().setPayload(clone(buf)));
expect.add(new TextFrame().setPayload(clone(buf)));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -204,11 +205,11 @@ public class TestABCase1 extends AbstractABCase
ByteBuffer buf = ByteBuffer.wrap(payload);
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.text().setPayload(buf));
send.add(new TextFrame().setPayload(buf));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.text().setPayload(clone(buf)));
expect.add(new TextFrame().setPayload(clone(buf)));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -275,11 +276,11 @@ public class TestABCase1 extends AbstractABCase
int segmentSize = 997;
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.text().setPayload(buf));
send.add(new TextFrame().setPayload(buf));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.text().setPayload(clone(buf)));
expect.add(new TextFrame().setPayload(clone(buf)));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -305,11 +306,11 @@ public class TestABCase1 extends AbstractABCase
public void testCase1_2_1() throws Exception
{
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.binary());
send.add(new BinaryFrame());
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.binary());
expect.add(new BinaryFrame());
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -338,11 +339,11 @@ public class TestABCase1 extends AbstractABCase
ByteBuffer buf = ByteBuffer.wrap(payload);
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.binary().setPayload(buf));
send.add(new BinaryFrame().setPayload(buf));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.binary().setPayload(clone(buf)));
expect.add(new BinaryFrame().setPayload(clone(buf)));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -371,11 +372,11 @@ public class TestABCase1 extends AbstractABCase
ByteBuffer buf = ByteBuffer.wrap(payload);
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.binary().setPayload(buf));
send.add(new BinaryFrame().setPayload(buf));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.binary().setPayload(clone(buf)));
expect.add(new BinaryFrame().setPayload(clone(buf)));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -404,11 +405,11 @@ public class TestABCase1 extends AbstractABCase
ByteBuffer buf = ByteBuffer.wrap(payload);
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.binary().setPayload(buf));
send.add(new BinaryFrame().setPayload(buf));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.binary().setPayload(clone(buf)));
expect.add(new BinaryFrame().setPayload(clone(buf)));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -437,11 +438,11 @@ public class TestABCase1 extends AbstractABCase
ByteBuffer buf = ByteBuffer.wrap(payload);
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.binary().setPayload(buf));
send.add(new BinaryFrame().setPayload(buf));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.binary().setPayload(clone(buf)));
expect.add(new BinaryFrame().setPayload(clone(buf)));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -470,11 +471,11 @@ public class TestABCase1 extends AbstractABCase
ByteBuffer buf = ByteBuffer.wrap(payload);
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.binary().setPayload(buf));
send.add(new BinaryFrame().setPayload(buf));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.binary().setPayload(clone(buf)));
expect.add(new BinaryFrame().setPayload(clone(buf)));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -503,11 +504,11 @@ public class TestABCase1 extends AbstractABCase
ByteBuffer buf = ByteBuffer.wrap(payload);
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.binary().setPayload(buf));
send.add(new BinaryFrame().setPayload(buf));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.binary().setPayload(clone(buf)));
expect.add(new BinaryFrame().setPayload(clone(buf)));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -541,11 +542,11 @@ public class TestABCase1 extends AbstractABCase
int segmentSize = 997;
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.binary().setPayload(buf));
send.add(new BinaryFrame().setPayload(buf));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.binary().setPayload(clone(buf)));
expect.add(new BinaryFrame().setPayload(clone(buf)));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);

View File

@ -45,9 +45,9 @@ public class TestABCase2 extends AbstractABCase
@Test
public void testCase2_1() throws Exception
{
WebSocketFrame send = WebSocketFrame.ping();
WebSocketFrame send = new PingFrame();
WebSocketFrame expect = WebSocketFrame.pong();
WebSocketFrame expect = new PongFrame();
Fuzzer fuzzer = new Fuzzer(this);
try
@ -309,7 +309,7 @@ public class TestABCase2 extends AbstractABCase
public void testCase2_7() throws Exception
{
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.pong()); // unsolicited pong
send.add(new PongFrame()); // unsolicited pong
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();

View File

@ -26,7 +26,9 @@ import org.eclipse.jetty.toolchain.test.AdvancedRunner;
import org.eclipse.jetty.websocket.api.StatusCode;
import org.eclipse.jetty.websocket.common.CloseInfo;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.BinaryFrame;
import org.eclipse.jetty.websocket.common.frames.PingFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -42,7 +44,7 @@ public class TestABCase3 extends AbstractABCase
@Test
public void testCase3_1() throws Exception
{
WebSocketFrame send = WebSocketFrame.text("small").setRsv1(true); // intentionally bad
WebSocketFrame send = new TextFrame().setPayload("small").setRsv1(true); // intentionally bad
WebSocketFrame expect = new CloseInfo(StatusCode.PROTOCOL).asFrame();
@ -67,12 +69,12 @@ public class TestABCase3 extends AbstractABCase
public void testCase3_2() throws Exception
{
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.text("small"));
send.add(WebSocketFrame.text("small").setRsv2(true)); // intentionally bad
send.add(new TextFrame().setPayload("small"));
send.add(new TextFrame().setPayload("small").setRsv2(true)); // intentionally bad
send.add(new PingFrame("ping"));
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.text("small")); // echo on good frame
expect.add(new TextFrame().setPayload("small")); // echo on good frame
expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -96,12 +98,12 @@ public class TestABCase3 extends AbstractABCase
public void testCase3_3() throws Exception
{
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.text("small"));
send.add(WebSocketFrame.text("small").setRsv1(true).setRsv2(true)); // intentionally bad
send.add(new TextFrame().setPayload("small"));
send.add(new TextFrame().setPayload("small").setRsv1(true).setRsv2(true)); // intentionally bad
send.add(new PingFrame("ping"));
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.text("small")); // echo on good frame
expect.add(new TextFrame().setPayload("small")); // echo on good frame
expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -125,12 +127,12 @@ public class TestABCase3 extends AbstractABCase
public void testCase3_4() throws Exception
{
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.text("small"));
send.add(WebSocketFrame.text("small").setRsv3(true)); // intentionally bad
send.add(new TextFrame().setPayload("small"));
send.add(new TextFrame().setPayload("small").setRsv3(true)); // intentionally bad
send.add(new PingFrame("ping"));
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.text("small")); // echo on good frame
expect.add(new TextFrame().setPayload("small")); // echo on good frame
expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -158,7 +160,7 @@ public class TestABCase3 extends AbstractABCase
Arrays.fill(payload,(byte)0xFF);
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.binary(payload).setRsv3(true).setRsv1(true)); // intentionally bad
send.add(new BinaryFrame(payload).setRsv3(true).setRsv1(true)); // intentionally bad
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame());

View File

@ -27,6 +27,8 @@ import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.websocket.api.StatusCode;
import org.eclipse.jetty.websocket.common.CloseInfo;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.PingFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -98,12 +100,12 @@ public class TestABCase4 extends AbstractABCase
public void testCase4_1_3() throws Exception
{
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.text("hello"));
send.add(new TextFrame().setPayload("hello"));
send.add(new BadFrame((byte)5)); // intentionally bad
send.add(WebSocketFrame.ping());
send.add(new PingFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.text("hello")); // echo
expect.add(new TextFrame().setPayload("hello")); // echo
expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -129,12 +131,12 @@ public class TestABCase4 extends AbstractABCase
ByteBuffer buf = ByteBuffer.wrap(StringUtil.getUtf8Bytes("bad"));
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.text("hello"));
send.add(new TextFrame().setPayload("hello"));
send.add(new BadFrame((byte)6).setPayload(buf)); // intentionally bad
send.add(WebSocketFrame.ping());
send.add(new PingFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.text("hello")); // echo
expect.add(new TextFrame().setPayload("hello")); // echo
expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -160,12 +162,12 @@ public class TestABCase4 extends AbstractABCase
ByteBuffer buf = ByteBuffer.wrap(StringUtil.getUtf8Bytes("bad"));
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.text("hello"));
send.add(new TextFrame().setPayload("hello"));
send.add(new BadFrame((byte)7).setPayload(buf)); // intentionally bad
send.add(WebSocketFrame.ping());
send.add(new PingFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.text("hello")); // echo
expect.add(new TextFrame().setPayload("hello")); // echo
expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -243,12 +245,12 @@ public class TestABCase4 extends AbstractABCase
public void testCase4_2_3() throws Exception
{
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.text("hello"));
send.add(new TextFrame().setPayload("hello"));
send.add(new BadFrame((byte)13)); // intentionally bad
send.add(WebSocketFrame.ping());
send.add(new PingFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.text("hello")); // echo
expect.add(new TextFrame().setPayload("hello")); // echo
expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -274,12 +276,12 @@ public class TestABCase4 extends AbstractABCase
ByteBuffer buf = ByteBuffer.wrap(StringUtil.getUtf8Bytes("bad"));
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.text("hello"));
send.add(new TextFrame().setPayload("hello"));
send.add(new BadFrame((byte)14).setPayload(buf)); // intentionally bad
send.add(WebSocketFrame.ping());
send.add(new PingFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.text("hello")); // echo
expect.add(new TextFrame().setPayload("hello")); // echo
expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -305,12 +307,12 @@ public class TestABCase4 extends AbstractABCase
ByteBuffer buf = ByteBuffer.wrap(StringUtil.getUtf8Bytes("bad"));
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.text("hello"));
send.add(new TextFrame().setPayload("hello"));
send.add(new BadFrame((byte)15).setPayload(buf)); // intentionally bad
send.add(WebSocketFrame.ping());
send.add(new PingFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.text("hello")); // echo
expect.add(new TextFrame().setPayload("hello")); // echo
expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);

View File

@ -226,7 +226,7 @@ public class TestABCase5 extends AbstractABCase
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.text("fragment1fragment2"));
expect.add(new TextFrame().setPayload("fragment1fragment2"));
expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -361,7 +361,7 @@ public class TestABCase5 extends AbstractABCase
List<WebSocketFrame> expect2 = new ArrayList<>();
expect2.add(new PongFrame("pong-2"));
expect2.add(WebSocketFrame.text("f1,f2,f3,f4,f5"));
expect2.add(new TextFrame().setPayload("f1,f2,f3,f4,f5"));
expect2.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -438,7 +438,7 @@ public class TestABCase5 extends AbstractABCase
List<WebSocketFrame> expect2 = new ArrayList<>();
expect2.add(new PongFrame("pong-2"));
expect2.add(WebSocketFrame.text("f1,f2,f3,f4,f5"));
expect2.add(new TextFrame().setPayload("f1,f2,f3,f4,f5"));
expect2.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -484,7 +484,7 @@ public class TestABCase5 extends AbstractABCase
List<WebSocketFrame> expect2 = new ArrayList<>();
expect2.add(new PongFrame("pong-2"));
expect2.add(WebSocketFrame.text("f1,f2,f3,f4,f5"));
expect2.add(new TextFrame().setPayload("f1,f2,f3,f4,f5"));
expect2.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -520,7 +520,7 @@ public class TestABCase5 extends AbstractABCase
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.text("hello, world"));
expect.add(new TextFrame().setPayload("hello, world"));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -549,7 +549,7 @@ public class TestABCase5 extends AbstractABCase
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.text("hello, world"));
expect.add(new TextFrame().setPayload("hello, world"));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -578,7 +578,7 @@ public class TestABCase5 extends AbstractABCase
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.text("hello, world"));
expect.add(new TextFrame().setPayload("hello, world"));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -610,7 +610,7 @@ public class TestABCase5 extends AbstractABCase
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new PongFrame("ping"));
expect.add(WebSocketFrame.text("hello, world"));
expect.add(new TextFrame().setPayload("hello, world"));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -641,7 +641,7 @@ public class TestABCase5 extends AbstractABCase
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new PongFrame("ping"));
expect.add(WebSocketFrame.text("hello, world"));
expect.add(new TextFrame().setPayload("hello, world"));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -672,7 +672,7 @@ public class TestABCase5 extends AbstractABCase
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new PongFrame("ping"));
expect.add(WebSocketFrame.text("hello, world"));
expect.add(new TextFrame().setPayload("hello, world"));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);

View File

@ -82,11 +82,11 @@ public class TestABCase6 extends AbstractABCase
public void testCase6_1_1() throws Exception
{
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.text());
send.add(new TextFrame());
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.text());
expect.add(new TextFrame());
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -116,7 +116,7 @@ public class TestABCase6 extends AbstractABCase
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.text());
expect.add(new TextFrame());
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -146,7 +146,7 @@ public class TestABCase6 extends AbstractABCase
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.text("middle"));
expect.add(new TextFrame().setPayload("middle"));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);

View File

@ -55,11 +55,11 @@ public class TestABCase7 extends AbstractABCase
public void testCase7_1_1() throws Exception
{
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.text("Hello World"));
send.add(new TextFrame().setPayload("Hello World"));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.text("Hello World"));
expect.add(new TextFrame().setPayload("Hello World"));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -140,7 +140,7 @@ public class TestABCase7 extends AbstractABCase
{
List<WebSocketFrame> send = new ArrayList<>();
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
send.add(WebSocketFrame.text("out of band text"));
send.add(new TextFrame().setPayload("out of band text"));
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());

View File

@ -149,11 +149,11 @@ public class TestABCase9 extends AbstractABCase
String msg = StringUtil.toUTF8String(utf,0,utf.length);
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.text(msg));
send.add(new TextFrame().setPayload(msg));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.text(msg));
expect.add(new TextFrame().setPayload(msg));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -185,7 +185,7 @@ public class TestABCase9 extends AbstractABCase
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.text().setPayload(clone(buf)));
expect.add(new TextFrame().setPayload(clone(buf)));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -214,11 +214,11 @@ public class TestABCase9 extends AbstractABCase
ByteBuffer buf = ByteBuffer.wrap(utf);
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.text().setPayload(buf));
send.add(new TextFrame().setPayload(buf));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.text().setPayload(clone(buf)));
expect.add(new TextFrame().setPayload(clone(buf)));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -247,11 +247,11 @@ public class TestABCase9 extends AbstractABCase
ByteBuffer buf = ByteBuffer.wrap(utf);
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.text().setPayload(buf));
send.add(new TextFrame().setPayload(buf));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.text().setPayload(clone(buf)));
expect.add(new TextFrame().setPayload(clone(buf)));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -280,11 +280,11 @@ public class TestABCase9 extends AbstractABCase
ByteBuffer buf = ByteBuffer.wrap(utf);
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.text().setPayload(buf));
send.add(new TextFrame().setPayload(buf));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.text().setPayload(clone(buf)));
expect.add(new TextFrame().setPayload(clone(buf)));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -313,11 +313,11 @@ public class TestABCase9 extends AbstractABCase
ByteBuffer buf = ByteBuffer.wrap(utf);
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.text().setPayload(buf));
send.add(new TextFrame().setPayload(buf));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.text().setPayload(clone(buf)));
expect.add(new TextFrame().setPayload(clone(buf)));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -344,11 +344,11 @@ public class TestABCase9 extends AbstractABCase
Arrays.fill(data,(byte)0x21);
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.binary(data));
send.add(new BinaryFrame(data));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.binary(copyOf(data)));
expect.add(new BinaryFrame().setPayload(copyOf(data)));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -376,11 +376,11 @@ public class TestABCase9 extends AbstractABCase
ByteBuffer buf = ByteBuffer.wrap(data);
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.binary().setPayload(buf));
send.add(new BinaryFrame().setPayload(buf));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.binary().setPayload(clone(buf)));
expect.add(new BinaryFrame().setPayload(clone(buf)));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -409,11 +409,11 @@ public class TestABCase9 extends AbstractABCase
ByteBuffer buf = ByteBuffer.wrap(data);
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.binary().setPayload(buf));
send.add(new BinaryFrame().setPayload(buf));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.binary().setPayload(clone(buf)));
expect.add(new BinaryFrame().setPayload(clone(buf)));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -442,11 +442,11 @@ public class TestABCase9 extends AbstractABCase
ByteBuffer buf = ByteBuffer.wrap(data);
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.binary().setPayload(buf));
send.add(new BinaryFrame().setPayload(buf));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.binary().setPayload(clone(buf)));
expect.add(new BinaryFrame().setPayload(clone(buf)));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -475,11 +475,11 @@ public class TestABCase9 extends AbstractABCase
ByteBuffer buf = ByteBuffer.wrap(data);
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.binary().setPayload(buf));
send.add(new BinaryFrame().setPayload(buf));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.binary().setPayload(clone(buf)));
expect.add(new BinaryFrame().setPayload(clone(buf)));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);
@ -508,11 +508,11 @@ public class TestABCase9 extends AbstractABCase
ByteBuffer buf = ByteBuffer.wrap(data);
List<WebSocketFrame> send = new ArrayList<>();
send.add(WebSocketFrame.binary().setPayload(buf));
send.add(new BinaryFrame().setPayload(buf));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(WebSocketFrame.binary().setPayload(clone(buf)));
expect.add(new BinaryFrame().setPayload(clone(buf)));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
Fuzzer fuzzer = new Fuzzer(this);

View File

@ -428,7 +428,7 @@ public class BlockheadClient implements IncomingFrames, OutgoingFrames, Connecti
LOG.info("Client parsed {} frames",count);
}
if (frame.getType() == Frame.Type.CLOSE)
if (frame.getOpCode() == OpCode.CLOSE)
{
CloseInfo close = new CloseInfo(frame);
ioState.onCloseRemote(close);
@ -495,7 +495,7 @@ public class BlockheadClient implements IncomingFrames, OutgoingFrames, Connecti
bufferPool.release(headerBuf);
}
if (frame.getType().getOpCode() == OpCode.CLOSE)
if (frame.getOpCode() == OpCode.CLOSE)
{
disconnect();
}

View File

@ -27,6 +27,7 @@ import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketFrame;
import org.eclipse.jetty.websocket.api.annotations.WebSocket;
import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.common.OpCode;
/**
* Echo back the incoming text or binary as 2 frames of (roughly) equal size.
@ -37,8 +38,9 @@ public class EchoFragmentSocket
@OnWebSocketFrame
public void onFrame(Session session, Frame frame)
{
if (frame.getType().isData())
if (!frame.getType().isData())
{
// Don't process non-data frames
return;
}