ONOS-2739 - OSPF Basic Packet Structures , which includes encoding and decoding
Change-Id: Ic37fcf98dfb6c7a15a124b495aee8517a8df23c9
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/TlvHeaderTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/TlvHeaderTest.java
new file mode 100644
index 0000000..5857083
--- /dev/null
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/TlvHeaderTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Unit test class for Tlv Header.
+ */
+public class TlvHeaderTest {
+
+ private TlvHeader tlvHeader;
+ private byte[] result;
+
+
+ @Before
+ public void setUp() throws Exception {
+ tlvHeader = new TlvHeader();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ tlvHeader = null;
+ result = null;
+ }
+
+ /**
+ * Tests to string method.
+ */
+ @Test
+ public void testToString() throws Exception {
+ assertThat(tlvHeader.toString(), is(notNullValue()));
+ }
+
+ /**
+ * Tests tlvLength() getter method.
+ */
+ @Test
+ public void testGetTlvLength() throws Exception {
+ tlvHeader.setTlvLength(2);
+ assertThat(tlvHeader.tlvLength(), is(2));
+ }
+
+ /**
+ * Tests tlvLength() setter method.
+ */
+ @Test
+ public void testSetTlvLength() throws Exception {
+ tlvHeader.setTlvLength(2);
+ assertThat(tlvHeader.tlvLength(), is(2));
+ }
+
+ /**
+ * Tests tlvType() getter method.
+ */
+ @Test
+ public void testGetTlvType() throws Exception {
+ tlvHeader.setTlvType(2);
+ assertThat(tlvHeader.tlvType(), is(2));
+ }
+
+ /**
+ * Tests tlvType() setter method.
+ */
+ @Test
+ public void testSetTlvType() throws Exception {
+ tlvHeader.setTlvType(2);
+ assertThat(tlvHeader.tlvType(), is(2));
+ }
+
+ /**
+ * Tests getTlvHeaderAsByteArray() method.
+ */
+ @Test
+ public void testGetTlvHeaderAsByteArray() throws Exception {
+ result = tlvHeader.getTlvHeaderAsByteArray();
+ assertThat(result, is(notNullValue()));
+ }
+}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/AdministrativeGroupTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/AdministrativeGroupTest.java
new file mode 100644
index 0000000..3b5b9c2
--- /dev/null
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/AdministrativeGroupTest.java
@@ -0,0 +1,110 @@
+/*
+ * 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.linksubtype;
+
+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.onosproject.ospf.protocol.lsa.TlvHeader;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+
+/**
+ * Unit test class for AdministrativeGroup.
+ */
+public class AdministrativeGroupTest {
+
+ private final byte[] packet = {0, 0, 0, 1};
+ private AdministrativeGroup administrativeGroup;
+ private ChannelBuffer channelBuffer;
+ private TlvHeader tlvHeader;
+ private byte[] result;
+
+ @Before
+ public void setUp() throws Exception {
+ administrativeGroup = new AdministrativeGroup(new TlvHeader());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ administrativeGroup = null;
+ channelBuffer = null;
+ tlvHeader = null;
+ }
+
+ /**
+ * Tests administrativeGroup() getter method.
+ */
+ @Test
+ public void testGetAdministrativeGroup() throws Exception {
+ administrativeGroup.setAdministrativeGroup(1);
+ assertThat(administrativeGroup.administrativeGroup(), is(1));
+ }
+
+ /**
+ * Tests administrativeGroup() setter method.
+ */
+ @Test
+ public void testSetAdministrativeGroup() throws Exception {
+ administrativeGroup.setAdministrativeGroup(1);
+ assertThat(administrativeGroup.administrativeGroup(), is(1));
+ }
+
+ /**
+ * Tests readFrom() method.
+ */
+ @Test
+ public void testReadFrom() throws Exception {
+ tlvHeader = new TlvHeader();
+ tlvHeader.setTlvType(9);
+ tlvHeader.setTlvLength(4);
+ administrativeGroup = new AdministrativeGroup(tlvHeader);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet);
+ administrativeGroup.readFrom(channelBuffer);
+ assertThat(administrativeGroup.administrativeGroup(), is(notNullValue()));
+ }
+
+ /**
+ * Tests asBytes() method.
+ */
+ @Test
+ public void testAsBytes() throws Exception {
+ result = administrativeGroup.asBytes();
+ assertThat(result, is(notNullValue()));
+ }
+
+
+ /**
+ * Tests getLinkSubTypeTlvBodyAsByteArray() method.
+ */
+ @Test
+ public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception {
+ result = administrativeGroup.getLinkSubTypeTlvBodyAsByteArray();
+ assertThat(result, is(notNullValue()));
+ }
+
+ /**
+ * Tests to string method.
+ */
+ @Test
+ public void testToString() throws Exception {
+ assertThat(administrativeGroup.toString(), is(notNullValue()));
+ }
+}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkIdTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkIdTest.java
new file mode 100644
index 0000000..bb68c00
--- /dev/null
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkIdTest.java
@@ -0,0 +1,124 @@
+/*
+ * 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.linksubtype;
+
+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.onosproject.ospf.protocol.lsa.TlvHeader;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+
+/**
+ * Unit test class for LinkId.
+ */
+public class LinkIdTest {
+
+ private final byte[] packet = {1, 1, 1, 1};
+ private final byte[] packet1 = {0, 0, 1};
+ private LinkId linkId;
+ private TlvHeader tlvHeader;
+ private ChannelBuffer channelBuffer;
+ private byte[] result;
+
+ @Before
+ public void setUp() throws Exception {
+ linkId = new LinkId(new TlvHeader());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ linkId = null;
+ channelBuffer = null;
+ tlvHeader = null;
+ }
+
+ /**
+ * Tests to string method.
+ */
+ @Test
+ public void testToString() throws Exception {
+ assertThat(linkId.toString(), is(notNullValue()));
+ }
+
+ /**
+ * Tests linkId() getter method.
+ */
+ @Test
+ public void testGetLinkId() throws Exception {
+ linkId.setLinkId("1.1.1.1");
+ assertThat(linkId, is(notNullValue()));
+ }
+
+ /**
+ * Tests linkId() setter method.
+ */
+ @Test
+ public void testSetLinkId() throws Exception {
+ linkId.setLinkId("1.1.1.1");
+ assertThat(linkId, is(notNullValue()));
+ }
+
+ /**
+ * Tests readFrom() method.
+ */
+ @Test
+ public void testReadFrom() throws Exception {
+ tlvHeader = new TlvHeader();
+ tlvHeader.setTlvType(2);
+ tlvHeader.setTlvLength(4);
+ linkId = new LinkId(tlvHeader);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet);
+ linkId.readFrom(channelBuffer);
+ assertThat(linkId, is(notNullValue()));
+ }
+
+ /**
+ * Tests readFrom() method.
+ */
+ @Test(expected = Exception.class)
+ public void testReadFrom1() throws Exception {
+ tlvHeader = new TlvHeader();
+ tlvHeader.setTlvType(2);
+ tlvHeader.setTlvLength(4);
+ linkId = new LinkId(tlvHeader);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet1);
+ linkId.readFrom(channelBuffer);
+ assertThat(linkId, is(notNullValue()));
+ }
+
+ /**
+ * Tests asBytes() method.
+ */
+ @Test
+ public void testAsBytes() throws Exception {
+ result = linkId.asBytes();
+ assertThat(result, is(notNullValue()));
+ }
+
+ /**
+ * Tests getLinkSubTypeTlvBodyAsByteArray() method.
+ */
+ @Test
+ public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception {
+ result = linkId.getLinkSubTypeTlvBodyAsByteArray();
+ assertThat(result, is(notNullValue()));
+ }
+}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkTypeTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkTypeTest.java
new file mode 100644
index 0000000..7e00afc
--- /dev/null
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkTypeTest.java
@@ -0,0 +1,125 @@
+/*
+ * 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.linksubtype;
+
+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.onosproject.ospf.protocol.lsa.TlvHeader;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+
+/**
+ * Unit test class for LinkType.
+ */
+public class LinkTypeTest {
+
+ private final byte[] packet = {0, 0, 0, 1};
+ private final byte[] packet1 = {0, 0, 1};
+ private LinkType linkType;
+ private byte[] result;
+ private ChannelBuffer channelBuffer;
+ private TlvHeader tlvHeader;
+
+ @Before
+ public void setUp() throws Exception {
+ linkType = new LinkType();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ linkType = null;
+ channelBuffer = null;
+ tlvHeader = null;
+ }
+
+ /**
+ * Tests to string method.
+ */
+ @Test
+ public void testToString() throws Exception {
+ assertThat(linkType.toString(), is(notNullValue()));
+ }
+
+ /**
+ * Tests linkType() getter method.
+ */
+ @Test
+ public void testGetLinkType() throws Exception {
+ linkType.setLinkType(1);
+ assertThat(linkType, is(notNullValue()));
+ }
+
+ /**
+ * Tests linkType() setter method.
+ */
+ @Test
+ public void testSetLinkType() throws Exception {
+ linkType.setLinkType(1);
+ assertThat(linkType, is(notNullValue()));
+ }
+
+ /**
+ * Tests readFrom() method.
+ */
+ @Test
+ public void testReadFrom() throws Exception {
+ tlvHeader = new TlvHeader();
+ tlvHeader.setTlvType(1);
+ tlvHeader.setTlvLength(4);
+ linkType = new LinkType(tlvHeader);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet);
+ linkType.readFrom(channelBuffer);
+ assertThat(linkType, is(notNullValue()));
+ }
+
+ /**
+ * Tests readFrom() method.
+ */
+ @Test
+ public void testReadFrom1() throws Exception {
+ tlvHeader = new TlvHeader();
+ tlvHeader.setTlvType(1);
+ tlvHeader.setTlvLength(4);
+ linkType = new LinkType(tlvHeader);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet1);
+ linkType.readFrom(channelBuffer);
+ assertThat(linkType, is(notNullValue()));
+ }
+
+ /**
+ * Tests asBytes() method.
+ */
+ @Test
+ public void testAsBytes() throws Exception {
+ result = linkType.asBytes();
+ assertThat(result, is(notNullValue()));
+ }
+
+
+ /**
+ * Tests getLinkSubTypeTlvBodyAsByteArray() method.
+ */
+ @Test
+ public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception {
+ result = linkType.getLinkSubTypeTlvBodyAsByteArray();
+ assertThat(result, is(notNullValue()));
+ }
+}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/LocalInterfaceIpAddressTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/LocalInterfaceIpAddressTest.java
new file mode 100644
index 0000000..970ae30
--- /dev/null
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/LocalInterfaceIpAddressTest.java
@@ -0,0 +1,117 @@
+/*
+ * 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.linksubtype;
+
+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.onosproject.ospf.protocol.lsa.TlvHeader;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+
+/**
+ * Unit test class for LocalInterfaceIpAddress.
+ */
+public class LocalInterfaceIpAddressTest {
+
+ private final byte[] packet = {1, 1, 1, 1};
+ private final byte[] packet1 = {};
+ private LocalInterfaceIpAddress localInterfaceIpAddress;
+ private TlvHeader tlvHeader;
+ private byte[] result;
+ private ChannelBuffer channelBuffer;
+
+ @Before
+ public void setUp() throws Exception {
+ localInterfaceIpAddress = new LocalInterfaceIpAddress(new TlvHeader());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ localInterfaceIpAddress = null;
+ tlvHeader = null;
+ result = null;
+ channelBuffer = null;
+ }
+
+ /**
+ * Tests to string method.
+ */
+ @Test
+ public void testToString() throws Exception {
+ assertThat(localInterfaceIpAddress.toString(), is(notNullValue()));
+ }
+
+ /**
+ * Tests addLocalInterfaceIPAddress() method.
+ */
+ @Test
+ public void testAddLocalInterfaceIPAddress() throws Exception {
+ localInterfaceIpAddress.addLocalInterfaceIPAddress("1.1.1.1");
+ assertThat(localInterfaceIpAddress, is(notNullValue()));
+ }
+
+ /**
+ * Tests readFrom() method.
+ */
+ @Test
+ public void testReadFrom() throws Exception {
+ tlvHeader = new TlvHeader();
+ tlvHeader.setTlvType(3);
+ tlvHeader.setTlvLength(4);
+ localInterfaceIpAddress = new LocalInterfaceIpAddress(tlvHeader);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet);
+ localInterfaceIpAddress.readFrom(channelBuffer);
+ assertThat(localInterfaceIpAddress, is(notNullValue()));
+ }
+
+ /**
+ * Tests readFrom() method.
+ */
+ @Test
+ public void testReadFrom1() throws Exception {
+ tlvHeader = new TlvHeader();
+ tlvHeader.setTlvType(3);
+ tlvHeader.setTlvLength(4);
+ localInterfaceIpAddress = new LocalInterfaceIpAddress(tlvHeader);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet1);
+ localInterfaceIpAddress.readFrom(channelBuffer);
+ assertThat(localInterfaceIpAddress, is(notNullValue()));
+ }
+
+ /**
+ * Tests asBytes() method.
+ */
+ @Test
+ public void testAsBytes() throws Exception {
+ result = localInterfaceIpAddress.asBytes();
+ assertThat(result, is(notNullValue()));
+ }
+
+
+ /**
+ * Tests getLinkSubTypeTlvBodyAsByteArray() method.
+ */
+ @Test
+ public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception {
+ result = localInterfaceIpAddress.getLinkSubTypeTlvBodyAsByteArray();
+ assertThat(result, is(notNullValue()));
+ }
+}
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/MaximumBandwidthTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/MaximumBandwidthTest.java
new file mode 100644
index 0000000..e29b611
--- /dev/null
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/MaximumBandwidthTest.java
@@ -0,0 +1,92 @@
+/*
+ * 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.linksubtype;
+
+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.onosproject.ospf.protocol.lsa.TlvHeader;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+
+/**
+ * Unit test class for MaximumBandwidth.
+ */
+public class MaximumBandwidthTest {
+
+ private final byte[] packet = {0, 0, 0, 0};
+ private MaximumBandwidth maximumBandwidth;
+ private TlvHeader header;
+ private ChannelBuffer channelBuffer;
+ private byte[] result;
+
+ @Before
+ public void setUp() throws Exception {
+ maximumBandwidth = new MaximumBandwidth(new TlvHeader());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ maximumBandwidth = null;
+ header = null;
+ channelBuffer = null;
+ result = null;
+ }
+
+ /**
+ * Tests maximumBandwidth() setter method.
+ */
+ @Test
+ public void testSetMaximumBandwidth() throws Exception {
+ maximumBandwidth.setMaximumBandwidth(123456.00f);
+ assertThat(maximumBandwidth, is(notNullValue()));
+ }
+
+ /**
+ * Tests readFrom() method.
+ */
+ @Test
+ public void testReadFrom() throws Exception {
+ header = new TlvHeader();
+ header.setTlvType(6);
+ header.setTlvLength(4);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet);
+ maximumBandwidth = new MaximumBandwidth(header);
+ maximumBandwidth.readFrom(channelBuffer);
+ assertThat(maximumBandwidth, is(notNullValue()));
+ }
+
+ /**
+ * Tests asBytes() method.
+ */
+ @Test
+ public void testAsBytes() throws Exception {
+ result = maximumBandwidth.asBytes();
+ assertThat(result, is(notNullValue()));
+ }
+
+ /**
+ * Tests to string method.
+ */
+ @Test
+ public void testToString() throws Exception {
+ assertThat(maximumBandwidth.toString(), is(notNullValue()));
+ }
+}
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/MaximumReservableBandwidthTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/MaximumReservableBandwidthTest.java
new file mode 100644
index 0000000..95506ca
--- /dev/null
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/MaximumReservableBandwidthTest.java
@@ -0,0 +1,103 @@
+/*
+ * 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.linksubtype;
+
+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.onosproject.ospf.protocol.lsa.TlvHeader;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+
+/**
+ * Unit test class for MaximumReservableBandwidth.
+ */
+public class MaximumReservableBandwidthTest {
+
+ private final byte[] packet = {0, 0, 0, 0};
+ private MaximumReservableBandwidth maximumReservableBandwidth;
+ private TlvHeader header;
+ private ChannelBuffer channelBuffer;
+ private byte[] result;
+
+ @Before
+ public void setUp() throws Exception {
+ maximumReservableBandwidth = new MaximumReservableBandwidth(new TlvHeader());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ maximumReservableBandwidth = null;
+ header = null;
+ channelBuffer = null;
+ result = null;
+ }
+
+
+ /**
+ * Tests maximumBandwidth() setter method.
+ */
+ @Test
+ public void testSetMaximumBandwidth() throws Exception {
+ maximumReservableBandwidth.setMaximumBandwidth(123456.78f);
+ assertThat(maximumReservableBandwidth, is(notNullValue()));
+ }
+
+ /**
+ * Tests readFrom() method.
+ */
+ @Test
+ public void testReadFrom() throws Exception {
+ header = new TlvHeader();
+ header.setTlvType(6);
+ header.setTlvLength(4);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet);
+ maximumReservableBandwidth = new MaximumReservableBandwidth(header);
+ maximumReservableBandwidth.readFrom(channelBuffer);
+ assertThat(maximumReservableBandwidth, is(notNullValue()));
+ }
+
+ /**
+ * Tests asBytes() method.
+ */
+ @Test
+ public void testAsBytes() throws Exception {
+ result = maximumReservableBandwidth.asBytes();
+ assertThat(result, is(notNullValue()));
+ }
+
+
+ /**
+ * Tests getLinkSubTypeTlvBodyAsByteArray() method.
+ */
+ @Test
+ public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception {
+ result = maximumReservableBandwidth.getLinksubTypeTlvBodyAsByteArray();
+ assertThat(result, is(notNullValue()));
+ }
+
+ /**
+ * Tests to string method.
+ */
+ @Test
+ public void testToString() throws Exception {
+ assertThat(maximumReservableBandwidth.toString(), is(notNullValue()));
+ }
+}
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/RemoteInterfaceIpAddressTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/RemoteInterfaceIpAddressTest.java
new file mode 100644
index 0000000..920bf1f
--- /dev/null
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/RemoteInterfaceIpAddressTest.java
@@ -0,0 +1,119 @@
+/*
+ * 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.linksubtype;
+
+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.onosproject.ospf.protocol.lsa.TlvHeader;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+
+
+/**
+ * Unit test class for RemoteInterfaceIpAddress.
+ */
+public class RemoteInterfaceIpAddressTest {
+
+ private final byte[] packet = {1, 1, 1, 1};
+ private final byte[] packet1 = {};
+ private byte[] result;
+ private TlvHeader tlvHeader;
+ private RemoteInterfaceIpAddress remoteInterfaceIpAddress;
+ private ChannelBuffer channelBuffer;
+
+ @Before
+ public void setUp() throws Exception {
+ remoteInterfaceIpAddress = new RemoteInterfaceIpAddress(new TlvHeader());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ remoteInterfaceIpAddress = null;
+ result = null;
+ tlvHeader = null;
+ channelBuffer = null;
+ }
+
+ /**
+ * Tests addRemoteInterfaceAddress() method.
+ */
+ @Test
+ public void testAddRemoteInterfaceIpAddress() throws Exception {
+ remoteInterfaceIpAddress.addRemoteInterfaceAddress("1.1.1.1");
+ assertThat(remoteInterfaceIpAddress, is(notNullValue()));
+ }
+
+
+ /**
+ * Tests readFrom() method.
+ */
+ @Test
+ public void testReadFrom() throws Exception {
+ tlvHeader = new TlvHeader();
+ tlvHeader.setTlvType(4);
+ tlvHeader.setTlvLength(4);
+ remoteInterfaceIpAddress = new RemoteInterfaceIpAddress(tlvHeader);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet);
+ remoteInterfaceIpAddress.readFrom(channelBuffer);
+ assertThat(remoteInterfaceIpAddress, is(notNullValue()));
+ }
+
+ /**
+ * Tests readFrom() method.
+ */
+ @Test
+ public void testReadFrom1() throws Exception {
+ tlvHeader = new TlvHeader();
+ tlvHeader.setTlvType(4);
+ tlvHeader.setTlvLength(4);
+ remoteInterfaceIpAddress = new RemoteInterfaceIpAddress(tlvHeader);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet1);
+ remoteInterfaceIpAddress.readFrom(channelBuffer);
+ assertThat(remoteInterfaceIpAddress, is(notNullValue()));
+ }
+
+ /**
+ * Tests asBytes() method.
+ */
+ @Test
+ public void testAsBytes() throws Exception {
+ result = remoteInterfaceIpAddress.asBytes();
+ assertThat(result, is(notNullValue()));
+ }
+
+
+ /**
+ * Tests getLinkSubTypeTlvBodyAsByteArray() method.
+ */
+ @Test
+ public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception {
+ result = remoteInterfaceIpAddress.getLinkSubTypeTlvBodyAsByteArray();
+ assertThat(result, is(notNullValue()));
+ }
+
+ /**
+ * Tests to string method.
+ */
+ @Test
+ public void testToString() throws Exception {
+ assertThat(remoteInterfaceIpAddress.toString(), is(notNullValue()));
+ }
+}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/TrafficEngineeringMetricTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/TrafficEngineeringMetricTest.java
new file mode 100644
index 0000000..799cb97
--- /dev/null
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/TrafficEngineeringMetricTest.java
@@ -0,0 +1,103 @@
+/*
+ * 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.linksubtype;
+
+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.onosproject.ospf.protocol.lsa.TlvHeader;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+/**
+ * Unit test class for TrafficEngineeringMetric.
+ */
+public class TrafficEngineeringMetricTest {
+
+ private final byte[] packet = {0, 0, 1, 1};
+ private TrafficEngineeringMetric trafficEngineeringMetric;
+ private TlvHeader header;
+ private byte[] result;
+ private ChannelBuffer channelBuffer;
+
+ @Before
+ public void setUp() throws Exception {
+ trafficEngineeringMetric = new TrafficEngineeringMetric(new TlvHeader());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ trafficEngineeringMetric = null;
+ header = null;
+ result = null;
+ channelBuffer = null;
+ }
+
+
+ /**
+ * Tests trafficEngineeringMetric() setter method.
+ */
+ @Test
+ public void testSetTrafficEngineeringMetric() throws Exception {
+ trafficEngineeringMetric.setTrafficEngineeringMetric(123456789L);
+ assertThat(trafficEngineeringMetric, is(notNullValue()));
+ }
+
+ /**
+ * Tests readFrom() method.
+ */
+ @Test
+ public void testReadFrom() throws Exception {
+ header = new TlvHeader();
+ header.setTlvLength(4);
+ header.setTlvType(5);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet);
+ trafficEngineeringMetric = new TrafficEngineeringMetric(header);
+ trafficEngineeringMetric.readFrom(channelBuffer);
+ assertThat(trafficEngineeringMetric, is(notNullValue()));
+ }
+
+ /**
+ * Tests asBytes() method.
+ */
+ @Test
+ public void testAsBytes() throws Exception {
+ result = trafficEngineeringMetric.asBytes();
+ assertThat(result, is(notNullValue()));
+ }
+
+
+ /**
+ * Tests getLinkSubTypeTlvBodyAsByteArray() method.
+ */
+ @Test
+ public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception {
+ result = trafficEngineeringMetric.getLinkSubTypeTlvBodyAsByteArray();
+ assertThat(result, is(notNullValue()));
+ }
+
+ /**
+ * Tests to string method.
+ */
+ @Test
+ public void testToString() throws Exception {
+ assertThat(trafficEngineeringMetric.toString(), is(notNullValue()));
+ }
+}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/UnknownLinkSubTypeTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/UnknownLinkSubTypeTest.java
new file mode 100644
index 0000000..8f2b31b
--- /dev/null
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/UnknownLinkSubTypeTest.java
@@ -0,0 +1,110 @@
+/*
+ * 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.linksubtype;
+
+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.onosproject.ospf.protocol.lsa.TlvHeader;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+
+/**
+ * Unit test class for UnknownLinkSubType.
+ */
+public class UnknownLinkSubTypeTest {
+ private final byte[] packet = {0, 114, 0, 4, 0, 0, 0, 1};
+ private UnknownLinkSubType unknownLinkSubType;
+ private TlvHeader header;
+ private ChannelBuffer channelBuffer;
+ private byte[] result;
+
+ @Before
+ public void setUp() throws Exception {
+ unknownLinkSubType = new UnknownLinkSubType(new TlvHeader());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ unknownLinkSubType = null;
+ header = null;
+ }
+
+ /**
+ * Tests value() getter method.
+ */
+ @Test
+ public void testValue() throws Exception {
+ unknownLinkSubType.setValue(packet);
+ assertThat(unknownLinkSubType.value(), is(notNullValue()));
+ }
+
+ /**
+ * Tests value() setter method.
+ */
+ @Test
+ public void testSetValue() throws Exception {
+ unknownLinkSubType.setValue(packet);
+ assertThat(unknownLinkSubType.value(), is(notNullValue()));
+ }
+
+ /**
+ * Tests readFrom() method.
+ */
+ @Test
+ public void testReadFrom() throws Exception {
+ header = new TlvHeader();
+ header.setTlvLength(8);
+ header.setTlvType(114);
+ unknownLinkSubType = new UnknownLinkSubType(header);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet);
+ unknownLinkSubType.readFrom(channelBuffer);
+ assertThat(unknownLinkSubType, is(notNullValue()));
+ }
+
+ /**
+ * Tests asBytes() method.
+ */
+ @Test(expected = Exception.class)
+ public void testAsBytes() throws Exception {
+ result = unknownLinkSubType.asBytes();
+ assertThat(result, is(notNullValue()));
+ }
+
+
+ /**
+ * Tests getLinkSubTypeTlvBodyAsByteArray() method.
+ */
+ @Test
+ public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception {
+ channelBuffer = ChannelBuffers.copiedBuffer(packet);
+ unknownLinkSubType.readFrom(channelBuffer);
+ result = unknownLinkSubType.getLinkSubTypeTlvBodyAsByteArray();
+ assertThat(result, is(notNullValue()));
+ }
+
+ /**
+ * Tests to string method.
+ */
+ @Test
+ public void testToString() throws Exception {
+ assertThat(unknownLinkSubType.toString(), is(notNullValue()));
+ }
+}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/UnreservedBandwidthTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/UnreservedBandwidthTest.java
new file mode 100644
index 0000000..0357ea1
--- /dev/null
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/UnreservedBandwidthTest.java
@@ -0,0 +1,104 @@
+/*
+ * 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.linksubtype;
+
+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.onosproject.ospf.protocol.lsa.TlvHeader;
+
+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 UnreservedBandwidthTest {
+
+ private final byte[] packet = {0, 0, 0, 1};
+ private UnreservedBandwidth unreservedBandwidth;
+ private TlvHeader header;
+ private byte[] result;
+ private ChannelBuffer channelBuffer;
+
+ @Before
+ public void setUp() throws Exception {
+ unreservedBandwidth = new UnreservedBandwidth(new TlvHeader());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ unreservedBandwidth = null;
+ header = null;
+ result = null;
+ channelBuffer = null;
+ }
+
+ /**
+ * Tests to string method.
+ */
+ @Test
+ public void testToString() throws Exception {
+ assertThat(unreservedBandwidth.toString(), is(notNullValue()));
+ }
+
+ /**
+ * Tests addUnReservedBandwidth() method.
+ */
+ @Test
+ public void testAddUnReservedBandwidth() throws Exception {
+ unreservedBandwidth.addUnReservedBandwidth(123456.78f);
+ assertThat(unreservedBandwidth, is(notNullValue()));
+ }
+
+
+ /**
+ * Tests readFrom() method.
+ */
+ @Test
+ public void testReadFrom() throws Exception {
+ header = new TlvHeader();
+ header.setTlvLength(4);
+ header.setTlvType(8);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet);
+ unreservedBandwidth = new UnreservedBandwidth(header);
+ unreservedBandwidth.readFrom(channelBuffer);
+ unreservedBandwidth.readFrom(channelBuffer);
+ assertThat(unreservedBandwidth, is(notNullValue()));
+ }
+
+ /**
+ * Tests asBytes() method.
+ */
+ @Test
+ public void testAsBytes() throws Exception {
+ result = unreservedBandwidth.asBytes();
+ assertThat(result, is(notNullValue()));
+ }
+
+
+ /**
+ * Tests getLinkSubTypeTlvBodyAsByteArray() method.
+ */
+ @Test
+ public void testGetLinkSubTypeTLVBodyAsByteArray() throws Exception {
+ result = unreservedBandwidth.getLinkSubTypeTlvBodyAsByteArray();
+ assertThat(result, is(notNullValue()));
+ }
+}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/tlvtypes/LinkTlvTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/tlvtypes/LinkTlvTest.java
new file mode 100644
index 0000000..2387890
--- /dev/null
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/tlvtypes/LinkTlvTest.java
@@ -0,0 +1,180 @@
+/*
+ * 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.tlvtypes;
+
+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.onosproject.ospf.protocol.lsa.TlvHeader;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.*;
+
+/**
+ * Unit test class for LinkTlv.
+ */
+public class LinkTlvTest {
+
+ private final byte[] packet1 = {0, 9, 0, 4, 0, 0, 0, 1};
+ private final byte[] packet2 = {0, 1, 0, 4, 0, 0, 0, 1};
+ private final byte[] packet3 = {0, 2, 0, 4, 0, 0, 0, 1};
+ private final byte[] packet4 = {0, 3, 0, 4, 0, 0, 0, 1};
+ private final byte[] packet5 = {0, 4, 0, 4, 0, 0, 0, 1};
+ private final byte[] packet6 = {0, 6, 0, 4, 0, 0, 0, 1};
+ private final byte[] packet7 = {0, 7, 0, 4, 0, 0, 0, 1};
+ private final byte[] packet8 = {0, 8, 0, 4, 0, 0, 0, 1};
+ private final byte[] packet9 = {0, 9, 0, 4, 0, 0, 0, 1,
+ 0, 9, 0, 4, 0, 0, 0, 1,
+ 0, 1, 0, 4, 0, 0, 0, 1,
+ 0, 2, 0, 4, 0, 0, 0, 1,
+ 0, 3, 0, 4, 0, 0, 0, 1,
+ 0, 4, 0, 4, 0, 0, 0, 1,
+ 0, 6, 0, 4, 0, 0, 0, 1,
+ 0, 7, 0, 4, 0, 0, 0, 1,
+ 0, 8, 0, 4, 0, 0, 0, 1,
+ };
+ private LinkTlv linkTlv;
+ private TlvHeader header;
+ private ChannelBuffer channelBuffer;
+ private byte[] result;
+
+ @Before
+ public void setUp() throws Exception {
+ linkTlv = new LinkTlv(new TlvHeader());
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ linkTlv = null;
+ header = null;
+ channelBuffer = null;
+ result = null;
+ }
+
+ /**
+ * Tests to string method.
+ */
+ @Test
+ public void testToString() throws Exception {
+ assertThat(linkTlv.toString(), is(notNullValue()));
+ }
+
+ /**
+ * Tests readFrom() method.
+ */
+ @Test
+ public void testReadFrom() throws Exception {
+
+ header = new TlvHeader();
+ header.setTlvLength(8);
+ header.setTlvType(9);
+ linkTlv = new LinkTlv(header);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet1);
+ linkTlv.readFrom(channelBuffer);
+ assertThat(linkTlv, is(notNullValue()));
+
+ header = new TlvHeader();
+ header.setTlvLength(8);
+ header.setTlvType(1);
+ linkTlv = new LinkTlv(header);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet2);
+ linkTlv.readFrom(channelBuffer);
+ assertThat(linkTlv, is(notNullValue()));
+
+ header = new TlvHeader();
+ header.setTlvLength(8);
+ header.setTlvType(2);
+ linkTlv = new LinkTlv(header);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet3);
+ linkTlv.readFrom(channelBuffer);
+ assertThat(linkTlv, is(notNullValue()));
+
+ header = new TlvHeader();
+ header.setTlvLength(8);
+ header.setTlvType(3);
+ linkTlv = new LinkTlv(header);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet4);
+ linkTlv.readFrom(channelBuffer);
+ assertThat(linkTlv, is(notNullValue()));
+
+ header = new TlvHeader();
+ header.setTlvLength(8);
+ header.setTlvType(4);
+ linkTlv = new LinkTlv(header);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet5);
+ linkTlv.readFrom(channelBuffer);
+ assertThat(linkTlv, is(notNullValue()));
+
+ header = new TlvHeader();
+ header.setTlvLength(8);
+ header.setTlvType(5);
+ linkTlv = new LinkTlv(header);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet1);
+ linkTlv.readFrom(channelBuffer);
+ assertThat(linkTlv, is(notNullValue()));
+
+ header = new TlvHeader();
+ header.setTlvLength(8);
+ header.setTlvType(6);
+ linkTlv = new LinkTlv(header);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet6);
+ linkTlv.readFrom(channelBuffer);
+ assertThat(linkTlv, is(notNullValue()));
+
+ header = new TlvHeader();
+ header.setTlvLength(8);
+ header.setTlvType(7);
+ linkTlv = new LinkTlv(header);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet7);
+ linkTlv.readFrom(channelBuffer);
+ assertThat(linkTlv, is(notNullValue()));
+
+ header = new TlvHeader();
+ header.setTlvLength(8);
+ header.setTlvType(8);
+ linkTlv = new LinkTlv(header);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet8);
+ linkTlv.readFrom(channelBuffer);
+ assertThat(linkTlv, is(notNullValue()));
+ assertThat(linkTlv, instanceOf(LinkTlv.class));
+ }
+
+ /**
+ * Tests asBytes() method.
+ */
+ @Test
+ public void testAsBytes() throws Exception {
+ result = linkTlv.asBytes();
+ assertThat(result, is(notNullValue()));
+ }
+
+
+ /**
+ * Tests getTlvBodyAsByteArray() method.
+ */
+ @Test
+ public void testGetTlvBodyAsByteArray() throws Exception {
+
+ channelBuffer = ChannelBuffers.copiedBuffer(packet9);
+ linkTlv.readFrom(channelBuffer);
+
+ result = linkTlv.getTlvBodyAsByteArray();
+ assertThat(result, is(notNullValue()));
+ }
+}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/tlvtypes/RouterTlvTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/tlvtypes/RouterTlvTest.java
new file mode 100644
index 0000000..9a3d10e
--- /dev/null
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/tlvtypes/RouterTlvTest.java
@@ -0,0 +1,127 @@
+/*
+ * 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.tlvtypes;
+
+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.protocol.lsa.TlvHeader;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.*;
+
+/**
+ * Unit test class for RouterTlv.
+ */
+public class RouterTlvTest {
+
+ private final byte[] packet = {1, 1, 1, 1};
+ private final byte[] packet1 = {1, 1, 1};
+ private RouterTlv rtlv;
+ private TlvHeader header;
+ private ChannelBuffer channelBuffer;
+ private byte[] result;
+
+ @Before
+ public void setUp() throws Exception {
+ rtlv = new RouterTlv(new TlvHeader());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ rtlv = null;
+ header = null;
+ channelBuffer = null;
+ result = null;
+ }
+
+ /**
+ * Tests routerAddress() getter method.
+ */
+ @Test
+ public void testGetRouterAddress() throws Exception {
+ rtlv.setRouterAddress(Ip4Address.valueOf("1.1.1.1"));
+ assertThat(rtlv.routerAddress(), is(Ip4Address.valueOf("1.1.1.1")));
+ }
+
+ /**
+ * Tests routerAddress() setter method.
+ */
+ @Test
+ public void testSetRouterAddress() throws Exception {
+ rtlv.setRouterAddress(Ip4Address.valueOf("1.1.1.1"));
+ assertThat(rtlv.routerAddress(), is(Ip4Address.valueOf("1.1.1.1")));
+ }
+
+ /**
+ * Tests readFrom() method.
+ */
+ @Test
+ public void testReadFrom() throws Exception {
+ header = new TlvHeader();
+ header.setTlvType(1);
+ header.setTlvLength(4);
+ rtlv = new RouterTlv(header);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet);
+ rtlv.readFrom(channelBuffer);
+ assertThat(rtlv, is(notNullValue()));
+ assertThat(rtlv, instanceOf(RouterTlv.class));
+ }
+
+ /**
+ * Tests readFrom() method.
+ */
+ @Test(expected = Exception.class)
+ public void testReadFrom1() throws Exception {
+ header = new TlvHeader();
+ header.setTlvType(1);
+ header.setTlvLength(4);
+ rtlv = new RouterTlv(header);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet1);
+ rtlv.readFrom(channelBuffer);
+ assertThat(rtlv, is(notNullValue()));
+ assertThat(rtlv, instanceOf(RouterTlv.class));
+ }
+
+ /**
+ * Tests asBytes() method.
+ */
+ @Test(expected = Exception.class)
+ public void testAsBytes() throws Exception {
+ result = rtlv.asBytes();
+ assertThat(result, is(notNullValue()));
+ }
+
+ /**
+ * Tests getTlvBodyAsByteArray() method.
+ */
+ @Test(expected = Exception.class)
+ public void testGetTLVBodyAsByteArray() throws Exception {
+ result = rtlv.getTlvBodyAsByteArray();
+ assertThat(result, is(notNullValue()));
+ }
+
+ /**
+ * Tests to string method.
+ */
+ @Test
+ public void testToString() throws Exception {
+ assertThat(rtlv.toString(), is(notNullValue()));
+ }
+}