@Test
public void testOutgoingPing() throws IOException {

    PerMessageDeflateExtension ext = new PerMessageDeflateExtension();
    ext.setPolicy(WebSocketPolicy.newServerPolicy());
    ExtensionConfig config = ExtensionConfig.parse("permessage-deflate");
    ext.setConfig(config);
    // Setup capture of outgoing frames
    OutgoingFramesCapture capture = new OutgoingFramesCapture();
    // Wire up stack
    ext.setNextOutgoingFrames(capture);
    String payload = "Are you there?";
    Frame ping = new PingFrame().setPayload(payload);
    ext.outgoingFrame(ping, null);
    capture.assertFrameCount(1);
    capture.assertHasFrame(OpCode.PING, 1);
    WebSocketFrame actual = capture.getFrames().getFirst();
    assertEquals(OpCode.PING, actual.getOpCode());
    assertTrue(actual.isFin());
    assertFalse(actual.isRsv1());
    assertFalse(actual.isRsv2());
    assertFalse(actual.isRsv3());
    ByteBuffer expected = BufferUtils.toBuffer(payload, StandardCharsets.UTF_8);
    assertEquals(expected.remaining(), actual.getPayloadLength());
    ByteBufferAssert.assertEquals("Frame.payload", expected, actual.getPayload().slice());
}