@Test
public void testDiscardTooLongFrame2() {

    ByteBuf buf = Unpooled.buffer();
    buf.writeInt(32);
    for (int i = 0; i < 32; i++) {
        buf.writeByte(i);
    }
    buf.writeInt(1);
    buf.writeByte('a');
    EmbeddedChannel channel = new EmbeddedChannel(new LengthFieldBasedFrameDecoder(16, 0, 4));
    try {
        channel.writeInbound(buf.readRetainedSlice(14));
        Assert.fail();
    } catch (TooLongFrameException e) {
        // expected
    }
    Assert.assertTrue(channel.writeInbound(buf.readRetainedSlice(buf.readableBytes())));
    Assert.assertTrue(channel.finish());
    ByteBuf b = channel.readInbound();
    Assert.assertEquals(5, b.readableBytes());
    Assert.assertEquals(1, b.readInt());
    Assert.assertEquals('a', b.readByte());
    b.release();
    Assert.assertNull(channel.readInbound());
    channel.finish();
    buf.release();
}