@Test
  public void testCompress_TimeTimeTime() {
    // What pywebsocket produces for "time:", "time:", "time:"
    String expected[] = new String[] {"2AC9CC4DB50200", "2A01110000", "02130000"};

    // Lets see what we produce
    CapturedHexPayloads capture = new CapturedHexPayloads();
    DeflateFrameExtension ext = new DeflateFrameExtension();
    init(ext);
    ext.setNextOutgoingFrames(capture);

    ext.outgoingFrame(new TextFrame().setPayload("time:"), null);
    ext.outgoingFrame(new TextFrame().setPayload("time:"), null);
    ext.outgoingFrame(new TextFrame().setPayload("time:"), null);

    List<String> actual = capture.getCaptured();

    Assert.assertThat("Compressed Payloads", actual, contains(expected));
  }
  @Test
  public void testGeneratedTwoFrames() throws IOException {
    WebSocketPolicy policy = WebSocketPolicy.newClientPolicy();

    DeflateFrameExtension ext = new DeflateFrameExtension();
    ext.setBufferPool(bufferPool);
    ext.setPolicy(policy);
    ext.setConfig(new ExtensionConfig(ext.getName()));

    boolean validating = true;
    Generator generator = new Generator(policy, bufferPool, validating);
    generator.configureFromExtensions(Collections.singletonList(ext));

    OutgoingNetworkBytesCapture capture = new OutgoingNetworkBytesCapture(generator);
    ext.setNextOutgoingFrames(capture);

    ext.outgoingFrame(new TextFrame().setPayload("Hello"), null);
    ext.outgoingFrame(new TextFrame().setPayload("There"), null);

    capture.assertBytes(0, "c107f248cdc9c90700");
  }
  private void assertOutgoing(String text, String expectedHex) throws IOException {
    WebSocketPolicy policy = WebSocketPolicy.newClientPolicy();

    DeflateFrameExtension ext = new DeflateFrameExtension();
    ext.setBufferPool(bufferPool);
    ext.setPolicy(policy);

    ExtensionConfig config = ExtensionConfig.parse("deflate-frame");
    ext.setConfig(config);

    boolean validating = true;
    Generator generator = new Generator(policy, bufferPool, validating);
    generator.configureFromExtensions(Collections.singletonList(ext));

    OutgoingNetworkBytesCapture capture = new OutgoingNetworkBytesCapture(generator);
    ext.setNextOutgoingFrames(capture);

    Frame frame = new TextFrame().setPayload(text);
    ext.outgoingFrame(frame, null);

    capture.assertBytes(0, expectedHex);
  }