ONOS-4083,ONOS-4084:JUNIT for ISIS PDU TLV Data Structures
Change-Id: I0849d87ad1c7f9a8e08aabebd547dfd2dfde49df
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/AdministrativeGroupTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/AdministrativeGroupTest.java
new file mode 100644
index 0000000..37179de
--- /dev/null
+++ b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/AdministrativeGroupTest.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2016-present 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.isis.io.isispacket.tlv.subtlv;
+
+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.isis.io.isispacket.tlv.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.tlvBodyAsBytes();
+ 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/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/InterfaceIpAddressTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/InterfaceIpAddressTest.java
new file mode 100644
index 0000000..5acb728
--- /dev/null
+++ b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/InterfaceIpAddressTest.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2016-present 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.isis.io.isispacket.tlv.subtlv;
+
+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.isis.io.isispacket.tlv.TlvHeader;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+
+/**
+ * Unit test class for InterfaceIpAddress.
+ */
+public class InterfaceIpAddressTest {
+ private final byte[] packet = {1, 1, 1, 1};
+ private final byte[] packet1 = {};
+ private InterfaceIpAddress interfaceIpAddress;
+ private TlvHeader tlvHeader;
+ private Ip4Address ip4Address = Ip4Address.valueOf("1.1.1.1");
+ private byte[] result;
+ private ChannelBuffer channelBuffer;
+
+ @Before
+ public void setUp() throws Exception {
+ interfaceIpAddress = new InterfaceIpAddress(new TlvHeader());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ interfaceIpAddress = null;
+ tlvHeader = null;
+ result = null;
+ channelBuffer = null;
+ }
+
+ /**
+ * Tests to string method.
+ */
+ @Test
+ public void testToString() throws Exception {
+ assertThat(interfaceIpAddress.toString(), is(notNullValue()));
+ }
+
+ /**
+ * Tests addLocalInterfaceIPAddress() method.
+ */
+ @Test
+ public void testAddLocalInterfaceIPAddress() throws Exception {
+ interfaceIpAddress.addLocalInterfaceIPAddress(ip4Address);
+ assertThat(interfaceIpAddress, is(notNullValue()));
+ }
+
+ /**
+ * Tests readFrom() method.
+ */
+ @Test
+ public void testReadFrom() {
+ tlvHeader = new TlvHeader();
+ tlvHeader.setTlvType(3);
+ tlvHeader.setTlvLength(4);
+ interfaceIpAddress = new InterfaceIpAddress(tlvHeader);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet);
+ interfaceIpAddress.readFrom(channelBuffer);
+ assertThat(interfaceIpAddress, is(notNullValue()));
+ }
+
+ /**
+ * Tests readFrom() method.
+ */
+ @Test
+ public void testReadFrom1() throws Exception {
+ tlvHeader = new TlvHeader();
+ tlvHeader.setTlvType(3);
+ tlvHeader.setTlvLength(4);
+ interfaceIpAddress = new InterfaceIpAddress(tlvHeader);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet1);
+ interfaceIpAddress.readFrom(channelBuffer);
+ assertThat(interfaceIpAddress, is(notNullValue()));
+ }
+
+ /**
+ * Tests asBytes() method.
+ */
+ @Test
+ public void testAsBytes() throws Exception {
+ result = interfaceIpAddress.asBytes();
+ assertThat(result, is(notNullValue()));
+ }
+
+ /**
+ * Tests getLinkSubTypeTlvBodyAsByteArray() method.
+ */
+ @Test
+ public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception {
+ result = interfaceIpAddress.tlvBodyAsBytes();
+ assertThat(result, is(notNullValue()));
+ }
+}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/MaximumBandwidthTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/MaximumBandwidthTest.java
new file mode 100644
index 0000000..32caade
--- /dev/null
+++ b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/MaximumBandwidthTest.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2016-present 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.isis.io.isispacket.tlv.subtlv;
+
+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.isis.io.isispacket.tlv.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/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/MaximumReservableBandwidthTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/MaximumReservableBandwidthTest.java
new file mode 100644
index 0000000..4fd2594
--- /dev/null
+++ b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/MaximumReservableBandwidthTest.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2016-present 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.isis.io.isispacket.tlv.subtlv;
+
+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.isis.io.isispacket.tlv.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.tlvBodyAsBytes();
+ assertThat(result, is(notNullValue()));
+ }
+
+ /**
+ * Tests to string method.
+ */
+ @Test
+ public void testToString() throws Exception {
+ assertThat(maximumReservableBandwidth.toString(), is(notNullValue()));
+ }
+}
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvFinderTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvFinderTest.java
new file mode 100644
index 0000000..6ad0f46
--- /dev/null
+++ b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvFinderTest.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2016-present 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.isis.io.isispacket.tlv.subtlv;
+
+import org.easymock.EasyMock;
+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.isis.io.isispacket.tlv.TlvHeader;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+
+/**
+ * Unit test class for SubTlvFinder.
+ */
+public class SubTlvFinderTest {
+ private final byte[] packet1 = {0, 0, 0, 1};
+ private TlvHeader tlvHeader;
+ private ChannelBuffer channelBuffer;
+ private TrafficEngineeringSubTlv tlv;
+
+ @Before
+ public void setUp() throws Exception {
+ tlvHeader = new TlvHeader();
+ channelBuffer = EasyMock.createMock(ChannelBuffer.class);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ tlvHeader = null;
+ channelBuffer = null;
+ }
+
+ @Test
+ public void testFindSubTlv() throws Exception {
+
+ tlvHeader.setTlvLength(4);
+ tlvHeader.setTlvType(SubTlvType.ADMINISTRATIVEGROUP.value());
+ AdministrativeGroup administrativeGroup = new AdministrativeGroup(tlvHeader);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet1);
+ tlv = SubTlvFinder.findSubTlv(tlvHeader, channelBuffer);
+ assertThat(tlv, is(notNullValue()));
+
+ tlvHeader = new TlvHeader();
+ tlvHeader.setTlvLength(4);
+ tlvHeader.setTlvType(SubTlvType.TRAFFICENGINEERINGMETRIC.value());
+ TrafficEngineeringMetric trafficEngineeringMetric = new TrafficEngineeringMetric(tlvHeader);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet1);
+ tlv = SubTlvFinder.findSubTlv(tlvHeader, channelBuffer);
+ assertThat(tlv, is(notNullValue()));
+
+ tlvHeader = new TlvHeader();
+ tlvHeader.setTlvLength(4);
+ tlvHeader.setTlvType(SubTlvType.MAXIMUMBANDWIDTH.value());
+ MaximumBandwidth maximumBandwidth = new MaximumBandwidth(tlvHeader);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet1);
+ tlv = SubTlvFinder.findSubTlv(tlvHeader, channelBuffer);
+ assertThat(tlv, is(notNullValue()));
+
+ tlvHeader = new TlvHeader();
+ tlvHeader.setTlvLength(4);
+ tlvHeader.setTlvType(SubTlvType.MAXIMUMRESERVABLEBANDWIDTH.value());
+ MaximumReservableBandwidth maximumReservableBandwidth = new MaximumReservableBandwidth(tlvHeader);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet1);
+ tlv = SubTlvFinder.findSubTlv(tlvHeader, channelBuffer);
+ assertThat(tlv, is(notNullValue()));
+
+ tlvHeader = new TlvHeader();
+ tlvHeader.setTlvLength(4);
+ tlvHeader.setTlvType(SubTlvType.UNRESERVEDBANDWIDTH.value());
+ UnreservedBandwidth unreservedBandwidth = new UnreservedBandwidth(tlvHeader);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet1);
+ tlv = SubTlvFinder.findSubTlv(tlvHeader, channelBuffer);
+ assertThat(tlv, is(notNullValue()));
+
+ tlvHeader = new TlvHeader();
+ tlvHeader.setTlvLength(4);
+ tlvHeader.setTlvType(SubTlvType.INTERFACEADDRESS.value());
+ InterfaceIpAddress ipInterfaceAddressTlv = new InterfaceIpAddress(tlvHeader);
+ channelBuffer = ChannelBuffers.copiedBuffer(packet1);
+ tlv = SubTlvFinder.findSubTlv(tlvHeader, channelBuffer);
+ assertThat(tlv, is(notNullValue()));
+ }
+}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvToBytesTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvToBytesTest.java
new file mode 100644
index 0000000..f6f2ac8
--- /dev/null
+++ b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvToBytesTest.java
@@ -0,0 +1,72 @@
+package org.onosproject.isis.io.isispacket.tlv.subtlv;
+
+import org.easymock.EasyMock;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
+
+import java.util.List;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+
+/**
+ * Unit test class for SubTlvToBytes.
+ */
+public class SubTlvToBytesTest {
+ private TlvHeader tlvHeader;
+ private ChannelBuffer channelBuffer;
+ private List<Byte> tlv;
+
+ @Before
+ public void setUp() throws Exception {
+ tlvHeader = new TlvHeader();
+ channelBuffer = EasyMock.createMock(ChannelBuffer.class);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ tlvHeader = null;
+ channelBuffer = null;
+ }
+
+ @Test
+ public void testTlvToBytes() throws Exception {
+ tlvHeader.setTlvLength(4);
+ tlvHeader.setTlvType(9);
+ AdministrativeGroup administrativeGroup = new AdministrativeGroup(tlvHeader);
+ tlv = SubTlvToBytes.tlvToBytes(administrativeGroup);
+ assertThat(tlv, is(notNullValue()));
+
+ tlvHeader = new TlvHeader();
+ tlvHeader.setTlvLength(4);
+ tlvHeader.setTlvType(5);
+ TrafficEngineeringMetric trafficEngineeringMetric = new TrafficEngineeringMetric(tlvHeader);
+ tlv = SubTlvToBytes.tlvToBytes(trafficEngineeringMetric);
+ assertThat(tlv, is(notNullValue()));
+
+ tlvHeader = new TlvHeader();
+ tlvHeader.setTlvLength(4);
+ tlvHeader.setTlvType(6);
+ MaximumBandwidth maximumBandwidth = new MaximumBandwidth(tlvHeader);
+ tlv = SubTlvToBytes.tlvToBytes(maximumBandwidth);
+ assertThat(tlv, is(notNullValue()));
+
+ tlvHeader = new TlvHeader();
+ tlvHeader.setTlvLength(4);
+ tlvHeader.setTlvType(7);
+ MaximumReservableBandwidth maximumReservableBandwidth = new MaximumReservableBandwidth(tlvHeader);
+ tlv = SubTlvToBytes.tlvToBytes(maximumReservableBandwidth);
+ assertThat(tlv, is(notNullValue()));
+
+ tlvHeader = new TlvHeader();
+ tlvHeader.setTlvLength(4);
+ tlvHeader.setTlvType(8);
+ UnreservedBandwidth unreservedBandwidth = new UnreservedBandwidth(tlvHeader);
+ tlv = SubTlvToBytes.tlvToBytes(unreservedBandwidth);
+ assertThat(tlv, is(notNullValue()));
+ }
+}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/TrafficEngineeringMetricTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/TrafficEngineeringMetricTest.java
new file mode 100644
index 0000000..0d7ff0c
--- /dev/null
+++ b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/TrafficEngineeringMetricTest.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2016-present 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.isis.io.isispacket.tlv.subtlv;
+
+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 static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
+
+/**
+ * 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.tlvBodyAsBytes();
+ 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/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/UnreservedBandwidthTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/UnreservedBandwidthTest.java
new file mode 100644
index 0000000..50c4c46
--- /dev/null
+++ b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/UnreservedBandwidthTest.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2016-present 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.isis.io.isispacket.tlv.subtlv;
+
+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.isis.io.isispacket.tlv.TlvHeader;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+
+/**
+ * Unit test class for UnreservedBandwidth.
+ */
+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.asBytes();
+ assertThat(result, is(notNullValue()));
+ }
+}
\ No newline at end of file