X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=netconf%2Fnetconf-client%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fclient%2FNetconfClientDispatcherImplTest.java;h=3a1e0d702468e73bc383368ed5e2bcee68a878c8;hb=de76f7996dc99d8580345e20ac4cd6e90330037f;hp=c2c1289555e0d136e96581b4413b166fcf2dd4cb;hpb=8f381a390a956759a6cfeede40f13e3e2825bbdd;p=netconf.git diff --git a/netconf/netconf-client/src/test/java/org/opendaylight/netconf/client/NetconfClientDispatcherImplTest.java b/netconf/netconf-client/src/test/java/org/opendaylight/netconf/client/NetconfClientDispatcherImplTest.java index c2c1289555..3a1e0d7024 100644 --- a/netconf/netconf-client/src/test/java/org/opendaylight/netconf/client/NetconfClientDispatcherImplTest.java +++ b/netconf/netconf-client/src/test/java/org/opendaylight/netconf/client/NetconfClientDispatcherImplTest.java @@ -9,7 +9,7 @@ package org.opendaylight.netconf.client; import static org.junit.Assert.assertNotNull; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import io.netty.channel.Channel; @@ -47,9 +47,12 @@ public class NetconfClientDispatcherImplTest { ChannelPromise promise = Mockito.mock(ChannelPromise.class); doReturn(promise).when(chf).addListener(any(GenericFutureListener.class)); doReturn(thr).when(chf).cause(); + doReturn(true).when(chf).isDone(); + doReturn(false).when(chf).isSuccess(); Long timeout = 200L; - NetconfHelloMessageAdditionalHeader header = new NetconfHelloMessageAdditionalHeader("a", "host", "port", "trans", "id"); + NetconfHelloMessageAdditionalHeader header = + new NetconfHelloMessageAdditionalHeader("a", "host", "port", "trans", "id"); NetconfClientSessionListener listener = new SimpleNetconfClientSessionListener(); InetSocketAddress address = InetSocketAddress.createUnresolved("host", 830); ReconnectStrategyFactory reconnectStrategyFactory = Mockito.mock(ReconnectStrategyFactory.class); @@ -62,37 +65,53 @@ public class NetconfClientDispatcherImplTest { doReturn("").when(reconnectStrategyFactory).toString(); doReturn(reconnect).when(reconnectStrategyFactory).createReconnectStrategy(); - NetconfReconnectingClientConfiguration cfg = NetconfReconnectingClientConfigurationBuilder.create(). - withProtocol(NetconfClientConfiguration.NetconfClientProtocol.SSH). - withAddress(address). - withConnectionTimeoutMillis(timeout). - withReconnectStrategy(reconnect). - withAdditionalHeader(header). - withSessionListener(listener). - withConnectStrategyFactory(reconnectStrategyFactory). - withAuthHandler(handler).build(); - - NetconfReconnectingClientConfiguration cfg2 = NetconfReconnectingClientConfigurationBuilder.create(). - withProtocol(NetconfClientConfiguration.NetconfClientProtocol.TCP). - withAddress(address). - withConnectionTimeoutMillis(timeout). - withReconnectStrategy(reconnect). - withAdditionalHeader(header). - withSessionListener(listener). - withConnectStrategyFactory(reconnectStrategyFactory). - withAuthHandler(handler).build(); + NetconfReconnectingClientConfiguration cfg = NetconfReconnectingClientConfigurationBuilder.create() + .withProtocol(NetconfClientConfiguration.NetconfClientProtocol.SSH) + .withAddress(address) + .withConnectionTimeoutMillis(timeout) + .withReconnectStrategy(reconnect) + .withAdditionalHeader(header) + .withSessionListener(listener) + .withConnectStrategyFactory(reconnectStrategyFactory) + .withAuthHandler(handler).build(); + + NetconfReconnectingClientConfiguration cfg2 = NetconfReconnectingClientConfigurationBuilder.create() + .withProtocol(NetconfClientConfiguration.NetconfClientProtocol.TCP) + .withAddress(address) + .withConnectionTimeoutMillis(timeout) + .withReconnectStrategy(reconnect) + .withAdditionalHeader(header) + .withSessionListener(listener) + .withConnectStrategyFactory(reconnectStrategyFactory) + .withAuthHandler(handler).build(); NetconfClientDispatcherImpl dispatcher = new NetconfClientDispatcherImpl(bossGroup, workerGroup, timer); Future sshSession = dispatcher.createClient(cfg); Future tcpSession = dispatcher.createClient(cfg2); Future sshReconn = dispatcher.createReconnectingClient(cfg); - Future tcpReconn = dispatcher.createReconnectingClient(cfg2); + final Future tcpReconn = dispatcher.createReconnectingClient(cfg2); assertNotNull(sshSession); assertNotNull(tcpSession); assertNotNull(sshReconn); assertNotNull(tcpReconn); + SslHandlerFactory sslHandlerFactory = Mockito.mock(SslHandlerFactory.class); + NetconfReconnectingClientConfiguration cfg3 = NetconfReconnectingClientConfigurationBuilder.create() + .withProtocol(NetconfClientConfiguration.NetconfClientProtocol.TLS) + .withAddress(address) + .withConnectionTimeoutMillis(timeout) + .withReconnectStrategy(reconnect) + .withAdditionalHeader(header) + .withSessionListener(listener) + .withConnectStrategyFactory(reconnectStrategyFactory) + .withSslHandlerFactory(sslHandlerFactory).build(); + + Future tlsSession = dispatcher.createClient(cfg3); + Future tlsReconn = dispatcher.createReconnectingClient(cfg3); + + assertNotNull(tlsSession); + assertNotNull(tlsReconn); } }