@Test
public void testFlush() {

    Lz4FrameEncoder encoder = new Lz4FrameEncoder();
    EmbeddedChannel channel = new EmbeddedChannel(encoder);
    int size = 27;
    ByteBuf buf = ByteBufAllocator.DEFAULT.buffer(size, size);
    buf.writerIndex(size);
    Assert.assertEquals(0, encoder.getBackingBuffer().readableBytes());
    channel.write(buf);
    Assert.assertTrue(channel.outboundMessages().isEmpty());
    Assert.assertEquals(size, encoder.getBackingBuffer().readableBytes());
    channel.flush();
    Assert.assertTrue(channel.finish());
    Assert.assertTrue(channel.releaseOutbound());
    Assert.assertFalse(channel.releaseInbound());
}