@Test
public void receivingGoAwayFailsBufferedStreams() {

    encoder.writeSettingsAck(ctx, newPromise());
    setMaxConcurrentStreams(5);
    int streamId = 3;
    List<ChannelFuture> futures = new ArrayList<ChannelFuture>();
    for (int i = 0; i < 9; i++) {
        futures.add(encoderWriteHeaders(streamId, newPromise()));
        streamId += 2;
    }
    assertEquals(4, encoder.numBufferedStreams());
    connection.goAwayReceived(11, 8, EMPTY_BUFFER);
    assertEquals(5, connection.numActiveStreams());
    int failCount = 0;
    for (ChannelFuture f : futures) {
        if (f.cause() != null) {
            failCount++;
        }
    }
    assertEquals(9, failCount);
    assertEquals(0, encoder.numBufferedStreams());
}