@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)); // bad frame, must be continuation
    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"));
}