Used onlab.packet.Ethernet:VOL-391

Change-Id: Ifadb1c6bb4451a0834664fe181d7fa2deac80c60
diff --git a/src/test/java/org/opencord/dhcpl2relay/DhcpL2RelayTest.java b/src/test/java/org/opencord/dhcpl2relay/DhcpL2RelayTest.java
index e6f97a8..66c9b4e 100755
--- a/src/test/java/org/opencord/dhcpl2relay/DhcpL2RelayTest.java
+++ b/src/test/java/org/opencord/dhcpl2relay/DhcpL2RelayTest.java
@@ -15,61 +15,55 @@
  */
 package org.opencord.dhcpl2relay;
 
-import org.easymock.EasyMock;
-
-import com.google.common.collect.Lists;
 import com.google.common.collect.ImmutableSet;
-
+import com.google.common.collect.Lists;
+import org.easymock.EasyMock;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-
 import org.onlab.osgi.ComponentContextAdapter;
 import org.onlab.packet.ChassisId;
 import org.onlab.packet.DHCP;
 import org.onlab.packet.DHCPOption;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.Ip4Address;
+import org.onlab.packet.Ethernet;
 import org.onlab.packet.IPv4;
+import org.onlab.packet.Ip4Address;
+import org.onlab.packet.IpAddress;
 import org.onlab.packet.MacAddress;
 import org.onlab.packet.UDP;
 import org.onlab.packet.VlanId;
-
-import org.onosproject.mastership.MastershipServiceAdapter;
-import org.onosproject.net.Annotations;
-import org.onosproject.net.AnnotationKeys;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.PortNumber;
 import org.onosproject.cfg.ComponentConfigService;
 import org.onosproject.core.CoreServiceAdapter;
-import org.onosproject.net.config.Config;
-import org.onosproject.net.config.NetworkConfigRegistryAdapter;
+import org.onosproject.mastership.MastershipServiceAdapter;
+import org.onosproject.net.AnnotationKeys;
+import org.onosproject.net.Annotations;
 import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.device.DeviceServiceAdapter;
+import org.onosproject.net.DefaultAnnotations;
 import org.onosproject.net.DefaultDevice;
 import org.onosproject.net.DefaultHost;
 import org.onosproject.net.Device;
+import org.onosproject.net.DeviceId;
 import org.onosproject.net.Element;
-import org.onosproject.net.host.HostServiceAdapter;
 import org.onosproject.net.Host;
 import org.onosproject.net.HostId;
 import org.onosproject.net.HostLocation;
-import org.onosproject.net.provider.ProviderId;
 import org.onosproject.net.Port;
-
-import org.opencord.dhcpl2relay.packet.DhcpEthernet;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.config.Config;
+import org.onosproject.net.config.NetworkConfigRegistryAdapter;
+import org.onosproject.net.device.DeviceServiceAdapter;
+import org.onosproject.net.host.HostServiceAdapter;
+import org.onosproject.net.provider.ProviderId;
 import org.opencord.dhcpl2relay.packet.DhcpOption82;
 import org.opencord.sadis.SubscriberAndDeviceInformation;
 import org.opencord.sadis.SubscriberAndDeviceInformationService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.nio.ByteBuffer;
 import java.util.List;
 import java.util.Set;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import static org.junit.Assert.assertEquals;
 
 public class DhcpL2RelayTest extends DhcpL2RelayTestBase {
@@ -132,11 +126,11 @@
     public void testDhcpDiscover()  throws Exception {
         //  (1) Sending DHCP discover packet
         System.out.println("Sending pakcet");
-        DhcpEthernet discoverPacket = constructDhcpDiscoverPacket(CLIENT_MAC);
+        Ethernet discoverPacket = constructDhcpDiscoverPacket(CLIENT_MAC);
 
         sendPacket(discoverPacket, ConnectPoint.deviceConnectPoint(OLT_DEV_ID + "/" + 1));
 
-        DhcpEthernet discoverRelayed = (DhcpEthernet) getPacket();
+        Ethernet discoverRelayed = (Ethernet) getPacket();
         compareClientPackets(discoverPacket, discoverRelayed);
     }
 
@@ -149,11 +143,11 @@
     public void testDhcpRequest()  throws Exception {
         //  (1) Sending DHCP discover packet
         System.out.println("Sending pakcet");
-        DhcpEthernet requestPacket = constructDhcpRequestPacket(CLIENT_MAC);
+        Ethernet requestPacket = constructDhcpRequestPacket(CLIENT_MAC);
 
         sendPacket(requestPacket, ConnectPoint.deviceConnectPoint(OLT_DEV_ID + "/" + 1));
 
-        DhcpEthernet requestRelayed = (DhcpEthernet) getPacket();
+        Ethernet requestRelayed = (Ethernet) getPacket();
         compareClientPackets(requestPacket, requestRelayed);
     }
 
@@ -166,12 +160,12 @@
     public void testDhcpOffer() {
         //  (1) Sending DHCP discover packet
         System.out.println("Sending pakcet");
-        DhcpEthernet offerPacket = constructDhcpOfferPacket(MacAddress.valueOf("bb:bb:bb:bb:bb:bb"),
+        Ethernet offerPacket = constructDhcpOfferPacket(MacAddress.valueOf("bb:bb:bb:bb:bb:bb"),
                 CLIENT_MAC, "1.1.1.1", "2.2.2.2");
 
         sendPacket(offerPacket, ConnectPoint.deviceConnectPoint(OLT_DEV_ID + "/" + 1));
 
-        DhcpEthernet offerRelayed = (DhcpEthernet) getPacket();
+        Ethernet offerRelayed = (Ethernet) getPacket();
         compareServerPackets(offerPacket, offerRelayed);
     }
 
@@ -183,18 +177,18 @@
     @Test
     public void testDhcpAck() {
 
-        DhcpEthernet ackPacket = constructDhcpAckPacket(MacAddress.valueOf("bb:bb:bb:bb:bb:bb"),
+        Ethernet ackPacket = constructDhcpAckPacket(MacAddress.valueOf("bb:bb:bb:bb:bb:bb"),
                 CLIENT_MAC, "1.1.1.1", "2.2.2.2");
 
         sendPacket(ackPacket, ConnectPoint.deviceConnectPoint(OLT_DEV_ID + "/" + 1));
 
-        DhcpEthernet ackRelayed = (DhcpEthernet) getPacket();
+        Ethernet ackRelayed = (Ethernet) getPacket();
         compareServerPackets(ackPacket, ackRelayed);
     }
 
-    public void compareClientPackets(DhcpEthernet sent, DhcpEthernet relayed) {
-        sent.setSourceMacAddress(OLT_MAC_ADDRESS);
-        sent.setQinQVid(CLIENT_S_TAG.toShort());
+    public void compareClientPackets(Ethernet sent, Ethernet relayed) {
+        sent.setSourceMACAddress(OLT_MAC_ADDRESS);
+        sent.setQinQVID(CLIENT_S_TAG.toShort());
         sent.setVlanID(CLIENT_C_TAG.toShort());
 
         IPv4 ipv4Packet = (IPv4) sent.getPayload();
@@ -212,27 +206,19 @@
 
         options.add(options.size() - 1, option);
         dhcpPacket.setOptions(options);
-
-        final ByteBuffer byteBuffer = ByteBuffer.wrap(sent.serialize());
-        DhcpEthernet expectedPacket = null;
-        try {
-            expectedPacket = DhcpEthernet.deserializer().deserialize(byteBuffer.array(),
-                    0, byteBuffer.array().length);
-        } catch (Exception e) {
-        }
-        assertEquals(expectedPacket, relayed);
+        assertEquals(sent, relayed);
 
     }
 
-    public void compareServerPackets(DhcpEthernet sent, DhcpEthernet relayed) {
-        sent.setDestinationMacAddress(CLIENT_MAC);
-        sent.setQinQVid(CLIENT_S_TAG.toShort());
+    public void compareServerPackets(Ethernet sent, Ethernet relayed) {
+        sent.setDestinationMACAddress(CLIENT_MAC);
+        sent.setQinQVID(CLIENT_S_TAG.toShort());
         sent.setVlanID(CLIENT_C_TAG.toShort());
 
         final ByteBuffer byteBuffer = ByteBuffer.wrap(sent.serialize());
-        DhcpEthernet expectedPacket = null;
+        Ethernet expectedPacket = null;
         try {
-            expectedPacket = DhcpEthernet.deserializer().deserialize(byteBuffer.array(),
+            expectedPacket = Ethernet.deserializer().deserialize(byteBuffer.array(),
                     0, byteBuffer.array().length);
         } catch (Exception e) {
         }
diff --git a/src/test/java/org/opencord/dhcpl2relay/DhcpL2RelayTestBase.java b/src/test/java/org/opencord/dhcpl2relay/DhcpL2RelayTestBase.java
index a80c0f8..540a691 100755
--- a/src/test/java/org/opencord/dhcpl2relay/DhcpL2RelayTestBase.java
+++ b/src/test/java/org/opencord/dhcpl2relay/DhcpL2RelayTestBase.java
@@ -34,7 +34,6 @@
 import org.onosproject.net.packet.PacketProcessor;
 import org.onosproject.net.packet.PacketServiceAdapter;
 
-import org.opencord.dhcpl2relay.packet.DhcpEthernet;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -89,7 +88,7 @@
         @Override
         public void emit(OutboundPacket packet) {
             try {
-                DhcpEthernet eth = DhcpEthernet.deserializer().deserialize(packet.data().array(),
+                Ethernet eth = Ethernet.deserializer().deserialize(packet.data().array(),
                         0, packet.data().array().length);
                 savePacket(eth);
             } catch (Exception e) {
@@ -119,9 +118,9 @@
      *
      * @param pkt Ethernet packet
      */
-    void sendPacket(DhcpEthernet pkt, ConnectPoint cp) {
+    void sendPacket(Ethernet pkt, ConnectPoint cp) {
         final ByteBuffer byteBuffer = ByteBuffer.wrap(pkt.serialize());
-        InboundPacket inPacket = new DefaultInboundPacket(cp, null, byteBuffer);
+        InboundPacket inPacket = new DefaultInboundPacket(cp, pkt, byteBuffer);
 
         PacketContext context = new TestPacketContext(127L, inPacket, null, false);
         packetProcessor.process(context);
@@ -132,14 +131,14 @@
      *
      * @return Ethernet packet
      */
-    private DhcpEthernet construcEthernetPacket(MacAddress srcMac, MacAddress dstMac,
+    private Ethernet construcEthernetPacket(MacAddress srcMac, MacAddress dstMac,
                                                 String dstIp, byte dhcpReqRsp,
                                                 MacAddress clientHwAddress,
                                                 Ip4Address dhcpClientIpAddress) {
         // Ethernet Frame.
-        DhcpEthernet ethPkt = new DhcpEthernet();
-        ethPkt.setSourceMacAddress(srcMac);
-        ethPkt.setDestinationMacAddress(dstMac);
+        Ethernet ethPkt = new Ethernet();
+        ethPkt.setSourceMACAddress(srcMac);
+        ethPkt.setDestinationMACAddress(dstMac);
         ethPkt.setEtherType(Ethernet.TYPE_IPV4);
         ethPkt.setVlanID((short) 2);
         ethPkt.setPriorityCode((byte) 6);
@@ -188,9 +187,9 @@
      *
      * @return Ethernet packet
      */
-    DhcpEthernet constructDhcpDiscoverPacket(MacAddress clientMac) {
+    Ethernet constructDhcpDiscoverPacket(MacAddress clientMac) {
 
-        DhcpEthernet pkt = construcEthernetPacket(clientMac, MacAddress.BROADCAST,
+        Ethernet pkt = construcEthernetPacket(clientMac, MacAddress.BROADCAST,
                 "255.255.255.255", DHCP.OPCODE_REQUEST, MacAddress.NONE,
                 Ip4Address.valueOf("0.0.0.0"));
 
@@ -208,9 +207,9 @@
      *
      * @return Ethernet packet
      */
-    DhcpEthernet constructDhcpRequestPacket(MacAddress clientMac) {
+    Ethernet constructDhcpRequestPacket(MacAddress clientMac) {
 
-        DhcpEthernet pkt = construcEthernetPacket(clientMac, MacAddress.BROADCAST,
+        Ethernet pkt = construcEthernetPacket(clientMac, MacAddress.BROADCAST,
                 "255.255.255.255", DHCP.OPCODE_REQUEST, MacAddress.NONE,
                 Ip4Address.valueOf("0.0.0.0"));
 
@@ -228,10 +227,10 @@
      *
      * @return Ethernet packet
      */
-    DhcpEthernet constructDhcpOfferPacket(MacAddress servMac, MacAddress clientMac,
+    Ethernet constructDhcpOfferPacket(MacAddress servMac, MacAddress clientMac,
                                            String ipAddress, String dhcpClientIpAddress) {
 
-        DhcpEthernet pkt = construcEthernetPacket(servMac, clientMac, ipAddress, DHCP.OPCODE_REPLY,
+        Ethernet pkt = construcEthernetPacket(servMac, clientMac, ipAddress, DHCP.OPCODE_REPLY,
                 clientMac, Ip4Address.valueOf(dhcpClientIpAddress));
 
         IPv4 ipv4Packet = (IPv4) pkt.getPayload();
@@ -248,10 +247,10 @@
      *
      * @return Ethernet packet
      */
-    DhcpEthernet constructDhcpAckPacket(MacAddress servMac, MacAddress clientMac,
+    Ethernet constructDhcpAckPacket(MacAddress servMac, MacAddress clientMac,
                                            String ipAddress, String dhcpClientIpAddress) {
 
-        DhcpEthernet pkt = construcEthernetPacket(servMac, clientMac, ipAddress, DHCP.OPCODE_REPLY,
+        Ethernet pkt = construcEthernetPacket(servMac, clientMac, ipAddress, DHCP.OPCODE_REPLY,
                 clientMac, Ip4Address.valueOf(dhcpClientIpAddress));
 
         IPv4 ipv4Packet = (IPv4) pkt.getPayload();