public static <T> FutureCallback<T> countDown(final CountDownLatch latch, final Consumer<T> consumer) {
        return new FutureCallback<T>() {

            @Override
            public void completed(final T result) {
                if (consumer != null) {
                    consumer.accept(result);
                }
                latch.countDown();
            }

            @Override
            public void failed(final Exception ex) {
                latch.countDown();
                Assertions.fail(ex);
            }

            @Override
            public void cancelled() {
                latch.countDown();
                Assertions.fail("Unexpected cancellation");
            }

        };

    }
Generates a response body with random content.
 @param nbytes length of the desired response body
 @return an {@link HttpEntity}
httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/HttpTestUtils.java