Search in sources :

Example 1 with SocketChannelConfig

use of io.netty.channel.socket.SocketChannelConfig in project grpc-java by grpc.

the class NettyClientTransportTest method setSoLingerChannelOption.

@Test
public void setSoLingerChannelOption() throws IOException {
    startServer();
    Map<ChannelOption<?>, Object> channelOptions = new HashMap<ChannelOption<?>, Object>();
    // set SO_LINGER option
    int soLinger = 123;
    channelOptions.put(ChannelOption.SO_LINGER, soLinger);
    NettyClientTransport transport = new NettyClientTransport(address, NioSocketChannel.class, channelOptions, group, newNegotiator(), DEFAULT_WINDOW_SIZE, DEFAULT_MAX_MESSAGE_SIZE, GrpcUtil.DEFAULT_MAX_HEADER_LIST_SIZE, authority, null);
    transports.add(transport);
    callMeMaybe(transport.start(clientTransportListener));
    // verify SO_LINGER has been set
    ChannelConfig config = transport.channel().config();
    assertTrue(config instanceof SocketChannelConfig);
    assertEquals(soLinger, ((SocketChannelConfig) config).getSoLinger());
}
Also used : ChannelOption(io.netty.channel.ChannelOption) HashMap(java.util.HashMap) SocketChannelConfig(io.netty.channel.socket.SocketChannelConfig) ChannelConfig(io.netty.channel.ChannelConfig) SocketChannelConfig(io.netty.channel.socket.SocketChannelConfig) Test(org.junit.Test)

Aggregations

ChannelConfig (io.netty.channel.ChannelConfig)1 ChannelOption (io.netty.channel.ChannelOption)1 SocketChannelConfig (io.netty.channel.socket.SocketChannelConfig)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1