3fbf785d77022162f2e68fa613bf0d1e38d9b3f1
[netconf.git] / protocol / netconf-server / src / test / java / org / opendaylight / netconf / server / NetconfServerSessionNegotiatorTest.java
1 /*
2  * Copyright (c) 2014, 2015 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 package org.opendaylight.netconf.server;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12
13 import io.netty.channel.local.LocalAddress;
14 import java.net.InetSocketAddress;
15 import org.junit.Test;
16 import org.opendaylight.netconf.shaded.sshd.common.util.net.SshdSocketAddress;
17
18 public class NetconfServerSessionNegotiatorTest {
19     @Test
20     public void testGetInetSocketAddress() throws Exception {
21
22         InetSocketAddress socketAddress = new InetSocketAddress(10);
23
24         assertNotNull(NetconfServerSessionNegotiator.getHostName(socketAddress));
25
26         assertEquals(socketAddress.getHostName(),
27             NetconfServerSessionNegotiator.getHostName(socketAddress).getValue());
28
29         socketAddress = new InetSocketAddress("TestPortInet", 20);
30
31         assertEquals(socketAddress.getHostName(),
32             NetconfServerSessionNegotiator.getHostName(socketAddress).getValue());
33
34         assertEquals(String.valueOf(socketAddress.getPort()),
35             NetconfServerSessionNegotiator.getHostName(socketAddress).getKey());
36
37         LocalAddress localAddress = new LocalAddress("TestPortLocal");
38
39         assertEquals(String.valueOf(localAddress.id()),
40             NetconfServerSessionNegotiator.getHostName(localAddress).getValue());
41
42         SshdSocketAddress embeddedAddress = new SshdSocketAddress("TestSshdName", 10);
43     }
44 }