WebSocket - Calling setPayload() outside of TextFrame and BinaryFrame
This commit is contained in:
parent
a089780701
commit
e56fddfc4a
|
@ -89,7 +89,7 @@ public class OnPartialTest
|
||||||
public void testOnTextPartial() throws Throwable
|
public void testOnTextPartial() throws Throwable
|
||||||
{
|
{
|
||||||
List<WebSocketFrame> frames = new ArrayList<>();
|
List<WebSocketFrame> frames = new ArrayList<>();
|
||||||
frames.add(new TextFrame("Saved").setFin(false));
|
frames.add(new TextFrame().setPayload("Saved").setFin(false));
|
||||||
frames.add(new ContinuationFrame(" by ").setFin(false));
|
frames.add(new ContinuationFrame(" by ").setFin(false));
|
||||||
frames.add(new ContinuationFrame("zero").setFin(true));
|
frames.add(new ContinuationFrame("zero").setFin(true));
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,7 @@ public class WebSocketRemoteEndpoint implements RemoteEndpoint
|
||||||
{
|
{
|
||||||
LOG.debug("sendBytes with {}",BufferUtil.toDetailString(data));
|
LOG.debug("sendBytes with {}",BufferUtil.toDetailString(data));
|
||||||
}
|
}
|
||||||
blockingWrite(new BinaryFrame(data));
|
blockingWrite(new BinaryFrame().setPayload(data));
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -144,7 +144,7 @@ public class WebSocketRemoteEndpoint implements RemoteEndpoint
|
||||||
{
|
{
|
||||||
LOG.debug("sendBytesByFuture with {}",BufferUtil.toDetailString(data));
|
LOG.debug("sendBytesByFuture with {}",BufferUtil.toDetailString(data));
|
||||||
}
|
}
|
||||||
return sendAsyncFrame(new BinaryFrame(data));
|
return sendAsyncFrame(new BinaryFrame().setPayload(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -156,7 +156,7 @@ public class WebSocketRemoteEndpoint implements RemoteEndpoint
|
||||||
{
|
{
|
||||||
LOG.debug("sendBytes({}, {})",BufferUtil.toDetailString(data),callback);
|
LOG.debug("sendBytes({}, {})",BufferUtil.toDetailString(data),callback);
|
||||||
}
|
}
|
||||||
sendFrame(new BinaryFrame(data),callback);
|
sendFrame(new BinaryFrame().setPayload(data),callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendFrame(WebSocketFrame frame, WriteCallback callback)
|
public void sendFrame(WebSocketFrame frame, WriteCallback callback)
|
||||||
|
@ -196,7 +196,7 @@ public class WebSocketRemoteEndpoint implements RemoteEndpoint
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
frame = new BinaryFrame(fragment);
|
frame = new BinaryFrame().setPayload(fragment);
|
||||||
}
|
}
|
||||||
frame.setFin(isLast);
|
frame.setFin(isLast);
|
||||||
blockingWrite(frame);
|
blockingWrite(frame);
|
||||||
|
@ -241,7 +241,7 @@ public class WebSocketRemoteEndpoint implements RemoteEndpoint
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
frame = new TextFrame(fragment);
|
frame = new TextFrame().setPayload(fragment);
|
||||||
}
|
}
|
||||||
frame.setFin(isLast);
|
frame.setFin(isLast);
|
||||||
blockingWrite(frame);
|
blockingWrite(frame);
|
||||||
|
@ -322,7 +322,7 @@ public class WebSocketRemoteEndpoint implements RemoteEndpoint
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
msgType.set(TEXT);
|
msgType.set(TEXT);
|
||||||
WebSocketFrame frame = new TextFrame(text);
|
WebSocketFrame frame = new TextFrame().setPayload(text);
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
{
|
{
|
||||||
LOG.debug("sendString with {}",BufferUtil.toDetailString(frame.getPayload()));
|
LOG.debug("sendString with {}",BufferUtil.toDetailString(frame.getPayload()));
|
||||||
|
@ -345,7 +345,7 @@ public class WebSocketRemoteEndpoint implements RemoteEndpoint
|
||||||
public Future<Void> sendStringByFuture(String text)
|
public Future<Void> sendStringByFuture(String text)
|
||||||
{
|
{
|
||||||
msgType.set(TEXT);
|
msgType.set(TEXT);
|
||||||
TextFrame frame = new TextFrame(text);
|
TextFrame frame = new TextFrame().setPayload(text);
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
{
|
{
|
||||||
LOG.debug("sendStringByFuture with {}",BufferUtil.toDetailString(frame.getPayload()));
|
LOG.debug("sendStringByFuture with {}",BufferUtil.toDetailString(frame.getPayload()));
|
||||||
|
@ -358,7 +358,7 @@ public class WebSocketRemoteEndpoint implements RemoteEndpoint
|
||||||
{
|
{
|
||||||
Objects.requireNonNull(callback,"WriteCallback cannot be null");
|
Objects.requireNonNull(callback,"WriteCallback cannot be null");
|
||||||
msgType.set(TEXT);
|
msgType.set(TEXT);
|
||||||
TextFrame frame = new TextFrame(text);
|
TextFrame frame = new TextFrame().setPayload(text);
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
{
|
{
|
||||||
LOG.debug("sendString({},{})",BufferUtil.toDetailString(frame.getPayload()),callback);
|
LOG.debug("sendString({},{})",BufferUtil.toDetailString(frame.getPayload()),callback);
|
||||||
|
|
|
@ -30,21 +30,22 @@ public class BinaryFrame extends DataFrame
|
||||||
super(OpCode.BINARY);
|
super(OpCode.BINARY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BinaryFrame(byte[] buf)
|
public BinaryFrame setPayload(ByteBuffer buf)
|
||||||
|
{
|
||||||
|
super.setPayload(buf);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BinaryFrame setPayload(byte[] buf)
|
||||||
{
|
{
|
||||||
this();
|
|
||||||
setPayload(ByteBuffer.wrap(buf));
|
setPayload(ByteBuffer.wrap(buf));
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BinaryFrame(ByteBuffer buf)
|
public BinaryFrame setPayload(String payload)
|
||||||
{
|
{
|
||||||
this();
|
setPayload(StringUtil.getUtf8Bytes(payload));
|
||||||
setPayload(buf);
|
return this;
|
||||||
}
|
|
||||||
|
|
||||||
public BinaryFrame(String payload)
|
|
||||||
{
|
|
||||||
this(StringUtil.getBytes(payload));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -23,7 +23,6 @@ import java.nio.ByteBuffer;
|
||||||
import org.eclipse.jetty.util.BufferUtil;
|
import org.eclipse.jetty.util.BufferUtil;
|
||||||
import org.eclipse.jetty.util.StringUtil;
|
import org.eclipse.jetty.util.StringUtil;
|
||||||
import org.eclipse.jetty.websocket.common.OpCode;
|
import org.eclipse.jetty.websocket.common.OpCode;
|
||||||
import org.eclipse.jetty.websocket.common.WebSocketFrame;
|
|
||||||
|
|
||||||
public class TextFrame extends DataFrame
|
public class TextFrame extends DataFrame
|
||||||
{
|
{
|
||||||
|
@ -32,19 +31,13 @@ public class TextFrame extends DataFrame
|
||||||
super(OpCode.TEXT);
|
super(OpCode.TEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextFrame(String msg)
|
|
||||||
{
|
|
||||||
this();
|
|
||||||
setPayload(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Type getType()
|
public Type getType()
|
||||||
{
|
{
|
||||||
return Type.TEXT;
|
return Type.TEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WebSocketFrame setPayload(String str)
|
public TextFrame setPayload(String str)
|
||||||
{
|
{
|
||||||
setPayload(ByteBuffer.wrap(StringUtil.getUtf8Bytes(str)));
|
setPayload(ByteBuffer.wrap(StringUtil.getUtf8Bytes(str)));
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -251,7 +251,7 @@ public class GeneratorTest
|
||||||
byte payload[] = new byte[10240];
|
byte payload[] = new byte[10240];
|
||||||
Arrays.fill(payload,(byte)0x44);
|
Arrays.fill(payload,(byte)0x44);
|
||||||
|
|
||||||
WebSocketFrame frame = new BinaryFrame(payload);
|
WebSocketFrame frame = new BinaryFrame().setPayload(payload);
|
||||||
|
|
||||||
// Generate
|
// Generate
|
||||||
int windowSize = 1024;
|
int windowSize = 1024;
|
||||||
|
@ -279,7 +279,7 @@ public class GeneratorTest
|
||||||
byte mask[] = new byte[]
|
byte mask[] = new byte[]
|
||||||
{ 0x2A, (byte)0xF0, 0x0F, 0x00 };
|
{ 0x2A, (byte)0xF0, 0x0F, 0x00 };
|
||||||
|
|
||||||
WebSocketFrame frame = new BinaryFrame(payload);
|
WebSocketFrame frame = new BinaryFrame().setPayload(payload);
|
||||||
frame.setMask(mask); // masking!
|
frame.setMask(mask); // masking!
|
||||||
|
|
||||||
// Generate
|
// Generate
|
||||||
|
|
|
@ -46,10 +46,10 @@ public class ParserTest
|
||||||
public void testParseCase5_15()
|
public void testParseCase5_15()
|
||||||
{
|
{
|
||||||
List<WebSocketFrame> send = new ArrayList<>();
|
List<WebSocketFrame> send = new ArrayList<>();
|
||||||
send.add(new TextFrame("fragment1").setFin(false));
|
send.add(new TextFrame().setPayload("fragment1").setFin(false));
|
||||||
send.add(new ContinuationFrame("fragment2").setFin(true));
|
send.add(new ContinuationFrame("fragment2").setFin(true));
|
||||||
send.add(new ContinuationFrame("fragment3").setFin(false)); // bad frame
|
send.add(new ContinuationFrame("fragment3").setFin(false)); // bad frame
|
||||||
send.add(new TextFrame("fragment4").setFin(true));
|
send.add(new TextFrame().setPayload("fragment4").setFin(true));
|
||||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||||
|
|
||||||
ByteBuffer completeBuf = UnitGenerator.generate(send);
|
ByteBuffer completeBuf = UnitGenerator.generate(send);
|
||||||
|
@ -71,8 +71,8 @@ public class ParserTest
|
||||||
public void testParseCase5_18()
|
public void testParseCase5_18()
|
||||||
{
|
{
|
||||||
List<WebSocketFrame> send = new ArrayList<>();
|
List<WebSocketFrame> send = new ArrayList<>();
|
||||||
send.add(new TextFrame("fragment1").setFin(false));
|
send.add(new TextFrame().setPayload("fragment1").setFin(false));
|
||||||
send.add(new TextFrame("fragment2").setFin(true)); // bad frame, must be continuation
|
send.add(new TextFrame().setPayload("fragment2").setFin(true)); // bad frame, must be continuation
|
||||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||||
|
|
||||||
ByteBuffer completeBuf = UnitGenerator.generate(send);
|
ByteBuffer completeBuf = UnitGenerator.generate(send);
|
||||||
|
@ -92,7 +92,7 @@ public class ParserTest
|
||||||
public void testParseCase5_19()
|
public void testParseCase5_19()
|
||||||
{
|
{
|
||||||
List<WebSocketFrame> send = new ArrayList<>();
|
List<WebSocketFrame> send = new ArrayList<>();
|
||||||
send.add(new TextFrame("f1").setFin(false));
|
send.add(new TextFrame().setPayload("f1").setFin(false));
|
||||||
send.add(new ContinuationFrame(",f2").setFin(false));
|
send.add(new ContinuationFrame(",f2").setFin(false));
|
||||||
send.add(new PingFrame().setPayload("pong-1"));
|
send.add(new PingFrame().setPayload("pong-1"));
|
||||||
send.add(new ContinuationFrame(",f3").setFin(false));
|
send.add(new ContinuationFrame(",f3").setFin(false));
|
||||||
|
@ -122,7 +122,7 @@ public class ParserTest
|
||||||
{
|
{
|
||||||
List<WebSocketFrame> send = new ArrayList<>();
|
List<WebSocketFrame> send = new ArrayList<>();
|
||||||
send.add(new PongFrame().setPayload("ping"));
|
send.add(new PongFrame().setPayload("ping"));
|
||||||
send.add(new TextFrame("hello, world"));
|
send.add(new TextFrame().setPayload("hello, world"));
|
||||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||||
|
|
||||||
ByteBuffer completeBuf = UnitGenerator.generate(send);
|
ByteBuffer completeBuf = UnitGenerator.generate(send);
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class RFC6455ExamplesGeneratorTest
|
||||||
@Test
|
@Test
|
||||||
public void testFragmentedUnmaskedTextMessage()
|
public void testFragmentedUnmaskedTextMessage()
|
||||||
{
|
{
|
||||||
WebSocketFrame text1 = new TextFrame("Hel").setFin(false);
|
WebSocketFrame text1 = new TextFrame().setPayload("Hel").setFin(false);
|
||||||
WebSocketFrame text2 = new ContinuationFrame("lo");
|
WebSocketFrame text2 = new ContinuationFrame("lo");
|
||||||
|
|
||||||
ByteBuffer actual1 = UnitGenerator.generate(text1);
|
ByteBuffer actual1 = UnitGenerator.generate(text1);
|
||||||
|
|
|
@ -290,7 +290,7 @@ public class TestABCase1_2
|
||||||
@Test
|
@Test
|
||||||
public void testGenerateEmptyBinaryCase1_2_1()
|
public void testGenerateEmptyBinaryCase1_2_1()
|
||||||
{
|
{
|
||||||
WebSocketFrame binaryFrame = new BinaryFrame(new byte[] {});
|
WebSocketFrame binaryFrame = new BinaryFrame().setPayload(new byte[] {});
|
||||||
|
|
||||||
ByteBuffer actual = UnitGenerator.generate(binaryFrame);
|
ByteBuffer actual = UnitGenerator.generate(binaryFrame);
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class EventDriverTest
|
||||||
|
|
||||||
private Frame makeBinaryFrame(String content, boolean fin)
|
private Frame makeBinaryFrame(String content, boolean fin)
|
||||||
{
|
{
|
||||||
return new BinaryFrame(content).setFin(fin);
|
return new BinaryFrame().setPayload(content).setFin(fin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -116,8 +116,8 @@ public class EventDriverTest
|
||||||
{
|
{
|
||||||
conn.open();
|
conn.open();
|
||||||
driver.incomingFrame(new PingFrame().setPayload("PING"));
|
driver.incomingFrame(new PingFrame().setPayload("PING"));
|
||||||
driver.incomingFrame(new TextFrame("Text Me"));
|
driver.incomingFrame(new TextFrame().setPayload("Text Me"));
|
||||||
driver.incomingFrame(new BinaryFrame("Hello Bin"));
|
driver.incomingFrame(new BinaryFrame().setPayload("Hello Bin"));
|
||||||
driver.incomingFrame(new CloseInfo(StatusCode.SHUTDOWN,"testcase").asFrame());
|
driver.incomingFrame(new CloseInfo(StatusCode.SHUTDOWN,"testcase").asFrame());
|
||||||
|
|
||||||
socket.capture.assertEventCount(6);
|
socket.capture.assertEventCount(6);
|
||||||
|
|
|
@ -164,14 +164,14 @@ public class FragmentExtensionTest
|
||||||
|
|
||||||
// Expected Frames
|
// Expected Frames
|
||||||
List<WebSocketFrame> expectedFrames = new ArrayList<>();
|
List<WebSocketFrame> expectedFrames = new ArrayList<>();
|
||||||
expectedFrames.add(new TextFrame("No amount of experim").setFin(false));
|
expectedFrames.add(new TextFrame().setPayload("No amount of experim").setFin(false));
|
||||||
expectedFrames.add(new ContinuationFrame("entation can ever pr").setFin(false));
|
expectedFrames.add(new ContinuationFrame("entation can ever pr").setFin(false));
|
||||||
expectedFrames.add(new ContinuationFrame("ove me right;").setFin(true));
|
expectedFrames.add(new ContinuationFrame("ove me right;").setFin(true));
|
||||||
|
|
||||||
expectedFrames.add(new TextFrame("a single experiment ").setFin(false));
|
expectedFrames.add(new TextFrame().setPayload("a single experiment ").setFin(false));
|
||||||
expectedFrames.add(new ContinuationFrame("can prove me wrong.").setFin(true));
|
expectedFrames.add(new ContinuationFrame("can prove me wrong.").setFin(true));
|
||||||
|
|
||||||
expectedFrames.add(new TextFrame("-- Albert Einstein").setFin(true));
|
expectedFrames.add(new TextFrame().setPayload("-- Albert Einstein").setFin(true));
|
||||||
|
|
||||||
capture.dump();
|
capture.dump();
|
||||||
|
|
||||||
|
@ -236,9 +236,9 @@ public class FragmentExtensionTest
|
||||||
|
|
||||||
// Expected Frames
|
// Expected Frames
|
||||||
List<WebSocketFrame> expectedFrames = new ArrayList<>();
|
List<WebSocketFrame> expectedFrames = new ArrayList<>();
|
||||||
expectedFrames.add(new TextFrame("No amount of experimentation can ever prove me right;"));
|
expectedFrames.add(new TextFrame().setPayload("No amount of experimentation can ever prove me right;"));
|
||||||
expectedFrames.add(new TextFrame("a single experiment can prove me wrong."));
|
expectedFrames.add(new TextFrame().setPayload("a single experiment can prove me wrong."));
|
||||||
expectedFrames.add(new TextFrame("-- Albert Einstein"));
|
expectedFrames.add(new TextFrame().setPayload("-- Albert Einstein"));
|
||||||
|
|
||||||
// capture.dump();
|
// capture.dump();
|
||||||
|
|
||||||
|
|
|
@ -222,7 +222,7 @@ public class MessageCompressionExtensionTest
|
||||||
// leave frames as-is, no compression, and pass into extension
|
// leave frames as-is, no compression, and pass into extension
|
||||||
for (String q : quote)
|
for (String q : quote)
|
||||||
{
|
{
|
||||||
TextFrame frame = new TextFrame(q);
|
TextFrame frame = new TextFrame().setPayload(q);
|
||||||
frame.setRsv1(false); // indication to extension that frame is not compressed (ie: a normal frame)
|
frame.setRsv1(false); // indication to extension that frame is not compressed (ie: a normal frame)
|
||||||
ext.incomingFrame(frame);
|
ext.incomingFrame(frame);
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,7 @@ public class WriteBytesProviderTest
|
||||||
int binPayloadSize = 50;
|
int binPayloadSize = 50;
|
||||||
byte bin[] = new byte[binPayloadSize];
|
byte bin[] = new byte[binPayloadSize];
|
||||||
Arrays.fill(bin,(byte)0x00);
|
Arrays.fill(bin,(byte)0x00);
|
||||||
BinaryFrame binFrame = new BinaryFrame(bin);
|
BinaryFrame binFrame = new BinaryFrame().setPayload(bin);
|
||||||
byte maskingKey[] = Hex.asByteArray("11223344");
|
byte maskingKey[] = Hex.asByteArray("11223344");
|
||||||
binFrame.setMask(maskingKey);
|
binFrame.setMask(maskingKey);
|
||||||
bytesProvider.enqueue(binFrame,binCallback);
|
bytesProvider.enqueue(binFrame,binCallback);
|
||||||
|
|
|
@ -103,7 +103,7 @@ public class WebSocketServletRFCTest
|
||||||
|
|
||||||
WebSocketFrame bin;
|
WebSocketFrame bin;
|
||||||
|
|
||||||
bin = new BinaryFrame(buf1).setFin(false);
|
bin = new BinaryFrame().setPayload(buf1).setFin(false);
|
||||||
|
|
||||||
client.write(bin); // write buf1 (fin=false)
|
client.write(bin); // write buf1 (fin=false)
|
||||||
|
|
||||||
|
|
|
@ -160,7 +160,7 @@ public class TestABCase3 extends AbstractABCase
|
||||||
Arrays.fill(payload,(byte)0xFF);
|
Arrays.fill(payload,(byte)0xFF);
|
||||||
|
|
||||||
List<WebSocketFrame> send = new ArrayList<>();
|
List<WebSocketFrame> send = new ArrayList<>();
|
||||||
send.add(new BinaryFrame(payload).setRsv3(true).setRsv1(true)); // intentionally bad
|
send.add(new BinaryFrame().setPayload(payload).setRsv3(true).setRsv1(true)); // intentionally bad
|
||||||
|
|
||||||
List<WebSocketFrame> expect = new ArrayList<>();
|
List<WebSocketFrame> expect = new ArrayList<>();
|
||||||
expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame());
|
expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame());
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class TestABCase5 extends AbstractABCase
|
||||||
{
|
{
|
||||||
List<WebSocketFrame> send = new ArrayList<>();
|
List<WebSocketFrame> send = new ArrayList<>();
|
||||||
send.add(new ContinuationFrame("sorry").setFin(true));
|
send.add(new ContinuationFrame("sorry").setFin(true));
|
||||||
send.add(new TextFrame("hello, world"));
|
send.add(new TextFrame().setPayload("hello, world"));
|
||||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||||
|
|
||||||
List<WebSocketFrame> expect = new ArrayList<>();
|
List<WebSocketFrame> expect = new ArrayList<>();
|
||||||
|
@ -106,7 +106,7 @@ public class TestABCase5 extends AbstractABCase
|
||||||
{
|
{
|
||||||
List<WebSocketFrame> send = new ArrayList<>();
|
List<WebSocketFrame> send = new ArrayList<>();
|
||||||
send.add(new ContinuationFrame("sorry").setFin(true));
|
send.add(new ContinuationFrame("sorry").setFin(true));
|
||||||
send.add(new TextFrame("hello, world"));
|
send.add(new TextFrame().setPayload("hello, world"));
|
||||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||||
|
|
||||||
List<WebSocketFrame> expect = new ArrayList<>();
|
List<WebSocketFrame> expect = new ArrayList<>();
|
||||||
|
@ -135,7 +135,7 @@ public class TestABCase5 extends AbstractABCase
|
||||||
{
|
{
|
||||||
List<WebSocketFrame> send = new ArrayList<>();
|
List<WebSocketFrame> send = new ArrayList<>();
|
||||||
send.add(new ContinuationFrame("sorry").setFin(false));
|
send.add(new ContinuationFrame("sorry").setFin(false));
|
||||||
send.add(new TextFrame("hello, world"));
|
send.add(new TextFrame().setPayload("hello, world"));
|
||||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||||
|
|
||||||
List<WebSocketFrame> expect = new ArrayList<>();
|
List<WebSocketFrame> expect = new ArrayList<>();
|
||||||
|
@ -163,7 +163,7 @@ public class TestABCase5 extends AbstractABCase
|
||||||
{
|
{
|
||||||
List<WebSocketFrame> send = new ArrayList<>();
|
List<WebSocketFrame> send = new ArrayList<>();
|
||||||
send.add(new ContinuationFrame("sorry").setFin(false));
|
send.add(new ContinuationFrame("sorry").setFin(false));
|
||||||
send.add(new TextFrame("hello, world"));
|
send.add(new TextFrame().setPayload("hello, world"));
|
||||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||||
|
|
||||||
List<WebSocketFrame> expect = new ArrayList<>();
|
List<WebSocketFrame> expect = new ArrayList<>();
|
||||||
|
@ -191,7 +191,7 @@ public class TestABCase5 extends AbstractABCase
|
||||||
{
|
{
|
||||||
List<WebSocketFrame> send = new ArrayList<>();
|
List<WebSocketFrame> send = new ArrayList<>();
|
||||||
send.add(new ContinuationFrame("sorry").setFin(false));
|
send.add(new ContinuationFrame("sorry").setFin(false));
|
||||||
send.add(new TextFrame("hello, world"));
|
send.add(new TextFrame().setPayload("hello, world"));
|
||||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||||
|
|
||||||
List<WebSocketFrame> expect = new ArrayList<>();
|
List<WebSocketFrame> expect = new ArrayList<>();
|
||||||
|
@ -219,10 +219,10 @@ public class TestABCase5 extends AbstractABCase
|
||||||
public void testCase5_15() throws Exception
|
public void testCase5_15() throws Exception
|
||||||
{
|
{
|
||||||
List<WebSocketFrame> send = new ArrayList<>();
|
List<WebSocketFrame> send = new ArrayList<>();
|
||||||
send.add(new TextFrame("fragment1").setFin(false));
|
send.add(new TextFrame().setPayload("fragment1").setFin(false));
|
||||||
send.add(new ContinuationFrame("fragment2").setFin(true));
|
send.add(new ContinuationFrame("fragment2").setFin(true));
|
||||||
send.add(new ContinuationFrame("fragment3").setFin(false)); // bad frame
|
send.add(new ContinuationFrame("fragment3").setFin(false)); // bad frame
|
||||||
send.add(new TextFrame("fragment4").setFin(true));
|
send.add(new TextFrame().setPayload("fragment4").setFin(true));
|
||||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||||
|
|
||||||
List<WebSocketFrame> expect = new ArrayList<>();
|
List<WebSocketFrame> expect = new ArrayList<>();
|
||||||
|
@ -251,10 +251,10 @@ public class TestABCase5 extends AbstractABCase
|
||||||
{
|
{
|
||||||
List<WebSocketFrame> send = new ArrayList<>();
|
List<WebSocketFrame> send = new ArrayList<>();
|
||||||
send.add(new ContinuationFrame("fragment1").setFin(false)); // bad frame
|
send.add(new ContinuationFrame("fragment1").setFin(false)); // bad frame
|
||||||
send.add(new TextFrame("fragment2").setFin(false));
|
send.add(new TextFrame().setPayload("fragment2").setFin(false));
|
||||||
send.add(new ContinuationFrame("fragment3").setFin(true));
|
send.add(new ContinuationFrame("fragment3").setFin(true));
|
||||||
send.add(new ContinuationFrame("fragment4").setFin(false)); // bad frame
|
send.add(new ContinuationFrame("fragment4").setFin(false)); // bad frame
|
||||||
send.add(new TextFrame("fragment5").setFin(false));
|
send.add(new TextFrame().setPayload("fragment5").setFin(false));
|
||||||
send.add(new ContinuationFrame("fragment6").setFin(true));
|
send.add(new ContinuationFrame("fragment6").setFin(true));
|
||||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||||
|
|
||||||
|
@ -283,10 +283,10 @@ public class TestABCase5 extends AbstractABCase
|
||||||
{
|
{
|
||||||
List<WebSocketFrame> send = new ArrayList<>();
|
List<WebSocketFrame> send = new ArrayList<>();
|
||||||
send.add(new ContinuationFrame("fragment1").setFin(true)); // nothing to continue
|
send.add(new ContinuationFrame("fragment1").setFin(true)); // nothing to continue
|
||||||
send.add(new TextFrame("fragment2").setFin(false));
|
send.add(new TextFrame().setPayload("fragment2").setFin(false));
|
||||||
send.add(new ContinuationFrame("fragment3").setFin(true));
|
send.add(new ContinuationFrame("fragment3").setFin(true));
|
||||||
send.add(new ContinuationFrame("fragment4").setFin(true)); // nothing to continue
|
send.add(new ContinuationFrame("fragment4").setFin(true)); // nothing to continue
|
||||||
send.add(new TextFrame("fragment5").setFin(false));
|
send.add(new TextFrame().setPayload("fragment5").setFin(false));
|
||||||
send.add(new ContinuationFrame("fragment6").setFin(true));
|
send.add(new ContinuationFrame("fragment6").setFin(true));
|
||||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||||
|
|
||||||
|
@ -314,8 +314,8 @@ public class TestABCase5 extends AbstractABCase
|
||||||
public void testCase5_18() throws Exception
|
public void testCase5_18() throws Exception
|
||||||
{
|
{
|
||||||
List<WebSocketFrame> send = new ArrayList<>();
|
List<WebSocketFrame> send = new ArrayList<>();
|
||||||
send.add(new TextFrame("fragment1").setFin(false));
|
send.add(new TextFrame().setPayload("fragment1").setFin(false));
|
||||||
send.add(new TextFrame("fragment2").setFin(true)); // bad frame, must be continuation
|
send.add(new TextFrame().setPayload("fragment2").setFin(true)); // bad frame, must be continuation
|
||||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||||
|
|
||||||
List<WebSocketFrame> expect = new ArrayList<>();
|
List<WebSocketFrame> expect = new ArrayList<>();
|
||||||
|
@ -344,7 +344,7 @@ public class TestABCase5 extends AbstractABCase
|
||||||
{
|
{
|
||||||
// phase 1
|
// phase 1
|
||||||
List<WebSocketFrame> send1 = new ArrayList<>();
|
List<WebSocketFrame> send1 = new ArrayList<>();
|
||||||
send1.add(new TextFrame("f1").setFin(false));
|
send1.add(new TextFrame().setPayload("f1").setFin(false));
|
||||||
send1.add(new ContinuationFrame(",f2").setFin(false));
|
send1.add(new ContinuationFrame(",f2").setFin(false));
|
||||||
send1.add(new PingFrame().setPayload("pong-1"));
|
send1.add(new PingFrame().setPayload("pong-1"));
|
||||||
|
|
||||||
|
@ -422,7 +422,7 @@ public class TestABCase5 extends AbstractABCase
|
||||||
public void testCase5_20() throws Exception
|
public void testCase5_20() throws Exception
|
||||||
{
|
{
|
||||||
List<WebSocketFrame> send1 = new ArrayList<>();
|
List<WebSocketFrame> send1 = new ArrayList<>();
|
||||||
send1.add(new TextFrame("f1").setFin(false));
|
send1.add(new TextFrame().setPayload("f1").setFin(false));
|
||||||
send1.add(new ContinuationFrame(",f2").setFin(false));
|
send1.add(new ContinuationFrame(",f2").setFin(false));
|
||||||
send1.add(new PingFrame().setPayload("pong-1"));
|
send1.add(new PingFrame().setPayload("pong-1"));
|
||||||
|
|
||||||
|
@ -468,7 +468,7 @@ public class TestABCase5 extends AbstractABCase
|
||||||
public void testCase5_20_slow() throws Exception
|
public void testCase5_20_slow() throws Exception
|
||||||
{
|
{
|
||||||
List<WebSocketFrame> send1 = new ArrayList<>();
|
List<WebSocketFrame> send1 = new ArrayList<>();
|
||||||
send1.add(new TextFrame("f1").setFin(false));
|
send1.add(new TextFrame().setPayload("f1").setFin(false));
|
||||||
send1.add(new ContinuationFrame(",f2").setFin(false));
|
send1.add(new ContinuationFrame(",f2").setFin(false));
|
||||||
send1.add(new PingFrame().setPayload("pong-1"));
|
send1.add(new PingFrame().setPayload("pong-1"));
|
||||||
|
|
||||||
|
@ -515,7 +515,7 @@ public class TestABCase5 extends AbstractABCase
|
||||||
public void testCase5_3() throws Exception
|
public void testCase5_3() throws Exception
|
||||||
{
|
{
|
||||||
List<WebSocketFrame> send = new ArrayList<>();
|
List<WebSocketFrame> send = new ArrayList<>();
|
||||||
send.add(new TextFrame("hello, ").setFin(false));
|
send.add(new TextFrame().setPayload("hello, ").setFin(false));
|
||||||
send.add(new ContinuationFrame("world").setFin(true));
|
send.add(new ContinuationFrame("world").setFin(true));
|
||||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||||
|
|
||||||
|
@ -544,7 +544,7 @@ public class TestABCase5 extends AbstractABCase
|
||||||
public void testCase5_4() throws Exception
|
public void testCase5_4() throws Exception
|
||||||
{
|
{
|
||||||
List<WebSocketFrame> send = new ArrayList<>();
|
List<WebSocketFrame> send = new ArrayList<>();
|
||||||
send.add(new TextFrame("hello, ").setFin(false));
|
send.add(new TextFrame().setPayload("hello, ").setFin(false));
|
||||||
send.add(new ContinuationFrame("world").setFin(true));
|
send.add(new ContinuationFrame("world").setFin(true));
|
||||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||||
|
|
||||||
|
@ -573,7 +573,7 @@ public class TestABCase5 extends AbstractABCase
|
||||||
public void testCase5_5() throws Exception
|
public void testCase5_5() throws Exception
|
||||||
{
|
{
|
||||||
List<WebSocketFrame> send = new ArrayList<>();
|
List<WebSocketFrame> send = new ArrayList<>();
|
||||||
send.add(new TextFrame("hello, ").setFin(false));
|
send.add(new TextFrame().setPayload("hello, ").setFin(false));
|
||||||
send.add(new ContinuationFrame("world").setFin(true));
|
send.add(new ContinuationFrame("world").setFin(true));
|
||||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||||
|
|
||||||
|
@ -603,7 +603,7 @@ public class TestABCase5 extends AbstractABCase
|
||||||
public void testCase5_6() throws Exception
|
public void testCase5_6() throws Exception
|
||||||
{
|
{
|
||||||
List<WebSocketFrame> send = new ArrayList<>();
|
List<WebSocketFrame> send = new ArrayList<>();
|
||||||
send.add(new TextFrame("hello, ").setFin(false));
|
send.add(new TextFrame().setPayload("hello, ").setFin(false));
|
||||||
send.add(new PingFrame().setPayload("ping"));
|
send.add(new PingFrame().setPayload("ping"));
|
||||||
send.add(new ContinuationFrame("world").setFin(true));
|
send.add(new ContinuationFrame("world").setFin(true));
|
||||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||||
|
@ -634,7 +634,7 @@ public class TestABCase5 extends AbstractABCase
|
||||||
public void testCase5_7() throws Exception
|
public void testCase5_7() throws Exception
|
||||||
{
|
{
|
||||||
List<WebSocketFrame> send = new ArrayList<>();
|
List<WebSocketFrame> send = new ArrayList<>();
|
||||||
send.add(new TextFrame("hello, ").setFin(false));
|
send.add(new TextFrame().setPayload("hello, ").setFin(false));
|
||||||
send.add(new PingFrame().setPayload("ping"));
|
send.add(new PingFrame().setPayload("ping"));
|
||||||
send.add(new ContinuationFrame("world").setFin(true));
|
send.add(new ContinuationFrame("world").setFin(true));
|
||||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||||
|
@ -665,7 +665,7 @@ public class TestABCase5 extends AbstractABCase
|
||||||
public void testCase5_8() throws Exception
|
public void testCase5_8() throws Exception
|
||||||
{
|
{
|
||||||
List<WebSocketFrame> send = new ArrayList<>();
|
List<WebSocketFrame> send = new ArrayList<>();
|
||||||
send.add(new TextFrame("hello, ").setFin(false));
|
send.add(new TextFrame().setPayload("hello, ").setFin(false));
|
||||||
send.add(new PingFrame().setPayload("ping"));
|
send.add(new PingFrame().setPayload("ping"));
|
||||||
send.add(new ContinuationFrame("world").setFin(true));
|
send.add(new ContinuationFrame("world").setFin(true));
|
||||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||||
|
@ -699,7 +699,7 @@ public class TestABCase5 extends AbstractABCase
|
||||||
|
|
||||||
List<WebSocketFrame> send = new ArrayList<>();
|
List<WebSocketFrame> send = new ArrayList<>();
|
||||||
send.add(new ContinuationFrame("sorry").setFin(true));
|
send.add(new ContinuationFrame("sorry").setFin(true));
|
||||||
send.add(new TextFrame("hello, world"));
|
send.add(new TextFrame().setPayload("hello, world"));
|
||||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||||
|
|
||||||
List<WebSocketFrame> expect = new ArrayList<>();
|
List<WebSocketFrame> expect = new ArrayList<>();
|
||||||
|
|
|
@ -344,7 +344,7 @@ public class TestABCase9 extends AbstractABCase
|
||||||
Arrays.fill(data,(byte)0x21);
|
Arrays.fill(data,(byte)0x21);
|
||||||
|
|
||||||
List<WebSocketFrame> send = new ArrayList<>();
|
List<WebSocketFrame> send = new ArrayList<>();
|
||||||
send.add(new BinaryFrame(data));
|
send.add(new BinaryFrame().setPayload(data));
|
||||||
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
|
||||||
|
|
||||||
List<WebSocketFrame> expect = new ArrayList<>();
|
List<WebSocketFrame> expect = new ArrayList<>();
|
||||||
|
|
Loading…
Reference in New Issue