@Test
public void testHandleOutboundMessage() throws InterruptedException {

    final CountDownLatch latch = new CountDownLatch(1);
    EmbeddedChannel channel = new EmbeddedChannel() {
        @Override
        protected void handleOutboundMessage(Object msg) {
            latch.countDown();
        }
    };
    channel.writeOneOutbound("Hello, Netty!");
    if (latch.await(50L, TimeUnit.MILLISECONDS)) {
        fail("Somebody called unexpectedly #flush()");
    }
    channel.flushOutbound();
    if (!latch.await(1L, TimeUnit.SECONDS)) {
        fail("Nobody called #handleOutboundMessage() in time.");
    }
}