use of org.eclipse.jetty.websocket.common.test.UnitParser in project jetty.project by eclipse.
the class TestABCase1_1 method testParse65535ByteTextCase1_1_6.
@Test
public void testParse65535ByteTextCase1_1_6() {
int length = 65535;
ByteBuffer expected = ByteBuffer.allocate(length + 5);
expected.put(new byte[] { (byte) 0x81 });
// no masking
byte b = 0x00;
b |= 0x7E;
expected.put(b);
expected.put(new byte[] { (byte) 0xff, (byte) 0xff });
for (int i = 0; i < length; ++i) {
expected.put("*".getBytes());
}
expected.flip();
WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.CLIENT);
policy.setMaxTextMessageSize(length);
Parser parser = new UnitParser(policy);
IncomingFramesCapture capture = new IncomingFramesCapture();
parser.setIncomingFramesHandler(capture);
parser.parse(expected);
capture.assertNoErrors();
capture.assertHasFrame(OpCode.TEXT, 1);
Frame pActual = capture.getFrames().poll();
Assert.assertThat("TextFrame.payloadLength", pActual.getPayloadLength(), is(length));
// Assert.assertEquals("TextFrame.payload",length,pActual.getPayloadData().length);
}
use of org.eclipse.jetty.websocket.common.test.UnitParser in project jetty.project by eclipse.
the class TestABCase1_1 method testParse125ByteTextCase1_1_2.
@Test
public void testParse125ByteTextCase1_1_2() {
int length = 125;
ByteBuffer expected = ByteBuffer.allocate(length + 5);
expected.put(new byte[] { (byte) 0x81 });
// no masking
byte b = 0x00;
b |= length & 0x7F;
expected.put(b);
for (int i = 0; i < length; ++i) {
expected.put("*".getBytes());
}
expected.flip();
Parser parser = new UnitParser(policy);
IncomingFramesCapture capture = new IncomingFramesCapture();
parser.setIncomingFramesHandler(capture);
parser.parse(expected);
capture.assertNoErrors();
capture.assertHasFrame(OpCode.TEXT, 1);
Frame pActual = capture.getFrames().poll();
Assert.assertThat("TextFrame.payloadLength", pActual.getPayloadLength(), is(length));
// Assert.assertEquals("TextFrame.payload",length,pActual.getPayloadData().length);
}
use of org.eclipse.jetty.websocket.common.test.UnitParser in project jetty.project by eclipse.
the class TestABCase1_2 method testParse65536ByteBinaryCase1_2_7.
@Test
public void testParse65536ByteBinaryCase1_2_7() {
int length = 65536;
ByteBuffer expected = ByteBuffer.allocate(length + 11);
expected.put(new byte[] { (byte) 0x82 });
// no masking
byte b = 0x00;
b |= 0x7F;
expected.put(b);
expected.put(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00 });
for (int i = 0; i < length; ++i) {
expected.put("*".getBytes());
}
expected.flip();
WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.CLIENT);
policy.setMaxBinaryMessageSize(length);
Parser parser = new UnitParser(policy);
IncomingFramesCapture capture = new IncomingFramesCapture();
parser.setIncomingFramesHandler(capture);
parser.parse(expected);
capture.assertNoErrors();
capture.assertHasFrame(OpCode.BINARY, 1);
Frame pActual = capture.getFrames().poll();
Assert.assertThat("BinaryFrame.payloadLength", pActual.getPayloadLength(), is(length));
// Assert.assertEquals("BinaryFrame.payload",length,pActual.getPayloadData().length);
}
use of org.eclipse.jetty.websocket.common.test.UnitParser in project jetty.project by eclipse.
the class TestABCase1_2 method testParse126ByteBinaryCase1_2_3.
@Test
public void testParse126ByteBinaryCase1_2_3() {
int length = 126;
ByteBuffer expected = ByteBuffer.allocate(length + 5);
expected.put(new byte[] { (byte) 0x82 });
// no masking
byte b = 0x00;
b |= length & 0x7E;
expected.put(b);
expected.putShort((short) length);
for (int i = 0; i < length; ++i) {
expected.put("*".getBytes());
}
expected.flip();
Parser parser = new UnitParser(policy);
IncomingFramesCapture capture = new IncomingFramesCapture();
parser.setIncomingFramesHandler(capture);
parser.parse(expected);
capture.assertNoErrors();
capture.assertHasFrame(OpCode.BINARY, 1);
Frame pActual = capture.getFrames().poll();
Assert.assertThat("BinaryFrame.payloadLength", pActual.getPayloadLength(), is(length));
// Assert.assertEquals("BinaryFrame.payload",length,pActual.getPayloadData().length);
}
use of org.eclipse.jetty.websocket.common.test.UnitParser in project jetty.project by eclipse.
the class TestABCase1_2 method testParse127ByteBinaryCase1_2_4.
@Test
public void testParse127ByteBinaryCase1_2_4() {
int length = 127;
ByteBuffer expected = ByteBuffer.allocate(length + 5);
expected.put(new byte[] { (byte) 0x82 });
// no masking
byte b = 0x00;
b |= length & 0x7E;
expected.put(b);
expected.putShort((short) length);
for (int i = 0; i < length; ++i) {
expected.put("*".getBytes());
}
expected.flip();
Parser parser = new UnitParser(policy);
IncomingFramesCapture capture = new IncomingFramesCapture();
parser.setIncomingFramesHandler(capture);
parser.parse(expected);
capture.assertNoErrors();
capture.assertHasFrame(OpCode.BINARY, 1);
Frame pActual = capture.getFrames().poll();
Assert.assertThat("BinaryFrame.payloadLength", pActual.getPayloadLength(), is(length));
// .assertEquals("BinaryFrame.payload",length,pActual.getPayloadData().length);
}
Aggregations