Merge "Make idle timeout configurable in ssh proxy server"
[controller.git] / opendaylight / netconf / netconf-client / src / test / java / org / opendaylight / controller / netconf / client / TcpClientChannelInitializerTest.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.netconf.client;
10
11 import io.netty.channel.Channel;
12 import io.netty.channel.ChannelHandler;
13 import io.netty.channel.ChannelPipeline;
14 import io.netty.util.concurrent.Promise;
15 import org.junit.Test;
16 import org.opendaylight.protocol.framework.SessionListenerFactory;
17 import org.opendaylight.protocol.framework.SessionNegotiator;
18
19 import static org.mockito.Mockito.*;
20
21 public class TcpClientChannelInitializerTest {
22     @Test
23     public void testInitializeSessionNegotiator() throws Exception {
24         NetconfClientSessionNegotiatorFactory factory = mock(NetconfClientSessionNegotiatorFactory.class);
25         SessionNegotiator<?> sessionNegotiator = mock(SessionNegotiator.class);
26         doReturn("").when(sessionNegotiator).toString();
27         doReturn(sessionNegotiator).when(factory).getSessionNegotiator(any(SessionListenerFactory.class), any(Channel.class), any(Promise.class));
28         NetconfClientSessionListener listener = mock(NetconfClientSessionListener.class);
29         TcpClientChannelInitializer initializer = new TcpClientChannelInitializer(factory, listener);
30         ChannelPipeline pipeline = mock(ChannelPipeline.class);
31         doReturn(pipeline).when(pipeline).addAfter(anyString(), anyString(), any(ChannelHandler.class));
32         Channel channel = mock(Channel.class);
33         doReturn(pipeline).when(channel).pipeline();
34         doReturn("").when(channel).toString();
35
36         Promise<NetconfClientSession> promise = mock(Promise.class);
37         doReturn("").when(promise).toString();
38
39         initializer.initializeSessionNegotiator(channel, promise);
40         verify(pipeline, times(1)).addAfter(anyString(), anyString(), any(ChannelHandler.class));
41     }
42 }