Fix checkstyle warnings in netconf-client
[controller.git] / opendaylight / netconf / netconf-client / src / test / java / org / opendaylight / controller / netconf / client / NetconfReconnectingClientConfigurationTest.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.NetconfReconnectingClientConfiguration;
18 import org.opendaylight.controller.netconf.client.conf.NetconfReconnectingClientConfigurationBuilder;
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;
22 import org.opendaylight.protocol.framework.ReconnectStrategyFactory;
23
24 public class NetconfReconnectingClientConfigurationTest {
25     @Test
26     public void testNetconfReconnectingClientConfiguration() throws Exception {
27         Long timeout = 200L;
28         NetconfHelloMessageAdditionalHeader header = new NetconfHelloMessageAdditionalHeader("a", "host", "port", "trans", "id");
29         NetconfClientSessionListener listener = new SimpleNetconfClientSessionListener();
30         InetSocketAddress address = InetSocketAddress.createUnresolved("host", 830);
31         ReconnectStrategyFactory strategy = Mockito.mock(ReconnectStrategyFactory.class);
32         AuthenticationHandler handler = Mockito.mock(AuthenticationHandler.class);
33         ReconnectStrategy reconnect = Mockito.mock(ReconnectStrategy.class);
34
35         NetconfReconnectingClientConfiguration cfg = NetconfReconnectingClientConfigurationBuilder.create().
36                 withProtocol(NetconfClientConfiguration.NetconfClientProtocol.SSH).
37                 withAddress(address).
38                 withConnectionTimeoutMillis(timeout).
39                 withReconnectStrategy(reconnect).
40                 withAdditionalHeader(header).
41                 withSessionListener(listener).
42                 withConnectStrategyFactory(strategy).
43                 withAuthHandler(handler).build();
44
45         Assert.assertEquals(timeout, cfg.getConnectionTimeoutMillis());
46         Assert.assertEquals(Optional.fromNullable(header), cfg.getAdditionalHeader());
47         Assert.assertEquals(listener, cfg.getSessionListener());
48         Assert.assertEquals(handler, cfg.getAuthHandler());
49         Assert.assertEquals(strategy, cfg.getConnectStrategyFactory());
50         Assert.assertEquals(NetconfClientConfiguration.NetconfClientProtocol.SSH, cfg.getProtocol());
51         Assert.assertEquals(address, cfg.getAddress());
52         Assert.assertEquals(reconnect, cfg.getReconnectStrategy());
53     }
54 }