@Test
public void writeHeadersUsingVoidPromise() throws Exception {

    final Throwable cause = new RuntimeException("fake exception");
    when(writer.writeHeaders(eq(ctx), eq(STREAM_ID), any(Http2Headers.class), anyInt(), anyShort(), anyBoolean(),
                             anyInt(), anyBoolean(), any(ChannelPromise.class)))
            .then(new Answer<ChannelFuture>() {
                @Override
                public ChannelFuture answer(InvocationOnMock invocationOnMock) throws Throwable {
                    ChannelPromise promise = invocationOnMock.getArgument(8);
                    assertFalse(promise.isVoid());
                    return promise.setFailure(cause);
                }
            });
    createStream(STREAM_ID, false);
    // END_STREAM flag, so that a listener is added to the future.
    encoder.writeHeaders(ctx, STREAM_ID, EmptyHttp2Headers.INSTANCE, 0, true, newVoidPromise(channel));
    verify(writer).writeHeaders(eq(ctx), eq(STREAM_ID), any(Http2Headers.class), anyInt(), anyShort(), anyBoolean(),
                                anyInt(), anyBoolean(), any(ChannelPromise.class));
    // When using a void promise, the error should be propagated via the channel pipeline.
    verify(pipeline).fireExceptionCaught(cause);
}