public int numBufferedStreams() {
        return pendingStreams.size();
    }
@Test
    public void receivingGoAwayFailsBufferedStreams() throws Http2Exception {
        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(5, connection.numActiveStreams());
        assertEquals(4, encoder.numBufferedStreams());

        connection.goAwayReceived(11, 8, EMPTY_BUFFER);

        assertEquals(5, connection.numActiveStreams());
        assertEquals(0, encoder.numBufferedStreams());
        int failCount = 0;
        for (ChannelFuture f : futures) {
            if (f.cause() != null) {
                assertTrue(f.cause() instanceof Http2GoAwayException);
                failCount++;
            }
        }
        assertEquals(4, failCount);
    }