@Test (expected = EncoderException.class)
public void testAllocateDirectBufferExceedMaxEncodeSize() {

    final int maxEncodeSize = 1024;
    Lz4FrameEncoder encoder = newEncoder(Lz4Constants.DEFAULT_BLOCK_SIZE, maxEncodeSize);
    int inputBufferSize = maxEncodeSize * 10;
    ByteBuf buf = ByteBufAllocator.DEFAULT.buffer(inputBufferSize, inputBufferSize);
    try {
        buf.writerIndex(inputBufferSize);
        encoder.allocateBuffer(ctx, buf, false);
    } finally {
        buf.release();
    }
}