Source:
public void testClientDeflateBufferSize() throws Exception { int deflateBufferSize = 6; TestFrameHandler clientHandler = new TestFrameHandler(); ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, serverUri, clientHandler); upgradeRequest.addExtensions("permessage-deflate; @deflate_buffer_size=" + deflateBufferSize); CompletableFuture<HttpFields.Mutable> futureRequestHeaders = new CompletableFuture<>(); upgradeRequest.addListener(new UpgradeListener() { @Override public void onHandshakeRequest(HttpRequest request) { futureRequestHeaders.complete(request.getHeaders()); } }); CompletableFuture<CoreSession> connect = client.connect(upgradeRequest); connect.get(5, TimeUnit.SECONDS); HttpFields.Mutable requestHeaders = futureRequestHeaders.get(); assertThat(requestHeaders.getFields(HttpHeader.SEC_WEBSOCKET_EXTENSIONS).size(), is(1)); assertThat(requestHeaders.get(HttpHeader.SEC_WEBSOCKET_EXTENSIONS), is("permessage-deflate")); String message = "0123456789"; clientHandler.sendText(message); int numFrames = 0; StringBuilder receivedMessage = new StringBuilder(); while (true) { Frame frame = Objects.requireNonNull(serverHandler.getFrames().poll(5, TimeUnit.SECONDS)); receivedMessage.append(frame.getPayloadAsUTF8()); numFrames++; if (frame.isFin()) break; } assertThat(numFrames, greaterThan(1)); assertThat(receivedMessage.toString(), Matchers.equalTo(message)); clientHandler.sendClose(); assertTrue(serverHandler.closed.await(5, TimeUnit.SECONDS)); assertTrue(clientHandler.closed.await(5, TimeUnit.SECONDS)); assertNull(serverHandler.getError()); assertNull(clientHandler.getError()); }

Target:
public void testClientDeflateBufferSize() throws Exception { int deflateBufferSize = 6; TestFrameHandler clientHandler = new TestFrameHandler(); ClientUpgradeRequest upgradeRequest = ClientUpgradeRequest.from(client, serverUri, clientHandler); upgradeRequest.addExtensions("permessage-deflate; @deflate_buffer_size=" + deflateBufferSize); CompletableFuture<HttpFields> futureRequestHeaders = new CompletableFuture<>(); upgradeRequest.addListener(new UpgradeListener() { @Override public void onHandshakeRequest(HttpRequest request) { futureRequestHeaders.complete(request.getHeaders()); } }); CompletableFuture<CoreSession> connect = client.connect(upgradeRequest); connect.get(5, TimeUnit.SECONDS); HttpFields requestHeaders = futureRequestHeaders.get(); assertThat(requestHeaders.getFields(HttpHeader.SEC_WEBSOCKET_EXTENSIONS).size(), is(1)); assertThat(requestHeaders.get(HttpHeader.SEC_WEBSOCKET_EXTENSIONS), is("permessage-deflate")); String message = "0123456789"; clientHandler.sendText(message); int numFrames = 0; StringBuilder receivedMessage = new StringBuilder(); while (true) { Frame frame = Objects.requireNonNull(serverHandler.getFrames().poll(5, TimeUnit.SECONDS)); receivedMessage.append(frame.getPayloadAsUTF8()); numFrames++; if (frame.isFin()) break; } assertThat(numFrames, greaterThan(1)); assertThat(receivedMessage.toString(), Matchers.equalTo(message)); clientHandler.sendClose(); assertTrue(serverHandler.closed.await(5, TimeUnit.SECONDS)); assertTrue(clientHandler.closed.await(5, TimeUnit.SECONDS)); assertNull(serverHandler.getError()); assertNull(clientHandler.getError()); }