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%2FNetconfClientConfigurationTest.java;fp=opendaylight%2Fnetconf%2Fnetconf-client%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fclient%2FNetconfClientConfigurationTest.java;h=592cdad4c196bdc47fb24588fad630192da593fa;hp=0000000000000000000000000000000000000000;hb=3c2b9f44d59d735907ef541d36542443221c5c68;hpb=ce9ca282f8e0eb5a0cd1b97cab882f9f80fa598a diff --git a/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfClientConfigurationTest.java b/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfClientConfigurationTest.java new file mode 100644 index 0000000000..592cdad4c1 --- /dev/null +++ b/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/NetconfClientConfigurationTest.java @@ -0,0 +1,51 @@ +/* + * 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 com.google.common.base.Optional; +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mockito; +import org.opendaylight.controller.netconf.client.NetconfClientSessionListener; +import org.opendaylight.controller.netconf.client.SimpleNetconfClientSessionListener; +import org.opendaylight.controller.netconf.client.conf.NetconfClientConfiguration; +import org.opendaylight.controller.netconf.client.conf.NetconfClientConfigurationBuilder; +import org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler; +import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessageAdditionalHeader; +import org.opendaylight.protocol.framework.ReconnectStrategy; + +import java.net.InetSocketAddress; + +public class NetconfClientConfigurationTest { + @Test + public void testNetconfClientConfiguration() throws Exception { + Long timeout = 200L; + NetconfHelloMessageAdditionalHeader header = new NetconfHelloMessageAdditionalHeader("a", "host", "port", "trans", "id"); + NetconfClientSessionListener listener = new SimpleNetconfClientSessionListener(); + InetSocketAddress address = InetSocketAddress.createUnresolved("host", 830); + ReconnectStrategy strategy = Mockito.mock(ReconnectStrategy.class); + AuthenticationHandler handler = Mockito.mock(AuthenticationHandler.class); + NetconfClientConfiguration cfg = NetconfClientConfigurationBuilder.create(). + withProtocol(NetconfClientConfiguration.NetconfClientProtocol.SSH). + withAddress(address). + withConnectionTimeoutMillis(timeout). + withReconnectStrategy(strategy). + withAdditionalHeader(header). + withSessionListener(listener). + withAuthHandler(handler).build(); + + Assert.assertEquals(timeout, cfg.getConnectionTimeoutMillis()); + Assert.assertEquals(Optional.fromNullable(header), cfg.getAdditionalHeader()); + Assert.assertEquals(listener, cfg.getSessionListener()); + Assert.assertEquals(handler, cfg.getAuthHandler()); + Assert.assertEquals(strategy, cfg.getReconnectStrategy()); + Assert.assertEquals(NetconfClientConfiguration.NetconfClientProtocol.SSH, cfg.getProtocol()); + Assert.assertEquals(address, cfg.getAddress()); + } +}