ONOS-4086 to ONOS-4091, ONOS-4098 to ONOS-4100:JUNIT for ISIS controller
Change-Id: If3501a55fcbf994cd69facfd97f43b4a4f0f7812
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisNeighbor.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisNeighbor.java
index 3180c5d..7fac0cb 100755
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisNeighbor.java
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisNeighbor.java
@@ -45,7 +45,8 @@
private String neighborSystemId;
private Ip4Address interfaceIp;
private MacAddress neighborMacAddress;
- private int holdingTime;
+ private volatile int holdingTime;
+ private int neighborDownInterval;
private IsisRouterType routerType;
private String l1LanId;
private String l2LanId;
@@ -54,6 +55,8 @@
private IsisInterfaceState neighborState = IsisInterfaceState.INITIAL;
private InternalInactivityTimeCheck inActivityTimeCheckTask;
private ScheduledExecutorService exServiceInActivity;
+ private InternalHoldingTimeCheck holdingTimeCheckTask;
+ private ScheduledExecutorService exServiceHoldingTimeCheck;
private boolean inActivityTimerScheduled = false;
private IsisInterface isisInterface;
@@ -72,6 +75,7 @@
this.interfaceIp = (helloMessage.interfaceIpAddresses() != null) ?
interfaceIpAddresses.get(0) : IsisConstants.DEFAULTIP;
this.holdingTime = helloMessage.holdingTime();
+ neighborDownInterval = holdingTime;
this.routerType = IsisRouterType.get(helloMessage.circuitType());
if (helloMessage instanceof L1L2HelloPdu) {
if (IsisPduType.L1HELLOPDU == helloMessage.isisPduType()) {
@@ -83,6 +87,7 @@
this.localCircuitId = ((P2PHelloPdu) helloMessage).localCircuitId();
}
this.isisInterface = isisInterface;
+ startHoldingTimeCheck();
}
/**
@@ -244,7 +249,7 @@
* @param l2LanId L2 lan ID
*/
public void setL2LanId(String l2LanId) {
- this.l1LanId = l1LanId;
+ this.l2LanId = l2LanId;
}
/**
@@ -293,6 +298,25 @@
}
/**
+ * Starts the holding time check timer.
+ */
+ public void startHoldingTimeCheck() {
+ log.debug("IsisNeighbor::startHoldingTimeCheck");
+ holdingTimeCheckTask = new InternalHoldingTimeCheck();
+ exServiceHoldingTimeCheck = Executors.newSingleThreadScheduledExecutor();
+ exServiceHoldingTimeCheck.scheduleAtFixedRate(holdingTimeCheckTask, 1,
+ 1, TimeUnit.SECONDS);
+ }
+
+ /**
+ * Stops the holding time check timer.
+ */
+ public void stopHoldingTimeCheck() {
+ log.debug("IsisNeighbor::stopHoldingTimeCheck ");
+ exServiceHoldingTimeCheck.shutdown();
+ }
+
+ /**
* Starts the inactivity timer.
*/
public void startInactivityTimeCheck() {
@@ -300,8 +324,8 @@
log.debug("IsisNeighbor::startInactivityTimeCheck");
inActivityTimeCheckTask = new InternalInactivityTimeCheck();
exServiceInActivity = Executors.newSingleThreadScheduledExecutor();
- exServiceInActivity.scheduleAtFixedRate(inActivityTimeCheckTask, holdingTime,
- holdingTime, TimeUnit.SECONDS);
+ exServiceInActivity.scheduleAtFixedRate(inActivityTimeCheckTask, neighborDownInterval,
+ neighborDownInterval, TimeUnit.SECONDS);
inActivityTimerScheduled = true;
}
}
@@ -328,6 +352,8 @@
isisInterface.setL2LanId(IsisConstants.DEFAULTLANID);
neighborState = IsisInterfaceState.DOWN;
+ stopInactivityTimeCheck();
+ stopHoldingTimeCheck();
isisInterface.removeNeighbor(this);
}
@@ -347,4 +373,20 @@
neighborDown();
}
}
+
+ /**
+ * Represents a Task which will decrement holding time for this neighbor.
+ */
+ private class InternalHoldingTimeCheck implements Runnable {
+ /**
+ * Creates an instance.
+ */
+ InternalHoldingTimeCheck() {
+ }
+
+ @Override
+ public void run() {
+ holdingTime--;
+ }
+ }
}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdb.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdb.java
index 33a0a17..8a58269 100755
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdb.java
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdb.java
@@ -15,6 +15,7 @@
*/
package org.onosproject.isis.controller.impl.lsdb;
+import org.jboss.netty.buffer.ChannelBuffers;
import org.onosproject.isis.controller.IsisInterface;
import org.onosproject.isis.controller.IsisLsdb;
import org.onosproject.isis.controller.IsisLsdbAge;
@@ -24,6 +25,7 @@
import org.onosproject.isis.controller.LspWrapper;
import org.onosproject.isis.io.isispacket.pdu.LsPdu;
import org.onosproject.isis.io.util.IsisConstants;
+import org.onosproject.isis.io.util.IsisUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -41,6 +43,9 @@
private Map<String, LspWrapper> isisL1Db = new ConcurrentHashMap<>();
private Map<String, LspWrapper> isisL2Db = new ConcurrentHashMap<>();
private IsisLsdbAge lsdbAge = null;
+
+
+
private int l1LspSeqNo = IsisConstants.STARTLSSEQUENCENUM;
private int l2LspSeqNo = IsisConstants.STARTLSSEQUENCENUM;
@@ -59,6 +64,23 @@
}
/**
+ * Sets the level 1 link state sequence number.
+ *
+ * @param l1LspSeqNo link state sequence number
+ */
+ public void setL1LspSeqNo(int l1LspSeqNo) {
+ this.l1LspSeqNo = l1LspSeqNo;
+ }
+
+ /**
+ * Sets the level 2 link state sequence number.
+ *
+ * @param l2LspSeqNo link state sequence number
+ */
+ public void setL2LspSeqNo(int l2LspSeqNo) {
+ this.l2LspSeqNo = l2LspSeqNo;
+ }
+ /**
* Returns the LSDB LSP key.
*
* @param systemId system ID
@@ -108,7 +130,7 @@
* @return List of LSPs
*/
public List<LspWrapper> allLspHeaders(boolean excludeMaxAgeLsp) {
- List<LspWrapper> summaryList = new CopyOnWriteArrayList();
+ List<LspWrapper> summaryList = new CopyOnWriteArrayList<>();
addLspToHeaderList(summaryList, excludeMaxAgeLsp, isisL1Db);
addLspToHeaderList(summaryList, excludeMaxAgeLsp, isisL2Db);
@@ -187,9 +209,17 @@
*/
public boolean addLsp(IsisMessage isisMessage, boolean isSelfOriginated, IsisInterface isisInterface) {
LsPdu lspdu = (LsPdu) isisMessage;
+ if (isSelfOriginated) {
+ //Add length and checksum
+ byte[] lspBytes = lspdu.asBytes();
+ lspdu.setPduLength(lspBytes.length);
+ lspBytes = IsisUtil.addChecksum(lspBytes, IsisConstants.CHECKSUMPOSITION,
+ IsisConstants.CHECKSUMPOSITION + 1);
+ byte[] checkSum = {lspBytes[IsisConstants.CHECKSUMPOSITION], lspBytes[IsisConstants.CHECKSUMPOSITION + 1]};
+ lspdu.setCheckSum(ChannelBuffers.copiedBuffer(checkSum).readUnsignedShort());
+ }
DefaultLspWrapper lspWrapper = new DefaultLspWrapper();
lspWrapper.setLspAgeReceived(IsisConstants.LSPMAXAGE - lspdu.remainingLifeTime());
- lspWrapper.setRemainingLifetime(IsisConstants.LSPMAXAGE - lsdbAge.ageCounter());
lspWrapper.setLspType(IsisPduType.get(lspdu.pduType()));
lspWrapper.setLsPdu(lspdu);
lspWrapper.setAgeCounterWhenReceived(lsdbAge.ageCounter());
@@ -198,7 +228,6 @@
lspWrapper.setIsisInterface(isisInterface);
lspWrapper.setLsdbAge(lsdbAge);
addLsp(lspWrapper, lspdu.lspId());
-
log.debug("Added LSp In LSDB: {}", lspWrapper);
return true;
@@ -217,9 +246,11 @@
switch (lspWrapper.lsPdu().isisPduType()) {
case L1LSPDU:
+ isisL1Db.remove(key);
isisL1Db.put(key, lspWrapper);
break;
case L2LSPDU:
+ isisL2Db.remove(key);
isisL2Db.put(key, lspWrapper);
break;
default:
@@ -228,7 +259,7 @@
}
//add it to bin
- Integer binNumber = lsdbAge.age2Bin(IsisConstants.LSPMAXAGE - lspWrapper.remainingLifetime());
+ Integer binNumber = lsdbAge.age2Bin(IsisConstants.LSPMAXAGE - lspWrapper.lspAgeReceived());
IsisLspBin lspBin = lsdbAge.getLspBin(binNumber);
if (lspBin != null) {
//remove from existing
@@ -264,7 +295,8 @@
public String isNewerOrSameLsp(IsisMessage lsp1, IsisMessage lsp2) {
LsPdu receivedLsp = (LsPdu) lsp1;
LsPdu lspFromDb = (LsPdu) lsp2;
- if (receivedLsp.sequenceNumber() > lspFromDb.sequenceNumber()) {
+ if (receivedLsp.sequenceNumber() > lspFromDb.sequenceNumber() ||
+ receivedLsp.checkSum() != lspFromDb.checkSum()) {
return "latest";
} else if (receivedLsp.sequenceNumber() < lspFromDb.sequenceNumber()) {
return "old";
@@ -312,4 +344,4 @@
break;
}
}
-}
\ No newline at end of file
+}
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/ControllerTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/ControllerTest.java
new file mode 100644
index 0000000..9a41bd3
--- /dev/null
+++ b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/ControllerTest.java
@@ -0,0 +1,61 @@
+/*
+ * 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.controller.impl;
+
+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.junit.Assert.assertThat;
+
+/**
+ * Unit test class for ControllerTest.
+ */
+public class ControllerTest {
+
+ private Controller controller;
+
+ @Before
+ public void setUp() throws Exception {
+ controller = new Controller();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ controller = null;
+ }
+
+ /**
+ * Tests isisDeactivate() method.
+ */
+ @Test(expected = Exception.class)
+ public void testIsisDeactivate() throws Exception {
+ controller.isisDeactivate();
+ assertThat(controller, is(notNullValue()));
+ }
+
+ /**
+ * Tests getAllConfiguredProcesses() method.
+ */
+ @Test
+ public void testGetAllConfiguredProcesses() throws Exception {
+ controller.getAllConfiguredProcesses();
+ assertThat(controller, is(notNullValue()));
+ }
+}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisControllerTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisControllerTest.java
new file mode 100644
index 0000000..915727d
--- /dev/null
+++ b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisControllerTest.java
@@ -0,0 +1,69 @@
+/*
+ * 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.controller.impl;
+
+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.junit.Assert.assertThat;
+
+/**
+ * Unit test case for DefaultIsisController.
+ */
+public class DefaultIsisControllerTest {
+ private DefaultIsisController defaultIsisController;
+
+ @Before
+ public void setUp() throws Exception {
+ defaultIsisController = new DefaultIsisController();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ defaultIsisController = null;
+ }
+
+ /**
+ * Tests activate() method.
+ */
+ @Test
+ public void testActivate() throws Exception {
+ defaultIsisController.activate();
+ assertThat(defaultIsisController, is(notNullValue()));
+ }
+
+ /**
+ * Tests deactivate() method.
+ */
+ @Test(expected = Exception.class)
+ public void testDeactivate() throws Exception {
+ defaultIsisController.activate();
+ defaultIsisController.deactivate();
+ assertThat(defaultIsisController, is(notNullValue()));
+ }
+
+ /**
+ * Tests allConfiguredProcesses() method.
+ */
+ @Test
+ public void testAllConfiguredProcesses() throws Exception {
+ defaultIsisController.allConfiguredProcesses();
+ assertThat(defaultIsisController, is(notNullValue()));
+ }
+}
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisInterfaceTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisInterfaceTest.java
new file mode 100644
index 0000000..7e7749f
--- /dev/null
+++ b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisInterfaceTest.java
@@ -0,0 +1,486 @@
+/*
+ * 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.controller.impl;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.Ip4Address;
+import org.onlab.packet.MacAddress;
+import org.onosproject.isis.controller.IsisInterface;
+import org.onosproject.isis.controller.IsisInterfaceState;
+import org.onosproject.isis.controller.IsisLsdb;
+import org.onosproject.isis.controller.IsisNeighbor;
+import org.onosproject.isis.controller.IsisNetworkType;
+import org.onosproject.isis.io.isispacket.IsisHeader;
+import org.onosproject.isis.io.isispacket.pdu.HelloPdu;
+import org.onosproject.isis.io.isispacket.pdu.L1L2HelloPdu;
+
+import java.util.Set;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Unit test case for DefaultIsisInterface.
+ */
+public class DefaultIsisInterfaceTest {
+ private final MacAddress macAddress = MacAddress.valueOf("AA:BB:CC:DD:EE:FF");
+ private final Ip4Address ip4Address = Ip4Address.valueOf("10.10.10.10");
+ private final byte[] mask = {
+ (byte) 255, (byte) 255, (byte) 255, (byte) 224
+ };
+ private final String intSysName = "ROUTER";
+ private final String sysId = "1111.1111.1111";
+ private final String areaAddr = "49.002";
+ private IsisInterfaceState resultIfState;
+ private DefaultIsisInterface defaultIsisInterface;
+ private HelloPdu helloPdu;
+ private IsisHeader isisHeader;
+ private IsisInterface isisInterface;
+ private Set<MacAddress> resultSet;
+ private int resultInt;
+ private IsisLsdb resultLsdb;
+ private IsisNeighbor resultNeighborList;
+ private Ip4Address resultIPv4Addr;
+ private MacAddress resultMacAddr;
+ private byte[] resultByteArr;
+ private String resultStr;
+ private IsisNetworkType resultNwType;
+
+
+ @Before
+ public void setUp() throws Exception {
+ defaultIsisInterface = new DefaultIsisInterface();
+ isisHeader = new IsisHeader();
+ isisHeader.setIrpDiscriminator((byte) 1);
+ helloPdu = new L1L2HelloPdu(isisHeader);
+ isisInterface = new DefaultIsisInterface();
+ resultNeighborList = new DefaultIsisNeighbor(helloPdu, isisInterface);
+
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ defaultIsisInterface = null;
+ helloPdu = null;
+ isisInterface = null;
+ resultNeighborList = null;
+ }
+
+ /**
+ * Tests interfaceIndex() getter method.
+ */
+ @Test
+ public void testInterfaceIndex() throws Exception {
+ defaultIsisInterface.setInterfaceIndex(2);
+ resultInt = defaultIsisInterface.interfaceIndex();
+ assertThat(resultInt, is(2));
+ }
+
+ /**
+ * Tests interfaceIndex() setter method.
+ */
+ @Test
+ public void testSetInterfaceIndex() throws Exception {
+ defaultIsisInterface.setInterfaceIndex(2);
+ resultInt = defaultIsisInterface.interfaceIndex();
+ assertThat(resultInt, is(2));
+
+ }
+
+ /**
+ * Tests interfaceIpAddress() getter method.
+ */
+ @Test
+ public void testInterfaceIpAddress() throws Exception {
+ defaultIsisInterface.setInterfaceIpAddress(ip4Address);
+ resultIPv4Addr = defaultIsisInterface.interfaceIpAddress();
+ assertThat(resultIPv4Addr, is(ip4Address));
+ }
+
+ /**
+ * Tests interfaceIpAddress() setter method.
+ */
+ @Test
+ public void testSetInterfaceIpAddress() throws Exception {
+ defaultIsisInterface.setInterfaceIpAddress(ip4Address);
+ resultIPv4Addr = defaultIsisInterface.interfaceIpAddress();
+ assertThat(resultIPv4Addr, is(ip4Address));
+ }
+
+ /**
+ * Tests networkMask() getter method.
+ */
+ @Test
+ public void testNetworkMask() throws Exception {
+ defaultIsisInterface.setNetworkMask(mask);
+ resultByteArr = defaultIsisInterface.networkMask();
+ assertThat(resultByteArr, is(mask));
+ }
+
+ /**
+ * Tests networkMask() setter method.
+ */
+ @Test
+ public void testSetNetworkMask() throws Exception {
+ defaultIsisInterface.setNetworkMask(mask);
+ resultByteArr = defaultIsisInterface.networkMask();
+ assertThat(resultByteArr, is(mask));
+ }
+
+ /**
+ * Tests getInterfaceMacAddress() getter method.
+ */
+ @Test
+ public void testGetInterfaceMacAddress() throws Exception {
+ defaultIsisInterface.setInterfaceMacAddress(macAddress);
+ resultMacAddr = defaultIsisInterface.getInterfaceMacAddress();
+ assertThat(resultMacAddr, is(macAddress));
+ }
+
+ /**
+ * Tests getInterfaceMacAddress() setter method.
+ */
+ @Test
+ public void testSetInterfaceMacAddress() throws Exception {
+ defaultIsisInterface.setInterfaceMacAddress(macAddress);
+ resultMacAddr = defaultIsisInterface.getInterfaceMacAddress();
+ assertThat(resultMacAddr, is(macAddress));
+ }
+
+ /**
+ * Tests intermediateSystemName() getter method.
+ */
+ @Test
+ public void testIntermediateSystemName() throws Exception {
+ defaultIsisInterface.setIntermediateSystemName(intSysName);
+ resultStr = defaultIsisInterface.intermediateSystemName();
+ assertThat(resultStr, is(intSysName));
+ }
+
+ /**
+ * Tests intermediateSystemName() setter method.
+ */
+ @Test
+ public void testSetIntermediateSystemName() throws Exception {
+ defaultIsisInterface.setIntermediateSystemName(intSysName);
+ resultStr = defaultIsisInterface.intermediateSystemName();
+ assertThat(resultStr, is(intSysName));
+ }
+
+ /**
+ * Tests systemId() getter method.
+ */
+ @Test
+ public void testSystemId() throws Exception {
+ defaultIsisInterface.setSystemId(sysId);
+ resultStr = defaultIsisInterface.systemId();
+ assertThat(resultStr, is(sysId));
+ }
+
+ /**
+ * Tests systemId() setter method.
+ */
+ @Test
+ public void testSetSystemId() throws Exception {
+ defaultIsisInterface.setSystemId(sysId);
+ resultStr = defaultIsisInterface.systemId();
+ assertThat(resultStr, is(sysId));
+ }
+
+ /**
+ * Tests l1LanId() getter method.
+ */
+ @Test
+ public void testL1LanId() throws Exception {
+ defaultIsisInterface.setL1LanId(sysId);
+ resultStr = defaultIsisInterface.l1LanId();
+ assertThat(resultStr, is(sysId));
+ }
+
+ /**
+ * Tests l1LanId() setter method.
+ */
+ @Test
+ public void testSetL1LanId() throws Exception {
+ defaultIsisInterface.setL1LanId(sysId);
+ resultStr = defaultIsisInterface.l1LanId();
+ assertThat(resultStr, is(sysId));
+ }
+
+ /**
+ * Tests l2LanId() getter method.
+ */
+ @Test
+ public void testL2LanId() throws Exception {
+ defaultIsisInterface.setL2LanId(sysId);
+ resultStr = defaultIsisInterface.l2LanId();
+ assertThat(resultStr, is(sysId));
+ }
+
+ /**
+ * Tests l2LanId() setter method.
+ */
+ @Test
+ public void testSetL2LanId() throws Exception {
+ defaultIsisInterface.setL2LanId(sysId);
+ resultStr = defaultIsisInterface.l2LanId();
+ assertThat(resultStr, is(sysId));
+ }
+
+ /**
+ * Tests getIdLength() getter method.
+ */
+ @Test
+ public void testGetIdLength() throws Exception {
+ defaultIsisInterface.setIdLength(8);
+ resultInt = defaultIsisInterface.getIdLength();
+ assertThat(resultInt, is(8));
+ }
+
+ /**
+ * Tests getIdLength() setter method.
+ */
+ @Test
+ public void testSetIdLength() throws Exception {
+ defaultIsisInterface.setIdLength(8);
+ resultInt = defaultIsisInterface.getIdLength();
+ assertThat(resultInt, is(8));
+ }
+
+ /**
+ * Tests getMaxAreaAddresses() getter method.
+ */
+ @Test
+ public void testGetMaxAreaAddresses() throws Exception {
+ defaultIsisInterface.setMaxAreaAddresses(3);
+ resultInt = defaultIsisInterface.getMaxAreaAddresses();
+ assertThat(resultInt, is(3));
+ }
+
+ /**
+ * Tests getMaxAreaAddresses() setter method.
+ */
+ @Test
+ public void testSetMaxAreaAddresses() throws Exception {
+ defaultIsisInterface.setMaxAreaAddresses(3);
+ resultInt = defaultIsisInterface.getMaxAreaAddresses();
+ assertThat(resultInt, is(3));
+ }
+
+ /**
+ * Tests setReservedPacketCircuitType() getter method.
+ */
+ @Test
+ public void testReservedPacketCircuitType() throws Exception {
+ defaultIsisInterface.setReservedPacketCircuitType(1);
+ resultInt = defaultIsisInterface.reservedPacketCircuitType();
+ assertThat(resultInt, is(1));
+ }
+
+ /**
+ * Tests setReservedPacketCircuitType() setter method.
+ */
+ @Test
+ public void testSetReservedPacketCircuitType() throws Exception {
+ defaultIsisInterface.setReservedPacketCircuitType(1);
+ resultInt = defaultIsisInterface.reservedPacketCircuitType();
+ assertThat(resultInt, is(1));
+ }
+
+ /**
+ * Tests networkType() getter method.
+ */
+ @Test
+ public void testNetworkType() throws Exception {
+ defaultIsisInterface.setNetworkType(IsisNetworkType.BROADCAST);
+ resultNwType = defaultIsisInterface.networkType();
+ assertThat(resultNwType, is(IsisNetworkType.BROADCAST));
+ }
+
+ /**
+ * Tests networkType() setter method.
+ */
+ @Test
+ public void testSetNetworkType() throws Exception {
+ defaultIsisInterface.setNetworkType(IsisNetworkType.BROADCAST);
+ resultNwType = defaultIsisInterface.networkType();
+ assertThat(resultNwType, is(IsisNetworkType.BROADCAST));
+ }
+
+ /**
+ * Tests areaAddress() getter method.
+ */
+ @Test
+ public void testAreaAddress() throws Exception {
+ defaultIsisInterface.setAreaAddress(areaAddr);
+ resultStr = defaultIsisInterface.areaAddress();
+ assertThat(resultStr, is(areaAddr));
+ }
+
+ /**
+ * Tests areaAddress() setter method.
+ */
+ @Test
+ public void testSetAreaAddress() throws Exception {
+ defaultIsisInterface.setAreaAddress(areaAddr);
+ resultStr = defaultIsisInterface.areaAddress();
+ assertThat(resultStr, is(areaAddr));
+ }
+
+ /**
+ * Tests getAreaLength() getter method.
+ */
+
+ @Test
+ public void testGetAreaLength() throws Exception {
+ defaultIsisInterface.setAreaLength(3);
+ resultInt = defaultIsisInterface.getAreaLength();
+ assertThat(resultInt, is(3));
+ }
+
+ /**
+ * Tests getAreaLength() setter method.
+ */
+ @Test
+ public void testSetAreaLength() throws Exception {
+ defaultIsisInterface.setAreaLength(3);
+ resultInt = defaultIsisInterface.getAreaLength();
+ assertThat(resultInt, is(3));
+ }
+
+ /**
+ * Tests getLspId() getter method.
+ */
+ @Test
+ public void testGetLspId() throws Exception {
+ defaultIsisInterface.setLspId(sysId);
+ resultStr = defaultIsisInterface.getLspId();
+ assertThat(resultStr, is(sysId));
+ }
+
+ /**
+ * Tests getLspId() setter method.
+ */
+ @Test
+ public void testSetLspId() throws Exception {
+ defaultIsisInterface.setLspId(sysId);
+ resultStr = defaultIsisInterface.getLspId();
+ assertThat(resultStr, is(sysId));
+ }
+
+ /**
+ * Tests holdingTime() getter method.
+ */
+ @Test
+ public void testHoldingTime() throws Exception {
+ defaultIsisInterface.setHoldingTime(10);
+ resultInt = defaultIsisInterface.holdingTime();
+ assertThat(resultInt, is(10));
+ }
+
+ /**
+ * Tests holdingTime() setter method.
+ */
+ @Test
+ public void testSetHoldingTime() throws Exception {
+ defaultIsisInterface.setHoldingTime(10);
+ resultInt = defaultIsisInterface.holdingTime();
+ assertThat(resultInt, is(10));
+ }
+
+ /**
+ * Tests priority() getter method.
+ */
+ @Test
+ public void testPriority() throws Exception {
+ defaultIsisInterface.setPriority(1);
+ resultInt = defaultIsisInterface.priority();
+ assertThat(resultInt, is(1));
+ }
+
+ /**
+ * Tests priority() setter method.
+ */
+ @Test
+ public void testSetPriority() throws Exception {
+ defaultIsisInterface.setPriority(1);
+ resultInt = defaultIsisInterface.priority();
+ assertThat(resultInt, is(1));
+ }
+
+ /**
+ * Tests helloInterval() getter method.
+ */
+ @Test
+ public void testHelloInterval() throws Exception {
+ defaultIsisInterface.setHelloInterval(10);
+ resultInt = defaultIsisInterface.helloInterval();
+ assertThat(resultInt, is(10));
+ }
+
+ /**
+ * Tests helloInterval() setter method.
+ */
+ @Test
+ public void testSetHelloInterval() throws Exception {
+ defaultIsisInterface.setHelloInterval(10);
+ resultInt = defaultIsisInterface.helloInterval();
+ assertThat(resultInt, is(10));
+ }
+
+ /**
+ * Tests interfaceState() getter method.
+ */
+ @Test
+ public void testInterfaceState() throws Exception {
+ defaultIsisInterface.setInterfaceState(IsisInterfaceState.UP);
+ resultIfState = defaultIsisInterface.interfaceState();
+ assertThat(resultIfState, is(IsisInterfaceState.UP));
+ }
+
+ /**
+ * Tests interfaceState() setter method.
+ */
+ @Test
+ public void testSetInterfaceState() throws Exception {
+ defaultIsisInterface.setInterfaceState(IsisInterfaceState.UP);
+ resultIfState = defaultIsisInterface.interfaceState();
+ assertThat(resultIfState, is(IsisInterfaceState.UP));
+ }
+
+ /**
+ * Tests setCircuitId() getter method.
+ */
+ @Test
+ public void testCircuitId() throws Exception {
+ defaultIsisInterface.setCircuitId(sysId);
+ resultStr = defaultIsisInterface.circuitId();
+ assertThat(resultStr, is(sysId));
+ }
+
+ /**
+ * Tests setCircuitId() setter method.
+ */
+ @Test
+ public void testSetCircuitId() throws Exception {
+ defaultIsisInterface.setCircuitId(sysId);
+ resultStr = defaultIsisInterface.circuitId();
+ assertThat(resultStr, is(sysId));
+ }
+}
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisNeighborTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisNeighborTest.java
new file mode 100644
index 0000000..fe9b867
--- /dev/null
+++ b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisNeighborTest.java
@@ -0,0 +1,347 @@
+/*
+ * 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.controller.impl;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.Ip4Address;
+import org.onlab.packet.MacAddress;
+import org.onosproject.isis.controller.IsisInterface;
+import org.onosproject.isis.controller.IsisInterfaceState;
+import org.onosproject.isis.controller.IsisMessage;
+import org.onosproject.isis.controller.IsisRouterType;
+import org.onosproject.isis.io.isispacket.IsisHeader;
+import org.onosproject.isis.io.isispacket.pdu.HelloPdu;
+import org.onosproject.isis.io.isispacket.pdu.L1L2HelloPdu;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Unit test class for DefaultIsisNeighbor.
+ */
+public class DefaultIsisNeighborTest {
+
+ private final String areaId = "490001";
+ private final String systemId = "2929.2929.2929";
+ private final String lanId = "0000.0000.0000.00";
+ private DefaultIsisNeighbor isisNeighbor;
+ private IsisInterface isisInterface;
+ private IsisMessage isisMessage;
+ private IsisHeader isisHeader;
+ private int result;
+ private String result1;
+ private Ip4Address interfaceIp = Ip4Address.valueOf("10.10.10.10");
+ private Ip4Address result2;
+ private MacAddress macAddress = MacAddress.valueOf("a4:23:05:00:00:00");
+ private MacAddress result3;
+ private IsisRouterType isisRouterType;
+ private IsisInterfaceState isisInterfaceState;
+ private byte result4;
+
+ @Before
+ public void setUp() throws Exception {
+ isisHeader = new IsisHeader();
+ isisMessage = new L1L2HelloPdu(isisHeader);
+ isisInterface = new DefaultIsisInterface();
+ isisNeighbor = new DefaultIsisNeighbor((HelloPdu) isisMessage, isisInterface);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ isisHeader = null;
+ isisMessage = null;
+ isisInterface = null;
+ isisNeighbor = null;
+ }
+
+ /**
+ * Tests localExtendedCircuitId() getter method.
+ */
+ @Test
+ public void testLocalExtendedCircuitId() throws Exception {
+ isisNeighbor.setLocalExtendedCircuitId(1);
+ result = isisNeighbor.localExtendedCircuitId();
+ assertThat(result, is(1));
+ }
+
+ /**
+ * Tests localExtendedCircuitId() setter method.
+ */
+ @Test
+ public void testSetLocalExtendedCircuitId() throws Exception {
+ isisNeighbor.setLocalExtendedCircuitId(1);
+ result = isisNeighbor.localExtendedCircuitId();
+ assertThat(result, is(1));
+ }
+
+ /**
+ * Tests neighborAreaId() getter method.
+ */
+ @Test
+ public void testNeighborAreaId() throws Exception {
+ isisNeighbor.setNeighborAreaId(areaId);
+ result1 = isisNeighbor.neighborAreaId();
+ assertThat(result1, is(areaId));
+ }
+
+ /**
+ * Tests neighborAreaId() setter method.
+ */
+ @Test
+ public void testSetNeighborAreaId() throws Exception {
+ isisNeighbor.setNeighborAreaId(areaId);
+ result1 = isisNeighbor.neighborAreaId();
+ assertThat(result1, is(areaId));
+ }
+
+ /**
+ * Tests neighborSystemId() getter method.
+ */
+ @Test
+ public void testNeighborSystemId() throws Exception {
+ isisNeighbor.setNeighborSystemId(systemId);
+ result1 = isisNeighbor.neighborSystemId();
+ assertThat(result1, is(systemId));
+ }
+
+ /**
+ * Tests neighborSystemId() setter method.
+ */
+ @Test
+ public void testSetNeighborSystemId() throws Exception {
+ isisNeighbor.setNeighborSystemId(systemId);
+ result1 = isisNeighbor.neighborSystemId();
+ assertThat(result1, is(systemId));
+ }
+
+ /**
+ * Tests interfaceIp() getter method.
+ */
+ @Test
+ public void testInterfaceIp() throws Exception {
+ isisNeighbor.setInterfaceIp(interfaceIp);
+ result2 = isisNeighbor.interfaceIp();
+ assertThat(result2, is(interfaceIp));
+ }
+
+ /**
+ * Tests interfaceIp() setter method.
+ */
+ @Test
+ public void testSetInterfaceIp() throws Exception {
+ isisNeighbor.setInterfaceIp(interfaceIp);
+ result2 = isisNeighbor.interfaceIp();
+ assertThat(result2, is(interfaceIp));
+ }
+
+ /**
+ * Tests neighborMacAddress() getter method.
+ */
+ @Test
+ public void testNeighborMacAddress() throws Exception {
+ isisNeighbor.setNeighborMacAddress(macAddress);
+ result3 = isisNeighbor.neighborMacAddress();
+ assertThat(result3, is(macAddress));
+ }
+
+ /**
+ * Tests neighborMacAddress() setter method.
+ */
+ @Test
+ public void testSetNeighborMacAddress() throws Exception {
+ isisNeighbor.setNeighborMacAddress(macAddress);
+ result3 = isisNeighbor.neighborMacAddress();
+ assertThat(result3, is(macAddress));
+ }
+
+ /**
+ * Tests holdingTime() getter method.
+ */
+ @Test
+ public void testHoldingTime() throws Exception {
+ isisNeighbor.setHoldingTime(1);
+ result = isisNeighbor.holdingTime();
+ assertThat(result, is(1));
+ }
+
+ /**
+ * Tests holdingTime() setter method.
+ */
+ @Test
+ public void testSetHoldingTime() throws Exception {
+ isisNeighbor.setHoldingTime(1);
+ result = isisNeighbor.holdingTime();
+ assertThat(result, is(1));
+ }
+
+ /**
+ * Tests routerType() getter method.
+ */
+ @Test
+ public void testRouterType() throws Exception {
+ isisNeighbor.setRouterType(IsisRouterType.L1);
+ isisRouterType = isisNeighbor.routerType();
+ assertThat(isisRouterType, is(IsisRouterType.L1));
+ }
+
+ /**
+ * Tests routerType() setter method.
+ */
+ @Test
+ public void testSetRouterType() throws Exception {
+ isisNeighbor.setRouterType(IsisRouterType.L1);
+ isisRouterType = isisNeighbor.routerType();
+ assertThat(isisRouterType, is(IsisRouterType.L1));
+ }
+
+ /**
+ * Tests l1LanId() getter method.
+ */
+ @Test
+ public void testL1LanId() throws Exception {
+ isisNeighbor.setL1LanId(systemId);
+ result1 = isisNeighbor.l1LanId();
+ assertThat(result1, is(systemId));
+ }
+
+ /**
+ * Tests l1LanId() setter method.
+ */
+ @Test
+ public void testSetL1LanId() throws Exception {
+ isisNeighbor.setL1LanId(lanId);
+ result1 = isisNeighbor.l1LanId();
+ assertThat(result1, is(lanId));
+ }
+
+ /**
+ * Tests l2LanId() getter method.
+ */
+ @Test
+ public void testL2LanId() throws Exception {
+ isisNeighbor.setL2LanId(lanId);
+ result1 = isisNeighbor.l2LanId();
+ assertThat(result1, is(lanId));
+ }
+
+ /**
+ * Tests l2LanId() setter method.
+ */
+ @Test
+ public void testSetL2LanId() throws Exception {
+ isisNeighbor.setL2LanId(lanId);
+ result1 = isisNeighbor.l2LanId();
+ assertThat(result1, is(lanId));
+ }
+
+ /**
+ * Tests neighborState() getter method.
+ */
+ @Test
+ public void testInterfaceState() throws Exception {
+ isisNeighbor.setNeighborState(IsisInterfaceState.DOWN);
+ isisInterfaceState = isisNeighbor.neighborState();
+ assertThat(isisInterfaceState, is(IsisInterfaceState.DOWN));
+ }
+
+ /**
+ * Tests neighborState() setter method.
+ */
+ @Test
+ public void testSetNeighborState() throws Exception {
+ isisNeighbor.setNeighborState(IsisInterfaceState.DOWN);
+ isisInterfaceState = isisNeighbor.neighborState();
+ assertThat(isisInterfaceState, is(IsisInterfaceState.DOWN));
+ }
+
+ /**
+ * Tests localCircuitId() getter method.
+ */
+ @Test
+ public void testLocalCircuitId() throws Exception {
+ isisNeighbor.setLocalCircuitId((byte) 1);
+ result4 = isisNeighbor.localCircuitId();
+ assertThat(result4, is((byte) 1));
+ }
+
+ /**
+ * Tests localCircuitId() setter method.
+ */
+ @Test
+ public void testSetLocalCircuitId() throws Exception {
+ isisNeighbor.setLocalCircuitId((byte) 1);
+ result4 = isisNeighbor.localCircuitId();
+ assertThat(result4, is((byte) 1));
+ }
+
+ /**
+ * Tests neighborState() getter method.
+ */
+ @Test
+ public void testNeighborState() throws Exception {
+ isisNeighbor.setNeighborState(IsisInterfaceState.DOWN);
+ isisInterfaceState = isisNeighbor.neighborState();
+ assertThat(isisInterfaceState, is(IsisInterfaceState.DOWN));
+ }
+
+ /**
+ * Tests startHoldingTimeCheck() method.
+ */
+ @Test
+ public void testStartHoldingTimeCheck() throws Exception {
+ isisNeighbor.startHoldingTimeCheck();
+ assertThat(isisNeighbor, is(notNullValue()));
+ }
+
+ /**
+ * Tests stopHoldingTimeCheck() method.
+ */
+ @Test
+ public void testStopHoldingTimeCheck() throws Exception {
+ isisNeighbor.stopHoldingTimeCheck();
+ assertThat(isisNeighbor, is(notNullValue()));
+ }
+
+ /**
+ * Tests startInactivityTimeCheck() method.
+ */
+ @Test(expected = Exception.class)
+ public void testStartInactivityTimeCheck() throws Exception {
+ isisNeighbor.startInactivityTimeCheck();
+ assertThat(isisNeighbor, is(notNullValue()));
+ }
+
+ /**
+ * Tests startInactivityTimeCheck() method.
+ */
+ @Test(expected = Exception.class)
+ public void testStopInactivityTimeCheck() throws Exception {
+ isisNeighbor.startInactivityTimeCheck();
+ assertThat(isisNeighbor, is(notNullValue()));
+ }
+
+ /**
+ * Tests neighborDown() method.
+ */
+ @Test(expected = Exception.class)
+ public void testNeighborDown() throws Exception {
+ isisNeighbor.neighborDown();
+ assertThat(isisNeighbor, is(notNullValue()));
+ }
+}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisProcessTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisProcessTest.java
new file mode 100644
index 0000000..3c16a14
--- /dev/null
+++ b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisProcessTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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.controller.impl;
+
+import org.easymock.EasyMock;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.isis.controller.IsisInterface;
+import org.onosproject.isis.controller.IsisProcess;
+
+import java.util.List;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Unit test class for DefaultIsisProcess.
+ */
+public class DefaultIsisProcessTest {
+
+ private final String processId = "1";
+ private IsisProcess isisProcess;
+ private String result;
+ private IsisInterface isisInterface;
+ private List<IsisInterface> isisInterfaceList;
+ private List<IsisInterface> result1;
+
+ @Before
+ public void setUp() throws Exception {
+ isisProcess = new DefaultIsisProcess();
+ isisInterface = EasyMock.createNiceMock(DefaultIsisInterface.class);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ isisProcess = null;
+ }
+
+ /**
+ * Tests processId() setter method.
+ */
+ @Test
+ public void testProcessId() throws Exception {
+ isisProcess.setProcessId(processId);
+ result = isisProcess.processId();
+ assertThat(result, is(processId));
+ }
+
+ /**
+ * Tests processId() getter method.
+ */
+ @Test
+ public void testSetProcessId() throws Exception {
+ isisProcess.setProcessId(processId);
+ result = isisProcess.processId();
+ assertThat(result, is(processId));
+ }
+
+ /**
+ * Tests isisInterfaceList() setter method.
+ */
+ @Test
+ public void testIsisInterfaceList() throws Exception {
+ isisProcess.setIsisInterfaceList(isisInterfaceList);
+ result1 = isisProcess.isisInterfaceList();
+ assertThat(result1, is(nullValue()));
+ }
+
+ /**
+ * Tests isisInterfaceList() getter method.
+ */
+ @Test
+ public void testSetIsisInterfaceList() throws Exception {
+ isisProcess.setIsisInterfaceList(isisInterfaceList);
+ result1 = isisProcess.isisInterfaceList();
+ assertThat(result1, is(nullValue()));
+ }
+}
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisChannelHandlerTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisChannelHandlerTest.java
new file mode 100644
index 0000000..1644b6e
--- /dev/null
+++ b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisChannelHandlerTest.java
@@ -0,0 +1,169 @@
+/*
+ * 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.controller.impl;
+
+import org.easymock.EasyMock;
+import org.jboss.netty.channel.ChannelHandlerContext;
+import org.jboss.netty.channel.ChannelStateEvent;
+import org.jboss.netty.channel.ExceptionEvent;
+import org.jboss.netty.channel.MessageEvent;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.isis.controller.IsisMessage;
+import org.onosproject.isis.controller.IsisProcess;
+import org.onosproject.isis.io.isispacket.pdu.L1L2HelloPdu;
+
+import java.util.List;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Unit test class for IsisChannelHandler.
+ */
+public class IsisChannelHandlerTest {
+
+ private final String processId = "1";
+ private final byte[] config = {0, 0, 0, 0, 0, 0, 0};
+ private IsisChannelHandler isisChannelHandler;
+ private Controller controller;
+ private IsisProcess isisProcess;
+ private List<IsisProcess> isisProcessList;
+ private ChannelHandlerContext channelHandlerContext;
+ private ChannelStateEvent channelStateEvent;
+ private ExceptionEvent exceptionEvent;
+ private MessageEvent messageEvent;
+ private IsisMessage isisMessage;
+
+ @Before
+ public void setUp() throws Exception {
+ controller = EasyMock.createNiceMock(Controller.class);
+ isisProcess = EasyMock.createNiceMock(IsisProcess.class);
+ channelHandlerContext = EasyMock.createNiceMock(ChannelHandlerContext.class);
+ channelStateEvent = EasyMock.createNiceMock(ChannelStateEvent.class);
+ exceptionEvent = EasyMock.createNiceMock(ExceptionEvent.class);
+ messageEvent = EasyMock.createNiceMock(MessageEvent.class);
+ isisMessage = EasyMock.createNiceMock(L1L2HelloPdu.class);
+ isisMessage.setInterfaceIndex(2);
+ isisChannelHandler = new IsisChannelHandler(controller, isisProcessList);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ isisChannelHandler = null;
+ }
+
+ /**
+ * Tests initializeInterfaceMap() method.
+ */
+ @Test(expected = Exception.class)
+ public void testInitializeInterfaceMap() throws Exception {
+ isisChannelHandler.initializeInterfaceMap();
+ assertThat(isisChannelHandler, is(notNullValue()));
+ }
+
+ /**
+ * Tests updateInterfaceMap() method.
+ */
+ @Test(expected = Exception.class)
+ public void testUpdateInterfaceMap() throws Exception {
+ isisChannelHandler.updateInterfaceMap(isisProcessList);
+ assertThat(isisChannelHandler, is(notNullValue()));
+ }
+
+ /**
+ * Tests initializeInterfaceIpList() method.
+ */
+ @Test(expected = Exception.class)
+ public void testInitializeInterfaceIpList() throws Exception {
+ isisChannelHandler.initializeInterfaceIpList();
+ assertThat(isisChannelHandler, is(notNullValue()));
+ }
+
+ /**
+ * Tests channelConnected() method.
+ */
+ @Test(expected = Exception.class)
+ public void testChannelConnected() throws Exception {
+ isisChannelHandler.channelConnected(channelHandlerContext, channelStateEvent);
+ assertThat(isisChannelHandler, is(notNullValue()));
+ }
+
+ /**
+ * Tests channelDisconnected() method.
+ */
+ @Test
+ public void testChannelDisconnected() throws Exception {
+ isisChannelHandler.channelDisconnected(channelHandlerContext, channelStateEvent);
+ assertThat(isisChannelHandler, is(notNullValue()));
+ }
+
+ /**
+ * Tests exceptionCaught() method.
+ */
+ @Test(expected = Exception.class)
+ public void testExceptionCaught() throws Exception {
+ isisChannelHandler.exceptionCaught(channelHandlerContext, exceptionEvent);
+ assertThat(isisChannelHandler, is(notNullValue()));
+ }
+
+ /**
+ * Tests messageReceived() method.
+ */
+ @Test
+ public void testMessageReceived() throws Exception {
+ isisChannelHandler.messageReceived(channelHandlerContext, messageEvent);
+ assertThat(isisChannelHandler, is(notNullValue()));
+ }
+
+ /**
+ * Tests processIsisMessage() method.
+ */
+ @Test(expected = Exception.class)
+ public void testProcessIsisMessage() throws Exception {
+ isisChannelHandler.processIsisMessage(isisMessage, channelHandlerContext);
+ assertThat(isisChannelHandler, is(notNullValue()));
+ }
+
+ /**
+ * Tests startHelloSender() method.
+ */
+ @Test
+ public void testStartHelloSender() throws Exception {
+ isisChannelHandler.startHelloSender();
+ assertThat(isisChannelHandler, is(notNullValue()));
+ }
+
+ /**
+ * Tests stopHelloSender() method.
+ */
+ @Test
+ public void testStopHelloSender() throws Exception {
+ isisChannelHandler.stopHelloSender();
+ assertThat(isisChannelHandler, is(notNullValue()));
+ }
+
+ /**
+ * Tests sentConfigPacket() method.
+ */
+ @Test
+ public void testSentConfigPacket() throws Exception {
+ isisChannelHandler.sentConfigPacket(config);
+ assertThat(isisChannelHandler, is(notNullValue()));
+ }
+}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisHelloPduSenderTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisHelloPduSenderTest.java
new file mode 100644
index 0000000..85228b2
--- /dev/null
+++ b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisHelloPduSenderTest.java
@@ -0,0 +1,106 @@
+/*
+ * 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.controller.impl;
+
+import org.easymock.EasyMock;
+import org.jboss.netty.channel.Channel;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.Ip4Address;
+import org.onosproject.isis.controller.IsisNetworkType;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Unit test class for IsisHelloPduSender.
+ */
+public class IsisHelloPduSenderTest {
+ private final String systemId = "1234.1234.1234";
+ private final String areaId = "490001";
+ private final String circuitId = "0";
+ private final String lanId = "0000.0000.0000.00";
+ private Channel channel;
+ private DefaultIsisInterface isisInterface;
+ private DefaultIsisInterface isisInterface1;
+ private IsisHelloPduSender isisHelloPduSender;
+ private IsisHelloPduSender isisHelloPduSender1;
+ private Ip4Address interfaceAddress = Ip4Address.valueOf("10.10.10.10");
+
+ @Before
+ public void setUp() throws Exception {
+ channel = EasyMock.createNiceMock(Channel.class);
+ isisInterface = new DefaultIsisInterface();
+ isisInterface1 = new DefaultIsisInterface();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ channel = null;
+ isisInterface = null;
+ }
+
+ /**
+ * Tests run() method.
+ */
+ @Test
+ public void testRun() throws Exception {
+ isisInterface.setNetworkType(IsisNetworkType.P2P);
+ isisInterface.setCircuitId(circuitId);
+ isisInterface.setSystemId(systemId);
+ isisInterface.setAreaAddress("490001");
+ isisInterface.setInterfaceIpAddress(interfaceAddress);
+ isisHelloPduSender = new IsisHelloPduSender(channel, isisInterface);
+ isisHelloPduSender.run();
+ assertThat(isisHelloPduSender, is(notNullValue()));
+
+ isisInterface1.setNetworkType(IsisNetworkType.BROADCAST);
+ isisInterface1.setCircuitId(circuitId);
+ isisInterface1.setSystemId(systemId);
+ isisInterface1.setAreaAddress(areaId);
+ isisInterface1.setInterfaceIpAddress(interfaceAddress);
+ isisInterface1.setReservedPacketCircuitType(1);
+ isisInterface1.setL1LanId(lanId);
+ isisHelloPduSender1 = new IsisHelloPduSender(channel, isisInterface1);
+ isisHelloPduSender1.run();
+ assertThat(isisHelloPduSender1, is(notNullValue()));
+
+ isisInterface1.setNetworkType(IsisNetworkType.BROADCAST);
+ isisInterface1.setCircuitId(circuitId);
+ isisInterface1.setSystemId(systemId);
+ isisInterface1.setAreaAddress(areaId);
+ isisInterface1.setInterfaceIpAddress(interfaceAddress);
+ isisInterface1.setReservedPacketCircuitType(2);
+ isisInterface1.setL2LanId(lanId);
+ isisHelloPduSender1 = new IsisHelloPduSender(channel, isisInterface1);
+ isisHelloPduSender1.run();
+ assertThat(isisHelloPduSender1, is(notNullValue()));
+
+ isisInterface1.setNetworkType(IsisNetworkType.BROADCAST);
+ isisInterface1.setCircuitId(circuitId);
+ isisInterface1.setSystemId(systemId);
+ isisInterface1.setAreaAddress(areaId);
+ isisInterface1.setInterfaceIpAddress(interfaceAddress);
+ isisInterface1.setReservedPacketCircuitType(3);
+ isisInterface1.setL1LanId(lanId);
+ isisInterface1.setL2LanId(lanId);
+ isisHelloPduSender1 = new IsisHelloPduSender(channel, isisInterface1);
+ isisHelloPduSender1.run();
+ assertThat(isisHelloPduSender1, is(notNullValue()));
+ }
+}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisMessageDecoderTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisMessageDecoderTest.java
new file mode 100644
index 0000000..a2c32b9
--- /dev/null
+++ b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisMessageDecoderTest.java
@@ -0,0 +1,56 @@
+package org.onosproject.isis.controller.impl;
+
+import com.google.common.primitives.Bytes;
+import org.easymock.EasyMock;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.jboss.netty.channel.Channel;
+import org.jboss.netty.channel.ChannelHandlerContext;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.isis.io.util.IsisUtil;
+
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+/**
+ * Unit test class for IsisMessageDecoder.
+ */
+public class IsisMessageDecoderTest {
+
+ private final byte[] hello = {
+ -125, 20, 1, 0, 17, 1, 0, 0,
+ 2, 51, 51, 51, 51, 51, 51, 0, 100, 5, -39, -126, 1, 4, 3,
+ 73, 0, 0, -127, 1, -52, -124, 4, -64, -88, 56, 102
+ };
+ private final String id = "127.0.0.1";
+ private IsisMessageDecoder isisMessageDecoder;
+ private ChannelHandlerContext ctx;
+ private Channel channel;
+ private SocketAddress socketAddress;
+ private ChannelBuffer channelBuffer;
+
+ @Before
+ public void setUp() throws Exception {
+ isisMessageDecoder = new IsisMessageDecoder();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ isisMessageDecoder = null;
+ }
+
+ @Test
+ public void testDecode() throws Exception {
+ channel = EasyMock.createMock(Channel.class);
+ socketAddress = InetSocketAddress.createUnresolved(id, 7000);
+ byte[] array = IsisUtil.getPaddingTlvs(hello.length);
+ channelBuffer = ChannelBuffers.copiedBuffer(Bytes.concat(hello, array));
+ assertThat(isisMessageDecoder.decode(ctx, channel, channelBuffer), is(nullValue()));
+ }
+}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisMessageEncoderTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisMessageEncoderTest.java
new file mode 100644
index 0000000..7738d78
--- /dev/null
+++ b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisMessageEncoderTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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.controller.impl;
+
+import com.google.common.primitives.Bytes;
+import org.easymock.EasyMock;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.jboss.netty.channel.Channel;
+import org.jboss.netty.channel.ChannelHandlerContext;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.isis.io.util.IsisUtil;
+
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+/**
+ * Unit test class for IsisMessageEncoder.
+ */
+public class IsisMessageEncoderTest {
+
+ private final String id = "127.0.0.1";
+ private final byte[] hello = {
+ -125, 20, 1, 0, 17, 1, 0, 0,
+ 2, 51, 51, 51, 51, 51, 51, 0, 100, 5, -39, -126, 1, 4, 3,
+ 73, 0, 0, -127, 1, -52, -124, 4, -64, -88, 56, 102
+ };
+ private IsisMessageEncoder isisMessageEncoder;
+ private ChannelHandlerContext ctx;
+ private Channel channel;
+ private SocketAddress socketAddress;
+ private ChannelBuffer channelBuffer;
+
+ @Before
+ public void setUp() throws Exception {
+ channel = EasyMock.createMock(Channel.class);
+ isisMessageEncoder = new IsisMessageEncoder();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ channel = null;
+ isisMessageEncoder = null;
+ }
+
+ /**
+ * Tests encode() method.
+ */
+ @Test
+ public void testEncode() throws Exception {
+ socketAddress = InetSocketAddress.createUnresolved(id, 7000);
+ byte[] array = IsisUtil.getPaddingTlvs(hello.length);
+ channelBuffer = ChannelBuffers.copiedBuffer(Bytes.concat(hello, array));
+ assertThat(isisMessageEncoder.encode(ctx, channel, channelBuffer.array()),
+ is(notNullValue()));
+ }
+}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisPipelineFactoryTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisPipelineFactoryTest.java
new file mode 100644
index 0000000..77ced07
--- /dev/null
+++ b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisPipelineFactoryTest.java
@@ -0,0 +1,75 @@
+/*
+ * 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.controller.impl;
+
+import org.jboss.netty.channel.ChannelPipeline;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.isis.controller.IsisInterface;
+import org.onosproject.isis.controller.IsisProcess;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Unit test class for IsisPipelineFactory.
+ */
+public class IsisPipelineFactoryTest {
+
+ private IsisPipelineFactory isisPipelineFactory;
+ private IsisChannelHandler isisChannelHandler;
+ private List<IsisProcess> isisProcessList = new ArrayList<>();
+ private Controller controller;
+ private ChannelPipeline channelPipeline;
+ private DefaultIsisProcess isisProcess;
+ private String processId = "1";
+ private DefaultIsisInterface isisInterface;
+ private List<IsisInterface> isisInterfaces = new ArrayList<>();
+
+ @Before
+ public void setUp() throws Exception {
+ controller = new Controller();
+ isisProcess = new DefaultIsisProcess();
+ isisInterface = new DefaultIsisInterface();
+ isisInterfaces.add(isisInterface);
+ isisProcess.setIsisInterfaceList(isisInterfaces);
+ isisProcess.setProcessId(processId);
+ isisProcessList.add(isisProcess);
+ isisChannelHandler = new IsisChannelHandler(controller, isisProcessList);
+ isisPipelineFactory = new IsisPipelineFactory(isisChannelHandler);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ controller = null;
+ isisChannelHandler = null;
+ isisPipelineFactory = null;
+ }
+
+ /**
+ * Tests getPipeline() method.
+ */
+ @Test
+ public void testGetPipeline() throws Exception {
+ channelPipeline = isisPipelineFactory.getPipeline();
+ assertThat(channelPipeline, is(instanceOf(ChannelPipeline.class)));
+ }
+}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbAgeTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbAgeTest.java
new file mode 100644
index 0000000..45adbd9
--- /dev/null
+++ b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbAgeTest.java
@@ -0,0 +1,171 @@
+/*
+ * 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.controller.impl.lsdb;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.isis.controller.IsisLspBin;
+import org.onosproject.isis.io.isispacket.IsisHeader;
+import org.onosproject.isis.io.isispacket.pdu.LsPdu;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Unit test case for DefaultIsisLsdbAge.
+ */
+public class DefaultIsisLsdbAgeTest {
+ private DefaultIsisLsdbAge defaultIsisLsdbAge;
+ private IsisLspBin isisLspBin;
+ private int resultInt;
+ private IsisLspBin resultLspBin;
+ private DefaultLspWrapper lspWrapper;
+ private LsPdu lsPdu;
+ private IsisHeader isisHeader;
+ private String lspId = "1234.1234.1234";
+
+ @Before
+ public void setUp() throws Exception {
+ defaultIsisLsdbAge = new DefaultIsisLsdbAge();
+ isisLspBin = new DefaultIsisLspBin(1);
+ lspWrapper = new DefaultLspWrapper();
+ lspWrapper.setBinNumber(1);
+ isisHeader = new IsisHeader();
+ lsPdu = new LsPdu(isisHeader);
+ lsPdu.setLspId(lspId);
+ lspWrapper.setLsPdu(lsPdu);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ defaultIsisLsdbAge = null;
+ isisLspBin = null;
+ }
+
+ /**
+ * Tests ageCounter() method.
+ */
+ @Test
+ public void testAgeCounter() throws Exception {
+ resultInt = defaultIsisLsdbAge.ageCounter();
+ assertThat(resultInt, is(0));
+ }
+
+ /**
+ * Tests ageCounterRollOver() method.
+ */
+ @Test
+ public void testAgeCounterRollOver() throws Exception {
+ resultInt = defaultIsisLsdbAge.ageCounterRollOver();
+ assertThat(resultInt, is(0));
+ }
+
+ /**
+ * Tests addLspBin() method.
+ */
+ @Test
+ public void testAddLspBin() throws Exception {
+ defaultIsisLsdbAge.addLspBin(1400, isisLspBin);
+ resultLspBin = defaultIsisLsdbAge.getLspBin(1);
+ assertThat(resultLspBin, is(notNullValue()));
+ }
+
+ /**
+ * Tests getLspBin() method.
+ */
+ @Test
+ public void testGetLspBin() throws Exception {
+ defaultIsisLsdbAge.addLspBin(1, isisLspBin);
+ resultLspBin = defaultIsisLsdbAge.getLspBin(1);
+ assertThat(resultLspBin, is(notNullValue()));
+ }
+
+ /**
+ * Tests removeLspFromBin() method.
+ */
+ @Test
+ public void testRemoveLspFromBin() throws Exception {
+ defaultIsisLsdbAge.addLspBin(1400, isisLspBin);
+ defaultIsisLsdbAge.removeLspFromBin(lspWrapper);
+ assertThat(resultLspBin, is(nullValue()));
+ }
+
+ /**
+ * Tests age2Bin() method.
+ */
+ @Test
+ public void testAge2Bin() throws Exception {
+ defaultIsisLsdbAge.age2Bin(1);
+ assertThat(defaultIsisLsdbAge, is(notNullValue()));
+
+ defaultIsisLsdbAge.age2Bin(-1);
+ assertThat(defaultIsisLsdbAge, is(notNullValue()));
+ }
+
+ /**
+ * Tests startDbAging() method.
+ */
+ @Test
+ public void testStartDbAging() throws Exception {
+ defaultIsisLsdbAge.startDbAging();
+ assertThat(defaultIsisLsdbAge, is(notNullValue()));
+ }
+
+ /**
+ * Tests ageLsp() method.
+ */
+ @Test
+ public void testAgeLsp() throws Exception {
+ defaultIsisLsdbAge.age2Bin(1);
+ defaultIsisLsdbAge.startDbAging();
+ defaultIsisLsdbAge.ageLsp();
+ assertThat(defaultIsisLsdbAge, is(notNullValue()));
+ }
+
+ /**
+ * Tests maxAgeLsa() method.
+ */
+ @Test
+ public void testMaxAgeLsa() throws Exception {
+ defaultIsisLsdbAge.age2Bin(1);
+ defaultIsisLsdbAge.startDbAging();
+ defaultIsisLsdbAge.maxAgeLsa();
+ assertThat(defaultIsisLsdbAge, is(notNullValue()));
+
+ defaultIsisLsdbAge.age2Bin(1400);
+ defaultIsisLsdbAge.startDbAging();
+ defaultIsisLsdbAge.maxAgeLsa();
+ assertThat(defaultIsisLsdbAge, is(notNullValue()));
+ }
+
+ /**
+ * Tests refreshLsa() method.
+ */
+ @Test
+ public void testRefreshLsa() throws Exception {
+ defaultIsisLsdbAge.age2Bin(1);
+ defaultIsisLsdbAge.startDbAging();
+ defaultIsisLsdbAge.refreshLsa();
+ assertThat(defaultIsisLsdbAge, is(notNullValue()));
+
+ defaultIsisLsdbAge.age2Bin(1400);
+ defaultIsisLsdbAge.startDbAging();
+ defaultIsisLsdbAge.refreshLsa();
+ assertThat(defaultIsisLsdbAge, is(notNullValue()));
+ }
+}
+
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbTest.java
new file mode 100644
index 0000000..d1c04fe
--- /dev/null
+++ b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbTest.java
@@ -0,0 +1,133 @@
+/*
+ * 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.controller.impl.lsdb;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.isis.controller.IsisLsdb;
+import org.onosproject.isis.controller.IsisLsdbAge;
+import org.onosproject.isis.controller.IsisPduType;
+import org.onosproject.isis.controller.LspWrapper;
+import org.onosproject.isis.io.util.IsisConstants;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Unit test case for DefaultIsisLsdb.
+ */
+public class DefaultIsisLsdbTest {
+ private final int l1LspSeqNo = IsisConstants.STARTLSSEQUENCENUM;
+ private final int l2LspSeqNo = IsisConstants.STARTLSSEQUENCENUM;
+ private final String srcId = "1111.1111.1111";
+
+ private DefaultIsisLsdb defaultIsisLsdb;
+ private IsisLsdbAge lsdbAge = null;
+
+
+ private int resultInt;
+ private Map<String, LspWrapper> resultMap = new ConcurrentHashMap<>();
+ private IsisLsdb resultLsdb;
+ private LspWrapper resultLspWrapper;
+
+
+ @Before
+ public void setUp() throws Exception {
+ defaultIsisLsdb = new DefaultIsisLsdb();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ defaultIsisLsdb = null;
+ }
+
+ /**
+ * Tests initializeDb() method.
+ */
+ @Test
+ public void testInitializeDb() throws Exception {
+ defaultIsisLsdb.initializeDb();
+ assertThat(lsdbAge, is(nullValue()));
+ }
+
+ /**
+ * Tests setL1LspSeqNo() method.
+ */
+ @Test
+ public void testSetL1LspSeqNo() throws Exception {
+ defaultIsisLsdb.setL1LspSeqNo(l1LspSeqNo);
+ assertThat(defaultIsisLsdb, is(notNullValue()));
+ }
+
+ /**
+ * Tests setL2LspSeqNo() method.
+ */
+ @Test
+ public void testSetL2LspSeqNo() throws Exception {
+ defaultIsisLsdb.setL2LspSeqNo(l2LspSeqNo);
+ assertThat(defaultIsisLsdb, is(notNullValue()));
+ }
+
+ /**
+ * Tests setL2LspSeqNo() method.
+ */
+ @Test
+ public void testLspKey() throws Exception {
+ defaultIsisLsdb.lspKey(srcId);
+ assertThat(defaultIsisLsdb, is(notNullValue()));
+ }
+
+ /**
+ * Tests setL2LspSeqNo() method.
+ */
+ @Test
+ public void testGetL1Db() throws Exception {
+ resultMap = defaultIsisLsdb.getL1Db();
+ assertThat(resultMap.isEmpty(), is(true));
+ }
+
+ /**
+ * Tests setL2LspSeqNo() method.
+ */
+ @Test
+ public void testGetL2Db() throws Exception {
+ resultMap = defaultIsisLsdb.getL2Db();
+ assertThat(resultMap.isEmpty(), is(true));
+ }
+
+ /**
+ * Tests setL2LspSeqNo() method.
+ */
+ @Test
+ public void testIsisLsdb() throws Exception {
+ resultLsdb = defaultIsisLsdb.isisLsdb();
+ assertThat(resultLsdb, is(notNullValue()));
+ }
+
+ /**
+ * Tests findLsp() method.
+ */
+ @Test
+ public void testFindLsp() throws Exception {
+ resultLspWrapper = defaultIsisLsdb.findLsp(IsisPduType.L1HELLOPDU, srcId);
+ assertThat(resultLspWrapper, is(nullValue()));
+ }
+}
+
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLspBinTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLspBinTest.java
new file mode 100644
index 0000000..7dd2abb
--- /dev/null
+++ b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLspBinTest.java
@@ -0,0 +1,107 @@
+/*
+ * 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.controller.impl.lsdb;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.isis.controller.LspWrapper;
+
+import java.util.Map;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Unit test case for DefaultIsisLspBin.
+ */
+public class DefaultIsisLspBinTest {
+
+ private DefaultIsisLspBin defaultIsisLspBin;
+ private int result;
+ private String key = "1";
+ private LspWrapper lspWrapper;
+ private LspWrapper result1;
+ private Map<String, LspWrapper> listOfLsp;
+
+ @Before
+ public void setUp() throws Exception {
+ defaultIsisLspBin = new DefaultIsisLspBin(1);
+ lspWrapper = new DefaultLspWrapper();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ defaultIsisLspBin = null;
+ }
+
+ /**
+ * Tests addIsisLsp() method.
+ */
+ @Test
+ public void testAddIsisLsp() throws Exception {
+ defaultIsisLspBin.addIsisLsp(key, lspWrapper);
+ assertThat(defaultIsisLspBin, is(notNullValue()));
+ }
+
+ /**
+ * Tests isisLsp() method.
+ */
+ @Test
+ public void testIsisLsp() throws Exception {
+ defaultIsisLspBin.addIsisLsp(key, lspWrapper);
+ result1 = defaultIsisLspBin.isisLsp(key);
+ assertThat(result1, is(notNullValue()));
+ }
+
+ /**
+ * Tests removeIsisLsp() method.
+ */
+ @Test
+ public void testRemoveIsisLsp() throws Exception {
+ defaultIsisLspBin.addIsisLsp(key, lspWrapper);
+ defaultIsisLspBin.removeIsisLsp(key, lspWrapper);
+ assertThat(defaultIsisLspBin, is(notNullValue()));
+ }
+
+ /**
+ * Tests listOfLsp() method.
+ */
+ @Test
+ public void testListOfLsp() throws Exception {
+ defaultIsisLspBin.addIsisLsp(key, lspWrapper);
+ listOfLsp = defaultIsisLspBin.listOfLsp();
+ assertThat(listOfLsp.size(), is(1));
+ }
+
+ /**
+ * Tests binNumber() method.
+ */
+ @Test
+ public void testBinNumber() throws Exception {
+ result = defaultIsisLspBin.binNumber();
+ assertThat(result, is(1));
+ }
+
+ /**
+ * Tests toString() method.
+ */
+ @Test
+ public void testToString() throws Exception {
+ assertThat(defaultIsisLspBin.toString(), is(notNullValue()));
+ }
+}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultLspWrapperTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultLspWrapperTest.java
new file mode 100644
index 0000000..617dece
--- /dev/null
+++ b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultLspWrapperTest.java
@@ -0,0 +1,111 @@
+/*
+ * 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.controller.impl.lsdb;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.isis.controller.IsisInterface;
+import org.onosproject.isis.controller.impl.DefaultIsisInterface;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Unit test case for DefaultLspWrapper.
+ */
+public class DefaultLspWrapperTest {
+
+ private DefaultLspWrapper defaultLspWrapper;
+ private String processing = "processing";
+ private String result;
+ private int result1;
+ private IsisInterface isisInterface;
+ private IsisInterface result2;
+
+ @Before
+ public void setUp() throws Exception {
+ defaultLspWrapper = new DefaultLspWrapper();
+ isisInterface = new DefaultIsisInterface();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ defaultLspWrapper = null;
+ }
+
+ /**
+ * Tests lspProcessing() getter method.
+ */
+ @Test
+ public void testLspProcessing() throws Exception {
+ defaultLspWrapper.setLspProcessing(processing);
+ result = defaultLspWrapper.lspProcessing();
+ assertThat(result, is(notNullValue()));
+ }
+
+ /**
+ * Tests lspProcessing() setter method.
+ */
+ @Test
+ public void testSetLspProcessing() throws Exception {
+ defaultLspWrapper.setLspProcessing(processing);
+ result = defaultLspWrapper.lspProcessing();
+ assertThat(result, is(notNullValue()));
+ }
+
+ /**
+ * Tests lspAgeReceived() getter method.
+ */
+ @Test
+ public void testLspAgeReceived() throws Exception {
+ defaultLspWrapper.setLspAgeReceived(1);
+ result1 = defaultLspWrapper.lspAgeReceived();
+ assertThat(result1, is(notNullValue()));
+ }
+
+ /**
+ * Tests lspAgeReceived() setter method.
+ */
+ @Test
+ public void testSetLspAgeReceived() throws Exception {
+ defaultLspWrapper.setLspAgeReceived(1);
+ result1 = defaultLspWrapper.lspAgeReceived();
+ assertThat(result1, is(notNullValue()));
+ }
+
+ /**
+ * Tests lspAgeReceived() getter method.
+ */
+ @Test
+ public void testIsisInterface() throws Exception {
+ defaultLspWrapper.setIsisInterface(isisInterface);
+ result2 = defaultLspWrapper.isisInterface();
+ assertThat(result2, is(notNullValue()));
+ }
+
+ /**
+ * Tests lspAgeReceived() getter method.
+ */
+ @Test
+ public void testSetIsisInterface() throws Exception {
+ defaultLspWrapper.setIsisInterface(isisInterface);
+ result2 = defaultLspWrapper.isisInterface();
+ assertThat(result2, is(notNullValue()));
+ }
+
+}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/IsisLspQueueConsumerTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/IsisLspQueueConsumerTest.java
new file mode 100644
index 0000000..2e592af
--- /dev/null
+++ b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/IsisLspQueueConsumerTest.java
@@ -0,0 +1,54 @@
+/*
+ * 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.controller.impl.lsdb;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.concurrent.BlockingQueue;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Unit test case for IsisLspQueueConsumer.
+ */
+public class IsisLspQueueConsumerTest {
+
+ private IsisLspQueueConsumer isisLspQueueConsumer;
+ private BlockingQueue blockingQueue;
+
+ @Before
+ public void setUp() throws Exception {
+ isisLspQueueConsumer = new IsisLspQueueConsumer(blockingQueue);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ isisLspQueueConsumer = null;
+ }
+
+ /**
+ * Tests run() method.
+ */
+ @Test
+ public void testRun() throws Exception {
+ isisLspQueueConsumer.run();
+ assertThat(isisLspQueueConsumer, is(notNullValue()));
+ }
+}
\ No newline at end of file