Merge "Remove raw references to Map in XSQL"
[controller.git] / opendaylight / netconf / netconf-client / src / test / java / org / opendaylight / controller / netconf / client / NetconfClientConfigurationTest.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 com.google.common.base.Optional;
12 import java.net.InetSocketAddress;
13 import org.junit.Assert;
14 import org.junit.Test;
15 import org.mockito.Mockito;
16 import org.opendaylight.controller.netconf.client.conf.NetconfClientConfiguration;
17 import org.opendaylight.controller.netconf.client.conf.NetconfClientConfigurationBuilder;
18 import org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
19 import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessageAdditionalHeader;
20 import org.opendaylight.protocol.framework.ReconnectStrategy;
21
22 public class NetconfClientConfigurationTest {
23     @Test
24     public void testNetconfClientConfiguration() throws Exception {
25         Long timeout = 200L;
26         NetconfHelloMessageAdditionalHeader header = new NetconfHelloMessageAdditionalHeader("a", "host", "port", "trans", "id");
27         NetconfClientSessionListener listener = new SimpleNetconfClientSessionListener();
28         InetSocketAddress address = InetSocketAddress.createUnresolved("host", 830);
29         ReconnectStrategy strategy = Mockito.mock(ReconnectStrategy.class);
30         AuthenticationHandler handler = Mockito.mock(AuthenticationHandler.class);
31         NetconfClientConfiguration cfg = NetconfClientConfigurationBuilder.create().
32                 withProtocol(NetconfClientConfiguration.NetconfClientProtocol.SSH).
33                 withAddress(address).
34                 withConnectionTimeoutMillis(timeout).
35                 withReconnectStrategy(strategy).
36                 withAdditionalHeader(header).
37                 withSessionListener(listener).
38                 withAuthHandler(handler).build();
39
40         Assert.assertEquals(timeout, cfg.getConnectionTimeoutMillis());
41         Assert.assertEquals(Optional.fromNullable(header), cfg.getAdditionalHeader());
42         Assert.assertEquals(listener, cfg.getSessionListener());
43         Assert.assertEquals(handler, cfg.getAuthHandler());
44         Assert.assertEquals(strategy, cfg.getReconnectStrategy());
45         Assert.assertEquals(NetconfClientConfiguration.NetconfClientProtocol.SSH, cfg.getProtocol());
46         Assert.assertEquals(address, cfg.getAddress());
47     }
48 }