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

    final int maxEncodeSize = Integer.MAX_VALUE;
    Lz4FrameEncoder encoder = newEncoder(Lz4Constants.DEFAULT_BLOCK_SIZE, maxEncodeSize);
    when(buffer.readableBytes()).thenReturn(maxEncodeSize);
    buffer.writerIndex(maxEncodeSize);
    encoder.allocateBuffer(ctx, buffer, false);
}