ONOS-2739 - OSPF Basic Packet Structures , which includes encoding and decoding

Change-Id: I3f09176ad4ccc330b8989f13b12f74dc86f53ae4
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/subtypes/OspfExternalDestinationTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/subtypes/OspfExternalDestinationTest.java
new file mode 100644
index 0000000..947f34a
--- /dev/null
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/subtypes/OspfExternalDestinationTest.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.ospf.protocol.lsa.subtypes;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.Ip4Address;
+
+import java.net.InetAddress;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+
+/**
+ * Unit test class for OspfRouterId.
+ */
+public class OspfExternalDestinationTest {
+
+    private OspfExternalDestination ospfExternalDestination;
+
+    @Before
+    public void setUp() throws Exception {
+        ospfExternalDestination = new OspfExternalDestination();
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        ospfExternalDestination = null;
+    }
+
+    /**
+     * Tests isType1orType2Metric() getter method.
+     */
+    @Test
+    public void testIsType1orType2Metric() throws Exception {
+        ospfExternalDestination.setType1orType2Metric(true);
+        assertThat(ospfExternalDestination.isType1orType2Metric(), is(true));
+    }
+
+    /**
+     * Tests isType1orType2Metric() setter method.
+     */
+    @Test
+    public void testSetType1orType2Metric() throws Exception {
+        ospfExternalDestination.setType1orType2Metric(true);
+        assertThat(ospfExternalDestination.isType1orType2Metric(), is(true));
+    }
+
+    /**
+     * Tests metric() getter method.
+     */
+    @Test
+    public void testGetMetric() throws Exception {
+        ospfExternalDestination.setMetric(100);
+        assertThat(ospfExternalDestination.metric(), is(100));
+    }
+
+    /**
+     * Tests metric() setter method.
+     */
+    @Test
+    public void testSetMetric() throws Exception {
+        ospfExternalDestination.setMetric(100);
+        assertThat(ospfExternalDestination.metric(), is(100));
+    }
+
+    /**
+     * Tests forwardingAddress() getter method.
+     */
+    @Test
+    public void testGetForwardingAddress() throws Exception {
+        ospfExternalDestination.setForwardingAddress(Ip4Address.valueOf(InetAddress.getLocalHost()));
+        assertThat(ospfExternalDestination.forwardingAddress(), is(Ip4Address.valueOf(InetAddress.getLocalHost())));
+
+    }
+
+    /**
+     * Tests forwardingAddress() setter method.
+     */
+    @Test
+    public void testSetForwardingAddress() throws Exception {
+        ospfExternalDestination.setForwardingAddress(Ip4Address.valueOf(InetAddress.getLocalHost()));
+        assertThat(ospfExternalDestination.forwardingAddress(), is(Ip4Address.valueOf(InetAddress.getLocalHost())));
+    }
+
+    /**
+     * Tests externalRouterTag() getter method.
+     */
+    @Test
+    public void testGetExternalRouterTag() throws Exception {
+        ospfExternalDestination.setExternalRouterTag(100);
+        assertThat(ospfExternalDestination.externalRouterTag(), is(100));
+    }
+
+    /**
+     * Tests externalRouterTag() setter method.
+     */
+    @Test
+    public void testSetExternalRouterTag() throws Exception {
+        ospfExternalDestination.setExternalRouterTag(100);
+        assertThat(ospfExternalDestination.externalRouterTag(), is(100));
+    }
+
+    /**
+     * Tests to string method.
+     */
+    @Test
+    public void testToString() throws Exception {
+        assertThat(ospfExternalDestination.toString(), is(notNullValue()));
+    }
+}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/subtypes/OspfLsaLinkTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/subtypes/OspfLsaLinkTest.java
new file mode 100644
index 0000000..0927e88
--- /dev/null
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/subtypes/OspfLsaLinkTest.java
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.ospf.protocol.lsa.subtypes;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+
+/**
+ * Unit test class for OspfLsaLink.
+ */
+public class OspfLsaLinkTest {
+
+    private OspfLsaLink ospfLsaLink;
+
+    @Before
+    public void setUp() throws Exception {
+        ospfLsaLink = new OspfLsaLink();
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        ospfLsaLink = null;
+    }
+
+    /**
+     * Tests linkId() getter method.
+     */
+    @Test
+    public void testGetLinkID() throws Exception {
+        ospfLsaLink.setLinkId("1.1.1.1");
+        assertThat(ospfLsaLink.linkId(), is("1.1.1.1"));
+    }
+
+    /**
+     * Tests linkId() setter method.
+     */
+    @Test
+    public void testSetLinkID() throws Exception {
+        ospfLsaLink.setLinkId("1.1.1.1");
+        assertThat(ospfLsaLink.linkId(), is("1.1.1.1"));
+    }
+
+    /**
+     * Tests linkData() getter method.
+     */
+    @Test
+    public void testGetLinkData() throws Exception {
+        ospfLsaLink.setLinkData("1.1.1.1");
+        assertThat(ospfLsaLink.linkData(), is("1.1.1.1"));
+    }
+
+    /**
+     * Tests linkData() setter method.
+     */
+    @Test
+    public void testSetLinkData() throws Exception {
+        ospfLsaLink.setLinkData("1.1.1.1");
+        assertThat(ospfLsaLink.linkData(), is("1.1.1.1"));
+    }
+
+    /**
+     * Tests linkType() getter method.
+     */
+    @Test
+    public void testGetLinkType() throws Exception {
+        ospfLsaLink.setLinkType(1);
+        assertThat(ospfLsaLink.linkType(), is(1));
+    }
+
+    /**
+     * Tests linkType() setter method.
+     */
+    @Test
+    public void testSetLinkType() throws Exception {
+        ospfLsaLink.setLinkType(1);
+        assertThat(ospfLsaLink.linkType(), is(1));
+    }
+
+    /**
+     * Tests metric() getter method.
+     */
+    @Test
+    public void testGetMetric() throws Exception {
+        ospfLsaLink.setMetric(100);
+        assertThat(ospfLsaLink.metric(), is(100));
+    }
+
+    /**
+     * Tests metric() setter method.
+     */
+    @Test
+    public void testSetMetric() throws Exception {
+        ospfLsaLink.setMetric(100);
+        assertThat(ospfLsaLink.metric(), is(100));
+    }
+
+    /**
+     * Tests tos() getter method.
+     */
+    @Test
+    public void testGetTos() throws Exception {
+        ospfLsaLink.setTos(100);
+        assertThat(ospfLsaLink.tos(), is(100));
+    }
+
+    /**
+     * Tests tos() setter method.
+     */
+    @Test
+    public void testSetTos() throws Exception {
+        ospfLsaLink.setTos(100);
+        assertThat(ospfLsaLink.tos(), is(100));
+    }
+
+    /**
+     * Tests to string method.
+     */
+    @Test
+    public void testToString() throws Exception {
+        assertThat(ospfLsaLink.toString(), is(notNullValue()));
+    }
+}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/AsbrSummaryLsaTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/AsbrSummaryLsaTest.java
new file mode 100644
index 0000000..13f97fd
--- /dev/null
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/AsbrSummaryLsaTest.java
@@ -0,0 +1,220 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.ospf.protocol.lsa.types;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.Ip4Address;
+import org.onosproject.ospf.controller.OspfLsaType;
+import org.onosproject.ospf.protocol.lsa.LsaHeader;
+
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+
+/**
+ * Unit test class for AsbrSummaryLsa.
+ */
+public class AsbrSummaryLsaTest {
+
+    private final Ip4Address ipAddress = Ip4Address.valueOf("10.226.165.164");
+    private AsbrSummaryLsa asbrSummaryLsa;
+    private Ip4Address result;
+    private int result1;
+    private int num;
+    private byte[] inputByteArray;
+    private byte[] result2;
+    private ChannelBuffer channelBuffer;
+    private LsaHeader lsaHeader;
+    private OspfLsaType ospflsaType;
+    private String result3;
+    private boolean result4;
+
+    @Before
+    public void setUp() throws Exception {
+        asbrSummaryLsa = new AsbrSummaryLsa(new LsaHeader());
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        asbrSummaryLsa = null;
+    }
+
+    /**
+     * Tests networkMask() getter method.
+     */
+    @Test
+    public void testGetNetworkMask() throws Exception {
+        asbrSummaryLsa.setNetworkMask(ipAddress);
+        result = asbrSummaryLsa.networkMask();
+        assertThat(result, is(notNullValue()));
+        assertThat(result, is(ipAddress));
+    }
+
+    /**
+     * Tests networkMask() setter method.
+     */
+    @Test
+    public void testSetNetworkMask() throws Exception {
+        asbrSummaryLsa.setNetworkMask(ipAddress);
+        result = asbrSummaryLsa.networkMask();
+        assertThat(result, is(notNullValue()));
+        assertThat(result, is(ipAddress));
+    }
+
+    /**
+     * Tests metric() getter method.
+     */
+    @Test
+    public void testGetMetric() throws Exception {
+        num = 10;
+        asbrSummaryLsa.setMetric(num);
+        result1 = asbrSummaryLsa.metric();
+        assertThat(result1, is(notNullValue()));
+        assertThat(result1, is(num));
+    }
+
+    /**
+     * Tests metric() setter method.
+     */
+    @Test
+    public void testSetMetric() throws Exception {
+        num = 20;
+        asbrSummaryLsa.setMetric(num);
+        result1 = asbrSummaryLsa.metric();
+        assertThat(result1, is(notNullValue()));
+        assertThat(result1, is(num));
+    }
+
+    /**
+     * Tests readFrom() method.
+     */
+    @Test
+    public void testReadFrom() throws Exception {
+        inputByteArray = createByteForNetworkLsa();
+        lsaHeader = createLsaHeader();
+        asbrSummaryLsa = new AsbrSummaryLsa(lsaHeader);
+        channelBuffer = ChannelBuffers.copiedBuffer(inputByteArray);
+        asbrSummaryLsa.readFrom(channelBuffer);
+        assertThat(asbrSummaryLsa, is(notNullValue()));
+    }
+
+    /**
+     * Tests readFrom() method.
+     */
+    @Test(expected = Exception.class)
+    public void testReadFrom1() throws Exception {
+        byte[] temp = {0, 1, 2, 3};
+        inputByteArray = temp;
+        lsaHeader = createLsaHeader();
+        asbrSummaryLsa = new AsbrSummaryLsa(lsaHeader);
+        channelBuffer = ChannelBuffers.copiedBuffer(inputByteArray);
+        asbrSummaryLsa.readFrom(channelBuffer);
+        assertThat(asbrSummaryLsa, is(notNullValue()));
+    }
+
+    /**
+     * Tests asBytes() method.
+     */
+    @Test(expected = Exception.class)
+    public void testAsBytes() throws Exception {
+        result2 = asbrSummaryLsa.asBytes();
+        assertThat(result2, is(notNullValue()));
+    }
+
+    /**
+     * Tests getLsaBodyAsByteArray() method.
+     */
+    @Test(expected = Exception.class)
+    public void testGetLsaBodyAsByteArray() throws Exception {
+        result2 = asbrSummaryLsa.getLsaBodyAsByteArray();
+        assertThat(result2, is(notNullValue()));
+    }
+
+    /**
+     * Tests ospfLsaType() getter method.
+     */
+    @Test
+    public void testGetOspfLsaType() throws Exception {
+
+        ospflsaType = asbrSummaryLsa.getOspfLsaType();
+        assertThat(ospflsaType, is(notNullValue()));
+        assertThat(ospflsaType, is(OspfLsaType.ASBR_SUMMARY));
+    }
+
+    /**
+     * Tests to string method.
+     */
+    @Test
+    public void testToString() throws Exception {
+
+        result3 = asbrSummaryLsa.toString();
+        assertThat(result3, is(notNullValue()));
+
+    }
+
+    /**
+     * Tests hashcode() method.
+     */
+    @Test
+    public void testHashcode() throws Exception {
+
+        result1 = asbrSummaryLsa.hashCode();
+        assertThat(result1, is(notNullValue()));
+
+    }
+
+    /**
+     * Tests equals() method.
+     */
+    @Test
+    public void testEqual() throws Exception {
+
+        result4 = asbrSummaryLsa.equals(new AsbrSummaryLsa(new LsaHeader()));
+        assertThat(result4, is(true));
+
+    }
+
+    /**
+     * Utility method used by junit methods.
+     */
+    private byte[] createByteForNetworkLsa() {
+        byte[] packet = {2, 1, 1, 52, -64, -88, 56, 1, -64, -88, 56, 1, 0, 100, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, -64,
+                -88, 56, 1, 0, 10, 1, 1, 0, 0, 0, 40, -64, -88, 56, 1, -64, -88, 56, 1, -64, -88, 56, 1, -64, -88, 56,
+                1};
+        return packet;
+    }
+
+    /**
+     * Utility method used by junit methods.
+     */
+    private LsaHeader createLsaHeader() {
+        lsaHeader = new LsaHeader();
+        lsaHeader.setLsType(1);
+        lsaHeader.setLsPacketLen(48);
+        lsaHeader.setLsCheckSum(10);
+        lsaHeader.setAge(4);
+        lsaHeader.setLinkStateId("10.226.165.164");
+        lsaHeader.setLsSequenceNo(250);
+        lsaHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
+        lsaHeader.setOptions(2);
+        return lsaHeader;
+    }
+}
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/ExternalLsaTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/ExternalLsaTest.java
new file mode 100644
index 0000000..5796f34
--- /dev/null
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/ExternalLsaTest.java
@@ -0,0 +1,267 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.ospf.protocol.lsa.types;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.Ip4Address;
+import org.onosproject.ospf.controller.OspfLsaType;
+import org.onosproject.ospf.protocol.lsa.LsaHeader;
+import org.onosproject.ospf.protocol.lsa.subtypes.OspfExternalDestination;
+
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Vector;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+
+/**
+ * Unit test class for ExternalLsa.
+ */
+public class ExternalLsaTest {
+
+    private ExternalLsa externalLsa;
+    private Vector<OspfExternalDestination> externalDestinations = new Vector<OspfExternalDestination>();
+    private Ip4Address result;
+    private OspfExternalDestination ospfExternalDestination;
+    private OspfExternalDestination ospfExternalDestination1;
+    private LsaHeader lsaHeader;
+    private byte[] inputByteArray;
+    private ChannelBuffer channelBuffer;
+    private byte[] result1;
+    private OspfLsaType ospflsaType;
+    private int result2;
+
+    @Before
+    public void setUp() throws Exception {
+        externalLsa = new ExternalLsa(new LsaHeader());
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        externalLsa = null;
+        externalDestinations = null;
+        result = null;
+        ospfExternalDestination = null;
+        ospfExternalDestination1 = null;
+        lsaHeader = null;
+        inputByteArray = null;
+        channelBuffer = null;
+        result1 = null;
+        ospflsaType = null;
+    }
+
+    /**
+     * Tests networkMask() getter method.
+     */
+    @Test
+    public void testGetNetworkMask() throws Exception {
+        externalLsa.setNetworkMask(Ip4Address.valueOf("10.226.165.164"));
+        result = externalLsa.networkMask();
+        assertThat(result, is(notNullValue()));
+        assertThat(result, is(Ip4Address.valueOf("10.226.165.164")));
+    }
+
+    /**
+     * Tests networkMask() setter method.
+     */
+    @Test
+    public void testSetNetworkMask() throws Exception {
+        externalLsa.setNetworkMask(Ip4Address.valueOf("10.226.165.164"));
+        result = externalLsa.networkMask();
+        assertThat(result, is(notNullValue()));
+        assertThat(result, is(Ip4Address.valueOf("10.226.165.164")));
+    }
+
+    /**
+     * Tests addExternalDesitnation() method.
+     */
+    @Test
+    public void testAddExternalDesitnation() throws Exception {
+        externalLsa.addExternalDestination(createOspfExternalDestination());
+        assertThat(externalLsa, is(notNullValue()));
+    }
+
+    /**
+     * Tests hashCode() method.
+     */
+    @Test
+    public void testHashcode() throws Exception {
+
+        result2 = externalLsa.hashCode();
+        assertThat(result2, is(notNullValue()));
+
+    }
+
+    /**
+     * Tests readFrom() method.
+     */
+    @Test
+    public void testReadFrom() throws Exception {
+        ospfExternalDestination = new OspfExternalDestination();
+        ospfExternalDestination.setExternalRouterTag(2);
+        ospfExternalDestination.setMetric(100);
+        ospfExternalDestination.setType1orType2Metric(true);
+        externalLsa.addExternalDestination(ospfExternalDestination);
+        ospfExternalDestination1 = new OspfExternalDestination();
+        ospfExternalDestination.setExternalRouterTag(3);
+        ospfExternalDestination.setMetric(50);
+        ospfExternalDestination.setType1orType2Metric(true);
+        externalLsa.addExternalDestination(ospfExternalDestination1);
+        ospfExternalDestination.setForwardingAddress(Ip4Address.valueOf(InetAddress.getLocalHost()));
+        inputByteArray = createByteForNetworkLsa();
+        lsaHeader = createLsaHeader();
+        externalLsa = new ExternalLsa(lsaHeader);
+        channelBuffer = ChannelBuffers.copiedBuffer(inputByteArray);
+        externalLsa.readFrom(channelBuffer);
+        assertThat(externalLsa, is(notNullValue()));
+    }
+
+    /**
+     * Tests readFrom() method.
+     */
+    @Test(expected = Exception.class)
+    public void testReadFrom1() throws Exception {
+        ospfExternalDestination = new OspfExternalDestination();
+        ospfExternalDestination.setExternalRouterTag(2);
+        ospfExternalDestination.setMetric(100);
+        ospfExternalDestination.setType1orType2Metric(true);
+        externalLsa.addExternalDestination(ospfExternalDestination);
+        ospfExternalDestination1 = new OspfExternalDestination();
+        ospfExternalDestination.setExternalRouterTag(3);
+        ospfExternalDestination.setMetric(50);
+        ospfExternalDestination.setType1orType2Metric(true);
+        externalLsa.addExternalDestination(ospfExternalDestination1);
+        ospfExternalDestination.setForwardingAddress(Ip4Address.valueOf(InetAddress.getLocalHost()));
+        byte[] temp = {0, 0, 0};
+        inputByteArray = temp;
+        lsaHeader = createLsaHeader();
+        externalLsa = new ExternalLsa(lsaHeader);
+        channelBuffer = ChannelBuffers.copiedBuffer(inputByteArray);
+        externalLsa.readFrom(channelBuffer);
+        assertThat(externalLsa, is(notNullValue()));
+    }
+
+    /**
+     * Tests asBytes() method.
+     */
+    @Test
+    public void testAsBytes() throws Exception {
+        result1 = externalLsa.asBytes();
+        assertThat(result1, is(notNullValue()));
+    }
+
+    /**
+     * Tests getLsaBodyAsByteArray() method.
+     */
+    @Test
+    public void testGetLsaBodyAsByteArray() throws Exception {
+        ospfExternalDestination = new OspfExternalDestination();
+        ospfExternalDestination.setExternalRouterTag(2);
+        ospfExternalDestination.setMetric(100);
+        ospfExternalDestination.setType1orType2Metric(true);
+        externalLsa.addExternalDestination(ospfExternalDestination);
+        ospfExternalDestination1 = new OspfExternalDestination();
+        ospfExternalDestination.setExternalRouterTag(3);
+        ospfExternalDestination.setMetric(100);
+        ospfExternalDestination.setType1orType2Metric(true);
+        externalLsa.addExternalDestination(ospfExternalDestination1);
+        result1 = externalLsa.getLsaBodyAsByteArray();
+        assertThat(result1, is(notNullValue()));
+    }
+
+    /**
+     * Tests getLsaBodyAsByteArray() method.
+     */
+    @Test
+    public void testGetLsaBodyAsByteArray1() throws Exception {
+        externalLsa.setNetworkMask(Ip4Address.valueOf("255.255.255.255"));
+        ospfExternalDestination = new OspfExternalDestination();
+        ospfExternalDestination.setExternalRouterTag(2);
+        ospfExternalDestination.setMetric(100);
+        ospfExternalDestination.setType1orType2Metric(true);
+        externalLsa.addExternalDestination(ospfExternalDestination);
+        ospfExternalDestination1 = new OspfExternalDestination();
+        ospfExternalDestination.setExternalRouterTag(3);
+        ospfExternalDestination.setMetric(100);
+        ospfExternalDestination.setType1orType2Metric(true);
+        externalLsa.addExternalDestination(ospfExternalDestination1);
+        result1 = externalLsa.getLsaBodyAsByteArray();
+        assertThat(result1, is(notNullValue()));
+    }
+
+    /**
+     * Tests getOspfLsaType() getter method.
+     */
+    @Test
+    public void testGetOspfLsaType() throws Exception {
+        ospflsaType = externalLsa.getOspfLsaType();
+        assertThat(ospflsaType, is(notNullValue()));
+        assertThat(ospflsaType, is(OspfLsaType.EXTERNAL_LSA));
+    }
+
+    /**
+     * Tests to string method.
+     */
+    @Test
+    public void testToString() throws Exception {
+        assertThat(externalLsa.toString(), is(notNullValue()));
+    }
+
+    /**
+     * Utility method used by junit methods.
+     */
+    private byte[] createByteForNetworkLsa() {
+        byte[] packet = {2, 1, 1, 52, -64, -88, 56, 1, -64, -88, 56, 1, 0, 100, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, -64,
+                -88, 56, 1, 0, 10, 1, 1, 0, 0, 0, 40, -64, -88, 56, 1, -64, -88, 56, 1, -64, -88, 56, 1, -64, -88, 56,
+                1};
+        return packet;
+    }
+
+    /**
+     * Utility method used by junit methods.
+     */
+    private LsaHeader createLsaHeader() {
+        lsaHeader = new LsaHeader();
+        lsaHeader.setLsType(1);
+        lsaHeader.setLsPacketLen(48);
+        lsaHeader.setLsCheckSum(10);
+        lsaHeader.setAge(4);
+        lsaHeader.setLinkStateId("10.226.165.164");
+        lsaHeader.setLsSequenceNo(250);
+        lsaHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
+        lsaHeader.setOptions(2);
+        return lsaHeader;
+    }
+
+    /**
+     * Utility method used by junit methods.
+     */
+    private OspfExternalDestination createOspfExternalDestination() throws UnknownHostException {
+        ospfExternalDestination = new OspfExternalDestination();
+        ospfExternalDestination.setExternalRouterTag(1);
+        ospfExternalDestination.setMetric(10);
+        ospfExternalDestination.setType1orType2Metric(true);
+        ospfExternalDestination.setForwardingAddress(Ip4Address.valueOf(InetAddress.getLocalHost()));
+        return ospfExternalDestination;
+    }
+}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/NetworkLsaTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/NetworkLsaTest.java
new file mode 100644
index 0000000..ecbd449
--- /dev/null
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/NetworkLsaTest.java
@@ -0,0 +1,230 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.ospf.protocol.lsa.types;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.Ip4Address;
+import org.onosproject.ospf.controller.OspfLsaType;
+import org.onosproject.ospf.protocol.lsa.LsaHeader;
+
+
+import java.net.InetAddress;
+import java.util.Vector;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+
+/**
+ * Unit test class for NetworkLsa.
+ */
+public class NetworkLsaTest {
+
+    private Vector<String> attachedRouters = new Vector();
+    private NetworkLsa networkLsa;
+    private Ip4Address result;
+    private Ip4Address inetAddres;
+    private byte[] inputByteArray;
+    private LsaHeader lsaHeader;
+    private ChannelBuffer channelBuffer;
+    private byte[] result1;
+    private OspfLsaType ospflsaType;
+    private int result2;
+
+    @Before
+    public void setUp() throws Exception {
+        networkLsa = new NetworkLsa();
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        networkLsa = null;
+        attachedRouters = null;
+        result = null;
+        inetAddres = null;
+        inputByteArray = null;
+        lsaHeader = null;
+        channelBuffer = null;
+        result1 = null;
+        ospflsaType = null;
+    }
+
+    /**
+     * Tests networkMask() getter method.
+     */
+    @Test
+    public void testGetNetworkMask() throws Exception {
+        networkLsa.setNetworkMask(Ip4Address.valueOf("10.226.165.164"));
+        result = networkLsa.networkMask();
+        assertThat(result, is(Ip4Address.valueOf("10.226.165.164")));
+    }
+
+    /**
+     * Tests networkMask() setter method.
+     */
+    @Test
+    public void testSetNetworkMask() throws Exception {
+        networkLsa.setNetworkMask(Ip4Address.valueOf("10.226.165.165"));
+        result = networkLsa.networkMask();
+        result = networkLsa.networkMask();
+        assertThat(result, is(Ip4Address.valueOf("10.226.165.165")));
+    }
+
+    /**
+     * Tests addAttachedRouter() getter method.
+     */
+    @Test
+    public void testGetAttachedRouters() throws Exception {
+        attachedRouters.add("1.1.1.1");
+        networkLsa.addAttachedRouter(Ip4Address.valueOf("1.1.1.1"));
+        assertThat(attachedRouters, is(notNullValue()));
+    }
+
+    /**
+     * Tests addAttachedRouter() setter method.
+     */
+    @Test
+    public void testSetAttachedRouters() throws Exception {
+        attachedRouters.add("1.1.1.1");
+        networkLsa.addAttachedRouter(Ip4Address.valueOf("1.1.1.1"));
+        assertThat(attachedRouters, is(notNullValue()));
+    }
+
+    /**
+     * Tests addAttachedRouter() method.
+     */
+    @Test
+    public void testAddAttachedRouter() throws Exception {
+        inetAddres = Ip4Address.valueOf(InetAddress.getLocalHost());
+        networkLsa.addAttachedRouter(inetAddres);
+        inetAddres = Ip4Address.valueOf(InetAddress.getLocalHost());
+        networkLsa.addAttachedRouter(inetAddres);
+        assertThat(networkLsa, is(notNullValue()));
+    }
+
+    /**
+     * Tests readFrom() method.
+     */
+
+    @Test
+    public void testReadFrom() throws Exception {
+        inputByteArray = createByteForNetworkLsa();
+        lsaHeader = createLsaHeader();
+        networkLsa = new NetworkLsa(lsaHeader);
+        channelBuffer = ChannelBuffers.copiedBuffer(inputByteArray);
+        networkLsa.readFrom(channelBuffer);
+        assertThat(networkLsa, is(notNullValue()));
+    }
+
+    /**
+     * Tests readFrom() method.
+     */
+    @Test(expected = Exception.class)
+    public void testReadFrom1() throws Exception {
+        byte[] temp = {0, 0, 0};
+        inputByteArray = temp;
+        lsaHeader = createLsaHeader();
+        networkLsa = new NetworkLsa(lsaHeader);
+        channelBuffer = ChannelBuffers.copiedBuffer(inputByteArray);
+        networkLsa.readFrom(channelBuffer);
+        assertThat(networkLsa, is(notNullValue()));
+    }
+
+    /**
+     * Tests asBytes() method.
+     */
+    @Test(expected = Exception.class)
+    public void testAsBytes() throws Exception {
+        result1 = networkLsa.asBytes();
+        assertThat(result1, is(notNullValue()));
+    }
+
+    /**
+     * Tests getLsaBodyAsByteArray() method.
+     */
+    @Test(expected = Exception.class)
+    public void testGetLsaBodyAsByteArray() throws Exception {
+        networkLsa.addAttachedRouter(Ip4Address.valueOf("1.1.1.1"));
+        networkLsa.addAttachedRouter(Ip4Address.valueOf("2.2.2.2"));
+        networkLsa.addAttachedRouter(Ip4Address.valueOf("3.3.3.3"));
+        result1 = networkLsa.getLSABodyAsByteArray();
+        assertThat(result1, is(notNullValue()));
+    }
+
+    /**
+     * Tests getLsaBodyAsByteArray() method.
+     */
+    @Test
+    public void testGetLsaBodyAsByteArray1() throws Exception {
+        networkLsa.setNetworkMask(Ip4Address.valueOf("255.255.255.255"));
+        networkLsa.addAttachedRouter(Ip4Address.valueOf("1.1.1.1"));
+        networkLsa.addAttachedRouter(Ip4Address.valueOf("2.2.2.2"));
+        networkLsa.addAttachedRouter(Ip4Address.valueOf("3.3.3.3"));
+        result1 = networkLsa.getLSABodyAsByteArray();
+        assertThat(result1, is(notNullValue()));
+    }
+
+    /**
+     * Tests getOspfLsaType() getter method.
+     */
+    @Test
+    public void testGetOspfLsaType() throws Exception {
+        networkLsa.setLsType(2);
+        ospflsaType = networkLsa.getOspfLsaType();
+        assertThat(ospflsaType, is(OspfLsaType.NETWORK));
+    }
+
+    /**
+     * Tests hashCode() method.
+     */
+    @Test
+    public void testHashcode() throws Exception {
+
+        result2 = networkLsa.hashCode();
+        assertThat(result2, is(notNullValue()));
+
+    }
+
+    /**
+     * Utility method used by junit methods.
+     */
+    private byte[] createByteForNetworkLsa() {
+        byte[] packet = {2, 1, 1, 52, -64, -88, 56, 1, -64, -88, 56, 1, 0, 100, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, -64,
+                -88, 56, 1, 0, 10, 1, 1, 0, 0, 0, 40, -64, -88, 56, 1, -64, -88, 56, 1, -64, -88, 56, 1, -64, -88, 56,
+                1};
+        return packet;
+    }
+
+    /**
+     * Utility method used by junit methods.
+     */
+    private LsaHeader createLsaHeader() {
+        lsaHeader = new LsaHeader();
+        lsaHeader.setLsType(2);
+        lsaHeader.setLsPacketLen(48);
+        lsaHeader.setLsCheckSum(10);
+        lsaHeader.setAge(4);
+        lsaHeader.setLinkStateId("10.226.165.164");
+        lsaHeader.setLsSequenceNo(250);
+        lsaHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
+        lsaHeader.setOptions(2);
+        return lsaHeader;
+    }
+}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa11Test.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa11Test.java
new file mode 100644
index 0000000..b8c6b44
--- /dev/null
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa11Test.java
@@ -0,0 +1,159 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.ospf.protocol.lsa.types;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.Ip4Address;
+import org.onosproject.ospf.controller.OspfLsaType;
+import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
+
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+
+/**
+ * Unit test class for OpaqueLsa11.
+ */
+public class OpaqueLsa11Test {
+
+    private final byte[] packet = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+            0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+    private OpaqueLsa11 opaqueLsa11;
+    private OpaqueLsaHeader opqueHeader;
+    private ChannelBuffer channelBuffer;
+    private byte[] result;
+    private int result1;
+    private String result2;
+    private OspfLsaType ospflsaType;
+
+    @Before
+    public void setUp() throws Exception {
+        opaqueLsa11 = new OpaqueLsa11(new OpaqueLsaHeader());
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        opaqueLsa11 = null;
+        opqueHeader = null;
+        channelBuffer = null;
+        result = null;
+        ospflsaType = null;
+    }
+
+    /**
+     * Tests readFrom()  method.
+     */
+    @Test
+    public void testReadFrom() throws Exception {
+        opqueHeader = new OpaqueLsaHeader();
+        opqueHeader.setLsType(11);
+        opqueHeader.setLsPacketLen(48);
+        opqueHeader.setLsCheckSum(10);
+        opqueHeader.setAge(4);
+        opqueHeader.setOpaqueId(1);
+        opqueHeader.setOpaqueType(11);
+        opqueHeader.setLsSequenceNo(250);
+        opqueHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
+        opqueHeader.setOptions(2);
+        opaqueLsa11 = new OpaqueLsa11(opqueHeader);
+        channelBuffer = ChannelBuffers.copiedBuffer(packet);
+        opaqueLsa11.readFrom(channelBuffer);
+        assertThat(opaqueLsa11, is(notNullValue()));
+    }
+
+    /**
+     * Tests asBytes()  method.
+     */
+    @Test
+    public void testAsBytes() throws Exception {
+        opqueHeader = new OpaqueLsaHeader();
+        opqueHeader.setLsType(11);
+        opqueHeader.setLsPacketLen(48);
+        opqueHeader.setLsCheckSum(10);
+        opqueHeader.setAge(4);
+        opqueHeader.setOpaqueId(1);
+        opqueHeader.setOpaqueType(11);
+        opqueHeader.setLsSequenceNo(250);
+        opqueHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
+        opqueHeader.setOptions(2);
+        opaqueLsa11 = new OpaqueLsa11(opqueHeader);
+        channelBuffer = ChannelBuffers.copiedBuffer(packet);
+        opaqueLsa11.readFrom(channelBuffer);
+        result = opaqueLsa11.asBytes();
+        assertThat(result, is(notNullValue()));
+    }
+
+    /**
+     * Tests getLsaBodyAsByteArray()  method.
+     */
+    @Test
+    public void testGetLsaBodyAsByteArray() throws Exception {
+        opqueHeader = new OpaqueLsaHeader();
+        opqueHeader.setLsType(11);
+        opqueHeader.setLsPacketLen(48);
+        opqueHeader.setLsCheckSum(10);
+        opqueHeader.setAge(4);
+        opqueHeader.setOpaqueId(1);
+        opqueHeader.setOpaqueType(11);
+        opqueHeader.setLsSequenceNo(250);
+        opqueHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
+        opqueHeader.setOptions(2);
+        opaqueLsa11 = new OpaqueLsa11(opqueHeader);
+        channelBuffer = ChannelBuffers.copiedBuffer(packet);
+        opaqueLsa11.readFrom(channelBuffer);
+        result = opaqueLsa11.getLsaBodyAsByteArray();
+        assertThat(result, is(notNullValue()));
+    }
+
+    /**
+     * Tests getOspfLsaType()  method.
+     */
+    @Test
+    public void testGetOspfLsaType() throws Exception {
+        opaqueLsa11.setLsType(11);
+        ospflsaType = opaqueLsa11.getOspfLsaType();
+        assertThat(ospflsaType, is(notNullValue()));
+        assertThat(ospflsaType, is(OspfLsaType.AS_OPAQUE_LSA));
+    }
+
+    /**
+     * Tests hashCode()  method.
+     */
+    @Test
+    public void testHashcode() throws Exception {
+
+        result1 = opaqueLsa11.hashCode();
+        assertThat(result1, is(notNullValue()));
+
+    }
+
+    /**
+     * Tests to string method.
+     */
+    @Test
+    public void testToString() throws Exception {
+
+        result2 = opaqueLsa11.toString();
+        assertThat(result2, is(notNullValue()));
+
+    }
+}
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa9Test.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa9Test.java
new file mode 100644
index 0000000..5c325ce
--- /dev/null
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa9Test.java
@@ -0,0 +1,160 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.ospf.protocol.lsa.types;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.Ip4Address;
+import org.onosproject.ospf.controller.OspfLsaType;
+import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
+
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+
+/**
+ * Unit test class for OpaqueLsa9.
+ */
+public class OpaqueLsa9Test {
+
+    private final byte[] packet = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+            0, 0, 0, 0, 0, 0, 0, 0};
+    private byte[] result;
+    private String result1;
+    private OpaqueLsaHeader opqueHeader;
+    private OpaqueLsa9 opaqueLsa9;
+    private ChannelBuffer channelBuffer;
+    private OspfLsaType ospflsaType;
+    private int result2;
+
+    @Before
+    public void setUp() throws Exception {
+        opaqueLsa9 = new OpaqueLsa9(new OpaqueLsaHeader());
+
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        opaqueLsa9 = null;
+        opqueHeader = null;
+        channelBuffer = null;
+        result = null;
+        ospflsaType = null;
+    }
+
+    /**
+     * Tests readFrom() method.
+     */
+    @Test
+    public void testReadFrom() throws Exception {
+        opqueHeader = new OpaqueLsaHeader();
+        opqueHeader.setLsType(1);
+        opqueHeader.setLsPacketLen(48);
+        opqueHeader.setLsCheckSum(10);
+        opqueHeader.setAge(4);
+        opqueHeader.setOpaqueId(9);
+        opqueHeader.setOpaqueType(9);
+        opqueHeader.setLsSequenceNo(250);
+        opqueHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
+        opqueHeader.setOptions(2);
+        opaqueLsa9 = new OpaqueLsa9(opqueHeader);
+        channelBuffer = ChannelBuffers.copiedBuffer(packet);
+        opaqueLsa9.readFrom(channelBuffer);
+        assertThat(opaqueLsa9, is(notNullValue()));
+    }
+
+    /**
+     * Tests asBytes() method.
+     */
+    @Test
+    public void testAsBytes() throws Exception {
+        opqueHeader = new OpaqueLsaHeader();
+        opqueHeader.setLsType(9);
+        opqueHeader.setLsPacketLen(48);
+        opqueHeader.setLsCheckSum(10);
+        opqueHeader.setAge(4);
+        opqueHeader.setOpaqueId(9);
+        opqueHeader.setOpaqueType(9);
+        opqueHeader.setLsSequenceNo(250);
+        opqueHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
+        opqueHeader.setOptions(2);
+        opaqueLsa9 = new OpaqueLsa9(opqueHeader);
+        channelBuffer = ChannelBuffers.copiedBuffer(packet);
+        opaqueLsa9.readFrom(channelBuffer);
+        result = opaqueLsa9.asBytes();
+        assertThat(result, is(notNullValue()));
+    }
+
+    /**
+     * Tests getLsaBodyAsByteArray() method.
+     */
+    @Test
+    public void testGetLsaBodyAsByteArray() throws Exception {
+        opqueHeader = new OpaqueLsaHeader();
+        opqueHeader.setLsType(9);
+        opqueHeader.setLsPacketLen(48);
+        opqueHeader.setLsCheckSum(10);
+        opqueHeader.setAge(4);
+        opqueHeader.setOpaqueId(9);
+        opqueHeader.setOpaqueType(9);
+        opqueHeader.setLsSequenceNo(250);
+        opqueHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
+        opqueHeader.setOptions(2);
+        opaqueLsa9 = new OpaqueLsa9(opqueHeader);
+        channelBuffer = ChannelBuffers.copiedBuffer(packet);
+        opaqueLsa9.readFrom(channelBuffer);
+        result = opaqueLsa9.getLsaBodyAsByteArray();
+        assertThat(result, is(notNullValue()));
+    }
+
+    /**
+     * Tests hashCode() method.
+     */
+    @Test
+    public void testHashcode() throws Exception {
+
+        result2 = opaqueLsa9.hashCode();
+        assertThat(result2, is(notNullValue()));
+
+    }
+
+    /**
+     * Tests to string method.
+     */
+    @Test
+    public void testToString() throws Exception {
+
+        result1 = opaqueLsa9.toString();
+        assertThat(result1, is(notNullValue()));
+
+    }
+
+    /**
+     * Tests to getOspfLsaType() getter method.
+     */
+    @Test
+    public void testGetOspfLsaType() throws Exception {
+        opaqueLsa9.setLsType(9);
+        ospflsaType = opaqueLsa9.getOspfLsaType();
+        assertThat(ospflsaType, is(notNullValue()));
+        assertThat(ospflsaType, is(OspfLsaType.LINK_LOCAL_OPAQUE_LSA));
+    }
+}
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/SummaryLsaTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/SummaryLsaTest.java
new file mode 100644
index 0000000..756afa1
--- /dev/null
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/SummaryLsaTest.java
@@ -0,0 +1,193 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.ospf.protocol.lsa.types;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.Ip4Address;
+import org.onosproject.ospf.controller.OspfLsaType;
+import org.onosproject.ospf.protocol.lsa.LsaHeader;
+
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+
+/**
+ * Unit test class for SummaryLsa.
+ */
+public class SummaryLsaTest {
+
+    private SummaryLsa summaryLsa;
+    private Ip4Address result;
+    private int result1;
+    private byte[] inputByteArray;
+    private LsaHeader lsaHeader;
+    private ChannelBuffer channelBuffer;
+    private byte[] result2;
+    private OspfLsaType ospflsaType;
+
+    @Before
+    public void setUp() throws Exception {
+        summaryLsa = new SummaryLsa(new LsaHeader());
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        summaryLsa = null;
+        result = null;
+        inputByteArray = null;
+        lsaHeader = null;
+        channelBuffer = null;
+        result2 = null;
+        ospflsaType = null;
+    }
+
+    /**
+     * Tests networkMask() getter method.
+     */
+    @Test
+    public void testGetNetworkMask() throws Exception {
+        summaryLsa.setNetworkMask(Ip4Address.valueOf("10.226.165.164"));
+        result = summaryLsa.networkMask();
+        assertThat(result, is(Ip4Address.valueOf("10.226.165.164")));
+    }
+
+    /**
+     * Tests networkMask() setter method.
+     */
+    @Test
+    public void testSetNetworkMask() throws Exception {
+        summaryLsa.setNetworkMask(Ip4Address.valueOf("10.226.165.164"));
+        result = summaryLsa.networkMask();
+        assertThat(result, is(Ip4Address.valueOf("10.226.165.164")));
+    }
+
+    /**
+     * Tests metric() getter method.
+     */
+    @Test
+    public void testGetMetric() throws Exception {
+        summaryLsa.setMetric(10);
+        result1 = summaryLsa.metric();
+        assertThat(result1, is(10));
+    }
+
+    /**
+     * Tests metric() setter method.
+     */
+    @Test
+    public void testSetMetric() throws Exception {
+        summaryLsa.setMetric(20);
+        result1 = summaryLsa.metric();
+        assertThat(result1, is(20));
+    }
+
+    /**
+     * Tests readFrom() method.
+     */
+    @Test
+    public void testReadFrom() throws Exception {
+        inputByteArray = createByteForNetworkLsa();
+        lsaHeader = createLsaHeader();
+        summaryLsa = new SummaryLsa(lsaHeader);
+        channelBuffer = ChannelBuffers.copiedBuffer(inputByteArray);
+        summaryLsa.readFrom(channelBuffer);
+        assertThat(summaryLsa, is(notNullValue()));
+    }
+
+    /**
+     * Tests readFrom() method.
+     */
+    @Test(expected = Exception.class)
+    public void testReadFrom1() throws Exception {
+        byte[] temp = {0, 0, 0};
+        inputByteArray = temp;
+        lsaHeader = createLsaHeader();
+        summaryLsa = new SummaryLsa(lsaHeader);
+        channelBuffer = ChannelBuffers.copiedBuffer(inputByteArray);
+        summaryLsa.readFrom(channelBuffer);
+        assertThat(summaryLsa, is(notNullValue()));
+    }
+
+    /**
+     * Tests asBytes() method.
+     */
+    @Test
+    public void testAsBytes() throws Exception {
+        result2 = summaryLsa.asBytes();
+        assertThat(result2, is(notNullValue()));
+    }
+
+    /**
+     * Tests getLsaBodyAsByteArray() method.
+     */
+    @Test
+    public void testGetLsaBodyAsByteArray() throws Exception {
+        result2 = summaryLsa.getLsaBodyAsByteArray();
+        assertThat(result2, is(notNullValue()));
+    }
+
+    /**
+     * Tests getOspfLsaType() getter method.
+     */
+    @Test
+    public void testGetOspfLsaType() throws Exception {
+        ospflsaType = summaryLsa.getOspfLsaType();
+        assertThat(ospflsaType, is(notNullValue()));
+        assertThat(ospflsaType, is(OspfLsaType.SUMMARY));
+    }
+
+    /**
+     * Utility method used by junit methods.
+     */
+    private byte[] createByteForNetworkLsa() {
+        byte[] packet = {2, 1, 1, 52, -64, -88, 56, 1, -64, -88, 56, 1, 0, 100, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, -64,
+                -88, 56, 1, 0, 10, 1, 1, 0, 0, 0, 40, -64, -88, 56, 1, -64, -88, 56, 1, -64, -88, 56, 1, -64, -88, 56,
+                1};
+        return packet;
+    }
+
+    /**
+     * Utility method used by junit methods.
+     */
+    private LsaHeader createLsaHeader() {
+        lsaHeader = new LsaHeader();
+        lsaHeader.setLsType(3);
+        lsaHeader.setLsPacketLen(48);
+        lsaHeader.setLsCheckSum(10);
+        lsaHeader.setAge(4);
+        lsaHeader.setLinkStateId("10.226.165.164");
+        lsaHeader.setLsSequenceNo(250);
+        lsaHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
+        lsaHeader.setOptions(2);
+        return lsaHeader;
+    }
+
+    /**
+     * Tests hashcode() method.
+     */
+    @Test
+    public void testHashcode() throws Exception {
+
+        result1 = summaryLsa.hashCode();
+        assertThat(result1, is(notNullValue()));
+
+    }
+}
\ No newline at end of file