@Test
public void testAutoReadingOff() throws Exception {

    final Exchanger<Channel> peerRef = new Exchanger<Channel>();
    final CountDownLatch latch = new CountDownLatch(3);
    ChannelInboundHandlerAdapter handler = new ChannelInboundHandlerAdapter() {
        @Override
        public void channelActive(ChannelHandlerContext ctx) throws Exception {
            peerRef.exchange(ctx.channel(), 1L, SECONDS);
            ctx.fireChannelActive();
        }
        @Override
        public void channelRead(ChannelHandlerContext ctx, Object msg) {
            ReferenceCountUtil.release(msg);
            latch.countDown();
        }
    };
    Channel server = newServer(false, handler);
    Channel client = newClient(server.localAddress());
    try {
        // The client connection on the server side
        Channel peer = peerRef.exchange(null, 1L, SECONDS);
        // Write the message
        client.writeAndFlush(newOneMessage())
            .syncUninterruptibly();
        // Read the message
        peer.read();
        // We received all three messages but hoped that only one
        // message was read because auto reading was off and we
        // invoked the read() method only once.
        assertTrue(latch.await(1L, SECONDS));
    } finally {
        client.close();
        server.close();
    }
}