X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-client%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fclient%2FTcpClientChannelInitializerTest.java;fp=opendaylight%2Fnetconf%2Fnetconf-client%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fclient%2FTcpClientChannelInitializerTest.java;h=e355cf45e7a51934e653c7f38161b6b0bc7fb038;hp=0000000000000000000000000000000000000000;hb=3c2b9f44d59d735907ef541d36542443221c5c68;hpb=ce9ca282f8e0eb5a0cd1b97cab882f9f80fa598a diff --git a/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/TcpClientChannelInitializerTest.java b/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/TcpClientChannelInitializerTest.java new file mode 100644 index 0000000000..e355cf45e7 --- /dev/null +++ b/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/TcpClientChannelInitializerTest.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.controller.netconf.client; + +import io.netty.channel.Channel; +import io.netty.channel.ChannelHandler; +import io.netty.channel.ChannelPipeline; +import io.netty.util.concurrent.Promise; +import org.junit.Test; +import org.opendaylight.controller.netconf.nettyutil.AbstractChannelInitializer; +import org.opendaylight.protocol.framework.SessionListenerFactory; +import org.opendaylight.protocol.framework.SessionNegotiator; + +import static org.mockito.Mockito.*; + +public class TcpClientChannelInitializerTest { + @Test + public void testInitializeSessionNegotiator() throws Exception { + NetconfClientSessionNegotiatorFactory factory = mock(NetconfClientSessionNegotiatorFactory.class); + SessionNegotiator sessionNegotiator = mock(SessionNegotiator.class); + doReturn("").when(sessionNegotiator).toString(); + doReturn(sessionNegotiator).when(factory).getSessionNegotiator(any(SessionListenerFactory.class), any(Channel.class), any(Promise.class)); + NetconfClientSessionListener listener = mock(NetconfClientSessionListener.class); + TcpClientChannelInitializer initializer = new TcpClientChannelInitializer(factory, listener); + ChannelPipeline pipeline = mock(ChannelPipeline.class); + doReturn(pipeline).when(pipeline).addAfter(anyString(), anyString(), any(ChannelHandler.class)); + Channel channel = mock(Channel.class); + doReturn(pipeline).when(channel).pipeline(); + doReturn("").when(channel).toString(); + + Promise promise = mock(Promise.class); + doReturn("").when(promise).toString(); + + initializer.initializeSessionNegotiator(channel, promise); + verify(pipeline, times(1)).addAfter(anyString(), anyString(), any(ChannelHandler.class)); + } +}