use of org.eclipse.jetty.websocket.common.test.IncomingFramesCapture in project jetty.project by eclipse.
the class TestABCase4 method testParserNonControlOpCode3Case4_1_1.
@Test
public void testParserNonControlOpCode3Case4_1_1() throws Exception {
ByteBuffer expected = ByteBuffer.allocate(32);
expected.put(new byte[] { (byte) 0x83, 0x00 });
expected.flip();
IncomingFramesCapture capture = new IncomingFramesCapture();
try (StacklessLogging logging = new StacklessLogging(Parser.class)) {
Parser parser = new UnitParser(policy);
parser.setIncomingFramesHandler(capture);
try {
parser.parse(expected);
} catch (ProtocolException ignore) {
// ignore
}
}
Assert.assertEquals("error on undefined opcode", 1, capture.getErrorCount(WebSocketException.class));
Throwable known = capture.getErrors().poll();
Assert.assertTrue("undefined option should be in message", known.getMessage().contains("Unknown opcode: 3"));
}
use of org.eclipse.jetty.websocket.common.test.IncomingFramesCapture in project jetty.project by eclipse.
the class TestABCase4 method testParserControlOpCode12WithPayloadCase4_2_2.
@Test
public void testParserControlOpCode12WithPayloadCase4_2_2() throws Exception {
ByteBuffer expected = ByteBuffer.allocate(32);
expected.put(new byte[] { (byte) 0x8c, 0x01, 0x00 });
expected.flip();
IncomingFramesCapture capture = new IncomingFramesCapture();
try (StacklessLogging logging = new StacklessLogging(Parser.class)) {
Parser parser = new UnitParser(policy);
parser.setIncomingFramesHandler(capture);
try {
parser.parse(expected);
} catch (ProtocolException ignore) {
// ignore
}
}
Assert.assertEquals("error on undefined opcode", 1, capture.getErrorCount(WebSocketException.class));
Throwable known = capture.getErrors().poll();
Assert.assertTrue("undefined option should be in message", known.getMessage().contains("Unknown opcode: 12"));
}
use of org.eclipse.jetty.websocket.common.test.IncomingFramesCapture in project jetty.project by eclipse.
the class TestABCase4 method testParserControlOpCode11Case4_2_1.
@Test
public void testParserControlOpCode11Case4_2_1() throws Exception {
ByteBuffer expected = ByteBuffer.allocate(32);
expected.put(new byte[] { (byte) 0x8b, 0x00 });
expected.flip();
IncomingFramesCapture capture = new IncomingFramesCapture();
try (StacklessLogging logging = new StacklessLogging(Parser.class)) {
Parser parser = new UnitParser(policy);
parser.setIncomingFramesHandler(capture);
try {
parser.parse(expected);
} catch (ProtocolException ignore) {
// ignore
}
}
Assert.assertEquals("error on undefined opcode", 1, capture.getErrorCount(WebSocketException.class));
Throwable known = capture.getErrors().poll();
Assert.assertTrue("undefined option should be in message", known.getMessage().contains("Unknown opcode: 11"));
}
use of org.eclipse.jetty.websocket.common.test.IncomingFramesCapture in project jetty.project by eclipse.
the class TestABCase7_3 method testCase7_3_3ParseCloseWithStatus.
@Test
public void testCase7_3_3ParseCloseWithStatus() {
ByteBuffer expected = ByteBuffer.allocate(5);
expected.put(new byte[] { (byte) 0x88, (byte) 0x02, 0x03, (byte) 0xe8 });
expected.flip();
Parser parser = new UnitParser(policy);
IncomingFramesCapture capture = new IncomingFramesCapture();
parser.setIncomingFramesHandler(capture);
parser.parse(expected);
capture.assertNoErrors();
capture.assertHasFrame(OpCode.CLOSE, 1);
Frame pActual = capture.getFrames().poll();
Assert.assertThat("CloseFrame.payloadLength", pActual.getPayloadLength(), is(2));
}
use of org.eclipse.jetty.websocket.common.test.IncomingFramesCapture in project jetty.project by eclipse.
the class TestABCase7_3 method testCase7_3_1ParseEmptyClose.
@Test
public void testCase7_3_1ParseEmptyClose() {
ByteBuffer expected = ByteBuffer.allocate(5);
expected.put(new byte[] { (byte) 0x88, (byte) 0x00 });
expected.flip();
Parser parser = new UnitParser(policy);
IncomingFramesCapture capture = new IncomingFramesCapture();
parser.setIncomingFramesHandler(capture);
parser.parse(expected);
capture.assertNoErrors();
capture.assertHasFrame(OpCode.CLOSE, 1);
Frame pActual = capture.getFrames().poll();
Assert.assertThat("CloseFrame.payloadLength", pActual.getPayloadLength(), is(0));
}
Aggregations