@Test
public void testInvalidSpdySettingsFrameLength() throws Exception {

    short type = 4;
    byte flags = 0;
    int numSettings = 2;
    int length = 8 * numSettings + 8; // invalid length
    byte idFlags = 0;
    int id = RANDOM.nextInt() & 0x00FFFFFF;
    int value = RANDOM.nextInt();
    ByteBuf buf = Unpooled.buffer(SPDY_HEADER_SIZE + length);
    encodeControlFrameHeader(buf, type, flags, length);
    buf.writeInt(numSettings);
    for (int i = 0; i < numSettings; i++) {
        buf.writeByte(idFlags);
        buf.writeMedium(id);
        buf.writeInt(value);
    }
    decoder.decode(buf);
    verify(delegate).readFrameError(anyString());
    assertFalse(buf.isReadable());
    buf.release();
}