Example usage for io.netty.channel ChannelOption valueOf

List of usage examples for io.netty.channel ChannelOption valueOf

Introduction

In this page you can find the example usage for io.netty.channel ChannelOption valueOf.

Prototype

@SuppressWarnings("unchecked")
public static <T> ChannelOption<T> valueOf(String name) 

Source Link

Document

Returns the ChannelOption of the specified name.

Usage

From source file:com.github.spapageo.jannel.client.JannelClientTest.java

License:Open Source License

@Test
public void testIdentifyConnectsToCorrectRemoteServerWithConnectionTimeout() throws Exception {

    Channel channel = mock(Channel.class, Answers.RETURNS_SMART_NULLS.get());
    mockWriteHandler = mock(ChannelHandler.class);

    DefaultChannelPromise completedFuture = new DefaultChannelPromise(channel);
    completedFuture.setSuccess();/*from  w ww.j  av  a  2 s . com*/

    ChannelPipeline channelPipeline = mock(ChannelPipeline.class);
    when(channelPipeline.addLast(anyString(), any(ChannelHandler.class))).thenReturn(channelPipeline);
    when(channelPipeline.addLast(any(EventExecutorGroup.class), anyString(), any(ChannelHandler.class)))
            .thenReturn(channelPipeline);
    when(channel.pipeline()).thenReturn(channelPipeline);
    when(channel.isActive()).thenReturn(true);
    when(channel.writeAndFlush(any())).thenReturn(completedFuture);

    when(bootstrap.connect(anyString(), anyInt())).thenReturn(completedFuture);

    ClientSessionConfiguration configuration = new ClientSessionConfiguration();
    configuration.setHost("testHost");
    configuration.setPort(1111);
    configuration.setConnectTimeout(10000);

    jannelClient.identify(configuration, null);

    verify(bootstrap).connect(configuration.getHost(), configuration.getPort());
    verify(bootstrap).option(ChannelOption.valueOf("connectTimeoutMillis"), configuration.getConnectTimeout());
}