@Test
public void testFlushViaClose() {

    final AtomicInteger flushCount = new AtomicInteger();
    EmbeddedChannel channel = newChannel(flushCount, false);
    // Simulate read loop;
    channel.pipeline().fireChannelRead(1L);
    assertEquals(0, flushCount.get());
    assertNull(channel.readOutbound());
    channel.close();
    assertEquals(1, flushCount.get());
    assertEquals(1L, channel.readOutbound());
    assertNull(channel.readOutbound());
    assertFalse(channel.finish());
}