Improve the resiliency of the packet deserialization code.

Packet deserializers now check for malformed input while reading the byte
stream. Deserializers are re-implemented as functions that take a byte array
and return a packet object. The old IPacket.deserialize(...) methods have been
deprecated with the goal of eventually moving to immutable packet objects.
Unit tests have been implemented for all Deserializer functions.

ONOS-1589

Change-Id: I9073d5e6e7991e15d43830cfd810989256b71c56
diff --git a/utils/misc/src/test/java/org/onlab/packet/ipv6/AuthenticationTest.java b/utils/misc/src/test/java/org/onlab/packet/ipv6/AuthenticationTest.java
index a6edc5d..39ab910 100644
--- a/utils/misc/src/test/java/org/onlab/packet/ipv6/AuthenticationTest.java
+++ b/utils/misc/src/test/java/org/onlab/packet/ipv6/AuthenticationTest.java
@@ -16,9 +16,11 @@
 
 package org.onlab.packet.ipv6;
 
+import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.onlab.packet.Data;
+import org.onlab.packet.Deserializer;
 import org.onlab.packet.UDP;
 
 import static org.hamcrest.Matchers.is;
@@ -38,6 +40,8 @@
     };
     private static byte[] bytePacket;
 
+    private Deserializer<Authentication> deserializer;
+
     @BeforeClass
     public static void setUpBeforeClass() throws Exception {
         data = new Data();
@@ -57,6 +61,11 @@
         System.arraycopy(bytePayload, 0, bytePacket, byteHeader.length, bytePayload.length);
     }
 
+    @Before
+    public void setUp() {
+        deserializer = Authentication.deserializer();
+    }
+
     /**
      * Tests serialize and setters.
      */
@@ -77,9 +86,8 @@
      * Tests deserialize and getters.
      */
     @Test
-    public void testDeserialize() {
-        Authentication auth = new Authentication();
-        auth.deserialize(bytePacket, 0, bytePacket.length);
+    public void testDeserialize() throws Exception {
+        Authentication auth = deserializer.deserialize(bytePacket, 0, bytePacket.length);
 
         assertThat(auth.getNextHeader(), is((byte) 0x11));
         assertThat(auth.getPayloadLength(), is((byte) 0x02));