EmbeddedChannel extends AbstractChannel { public boolean finish() { close(); runPendingTasks(); loop.cancelScheduledTasks(); checkException(); return !inboundMessages.isEmpty() || !outboundMessages.isEmpty(); } EmbeddedChannel(ChannelHandler... handlers); @Override ChannelMetadata metadata(); @Override ChannelConfig config(); @Override boolean isOpen(); @Override boolean isActive(); Queue<Object> inboundMessages(); @Deprecated Queue<Object> lastInboundBuffer(); Queue<Object> outboundMessages(); @Deprecated Queue<Object> lastOutboundBuffer(); Object readInbound(); Object readOutbound(); boolean writeInbound(Object... msgs); boolean writeOutbound(Object... msgs); boolean finish(); void runPendingTasks(); long runScheduledPendingTasks(); void checkException();  }
@Test public void testScheduledCancelled() throws Exception { EmbeddedChannel ch = new EmbeddedChannel(new ChannelInboundHandlerAdapter()); ScheduledFuture<?> future = ch.eventLoop().schedule(new Runnable() { @Override public void run() { } }, 1, TimeUnit.DAYS); ch.finish(); Assert.assertTrue(future.isCancelled()); }