diff options
Diffstat (limited to 'vpp-common/vpp-translate-utils/src/test/java/io')
2 files changed, 22 insertions, 0 deletions
diff --git a/vpp-common/vpp-translate-utils/src/test/java/io/fd/hc2vpp/common/translate/util/AddressTranslatorTest.java b/vpp-common/vpp-translate-utils/src/test/java/io/fd/hc2vpp/common/translate/util/AddressTranslatorTest.java index ba850af89..89f89f8a5 100644 --- a/vpp-common/vpp-translate-utils/src/test/java/io/fd/hc2vpp/common/translate/util/AddressTranslatorTest.java +++ b/vpp-common/vpp-translate-utils/src/test/java/io/fd/hc2vpp/common/translate/util/AddressTranslatorTest.java @@ -20,18 +20,23 @@ import java.util.Arrays; import org.junit.Assert; import org.junit.Test; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix; public class AddressTranslatorTest { private final static IpAddress IPV6_ADDR = new IpAddress(new Ipv6Address("a::")); + private final static IpAddressNoZone IPV6_ADDR_NO_ZONE = new IpAddressNoZone(new Ipv6AddressNoZone("a::")); private final static IpPrefix IPV6_PREFIX = new IpPrefix(new Ipv6Prefix("a::/48")); private final static byte IPV6_BYTE_PREFIX = 48; private final static IpAddress IPV4_ADDR = new IpAddress(new Ipv4Address("10.0.0.1")); + private final static IpAddressNoZone IPV4_ADDR_NO_ZONE = new IpAddressNoZone(new Ipv4AddressNoZone("10.0.0.1")); private final static IpPrefix IPV4_PREFIX = new IpPrefix(new Ipv4Prefix("10.0.0.1/24")); private final static byte IPV4_BYTE_PREFIX = 24; private static final byte[] IPV6_BYTE_ARRAY = @@ -49,6 +54,12 @@ public class AddressTranslatorTest { } @Test + public void ipAddressNoZoneToArrayTest() { + Assert.assertTrue(Arrays.equals(IPV6_BYTE_ARRAY, ADDR_TRANSLATOR.ipAddressToArray(IPV6_ADDR_NO_ZONE))); + Assert.assertTrue(Arrays.equals(IPV4_BYTE_ARRAY, ADDR_TRANSLATOR.ipAddressToArray(IPV4_ADDR_NO_ZONE))); + } + + @Test public void arrayToIpAddressTest() { Assert.assertTrue( ADDR_TRANSLATOR.addressesEqual(IPV6_ADDR, ADDR_TRANSLATOR.arrayToIpAddress(true, IPV6_BYTE_ARRAY))); diff --git a/vpp-common/vpp-translate-utils/src/test/java/io/fd/hc2vpp/common/translate/util/Ipv6TranslatorTest.java b/vpp-common/vpp-translate-utils/src/test/java/io/fd/hc2vpp/common/translate/util/Ipv6TranslatorTest.java index 3ed7433ea..57d7a657f 100644 --- a/vpp-common/vpp-translate-utils/src/test/java/io/fd/hc2vpp/common/translate/util/Ipv6TranslatorTest.java +++ b/vpp-common/vpp-translate-utils/src/test/java/io/fd/hc2vpp/common/translate/util/Ipv6TranslatorTest.java @@ -22,6 +22,7 @@ import static org.junit.Assert.assertTrue; import org.junit.Test; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix; @@ -95,6 +96,16 @@ public class Ipv6TranslatorTest implements Ipv6Translator { } @Test + public void testIsIpv6NoZoneCompressed() throws Exception { + assertTrue(isIpv6(new IpAddressNoZone(new Ipv6AddressNoZone(IPV6_COMPRESSED)))); + } + + @Test + public void testIsIpv6NoZoneFull() throws Exception { + assertTrue(isIpv6(new IpAddressNoZone(new Ipv6AddressNoZone(IPV6_FULL)))); + } + + @Test public void testTruncateIp4Array() throws Exception { assertArrayEquals(new byte[]{-64, -84, 2, 1}, truncateIp4Array(new byte[]{-64, -84, 2, 1, 0, 0, 0, 0})); } |