diff options
author | 2018-07-03 13:34:17 +0200 | |
---|---|---|
committer | 2018-07-03 13:34:17 +0200 | |
commit | 85cc9659e42eb637d25a0a456353149b63fcac93 (patch) | |
tree | b096327c9370dd9158e901f25ac336f30240b1bc /vpp-common/vpp-translate-utils/src/test/java/io | |
parent | 7ec72df18c9fad8165b35ecf2b66ae1e9c344df4 (diff) |
HC2VPP-79: provide AddressTranslator.ipAddressToArray for IpAddressNoZone
Change-Id: I637842ea6a582676ab305c29b5d8464987537be0
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
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})); } |