X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fsal%2Fapi%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Futils%2FNetUtilsTest.java;h=e16612759caebe9083efb17d38495b4a462de662;hb=541d0a36997f292bb037a2199463431eee538358;hp=77d1fe216413d38477eaffabdc5f8f1dea9bfea4;hpb=42210c03b0a4c54706320ba9f55794c0abd4d201;p=controller.git diff --git a/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/utils/NetUtilsTest.java b/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/utils/NetUtilsTest.java index 77d1fe2164..e16612759c 100644 --- a/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/utils/NetUtilsTest.java +++ b/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/utils/NetUtilsTest.java @@ -15,7 +15,6 @@ import java.util.Arrays; import org.junit.Assert; import org.junit.Test; -import org.opendaylight.controller.sal.utils.NetUtils; public class NetUtilsTest { @@ -274,4 +273,49 @@ public class NetUtilsTest { .isIPv6AddressValid("fe80:::0:0:0:204:61ff:fe9d/-1")); //not valid both } + + @Test + public void testInetAddressConflict() throws UnknownHostException { + + // test a ipv4 testAddress in the same subnet as the filter + // the method should return false as there is no conflict + Assert.assertFalse(NetUtils.inetAddressConflict( + InetAddress.getByName("9.9.1.1"), + InetAddress.getByName("9.9.1.0"), null, + InetAddress.getByName("255.255.255.0"))); + + // test a ipv4 testAddress not in the same subnet as the filter + // the method should return true as there is a conflict + Assert.assertTrue(NetUtils.inetAddressConflict( + InetAddress.getByName("9.9.2.1"), + InetAddress.getByName("9.9.1.0"), null, + InetAddress.getByName("255.255.255.0"))); + + // test a ipv4 testAddress more generic than the filter + // the method should return true as there is a conflict + Assert.assertTrue(NetUtils.inetAddressConflict( + InetAddress.getByName("9.9.1.1"), + InetAddress.getByName("9.9.1.0"), + InetAddress.getByName("255.255.0.0"), + InetAddress.getByName("255.255.255.0"))); + + // test a ipv4 testAddress less generic than the filter and in the same + // subnet as the filter + // the method should return false as there is no conflict + Assert.assertFalse(NetUtils.inetAddressConflict( + InetAddress.getByName("9.9.1.0"), + InetAddress.getByName("9.9.0.0"), + InetAddress.getByName("255.255.255.0"), + InetAddress.getByName("255.255.0.0"))); + + // test a ipv4 testAddress less generic than the filter and not in the + // same subnet as the filter + // the method should return true as there is a conflict + Assert.assertTrue(NetUtils.inetAddressConflict( + InetAddress.getByName("9.8.1.0"), + InetAddress.getByName("9.9.0.0"), + InetAddress.getByName("255.255.255.0"), + InetAddress.getByName("255.255.0.0"))); + + } }