Example usage for io.netty.channel.embedded EmbeddedChannel writeOneInbound

List of usage examples for io.netty.channel.embedded EmbeddedChannel writeOneInbound

Introduction

In this page you can find the example usage for io.netty.channel.embedded EmbeddedChannel writeOneInbound.

Prototype

public ChannelFuture writeOneInbound(Object msg) 

Source Link

Document

Writes one message to the inbound of this Channel and does not flush it.

Usage

From source file:org.apache.spark.network.ProtocolSuite.java

License:Apache License

private void testServerToClient(Message msg) {
    EmbeddedChannel serverChannel = new EmbeddedChannel(new FileRegionEncoder(), MessageEncoder.INSTANCE);
    serverChannel.writeOutbound(msg);/*  w ww. j  a v a2 s . c o  m*/

    EmbeddedChannel clientChannel = new EmbeddedChannel(NettyUtils.createFrameDecoder(),
            MessageDecoder.INSTANCE);

    while (!serverChannel.outboundMessages().isEmpty()) {
        clientChannel.writeOneInbound(serverChannel.readOutbound());
    }

    assertEquals(1, clientChannel.inboundMessages().size());
    assertEquals(msg, clientChannel.readInbound());
}

From source file:org.apache.spark.network.ProtocolSuite.java

License:Apache License

private void testClientToServer(Message msg) {
    EmbeddedChannel clientChannel = new EmbeddedChannel(new FileRegionEncoder(), MessageEncoder.INSTANCE);
    clientChannel.writeOutbound(msg);//  w ww  .ja v  a 2 s  .  co  m

    EmbeddedChannel serverChannel = new EmbeddedChannel(NettyUtils.createFrameDecoder(),
            MessageDecoder.INSTANCE);

    while (!clientChannel.outboundMessages().isEmpty()) {
        serverChannel.writeOneInbound(clientChannel.readOutbound());
    }

    assertEquals(1, serverChannel.inboundMessages().size());
    assertEquals(msg, serverChannel.readInbound());
}