Parser { public void setIncomingFramesHandler(IncomingFrames incoming) { this.incomingFramesHandler = incoming; } Parser(WebSocketPolicy wspolicy); void configureFromExtensions(List<? extends Extension> exts); IncomingFrames getIncomingFramesHandler(); WebSocketPolicy getPolicy(); boolean isRsv1InUse(); boolean isRsv2InUse(); boolean isRsv3InUse(); void parse(ByteBuffer buffer); void parseSingleFrame(ByteBuffer buffer); void setIncomingFramesHandler(IncomingFrames incoming); long getMessagesIn(); @Override String toString();  }
@Test public void testParseCase515() { List<WebSocketFrame> send = new ArrayList<>(); send.add(new TextFrame().setPayload("fragment1").setFin(false)); send.add(new ContinuationFrame().setPayload("fragment2").setFin(true)); send.add(new ContinuationFrame().setPayload("fragment3").setFin(false)); send.add(new TextFrame().setPayload("fragment4").setFin(true)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); ByteBuffer completeBuf = UnitGenerator.generate(send); UnitParser parser = new UnitParser(); IncomingFramesCapture capture = new IncomingFramesCapture(); parser.setIncomingFramesHandler(capture); ProtocolException x = assertThrows(ProtocolException.class, () -> parser.parseQuietly(completeBuf)); assertTrue(x.getMessage().contains("CONTINUATION frame without prior !FIN")); }
@Test public void testParseCase518() { List<WebSocketFrame> send = new ArrayList<>(); send.add(new TextFrame().setPayload("fragment1").setFin(false)); send.add(new TextFrame().setPayload("fragment2").setFin(true)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); ByteBuffer completeBuf = UnitGenerator.generate(send); UnitParser parser = new UnitParser(); IncomingFramesCapture capture = new IncomingFramesCapture(); parser.setIncomingFramesHandler(capture); ProtocolException x = assertThrows(ProtocolException.class, () -> parser.parseQuietly(completeBuf)); assertTrue(x.getMessage().contains("Unexpected TEXT frame")); }
@Test public void testParseCase519() { List<WebSocketFrame> send = new ArrayList<>(); send.add(new TextFrame().setPayload("f1").setFin(false)); send.add(new ContinuationFrame().setPayload(",f2").setFin(false)); send.add(new PingFrame().setPayload("pong-1")); send.add(new ContinuationFrame().setPayload(",f3").setFin(false)); send.add(new ContinuationFrame().setPayload(",f4").setFin(false)); send.add(new PingFrame().setPayload("pong-2")); send.add(new ContinuationFrame().setPayload(",f5").setFin(true)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); ByteBuffer completeBuf = UnitGenerator.generate(send); UnitParser parser = new UnitParser(); IncomingFramesCapture capture = new IncomingFramesCapture(); parser.setIncomingFramesHandler(capture); parser.parseQuietly(completeBuf); capture.assertHasFrame(OpCode.TEXT, 1); capture.assertHasFrame(OpCode.CONTINUATION, 4); capture.assertHasFrame(OpCode.CLOSE, 1); capture.assertHasFrame(OpCode.PING, 2); }