@Test public void testWriteOneOutbound() throws InterruptedException { final CountDownLatch latch = new CountDownLatch(1); final AtomicInteger flushCount = new AtomicInteger(0); EmbeddedChannel channel = new EmbeddedChannel(new ChannelOutboundHandlerAdapter() { @Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { ctx.write(msg, promise); latch.countDown(); } @Override public void flush(ChannelHandlerContext ctx) throws Exception { flushCount.incrementAndGet(); } }); channel.writeOneOutbound("Hello, Netty!"); if (!latch.await(1L, TimeUnit.SECONDS)) { fail("Nobody called #write() in time."); } channel.close().syncUninterruptibly(); assertEquals(0, flushCount.get()); }
public ChannelFuture writeOneOutbound(Object msg) { return writeOneOutbound(msg, newPromise()); }
EmbeddedChannel extends AbstractChannel { public ChannelFuture writeOneOutbound(Object msg) { return writeOneOutbound(msg, newPromise()); } }
EmbeddedChannel extends AbstractChannel { public ChannelFuture writeOneOutbound(Object msg) { return writeOneOutbound(msg, newPromise()); } EmbeddedChannel();  EmbeddedChannel(ChannelId channelId);  EmbeddedChannel(ChannelHandler... handlers);  EmbeddedChannel(boolean hasDisconnect, ChannelHandler... handlers);  EmbeddedChannel(boolean register, boolean hasDisconnect, ChannelHandler... handlers);  EmbeddedChannel(ChannelId channelId, ChannelHandler... handlers);  EmbeddedChannel(ChannelId channelId, boolean hasDisconnect, ChannelHandler... handlers);  EmbeddedChannel(ChannelId channelId, boolean register, boolean hasDisconnect,
                           final ChannelHandler... handlers);  EmbeddedChannel(ChannelId channelId, boolean hasDisconnect, final ChannelConfig config,
                           final ChannelHandler... handlers); }
EmbeddedChannel extends AbstractChannel { public ChannelFuture writeOneOutbound(Object msg) { return writeOneOutbound(msg, newPromise()); } EmbeddedChannel();  EmbeddedChannel(ChannelId channelId);  EmbeddedChannel(ChannelHandler... handlers);  EmbeddedChannel(boolean hasDisconnect, ChannelHandler... handlers);  EmbeddedChannel(boolean register, boolean hasDisconnect, ChannelHandler... handlers);  EmbeddedChannel(ChannelId channelId, ChannelHandler... handlers);  EmbeddedChannel(ChannelId channelId, boolean hasDisconnect, ChannelHandler... handlers);  EmbeddedChannel(ChannelId channelId, boolean register, boolean hasDisconnect,
                           final ChannelHandler... handlers);  EmbeddedChannel(ChannelId channelId, boolean hasDisconnect, final ChannelConfig config,
                           final ChannelHandler... handlers); void register(); @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(); @SuppressWarnings("unchecked") T readInbound(); @SuppressWarnings("unchecked") T readOutbound(); boolean writeInbound(Object... msgs); ChannelFuture writeOneInbound(Object msg); ChannelFuture writeOneInbound(Object msg, ChannelPromise promise); EmbeddedChannel flushInbound(); boolean writeOutbound(Object... msgs); ChannelFuture writeOneOutbound(Object msg); ChannelFuture writeOneOutbound(Object msg, ChannelPromise promise); EmbeddedChannel flushOutbound(); boolean finish(); boolean finishAndReleaseAll(); boolean releaseInbound(); boolean releaseOutbound(); @Override final ChannelFuture close(); @Override final ChannelFuture disconnect(); @Override final ChannelFuture close(ChannelPromise promise); @Override final ChannelFuture disconnect(ChannelPromise promise); void runPendingTasks(); long runScheduledPendingTasks(); void checkException(); @Override Unsafe unsafe(); }
EmbeddedChannel extends AbstractChannel { public ChannelFuture writeOneOutbound(Object msg) { return writeOneOutbound(msg, newPromise()); } EmbeddedChannel();  EmbeddedChannel(ChannelId channelId);  EmbeddedChannel(ChannelHandler... handlers);  EmbeddedChannel(boolean hasDisconnect, ChannelHandler... handlers);  EmbeddedChannel(boolean register, boolean hasDisconnect, ChannelHandler... handlers);  EmbeddedChannel(ChannelId channelId, ChannelHandler... handlers);  EmbeddedChannel(ChannelId channelId, boolean hasDisconnect, ChannelHandler... handlers);  EmbeddedChannel(ChannelId channelId, boolean register, boolean hasDisconnect,
                           final ChannelHandler... handlers);  EmbeddedChannel(ChannelId channelId, boolean hasDisconnect, final ChannelConfig config,
                           final ChannelHandler... handlers); void register(); @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(); @SuppressWarnings("unchecked") T readInbound(); @SuppressWarnings("unchecked") T readOutbound(); boolean writeInbound(Object... msgs); ChannelFuture writeOneInbound(Object msg); ChannelFuture writeOneInbound(Object msg, ChannelPromise promise); EmbeddedChannel flushInbound(); boolean writeOutbound(Object... msgs); ChannelFuture writeOneOutbound(Object msg); ChannelFuture writeOneOutbound(Object msg, ChannelPromise promise); EmbeddedChannel flushOutbound(); boolean finish(); boolean finishAndReleaseAll(); boolean releaseInbound(); boolean releaseOutbound(); @Override final ChannelFuture close(); @Override final ChannelFuture disconnect(); @Override final ChannelFuture close(ChannelPromise promise); @Override final ChannelFuture disconnect(ChannelPromise promise); void runPendingTasks(); long runScheduledPendingTasks(); void checkException(); @Override Unsafe unsafe();  }