@Test
public void testWriteContinuationFrames() throws Exception {

   String contentPart = "Content MSG Length @ ";
   StringBuilder contentBuilder = new StringBuilder(3 * maxFramePayloadLength);
   while (contentBuilder.length() < 2 * maxFramePayloadLength) {
      contentBuilder.append(contentPart);
      contentBuilder.append(contentBuilder.length());
      contentBuilder.append('\n');
   }
   String content = contentBuilder.toString();
   int length = content.length();
   assertTrue(length > 2 * maxFramePayloadLength); //at least 3 frames of data
   ByteBuf msg = Unpooled.copiedBuffer(content, StandardCharsets.UTF_8);
   ArgumentCaptor<WebSocketFrame> frameCaptor = ArgumentCaptor.forClass(WebSocketFrame.class);
   spy.write(ctx, msg, promise); //test
   assertEquals(0, msg.readableBytes());
   verify(spy).write(ctx, msg, promise);
   verify(ctx, times(3)).writeAndFlush(frameCaptor.capture(), eq(promise));
   List<WebSocketFrame> frames = frameCaptor.getAllValues();
   assertEquals(3, frames.size());
   int offset = 0;
   WebSocketFrame first = frames.get(0);
   assertTrue(first instanceof BinaryWebSocketFrame);
   assertFalse(first.isFinalFragment());
   assertEquals(content.substring(offset, offset + maxFramePayloadLength),
                first.content().toString(StandardCharsets.UTF_8));
   offset += maxFramePayloadLength;
   WebSocketFrame second = frames.get(1);
   assertTrue(second instanceof ContinuationWebSocketFrame);
   assertFalse(second.isFinalFragment());
   assertEquals(content.substring(offset, offset + maxFramePayloadLength),
                second.content().toString(StandardCharsets.UTF_8));
   offset += maxFramePayloadLength;
   WebSocketFrame last = frames.get(2);
   assertTrue(last instanceof ContinuationWebSocketFrame);
   assertTrue(last.isFinalFragment());
   assertEquals(content.substring(offset), last.content().toString(StandardCharsets.UTF_8));
   verifyNoMoreInteractions(spy, ctx);
   verifyZeroInteractions(promise);
}