Clean up NetconfServerSessionNegotiatorTest 50/110050/1
authorRobert Varga <robert.varga@pantheon.tech>
Sat, 27 Jan 2024 21:25:01 +0000 (22:25 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Sat, 27 Jan 2024 22:46:03 +0000 (23:46 +0100)
Split the three test cases into individual methods, migrating to JUnit5.
Since SshdSocketAddress is not asserted against, we remove it along with
the dependency on shaded-sshd.

Change-Id: I7b297ce843ac7dcd12312493663b4b04384fb370
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
protocol/netconf-server/pom.xml
protocol/netconf-server/src/test/java/org/opendaylight/netconf/server/NetconfServerSessionNegotiatorTest.java

index e4dc129535d5ae9883d3f999d4d83250a2575d0d..561f1a460efdd3e0edb33aed0603de91f1224140 100644 (file)
       <groupId>org.opendaylight.netconf</groupId>
       <artifactId>netconf-test-util</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.opendaylight.netconf</groupId>
-      <artifactId>shaded-sshd</artifactId>
-      <scope>test</scope>
-    </dependency>
     <dependency>
       <groupId>org.xmlunit</groupId>
       <artifactId>xmlunit-core</artifactId>
index 3fbf785d77022162f2e68fa613bf0d1e38d9b3f1..d9f72c4896f0b3d1f38800b5a589fd231b9bea56 100644 (file)
@@ -7,38 +7,34 @@
  */
 package org.opendaylight.netconf.server;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import io.netty.channel.local.LocalAddress;
 import java.net.InetSocketAddress;
-import org.junit.Test;
-import org.opendaylight.netconf.shaded.sshd.common.util.net.SshdSocketAddress;
+import org.junit.jupiter.api.Test;
 
-public class NetconfServerSessionNegotiatorTest {
+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");
+    void testPortTen() {
+        final var address = new InetSocketAddress(10);
+        final var hostname = NetconfServerSessionNegotiator.getHostName(address);
+        assertNotNull(hostname);
+        assertEquals(address.getHostName(), hostname.getValue());
+    }
 
-        assertEquals(String.valueOf(localAddress.id()),
-            NetconfServerSessionNegotiator.getHostName(localAddress).getValue());
+    @Test
+    void testPortTwenty() {
+        final var address = new InetSocketAddress("TestPortInet", 20);
+        final var hostname = NetconfServerSessionNegotiator.getHostName(address);
+        assertEquals(address.getHostName(), hostname.getValue());
+        assertEquals(String.valueOf(address.getPort()), hostname.getKey());
+    }
 
-        SshdSocketAddress embeddedAddress = new SshdSocketAddress("TestSshdName", 10);
+    @Test
+    void testGetInetSocketAddress() {
+        final var address = new LocalAddress("TestPortLocal");
+        final var hostname = NetconfServerSessionNegotiator.getHostName(address);
+        assertEquals(String.valueOf(address.id()), hostname.getValue());
     }
 }