Add DottedQuad/int interface
[mdsal.git] / model / ietf / ietf-type-util / src / test / java / org / opendaylight / mdsal / model / ietf / util / Ipv6UtilsTest.java
index 7828fbeb93476c5224f352aaf64095ad55e964a5..75f1ab63594ebad03d47abdf33560e19b1af1f67 100644 (file)
@@ -5,14 +5,17 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
+
 package org.opendaylight.mdsal.model.ietf.util;
 
 import static com.google.common.net.InetAddresses.forString;
 import static org.junit.Assert.assertArrayEquals;
-import static org.opendaylight.mdsal.model.ietf.util.Ipv6Utils.bytesForString;
+import static org.opendaylight.mdsal.model.ietf.util.Ipv6Utils.fillIpv6Bytes;
+
 import org.junit.Test;
 
 public class Ipv6UtilsTest {
+
     @Test
     public void testDiscards() {
         assertEqualResult("2001:0000:3238:DFE1:63:0000:0000:FEFB");
@@ -22,19 +25,11 @@ public class Ipv6UtilsTest {
         assertEqualResult("::");
     }
 
-    /**
-     * @author Anton Ivanov aivanov@brocade.com
-     */
     @Test
     public void testFullQuads() {
         assertEqualResult("0000:0000:0000:0000:0000:0000:0000:0001");
     }
 
-    @Test
-    public void testZoneIndex() {
-        assertArrayEquals(forString("::1").getAddress(), bytesForString("::1%2"));
-    }
-
     @Test
     public void testRfc4291() {
         assertEqualResult("ABCD:EF01:2345:6789:ABCD:EF01:2345:6789");
@@ -51,8 +46,9 @@ public class Ipv6UtilsTest {
         assertArrayEquals(test1, bytesForString("0:0:0:0:0:0:13.1.68.3"));
         assertArrayEquals(test1, bytesForString("::13.1.68.3"));
 
-        final byte[] test2 = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (byte)255, (byte)255,
-                (byte)129, (byte)144, 52, 38 };
+        final byte[] test2 = new byte[] {
+            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (byte)255, (byte)255, (byte)129, (byte)144, 52, 38
+        };
         assertArrayEquals(test2, bytesForString("0:0:0:0:0:FFFF:129.144.52.38"));
         assertArrayEquals(test2, bytesForString("::FFFF:129.144.52.38"));
     }
@@ -105,6 +101,12 @@ public class Ipv6UtilsTest {
         assertEqualResult("64:ff9b::192.0.2.33");
     }
 
+    private static byte[] bytesForString(final String str) {
+        final byte[] bytes = new byte[16];
+        fillIpv6Bytes(bytes, str, str.length());
+        return bytes;
+    }
+
     // Utility for quick comparison with Guava
     private static void assertEqualResult(final String str) {
         assertArrayEquals(forString(str).getAddress(), bytesForString(str));