2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.controller.netconf.client;
11 import com.google.common.base.Optional;
12 import org.junit.Assert;
13 import org.junit.Test;
14 import org.mockito.Mockito;
15 import org.opendaylight.controller.netconf.client.NetconfClientSessionListener;
16 import org.opendaylight.controller.netconf.client.SimpleNetconfClientSessionListener;
17 import org.opendaylight.controller.netconf.client.conf.NetconfClientConfiguration;
18 import org.opendaylight.controller.netconf.client.conf.NetconfClientConfigurationBuilder;
19 import org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
20 import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessageAdditionalHeader;
21 import org.opendaylight.protocol.framework.ReconnectStrategy;
23 import java.net.InetSocketAddress;
25 public class NetconfClientConfigurationTest {
27 public void testNetconfClientConfiguration() throws Exception {
29 NetconfHelloMessageAdditionalHeader header = new NetconfHelloMessageAdditionalHeader("a", "host", "port", "trans", "id");
30 NetconfClientSessionListener listener = new SimpleNetconfClientSessionListener();
31 InetSocketAddress address = InetSocketAddress.createUnresolved("host", 830);
32 ReconnectStrategy strategy = Mockito.mock(ReconnectStrategy.class);
33 AuthenticationHandler handler = Mockito.mock(AuthenticationHandler.class);
34 NetconfClientConfiguration cfg = NetconfClientConfigurationBuilder.create().
35 withProtocol(NetconfClientConfiguration.NetconfClientProtocol.SSH).
37 withConnectionTimeoutMillis(timeout).
38 withReconnectStrategy(strategy).
39 withAdditionalHeader(header).
40 withSessionListener(listener).
41 withAuthHandler(handler).build();
43 Assert.assertEquals(timeout, cfg.getConnectionTimeoutMillis());
44 Assert.assertEquals(Optional.fromNullable(header), cfg.getAdditionalHeader());
45 Assert.assertEquals(listener, cfg.getSessionListener());
46 Assert.assertEquals(handler, cfg.getAuthHandler());
47 Assert.assertEquals(strategy, cfg.getReconnectStrategy());
48 Assert.assertEquals(NetconfClientConfiguration.NetconfClientProtocol.SSH, cfg.getProtocol());
49 Assert.assertEquals(address, cfg.getAddress());