@Test
public void testSpdySynReplyFrameHeaderBlock() throws Exception {

    short type = 2;
    byte flags = 0;
    int length = 4;
    int headerBlockLength = 1024;
    int streamId = RANDOM.nextInt() & 0x7FFFFFFF | 0x01;
    ByteBuf buf = Unpooled.buffer(SPDY_HEADER_SIZE + length + headerBlockLength);
    encodeControlFrameHeader(buf, type, flags, length + headerBlockLength);
    buf.writeInt(streamId);
    ByteBuf headerBlock = Unpooled.buffer(headerBlockLength);
    for (int i = 0; i < 256; i ++) {
        headerBlock.writeInt(RANDOM.nextInt());
    }
    decoder.decode(buf);
    decoder.decode(headerBlock);
    verify(delegate).readSynReplyFrame(streamId, false);
    verify(delegate).readHeaderBlock(headerBlock.slice(0, headerBlock.writerIndex()));
    verify(delegate).readHeaderBlockEnd();
    assertFalse(buf.isReadable());
    assertFalse(headerBlock.isReadable());
    buf.release();
    headerBlock.release();
}