@Test
public void testRemoveAndWriteAll() {

    assertWrite(new TestHandler() {
        @Override
        public void flush(ChannelHandlerContext ctx) throws Exception {
            assertFalse("Should not be writable anymore", ctx.channel().isWritable());
            ChannelFuture future = queue.removeAndWriteAll();
            future.addListener(new ChannelFutureListener() {
                @Override
                public void operationComplete(ChannelFuture future) throws Exception {
                    assertQueueEmpty(queue);
                }
            });
            super.flush(ctx);
        }
    }, 3);
}