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/core/net/src/test/java/org/onosproject/net/host/impl/HostMonitorTest.java b/core/net/src/test/java/org/onosproject/net/host/impl/HostMonitorTest.java
index 679a888..90cf6b4 100644
--- a/core/net/src/test/java/org/onosproject/net/host/impl/HostMonitorTest.java
+++ b/core/net/src/test/java/org/onosproject/net/host/impl/HostMonitorTest.java
@@ -49,8 +49,14 @@
 import java.util.List;
 import java.util.Set;
 
-import static org.easymock.EasyMock.*;
-import static org.junit.Assert.*;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 public class HostMonitorTest {
 
@@ -151,10 +157,9 @@
         assertEquals(portNum, oi.port());
 
         // Check the output packet is correct (well the important bits anyway)
-        Ethernet eth = new Ethernet();
         final byte[] pktData = new byte[packet.data().remaining()];
         packet.data().get(pktData);
-        eth.deserialize(pktData, 0, pktData.length);
+        Ethernet eth = Ethernet.deserializer().deserialize(pktData, 0, pktData.length);
         assertEquals(Ethernet.VLAN_UNTAGGED, eth.getVlanID());
         ARP arp = (ARP) eth.getPayload();
         assertArrayEquals(SOURCE_ADDR.toOctets(),
@@ -220,10 +225,9 @@
         assertEquals(portNum, oi.port());
 
         // Check the output packet is correct (well the important bits anyway)
-        Ethernet eth = new Ethernet();
         final byte[] pktData = new byte[packet.data().remaining()];
         packet.data().get(pktData);
-        eth.deserialize(pktData, 0, pktData.length);
+        Ethernet eth = Ethernet.deserializer().deserialize(pktData, 0, pktData.length);
         assertEquals(vlan, eth.getVlanID());
         ARP arp = (ARP) eth.getPayload();
         assertArrayEquals(SOURCE_ADDR.toOctets(),