summaryrefslogtreecommitdiffstats
path: root/vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb
diff options
context:
space:
mode:
authorJan Srnicek <jsrnicek@cisco.com>2016-08-31 07:46:41 +0200
committerMaros Marsalek <mmarsale@cisco.com>2016-08-31 11:10:32 +0000
commit34f77c9cfc6ebfa265866b654990ae9ca55cc451 (patch)
treec762f55df811360162e831be7f2b8b5d1c563346 /vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb
parente36f307df4125f16484fff7a656e3302b831f311 (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/java/io/fd/honeycomb')
-rw-r--r--vpp-common/vpp-translate-utils/src/test/java/io/fd/honeycomb/translate/v3po/util/TranslateUtilsTest.java61
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