diff options
author | 2016-08-31 07:46:41 +0200 | |
---|---|---|
committer | 2016-08-31 11:10:32 +0000 | |
commit | aa3fb2c1271c948f9a3c5a4ab22ce146be13163e (patch) | |
tree | 81f358b3dd13f7e3f7c50d315bd6d6a415ce8ac8 /vpp-common/vpp-translate-utils/src/test | |
parent | cb9f4515611d3cbd72b73c5a0d6521187c3d488a (diff) |
HONEYCOMB-75 - Lisp implemetation
Rebased on final minimal distro
Change-Id: Ib71fc59e62dda4633f4f79c5c7417a4aaf02a177
Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Signed-off-by: Florin Coras <fcoras@cisco.com>
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'vpp-common/vpp-translate-utils/src/test')
-rw-r--r-- | vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/TranslateUtilsTest.java | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/TranslateUtilsTest.java b/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/TranslateUtilsTest.java index d9cb52f3a..a55c3053a 100644 --- a/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/TranslateUtilsTest.java +++ b/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/TranslateUtilsTest.java @@ -15,6 +15,9 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.junit.Test; 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.Ipv6AddressNoZone; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix; import org.opendaylight.yangtools.yang.binding.DataContainer; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @@ -134,4 +137,62 @@ public class TranslateUtilsTest { TranslateUtils.byteToBoolean((byte) 123); } + @Test + public void testIpv6NoZone(){ + final Ipv6AddressNoZone ipv6Addr = new Ipv6AddressNoZone("3ffe:1900:4545:3:200:f8ff:fe21:67cf"); + byte[] bytes = TranslateUtils.ipv6AddressNoZoneToArray(ipv6Addr); + assertEquals((byte)63,bytes[0]); + + bytes = reverseBytes(bytes); + final Ipv6AddressNoZone ivp6AddressNoZone = TranslateUtils.arrayToIpv6AddressNoZone(bytes); + assertEquals(ipv6Addr,ivp6AddressNoZone); + } + + @Test + public void testByteArrayToMacUnseparated(){ + byte[] address = TranslateUtils.parseMac("aa:bb:cc:dd:ee:ff"); + + String converted = TranslateUtils.byteArrayToMacUnseparated(address); + + assertEquals("aabbccddeeff",converted); + } + + @Test + public void testByteArrayToMacSeparated(){ + byte[] address = TranslateUtils.parseMac("aa:bb:cc:dd:ee:ff"); + + String converted = TranslateUtils.byteArrayToMacSeparated(address); + + assertEquals("aa:bb:cc:dd:ee:ff",converted); + } + + @Test(expected = IllegalArgumentException.class) + public void testByteArrayToMacUnseparatedIllegal(){ + TranslateUtils.byteArrayToMacUnseparated(new byte[]{54,26,87,32,14}); + } + + @Test(expected = IllegalArgumentException.class) + public void testByteArrayToMacSeparatedIllegal() { + TranslateUtils.byteArrayToMacSeparated(new byte[]{54, 26, 87, 32, 14}); + } + + @Test + public void testIpv4AddressPrefixToArray() { + byte[] ip = TranslateUtils.ipv4AddressPrefixToArray(new Ipv4Prefix("192.168.2.1/24")); + + assertEquals("1.2.168.192", TranslateUtils.arrayToIpv4AddressNoZone(ip).getValue()); + } + + @Test + public void testIpv6AddressPrefixToArray() { + byte[] ip = TranslateUtils.ipv6AddressPrefixToArray(new Ipv6Prefix("3ffe:1900:4545:3:200:f8ff:fe21:67cf/48")); + + assertEquals("cf67:21fe:fff8:2:300:4545:19:fe3f", TranslateUtils.arrayToIpv6AddressNoZone(ip).getValue()); + } + + @Test + public void testExtractPrefix() { + assertEquals(24, TranslateUtils.extractPrefix(new Ipv4Prefix("192.168.2.1/24"))); + assertEquals(48, TranslateUtils.extractPrefix(new Ipv6Prefix("3ffe:1900:4545:3:200:f8ff:fe21:67cf/48"))); + } }
\ No newline at end of file |