2 * Copyright (c) 2014, 2015 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
8 package org.opendaylight.netconf.server;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
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;
18 public class NetconfServerSessionNegotiatorTest {
20 public void testGetInetSocketAddress() throws Exception {
22 InetSocketAddress socketAddress = new InetSocketAddress(10);
24 assertNotNull(NetconfServerSessionNegotiator.getHostName(socketAddress));
26 assertEquals(socketAddress.getHostName(),
27 NetconfServerSessionNegotiator.getHostName(socketAddress).getValue());
29 socketAddress = new InetSocketAddress("TestPortInet", 20);
31 assertEquals(socketAddress.getHostName(),
32 NetconfServerSessionNegotiator.getHostName(socketAddress).getValue());
34 assertEquals(String.valueOf(socketAddress.getPort()),
35 NetconfServerSessionNegotiator.getHostName(socketAddress).getKey());
37 LocalAddress localAddress = new LocalAddress("TestPortLocal");
39 assertEquals(String.valueOf(localAddress.id()),
40 NetconfServerSessionNegotiator.getHostName(localAddress).getValue());
42 SshdSocketAddress embeddedAddress = new SshdSocketAddress("TestSshdName", 10);