@Test(timeout = 5000)
public void testChannelInactiveFired() throws InterruptedException {

    final AtomicBoolean inactive = new AtomicBoolean();
    EmbeddedChannel channel = new EmbeddedChannel(new ChannelInboundHandlerAdapter() {
        @Override
        public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
            ctx.close();
        }
        @Override
        public void channelInactive(ChannelHandlerContext ctx) throws Exception {
            inactive.set(true);
        }
    });
    channel.pipeline().fireExceptionCaught(new IllegalStateException());
    assertTrue(inactive.get());
}