List of usage examples for io.netty.channel.embedded EmbeddedChannel write
@Override
public ChannelFuture write(Object msg)
From source file:nats.codec.ClientFrameRecodeTest.java
License:Open Source License
private <T extends NatsFrame> T recode(T frame) { final EmbeddedChannel channel = new EmbeddedChannel(new ClientFrameEncoder(), new ClientFrameDecoder()); // Encode//from w w w.ja va 2 s. com channel.write(frame); channel.flush(); channel.checkException(); final ByteBuf data = (ByteBuf) channel.readOutbound(); // Decode channel.writeInbound(data); channel.checkException(); final T recodedFrame = (T) channel.readInbound(); // Ensure we got a frame assertNotNull(recodedFrame); return recodedFrame; }
From source file:nats.codec.ServerFrameRecodeTest.java
License:Open Source License
protected <T extends NatsFrame> T recode(T frame) { final EmbeddedChannel channel = new EmbeddedChannel(new ServerFrameEncoder(), new ServerFrameDecoder()); // Encode//from w w w.j a va 2 s . c o m channel.write(frame); channel.flush(); channel.checkException(); final ByteBuf data = (ByteBuf) channel.readOutbound(); // Decode channel.writeInbound(data); channel.checkException(); final T recodedFrame = (T) channel.readInbound(); // Ensure we got a frame assertNotNull(recodedFrame); return recodedFrame; }
From source file:org.helios.octo.ReadSuspendTest.java
License:Open Source License
/** * @param args//from ww w . ja v a 2 s. c o m */ public static void main(String[] args) { BasicConfigurator.configure(); InternalLoggerFactory.setDefaultFactory(new Log4JLoggerFactory()); EmbeddedChannel channel = new EmbeddedChannel(new Throttler(), new Decoder()); channel.config().setAutoRead(false); for (int i = 0; i < 20; i++) { LOG.info("Writing [" + i + "]"); channel.write(Unpooled.wrappedBuffer("any payload".getBytes())).syncUninterruptibly(); LOG.info("Wrote [" + i + "]"); } }