From: Robert Varga Date: Sat, 27 Jan 2024 21:25:01 +0000 (+0100) Subject: Clean up NetconfServerSessionNegotiatorTest X-Git-Tag: v7.0.0~90 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=b7c6e76ca1d43b22200fff61480147b10075dbdc;p=netconf.git Clean up NetconfServerSessionNegotiatorTest 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 --- diff --git a/protocol/netconf-server/pom.xml b/protocol/netconf-server/pom.xml index e4dc129535..561f1a460e 100644 --- a/protocol/netconf-server/pom.xml +++ b/protocol/netconf-server/pom.xml @@ -140,11 +140,6 @@ org.opendaylight.netconf netconf-test-util - - org.opendaylight.netconf - shaded-sshd - test - org.xmlunit xmlunit-core diff --git a/protocol/netconf-server/src/test/java/org/opendaylight/netconf/server/NetconfServerSessionNegotiatorTest.java b/protocol/netconf-server/src/test/java/org/opendaylight/netconf/server/NetconfServerSessionNegotiatorTest.java index 3fbf785d77..d9f72c4896 100644 --- a/protocol/netconf-server/src/test/java/org/opendaylight/netconf/server/NetconfServerSessionNegotiatorTest.java +++ b/protocol/netconf-server/src/test/java/org/opendaylight/netconf/server/NetconfServerSessionNegotiatorTest.java @@ -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()); } }