Move netconf{-client,impl,util} to protocol/
[netconf.git] / protocol / netconf-impl / src / test / java / org / opendaylight / netconf / impl / 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.impl;
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)
28                         .getValue());
29
30         socketAddress = new InetSocketAddress("TestPortInet", 20);
31
32         assertEquals(socketAddress.getHostName(),
33                 NetconfServerSessionNegotiator.getHostName(socketAddress)
34                         .getValue());
35
36         assertEquals(String.valueOf(socketAddress.getPort()),
37                 NetconfServerSessionNegotiator.getHostName(socketAddress)
38                         .getKey());
39
40         LocalAddress localAddress = new LocalAddress("TestPortLocal");
41
42         assertEquals(String.valueOf(localAddress.id()),
43                 NetconfServerSessionNegotiator.getHostName(localAddress)
44                         .getValue());
45
46         SshdSocketAddress embeddedAddress = new SshdSocketAddress(
47                 "TestSshdName", 10);
48
49     }
50 }