BUG-2243 Fixing invalid hello message handling
[controller.git] / opendaylight / netconf / netconf-impl / src / test / java / org / opendaylight / controller / netconf / impl / NetconfServerSessionNegotiatorTest.java
diff --git a/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/NetconfServerSessionNegotiatorTest.java b/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/NetconfServerSessionNegotiatorTest.java
new file mode 100644 (file)
index 0000000..c16046c
--- /dev/null
@@ -0,0 +1,45 @@
+package org.opendaylight.controller.netconf.impl;
+
+import io.netty.channel.local.LocalAddress;
+import org.apache.sshd.common.SshdSocketAddress;
+import org.junit.Test;
+
+import java.net.InetSocketAddress;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class NetconfServerSessionNegotiatorTest {
+
+    @Test
+    public void testGetInetSocketAddress() throws Exception {
+
+        InetSocketAddress socketAddress = new InetSocketAddress(10);
+
+        assertNotNull(NetconfServerSessionNegotiator.getHostName(socketAddress));
+
+        assertEquals(socketAddress.getHostName(),
+                NetconfServerSessionNegotiator.getHostName(socketAddress)
+                        .getValue());
+
+        socketAddress = new InetSocketAddress("TestPortInet", 20);
+
+        assertEquals(socketAddress.getHostName(),
+                NetconfServerSessionNegotiator.getHostName(socketAddress)
+                        .getValue());
+
+        assertEquals(String.valueOf(socketAddress.getPort()),
+                NetconfServerSessionNegotiator.getHostName(socketAddress)
+                        .getKey());
+
+        LocalAddress localAddress = new LocalAddress("TestPortLocal");
+
+        assertEquals(String.valueOf(localAddress.id()),
+                NetconfServerSessionNegotiator.getHostName(localAddress)
+                        .getValue());
+
+        SshdSocketAddress embeddedAddress = new SshdSocketAddress(
+                "TestSshdName", 10);
+
+    }
+}
\ No newline at end of file