@Test
public void testFlushViaScheduledTask() {

    final AtomicInteger flushCount = new AtomicInteger();
    EmbeddedChannel channel = newChannel(flushCount,  true);
    // Flushes should not go through immediately, as they're scheduled as an async task
    channel.flush();
    assertEquals(0, flushCount.get());
    channel.flush();
    assertEquals(0, flushCount.get());
    // Trigger the execution of the async task
    channel.runPendingTasks();
    assertEquals(1, flushCount.get());
    assertFalse(channel.finish());
}