ONOS-4505: Bug Fixes
Change-Id: Ia030aa3aff9e2ad34a5e27fbe4ba088dda65bfa7
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
index 9a41bd3..13ec2cc 100644
--- 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
@@ -16,6 +16,8 @@
package org.onosproject.isis.controller.impl;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -30,10 +32,65 @@
public class ControllerTest {
private Controller controller;
+ private ObjectMapper mapper;
+ private JsonNode jsonNode;
+ private JsonNode jsonNode1;
+ private String jsonString = "{" +
+ " \"processes\": [{" +
+ " \"processId\": \"4.4.4.4\"," +
+ " \"interface\": [{" +
+ " \"interfaceIndex\": \"2\"," +
+ " \"macAddress\": \"08:00:27:b7:ab:bf\"," +
+ " \"interfaceIp\": \"192.168.56.101\"," +
+ " \"networkMask\": \"255.255.255.224\"," +
+ " \"intermediateSystemName\": \"ROUTERONE\"," +
+ " \"systemId\": \"2929.2929.2929\"," +
+ " \"lanId\": \"0000.0000.0000.00\"," +
+ " \"idLength\": \"0\"," +
+ " \"maxAreaAddresses\": \"3\"," +
+ " \"reservedPacketCircuitType\": \"1\"," +
+ " \"circuitId\": \"10\"," +
+ " \"networkType\": \"2\"," +
+ " \"areaAddress\": \"490000\"," +
+ " \"areaLength\": \"3\"," +
+ " \"lspId\": \"1313131313130000\"," +
+ " \"holdingTime\": \"50\"," +
+ " \"helloInterval\": \"10\"," +
+ " \"priority\": \"0\"" +
+ " }]" +
+ " }]" +
+ "}";
+ private String jsonString1 = "{" +
+ " \"processes\": {" +
+ " \"interface\": [{" +
+ " \"interfaceIndex\": \"2\"," +
+ " \"interfaceIp\": \"100.100.100.100\"," +
+ " \"macAddress\": \"08:00:27:b7:ab:bf\"," +
+ " \"networkMask\": \"255.255.255.224\"," +
+ " \"intermediateSystemName\": \"ROUTERONE\"," +
+ " \"systemId\": \"2929.2929.2929\"," +
+ " \"lanId\": \"0000.0000.0000.00\"," +
+ " \"idLength\": \"0\"," +
+ " \"maxAreaAddresses\": \"3\"," +
+ " \"reservedPacketCircuitType\": \"1\"," +
+ " \"circuitId\": \"10\"," +
+ " \"networkType\": \"2\"," +
+ " \"areaAddress\": \"490000\"," +
+ " \"areaLength\": \"3\"," +
+ " \"lspId\": \"1313131313130000\"," +
+ " \"holdingTime\": \"50\"," +
+ " \"helloInterval\": \"10\"," +
+ " \"priority\": \"0\"" +
+ " }]" +
+ " }" +
+ "}";
@Before
public void setUp() throws Exception {
controller = new Controller();
+ mapper = new ObjectMapper();
+ jsonNode = mapper.readTree(jsonString);
+ jsonNode1 = mapper.readTree(jsonString1);
}
@After
@@ -58,4 +115,18 @@
controller.getAllConfiguredProcesses();
assertThat(controller, is(notNullValue()));
}
+
+ /**
+ * Tests updateConfig() method.
+ */
+ @Test
+ public void testUpdateConfig() throws Exception {
+ jsonNode.path("interface");
+ controller.updateConfig(jsonNode);
+ assertThat(controller, is(notNullValue()));
+
+ controller.updateConfig(jsonNode1);
+ 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
index 915727d..61af4d7 100644
--- 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
@@ -15,9 +15,13 @@
*/
package org.onosproject.isis.controller.impl;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.easymock.EasyMock;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.onosproject.isis.controller.topology.IsisRouterListener;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
@@ -27,11 +31,43 @@
* Unit test case for DefaultIsisController.
*/
public class DefaultIsisControllerTest {
+ private ObjectMapper mapper;
+ private JsonNode jsonNode;
private DefaultIsisController defaultIsisController;
+ private String jsonString = "{" +
+ " \"processes\": [{" +
+ " \"processId\": \"4.4.4.4\"," +
+ " \"interface\": [{" +
+ " \"interfaceIndex\": \"2\"," +
+ " \"macAddress\": \"08:00:27:b7:ab:bf\"," +
+ " \"interfaceIp\": \"192.168.56.101\"," +
+ " \"networkMask\": \"255.255.255.224\"," +
+ " \"intermediateSystemName\": \"ROUTERONE\"," +
+ " \"systemId\": \"2929.2929.2929\"," +
+ " \"lanId\": \"0000.0000.0000.00\"," +
+ " \"idLength\": \"0\"," +
+ " \"maxAreaAddresses\": \"3\"," +
+ " \"reservedPacketCircuitType\": \"1\"," +
+ " \"circuitId\": \"10\"," +
+ " \"networkType\": \"2\"," +
+ " \"areaAddress\": \"490000\"," +
+ " \"areaLength\": \"3\"," +
+ " \"lspId\": \"1313131313130000\"," +
+ " \"holdingTime\": \"50\"," +
+ " \"helloInterval\": \"10\"," +
+ " \"priority\": \"0\"" +
+ " }]" +
+ " }]" +
+ "}";
+
+ private IsisRouterListener isisRouterListener;
@Before
public void setUp() throws Exception {
defaultIsisController = new DefaultIsisController();
+ mapper = new ObjectMapper();
+ jsonNode = mapper.readTree(jsonString);
+ isisRouterListener = EasyMock.createNiceMock(IsisRouterListener.class);
}
@After
@@ -66,4 +102,31 @@
defaultIsisController.allConfiguredProcesses();
assertThat(defaultIsisController, is(notNullValue()));
}
+
+ /**
+ * Tests updateConfig() method.
+ */
+ @Test
+ public void testUpdateConfig() throws Exception {
+ defaultIsisController.updateConfig(jsonNode);
+ assertThat(defaultIsisController, is(notNullValue()));
+ }
+
+ /**
+ * Tests addRouterListener() method.
+ */
+ @Test
+ public void testaddRouterListener() throws Exception {
+ defaultIsisController.addRouterListener(isisRouterListener);
+ assertThat(defaultIsisController, is(notNullValue()));
+ }
+
+ /**
+ * Tests removeRouterListener() method.
+ */
+ @Test
+ public void testremoveRouterListener() throws Exception {
+ defaultIsisController.removeRouterListener(isisRouterListener);
+ 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
index 7e7749f..fe8a57a 100644
--- 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
@@ -15,6 +15,10 @@
*/
package org.onosproject.isis.controller.impl;
+import org.easymock.EasyMock;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.jboss.netty.channel.Channel;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -23,15 +27,30 @@
import org.onosproject.isis.controller.IsisInterface;
import org.onosproject.isis.controller.IsisInterfaceState;
import org.onosproject.isis.controller.IsisLsdb;
+import org.onosproject.isis.controller.IsisMessage;
import org.onosproject.isis.controller.IsisNeighbor;
import org.onosproject.isis.controller.IsisNetworkType;
+import org.onosproject.isis.controller.IsisPduType;
+import org.onosproject.isis.controller.IsisRouterType;
+import org.onosproject.isis.controller.impl.lsdb.DefaultIsisLsdb;
import org.onosproject.isis.io.isispacket.IsisHeader;
-import org.onosproject.isis.io.isispacket.pdu.HelloPdu;
+import org.onosproject.isis.io.isispacket.pdu.Csnp;
import org.onosproject.isis.io.isispacket.pdu.L1L2HelloPdu;
+import org.onosproject.isis.io.isispacket.pdu.LsPdu;
+import org.onosproject.isis.io.isispacket.pdu.P2PHelloPdu;
+import org.onosproject.isis.io.isispacket.pdu.Psnp;
+import org.onosproject.isis.io.isispacket.tlv.AdjacencyStateTlv;
+import org.onosproject.isis.io.isispacket.tlv.AreaAddressTlv;
+import org.onosproject.isis.io.isispacket.tlv.LspEntriesTlv;
+import org.onosproject.isis.io.isispacket.tlv.LspEntry;
+import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
+import org.onosproject.isis.io.isispacket.tlv.TlvType;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Set;
-import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;
/**
@@ -39,16 +58,26 @@
*/
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 MacAddress macAddress1 = MacAddress.valueOf("AA:CC:CC:DD:EE:FF");
+ private final Ip4Address ip4Address = Ip4Address.valueOf("10.10.0.0");
private final byte[] mask = {
(byte) 255, (byte) 255, (byte) 255, (byte) 224
};
+ private final byte[] mask1 = {
+ (byte) 0, (byte) 0, (byte) 0, (byte) 0
+ };
private final String intSysName = "ROUTER";
private final String sysId = "1111.1111.1111";
private final String areaAddr = "49.002";
+ private final byte[] csnpBytes = {
+ 0, 67, 18, 52, 18, 52, 0,
+ 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1,
+ -1, -1, 9, 32, 4, -81, 18, 52, 18, 52, 0, 18, 0, 0, 0,
+ 0, 0, 41, -92, -30, 4, -81, 41, 41, 41, 41, 41, 41, 0,
+ 0, 0, 0, 0, 1, 91, 126
+ };
private IsisInterfaceState resultIfState;
private DefaultIsisInterface defaultIsisInterface;
- private HelloPdu helloPdu;
private IsisHeader isisHeader;
private IsisInterface isisInterface;
private Set<MacAddress> resultSet;
@@ -60,18 +89,35 @@
private byte[] resultByteArr;
private String resultStr;
private IsisNetworkType resultNwType;
-
+ private List<Ip4Address> ip4Addresses = new ArrayList<>();
+ private DefaultIsisNeighbor defaultIsisNeighbor;
+ private IsisNeighbor result;
+ private IsisLsdb result1;
+ private Set<MacAddress> result2;
+ private Channel result3;
+ private IsisMessage isisMessage;
+ private IsisLsdb isisLsdb;
+ private Channel channel;
+ private L1L2HelloPdu helloPdu;
+ private LsPdu lsPdu;
+ private Csnp csnp;
+ private Psnp psnp;
+ private P2PHelloPdu p2PHelloPdu;
+ private boolean result4;
+ private String result5;
@Before
public void setUp() throws Exception {
+ channel = EasyMock.createNiceMock(Channel.class);
defaultIsisInterface = new DefaultIsisInterface();
+ defaultIsisInterface.setInterfaceMacAddress(macAddress);
isisHeader = new IsisHeader();
isisHeader.setIrpDiscriminator((byte) 1);
helloPdu = new L1L2HelloPdu(isisHeader);
isisInterface = new DefaultIsisInterface();
- resultNeighborList = new DefaultIsisNeighbor(helloPdu, isisInterface);
-
-
+ defaultIsisNeighbor = new DefaultIsisNeighbor(helloPdu, isisInterface);
+ defaultIsisNeighbor.setNeighborMacAddress(macAddress);
+ isisLsdb = new DefaultIsisLsdb();
}
@After
@@ -365,26 +411,6 @@
}
/**
- * 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
@@ -483,4 +509,369 @@
resultStr = defaultIsisInterface.circuitId();
assertThat(resultStr, is(sysId));
}
+
+ /**
+ * Tests setAllConfiguredInterfaceIps() setter method.
+ */
+ @Test
+ public void testSetAllConfiguredInterfaceIps() throws Exception {
+ ip4Addresses.add(ip4Address);
+ defaultIsisInterface.setAllConfiguredInterfaceIps(ip4Addresses);
+ assertThat(defaultIsisInterface, is(notNullValue()));
+ }
+
+ /**
+ * Tests setAllConfiguredInterfaceIps() method.
+ */
+ @Test
+ public void testRemoveNeighbor() throws Exception {
+ defaultIsisInterface.removeNeighbor(defaultIsisNeighbor);
+ assertThat(defaultIsisInterface, is(notNullValue()));
+ }
+
+ /**
+ * Tests lookup() method.
+ */
+ @Test
+ public void testLookup() throws Exception {
+ result = defaultIsisInterface.lookup(defaultIsisNeighbor.neighborMacAddress());
+ assertThat(result, is(nullValue()));
+ }
+
+ /**
+ * Tests isisLsdb() method.
+ */
+ @Test
+ public void testIsisLsdb() throws Exception {
+ result1 = defaultIsisInterface.isisLsdb();
+ assertThat(result1, is(nullValue()));
+ }
+
+ /**
+ * Tests neighbors() method.
+ */
+ @Test
+ public void testNeighbors() throws Exception {
+ result2 = defaultIsisInterface.neighbors();
+ assertThat(result2, is(notNullValue()));
+ }
+
+ /**
+ * Tests channel() method.
+ */
+ @Test
+ public void testChannel() throws Exception {
+ result3 = defaultIsisInterface.channel();
+ assertThat(result3, is(nullValue()));
+ }
+
+ /**
+ * Tests processIsisMessage() method.
+ */
+ @Test
+ public void testProcessIsisMessage() throws Exception {
+ helloPdu = new L1L2HelloPdu(isisHeader);
+ helloPdu.setSourceMac(macAddress1);
+ helloPdu.setIsisPduType(IsisPduType.L2HELLOPDU.value());
+ defaultIsisInterface.setNetworkType(IsisNetworkType.BROADCAST);
+ isisMessage = helloPdu;
+ defaultIsisInterface.processIsisMessage(isisMessage, isisLsdb, channel);
+ assertThat(defaultIsisInterface, is(notNullValue()));
+ }
+
+ /**
+ * Tests processIsisMessage() method.
+ */
+ @Test(expected = Exception.class)
+ public void testProcessIsisMessage1() throws Exception {
+ lsPdu = new LsPdu(isisHeader);
+ lsPdu.setSourceMac(macAddress1);
+ lsPdu.setIsisPduType(IsisPduType.L2LSPDU.value());
+ isisMessage = lsPdu;
+ defaultIsisInterface.processIsisMessage(isisMessage, isisLsdb, channel);
+ assertThat(defaultIsisInterface, is(notNullValue()));
+ }
+
+ /**
+ * Tests processIsisMessage() method.
+ */
+ @Test
+ public void testProcessIsisMessage2() throws Exception {
+ csnp = new Csnp(isisHeader);
+ csnp.setSourceMac(macAddress1);
+ csnp.setIsisPduType(IsisPduType.L2CSNP.value());
+ isisMessage = csnp;
+ defaultIsisInterface.processIsisMessage(isisMessage, isisLsdb, channel);
+ assertThat(defaultIsisInterface, is(notNullValue()));
+ }
+
+ /**
+ * Tests processIsisMessage() method.
+ */
+ @Test
+ public void testProcessIsisMessage3() throws Exception {
+ psnp = new Psnp(isisHeader);
+ psnp.setSourceMac(macAddress1);
+ psnp.setIsisPduType(IsisPduType.L2PSNP.value());
+ isisMessage = psnp;
+ defaultIsisInterface.processIsisMessage(isisMessage, isisLsdb, channel);
+ assertThat(defaultIsisInterface, is(notNullValue()));
+ }
+
+ /**
+ * Tests processIsisMessage() method.
+ */
+ @Test
+ public void testProcessIsisMessage4() throws Exception {
+ p2PHelloPdu = new P2PHelloPdu(isisHeader);
+ p2PHelloPdu.setSourceMac(macAddress1);
+ p2PHelloPdu.setIsisPduType(IsisPduType.P2PHELLOPDU.value());
+ defaultIsisInterface.setNetworkType(IsisNetworkType.P2P);
+ isisMessage = p2PHelloPdu;
+ defaultIsisInterface.processIsisMessage(isisMessage, isisLsdb, channel);
+ assertThat(defaultIsisInterface, is(notNullValue()));
+ }
+
+ /**
+ * Tests validateHelloMessage() method.
+ */
+ @Test
+ public void testValidateHelloMessage() throws Exception {
+ helloPdu = new L1L2HelloPdu(isisHeader);
+ result4 = defaultIsisInterface.validateHelloMessage(helloPdu);
+ assertThat(result4, is(false));
+ }
+
+ /**
+ * Tests processL1L2HelloPduMessage() method.
+ */
+ @Test(expected = Exception.class)
+ public void testProcessL1L2HelloPduMessage() throws Exception {
+ helloPdu = new L1L2HelloPdu(isisHeader);
+ helloPdu.setSourceMac(macAddress1);
+ helloPdu.setCircuitType((byte) IsisRouterType.L2.value());
+ defaultIsisInterface.processL1L2HelloPduMessage(helloPdu, channel);
+ assertThat(defaultIsisInterface, is(notNullValue()));
+ }
+
+ /**
+ * Tests processP2pHelloPduMessage() method.
+ */
+ @Test(expected = Exception.class)
+ public void testProcessP2pHelloPduMessagee() throws Exception {
+ defaultIsisInterface.setSystemId(sysId);
+ p2PHelloPdu = new P2PHelloPdu(isisHeader);
+ p2PHelloPdu.setIsisPduType(IsisPduType.P2PHELLOPDU.value());
+ p2PHelloPdu.setSourceMac(macAddress1);
+ p2PHelloPdu.setCircuitType((byte) IsisRouterType.L2.value());
+ defaultIsisInterface.setNetworkType(IsisNetworkType.P2P);
+ defaultIsisInterface.processIsisMessage(p2PHelloPdu, isisLsdb, channel);
+ assertThat(defaultIsisInterface, is(notNullValue()));
+ }
+
+ /**
+ * Tests processP2pHelloPduMessage() method.
+ */
+ @Test(expected = Exception.class)
+ public void testProcessP2pHelloPduMessagee1() throws Exception {
+ defaultIsisInterface.setSystemId(sysId);
+ p2PHelloPdu = new P2PHelloPdu(isisHeader);
+ p2PHelloPdu.setIsisPduType(IsisPduType.P2PHELLOPDU.value());
+ p2PHelloPdu.setSourceMac(macAddress1);
+ p2PHelloPdu.setCircuitType((byte) IsisRouterType.L2.value());
+ defaultIsisInterface.setNetworkType(IsisNetworkType.P2P);
+ defaultIsisInterface.setReservedPacketCircuitType(IsisRouterType.L2.value());
+ defaultIsisInterface.setAllConfiguredInterfaceIps(ip4Addresses);
+ defaultIsisInterface.setInterfaceIpAddress(ip4Address);
+ defaultIsisInterface.setNetworkMask(mask1);
+ defaultIsisInterface.processIsisMessage(p2PHelloPdu, isisLsdb, channel);
+ assertThat(defaultIsisInterface, is(notNullValue()));
+ }
+
+ /**
+ * Tests processP2pHelloPduMessage() method.
+ */
+ @Test(expected = Exception.class)
+ public void testProcessP2pHelloPduMessagee2() throws Exception {
+ defaultIsisInterface.setSystemId(sysId);
+ p2PHelloPdu = new P2PHelloPdu(isisHeader);
+ TlvHeader tlvHeader = new TlvHeader();
+ tlvHeader.setTlvType(TlvType.AREAADDRESS.value());
+ AreaAddressTlv areaAddressTlv = new AreaAddressTlv(tlvHeader);
+ areaAddressTlv.addAddress(areaAddr);
+ p2PHelloPdu.addTlv(areaAddressTlv);
+ p2PHelloPdu.setIsisPduType(IsisPduType.P2PHELLOPDU.value());
+ p2PHelloPdu.setSourceMac(macAddress1);
+ p2PHelloPdu.setCircuitType((byte) IsisRouterType.L1.value());
+ defaultIsisInterface.setNetworkType(IsisNetworkType.P2P);
+ defaultIsisInterface.setReservedPacketCircuitType(IsisRouterType.L1.value());
+ defaultIsisInterface.setAreaAddress(areaAddr);
+ defaultIsisInterface.setAllConfiguredInterfaceIps(ip4Addresses);
+ defaultIsisInterface.setInterfaceIpAddress(ip4Address);
+ defaultIsisInterface.setNetworkMask(mask1);
+ defaultIsisInterface.processIsisMessage(p2PHelloPdu, isisLsdb, channel);
+ assertThat(defaultIsisInterface, is(notNullValue()));
+ }
+
+ /**
+ * Tests processP2pHelloPduMessage() method.
+ */
+ @Test(expected = Exception.class)
+ public void testProcessP2pHelloPduMessagee3() throws Exception {
+ defaultIsisInterface.setSystemId(sysId);
+ p2PHelloPdu = new P2PHelloPdu(isisHeader);
+ TlvHeader tlvHeader = new TlvHeader();
+ tlvHeader.setTlvType(TlvType.ADJACENCYSTATE.value());
+ AdjacencyStateTlv adjacencyStateTlv = new AdjacencyStateTlv(tlvHeader);
+ adjacencyStateTlv.setNeighborSystemId(sysId);
+ adjacencyStateTlv.setAdjacencyType((byte) IsisInterfaceState.DOWN.value());
+ p2PHelloPdu.addTlv(adjacencyStateTlv);
+ tlvHeader = new TlvHeader();
+ tlvHeader.setTlvType(TlvType.AREAADDRESS.value());
+ AreaAddressTlv areaAddressTlv = new AreaAddressTlv(tlvHeader);
+ areaAddressTlv.addAddress(areaAddr);
+ p2PHelloPdu.addTlv(areaAddressTlv);
+ p2PHelloPdu.setIsisPduType(IsisPduType.P2PHELLOPDU.value());
+ p2PHelloPdu.setSourceMac(macAddress1);
+ p2PHelloPdu.setCircuitType((byte) IsisRouterType.L1.value());
+ defaultIsisInterface.setNetworkType(IsisNetworkType.P2P);
+ defaultIsisInterface.setReservedPacketCircuitType(IsisRouterType.L1.value());
+ defaultIsisInterface.setAreaAddress(areaAddr);
+ defaultIsisInterface.setAllConfiguredInterfaceIps(ip4Addresses);
+ defaultIsisInterface.setInterfaceIpAddress(ip4Address);
+ defaultIsisInterface.setNetworkMask(mask1);
+ defaultIsisInterface.processIsisMessage(p2PHelloPdu, isisLsdb, channel);
+ assertThat(defaultIsisInterface, is(notNullValue()));
+ }
+
+ /**
+ * Tests processP2pHelloPduMessage() method.
+ */
+ @Test(expected = Exception.class)
+ public void testProcessP2pHelloPduMessagee4() throws Exception {
+ defaultIsisInterface.setSystemId(sysId);
+ p2PHelloPdu = new P2PHelloPdu(isisHeader);
+ TlvHeader tlvHeader = new TlvHeader();
+ tlvHeader.setTlvType(TlvType.ADJACENCYSTATE.value());
+ AdjacencyStateTlv adjacencyStateTlv = new AdjacencyStateTlv(tlvHeader);
+ adjacencyStateTlv.setNeighborSystemId(sysId);
+ adjacencyStateTlv.setAdjacencyType((byte) IsisInterfaceState.INITIAL.value());
+ p2PHelloPdu.addTlv(adjacencyStateTlv);
+ tlvHeader = new TlvHeader();
+ tlvHeader.setTlvType(TlvType.AREAADDRESS.value());
+ AreaAddressTlv areaAddressTlv = new AreaAddressTlv(tlvHeader);
+ areaAddressTlv.addAddress(areaAddr);
+ p2PHelloPdu.addTlv(areaAddressTlv);
+ p2PHelloPdu.setIsisPduType(IsisPduType.P2PHELLOPDU.value());
+ p2PHelloPdu.setSourceMac(macAddress1);
+ p2PHelloPdu.setCircuitType((byte) IsisRouterType.L1.value());
+ defaultIsisInterface.setNetworkType(IsisNetworkType.P2P);
+ defaultIsisInterface.setReservedPacketCircuitType(IsisRouterType.L1L2.value());
+ defaultIsisInterface.setAreaAddress(areaAddr);
+ defaultIsisInterface.setAllConfiguredInterfaceIps(ip4Addresses);
+ defaultIsisInterface.setInterfaceIpAddress(ip4Address);
+ defaultIsisInterface.setNetworkMask(mask1);
+ defaultIsisInterface.processIsisMessage(p2PHelloPdu, isisLsdb, channel);
+ assertThat(defaultIsisInterface, is(notNullValue()));
+ }
+
+ @Test(expected = Exception.class)
+ public void testProcessP2pHelloPduMessagee5() throws Exception {
+ defaultIsisInterface.setSystemId(sysId);
+ p2PHelloPdu = new P2PHelloPdu(isisHeader);
+ TlvHeader tlvHeader = new TlvHeader();
+ tlvHeader.setTlvType(TlvType.ADJACENCYSTATE.value());
+ AdjacencyStateTlv adjacencyStateTlv = new AdjacencyStateTlv(tlvHeader);
+ adjacencyStateTlv.setNeighborSystemId(sysId);
+ adjacencyStateTlv.setAdjacencyType((byte) IsisInterfaceState.UP.value());
+ p2PHelloPdu.addTlv(adjacencyStateTlv);
+ tlvHeader = new TlvHeader();
+ tlvHeader.setTlvType(TlvType.AREAADDRESS.value());
+ AreaAddressTlv areaAddressTlv = new AreaAddressTlv(tlvHeader);
+ areaAddressTlv.addAddress(areaAddr);
+ p2PHelloPdu.addTlv(areaAddressTlv);
+ p2PHelloPdu.setIsisPduType(IsisPduType.P2PHELLOPDU.value());
+ p2PHelloPdu.setSourceMac(macAddress1);
+ p2PHelloPdu.setCircuitType((byte) IsisRouterType.L2.value());
+ defaultIsisInterface.setNetworkType(IsisNetworkType.P2P);
+ defaultIsisInterface.setReservedPacketCircuitType(IsisRouterType.L1L2.value());
+ defaultIsisInterface.setAreaAddress(areaAddr);
+ defaultIsisInterface.setAllConfiguredInterfaceIps(ip4Addresses);
+ defaultIsisInterface.setInterfaceIpAddress(ip4Address);
+ defaultIsisInterface.setNetworkMask(mask1);
+ defaultIsisInterface.processIsisMessage(p2PHelloPdu, isisLsdb, channel);
+ assertThat(defaultIsisInterface, is(notNullValue()));
+ }
+
+ /**
+ * Tests startHelloSender() method.
+ */
+ @Test(expected = Exception.class)
+ public void testStartHelloSender() throws Exception {
+ defaultIsisInterface.startHelloSender(channel);
+ assertThat(defaultIsisInterface, is(notNullValue()));
+ }
+
+ /**
+ * Tests lspKeyP2P() method.
+ */
+ @Test
+ public void testLspKeyP2P() throws Exception {
+ result5 = defaultIsisInterface.lspKeyP2P(sysId);
+ assertThat(result5, is(notNullValue()));
+ }
+
+ /**
+ * Tests processLsPduMessage() method.
+ */
+ @Test
+ public void testProcessLsPduMessage() throws Exception {
+ lsPdu = new LsPdu(isisHeader);
+ lsPdu.setSourceMac(macAddress1);
+ lsPdu.setIsisPduType(IsisPduType.L2LSPDU.value());
+ lsPdu.setLspId(sysId);
+ isisMessage = lsPdu;
+ defaultIsisInterface.setNetworkType(IsisNetworkType.P2P);
+ defaultIsisInterface.setSystemId(sysId);
+ defaultIsisInterface.processIsisMessage(isisMessage, isisLsdb, channel);
+ assertThat(defaultIsisInterface, is(notNullValue()));
+ }
+
+ /**
+ * Tests processPsnPduMessage() method.
+ */
+ @Test
+ public void testProcessPsnPduMessage() throws Exception {
+ psnp = new Psnp(isisHeader);
+ psnp.setSourceMac(macAddress1);
+ psnp.setIsisPduType(IsisPduType.L2PSNP.value());
+ TlvHeader tlvHeader = new TlvHeader();
+ tlvHeader.setTlvType(TlvType.LSPENTRY.value());
+ tlvHeader.setTlvLength(0);
+ LspEntriesTlv lspEntriesTlv = new LspEntriesTlv(tlvHeader);
+ LspEntry lspEntry = new LspEntry();
+ lspEntry.setLspChecksum(0);
+ lspEntry.setLspSequenceNumber(0);
+ lspEntry.setRemainingTime(0);
+ lspEntriesTlv.addLspEntry(lspEntry);
+ psnp.addTlv(lspEntriesTlv);
+ isisMessage = psnp;
+ defaultIsisInterface.processIsisMessage(isisMessage, isisLsdb, channel);
+ assertThat(defaultIsisInterface, is(notNullValue()));
+ }
+
+ /**
+ * Tests processCsnPduMessage() method.
+ */
+ @Test(expected = Exception.class)
+ public void testProcessCsnPduMessage() throws Exception {
+ ChannelBuffer channelBuffer = ChannelBuffers.copiedBuffer(csnpBytes);
+ csnp = new Csnp(isisHeader);
+ csnp.readFrom(channelBuffer);
+ csnp.setSourceMac(macAddress1);
+ csnp.setIsisPduType(IsisPduType.L2CSNP.value());
+ isisMessage = csnp;
+ defaultIsisInterface.processIsisMessage(isisMessage, isisLsdb, channel);
+ assertThat(defaultIsisInterface, is(notNullValue()));
+ }
}
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
index 3c16a14..95717cd 100644
--- 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
@@ -36,6 +36,7 @@
private final String processId = "1";
private IsisProcess isisProcess;
private String result;
+ private IsisProcess defaultIsisProcess;
private IsisInterface isisInterface;
private List<IsisInterface> isisInterfaceList;
private List<IsisInterface> result1;
@@ -44,6 +45,7 @@
public void setUp() throws Exception {
isisProcess = new DefaultIsisProcess();
isisInterface = EasyMock.createNiceMock(DefaultIsisInterface.class);
+ defaultIsisProcess = new DefaultIsisProcess();
}
@After
@@ -90,4 +92,4 @@
result1 = isisProcess.isisInterfaceList();
assertThat(result1, is(nullValue()));
}
-}
+}
\ No newline at end of file
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
index 1644b6e..9081cdf 100644
--- 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
@@ -23,10 +23,14 @@
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.onlab.packet.Ip4Address;
+import org.onosproject.isis.controller.IsisInterface;
import org.onosproject.isis.controller.IsisMessage;
+import org.onosproject.isis.controller.IsisNetworkType;
import org.onosproject.isis.controller.IsisProcess;
import org.onosproject.isis.io.isispacket.pdu.L1L2HelloPdu;
+import java.util.ArrayList;
import java.util.List;
import static org.hamcrest.CoreMatchers.is;
@@ -43,12 +47,14 @@
private IsisChannelHandler isisChannelHandler;
private Controller controller;
private IsisProcess isisProcess;
- private List<IsisProcess> isisProcessList;
+ private List<IsisProcess> isisProcessList = new ArrayList();
private ChannelHandlerContext channelHandlerContext;
private ChannelStateEvent channelStateEvent;
private ExceptionEvent exceptionEvent;
private MessageEvent messageEvent;
private IsisMessage isisMessage;
+ private List<IsisInterface> isisInterfaceList = new ArrayList<>();
+ private Ip4Address ip4Address = Ip4Address.valueOf("10.10.10.10");
@Before
public void setUp() throws Exception {
@@ -71,7 +77,7 @@
/**
* Tests initializeInterfaceMap() method.
*/
- @Test(expected = Exception.class)
+ @Test
public void testInitializeInterfaceMap() throws Exception {
isisChannelHandler.initializeInterfaceMap();
assertThat(isisChannelHandler, is(notNullValue()));
@@ -82,6 +88,32 @@
*/
@Test(expected = Exception.class)
public void testUpdateInterfaceMap() throws Exception {
+ IsisInterface isisInterface = new DefaultIsisInterface();
+ IsisInterface isisInterface1 = new DefaultIsisInterface();
+ isisInterface.setInterfaceIpAddress(ip4Address);
+ isisInterface.setInterfaceIndex(1);
+ isisInterfaceList.add(isisInterface);
+ IsisProcess isisProcess = new DefaultIsisProcess();
+ isisProcess.setIsisInterfaceList(isisInterfaceList);
+ isisProcessList.add(isisProcess);
+ isisChannelHandler.updateInterfaceMap(isisProcessList);
+ assertThat(isisChannelHandler, is(notNullValue()));
+ isisProcessList = new ArrayList<>();
+ isisInterface1.setInterfaceIpAddress(ip4Address);
+ isisInterface1.setInterfaceIndex(1);
+ isisInterface1.setInterfaceIpAddress(ip4Address);
+ isisInterface1.setInterfaceIndex(1);
+ isisInterface1.setSystemId("9999.9999.9999");
+ isisInterface1.setIntermediateSystemName("router");
+ isisInterface1.setReservedPacketCircuitType(3);
+ isisInterface1.setCircuitId("10");
+ isisInterface1.setNetworkType(IsisNetworkType.BROADCAST);
+ isisInterface1.setAreaAddress("490001");
+ isisInterface1.setHoldingTime(50);
+ isisInterface1.setHelloInterval(10);
+ isisInterfaceList.add(isisInterface1);
+ isisProcess.setIsisInterfaceList(isisInterfaceList);
+ isisProcessList.add(isisProcess);
isisChannelHandler.updateInterfaceMap(isisProcessList);
assertThat(isisChannelHandler, is(notNullValue()));
}
@@ -89,7 +121,7 @@
/**
* Tests initializeInterfaceIpList() method.
*/
- @Test(expected = Exception.class)
+ @Test
public void testInitializeInterfaceIpList() throws Exception {
isisChannelHandler.initializeInterfaceIpList();
assertThat(isisChannelHandler, is(notNullValue()));
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
index 85228b2..ef089a1 100644
--- 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
@@ -58,7 +58,7 @@
/**
* Tests run() method.
*/
- @Test
+ @Test(expected = Exception.class)
public void testRun() throws Exception {
isisInterface.setNetworkType(IsisNetworkType.P2P);
isisInterface.setCircuitId(circuitId);
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
index a2c32b9..4948ec6 100644
--- 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
@@ -24,11 +24,14 @@
public class IsisMessageDecoderTest {
private final byte[] hello = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-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 byte[] array2 = {0, 0, 0, 0, 0, 0, 0};
private final String id = "127.0.0.1";
+ private byte[] array1;
private IsisMessageDecoder isisMessageDecoder;
private ChannelHandlerContext ctx;
private Channel channel;
@@ -49,7 +52,8 @@
public void testDecode() throws Exception {
channel = EasyMock.createMock(Channel.class);
socketAddress = InetSocketAddress.createUnresolved(id, 7000);
- byte[] array = IsisUtil.getPaddingTlvs(hello.length);
+ byte[] array = IsisUtil.getPaddingTlvs(hello.length - 17);
+ array1 = Bytes.concat(hello, array);
channelBuffer = ChannelBuffers.copiedBuffer(Bytes.concat(hello, array));
assertThat(isisMessageDecoder.decode(ctx, channel, channelBuffer), is(nullValue()));
}
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
index d1c04fe..bc67ad3 100644
--- 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
@@ -22,8 +22,13 @@
import org.onosproject.isis.controller.IsisLsdbAge;
import org.onosproject.isis.controller.IsisPduType;
import org.onosproject.isis.controller.LspWrapper;
+import org.onosproject.isis.controller.impl.DefaultIsisInterface;
+import org.onosproject.isis.io.isispacket.IsisHeader;
+import org.onosproject.isis.io.isispacket.pdu.AttachedToOtherAreas;
+import org.onosproject.isis.io.isispacket.pdu.LsPdu;
import org.onosproject.isis.io.util.IsisConstants;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -37,19 +42,27 @@
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;
-
+ private List<LspWrapper> lspWrapperList;
+ private LsPdu lsPdu;
+ private IsisHeader isisHeader;
+ private DefaultIsisInterface defaultIsisInterface;
+ private String lspId = "1234.1234.1234.00-00";
+ private String result;
@Before
public void setUp() throws Exception {
+ defaultIsisInterface = new DefaultIsisInterface();
+ isisHeader = new IsisHeader();
+ lsPdu = new LsPdu(isisHeader);
+ lsPdu.setLspId(lspId);
+ lsPdu.setAttachedToOtherAreas(AttachedToOtherAreas.DEFAULTMETRIC);
+ lsPdu.setIsisPduType(IsisPduType.L1LSPDU.value());
defaultIsisLsdb = new DefaultIsisLsdb();
}
@@ -129,5 +142,60 @@
resultLspWrapper = defaultIsisLsdb.findLsp(IsisPduType.L1HELLOPDU, srcId);
assertThat(resultLspWrapper, is(nullValue()));
}
+
+ /**
+ * Tests allLspHeaders() method.
+ */
+ @Test
+ public void testAllLspHeaders() throws Exception {
+ defaultIsisLsdb.addLsp(lsPdu, false, defaultIsisInterface);
+ lspWrapperList = defaultIsisLsdb.allLspHeaders(true);
+ assertThat(lspWrapperList, is(notNullValue()));
+
+ defaultIsisLsdb.addLsp(lsPdu, true, defaultIsisInterface);
+ lspWrapperList = defaultIsisLsdb.allLspHeaders(true);
+ assertThat(lspWrapperList, is(notNullValue()));
+ }
+
+ /**
+ * Tests isNewerOrSameLsp() method.
+ */
+ @Test
+ public void testIsNewerOrSameLsp() throws Exception {
+ result = defaultIsisLsdb.isNewerOrSameLsp(lsPdu, lsPdu);
+ assertThat(result, is("same"));
+ }
+
+ /**
+ * Tests lsSequenceNumber() method.
+ */
+ @Test
+ public void testLsSequenceNumber() throws Exception {
+ resultInt = defaultIsisLsdb.lsSequenceNumber(IsisPduType.L1LSPDU);
+ assertThat(resultInt, is(1));
+
+ resultInt = defaultIsisLsdb.lsSequenceNumber(IsisPduType.L2LSPDU);
+ assertThat(resultInt, is(1));
+
+ resultInt = defaultIsisLsdb.lsSequenceNumber(IsisPduType.L1CSNP);
+ assertThat(resultInt, is(1));
+ }
+
+ /**
+ * Tests deleteLsp() method.
+ */
+ @Test
+ public void testdeleteLsp() throws Exception {
+ defaultIsisLsdb.deleteLsp(lsPdu);
+ assertThat(defaultIsisLsdb, is(notNullValue()));
+
+ lsPdu.setIsisPduType(IsisPduType.L2LSPDU.value());
+ defaultIsisLsdb.deleteLsp(lsPdu);
+ assertThat(defaultIsisLsdb, is(notNullValue()));
+
+ lsPdu.setIsisPduType(IsisPduType.L1CSNP.value());
+ defaultIsisLsdb.deleteLsp(lsPdu);
+ assertThat(defaultIsisLsdb, is(notNullValue()));
+ }
}
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
index 617dece..02eed12 100644
--- 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
@@ -19,7 +19,11 @@
import org.junit.Before;
import org.junit.Test;
import org.onosproject.isis.controller.IsisInterface;
+import org.onosproject.isis.controller.IsisLsdbAge;
+import org.onosproject.isis.controller.IsisPduType;
import org.onosproject.isis.controller.impl.DefaultIsisInterface;
+import org.onosproject.isis.io.isispacket.IsisHeader;
+import org.onosproject.isis.io.isispacket.pdu.LsPdu;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
@@ -36,11 +40,20 @@
private int result1;
private IsisInterface isisInterface;
private IsisInterface result2;
+ private IsisPduType isisPduType;
+ private boolean result3;
+ private LsPdu lsPdu;
+ private LsPdu pdu;
+ private DefaultIsisLsdbAge defaultIsisLsdbAge;
+ private IsisLsdbAge lsdbAge;
@Before
public void setUp() throws Exception {
defaultLspWrapper = new DefaultLspWrapper();
isisInterface = new DefaultIsisInterface();
+ pdu = new LsPdu(new IsisHeader());
+ defaultIsisLsdbAge = new DefaultIsisLsdbAge();
+ defaultIsisLsdbAge.startDbAging();
}
@After
@@ -108,4 +121,169 @@
assertThat(result2, is(notNullValue()));
}
+ /**
+ * Tests ageCounterWhenReceived() getter method.
+ */
+ @Test
+ public void testAgeCounterWhenReceived() throws Exception {
+ defaultLspWrapper.setAgeCounterWhenReceived(1);
+ result1 = defaultLspWrapper.ageCounterWhenReceived();
+ assertThat(result1, is(notNullValue()));
+ }
+
+ /**
+ * Tests ageCounterWhenReceived() setter method.
+ */
+ @Test
+ public void testSetAgeCounterWhenReceived() throws Exception {
+ defaultLspWrapper.setAgeCounterWhenReceived(1);
+ result1 = defaultLspWrapper.ageCounterWhenReceived();
+ assertThat(result1, is(notNullValue()));
+ }
+
+ /**
+ * Tests ageCounterRollOverWhenAdded() getter method.
+ */
+ @Test
+ public void testAgeCounterRollOverWhenAdded() throws Exception {
+ defaultLspWrapper.setAgeCounterRollOverWhenAdded(1);
+ result1 = defaultLspWrapper.ageCounterRollOverWhenAdded();
+ assertThat(result1, is(notNullValue()));
+ }
+
+ /**
+ * Tests ageCounterRollOverWhenAdded() setter method.
+ */
+ @Test
+ public void testSetAgeCounterRollOverWhenAdded() throws Exception {
+ defaultLspWrapper.setAgeCounterRollOverWhenAdded(1);
+ result1 = defaultLspWrapper.ageCounterRollOverWhenAdded();
+ assertThat(result1, is(notNullValue()));
+ }
+
+ /**
+ * Tests lspType() getter method.
+ */
+ @Test
+ public void testLspType() throws Exception {
+ defaultLspWrapper.setLspType(IsisPduType.L1LSPDU);
+ isisPduType = defaultLspWrapper.lspType();
+ assertThat(isisPduType, is(IsisPduType.L1LSPDU));
+ }
+
+ /**
+ * Tests lspType() setter method.
+ */
+ @Test
+ public void testSetLspType() throws Exception {
+ defaultLspWrapper.setLspType(IsisPduType.L1LSPDU);
+ isisPduType = defaultLspWrapper.lspType();
+ assertThat(isisPduType, is(IsisPduType.L1LSPDU));
+ }
+
+ /**
+ * Tests isSelfOriginated() getter method.
+ */
+ @Test
+ public void testIsSelfOriginated() throws Exception {
+ defaultLspWrapper.setSelfOriginated(true);
+ result3 = defaultLspWrapper.isSelfOriginated();
+ assertThat(result3, is(true));
+ }
+
+ /**
+ * Tests isSelfOriginated() setter method.
+ */
+ @Test
+ public void testSetSelfOriginated() throws Exception {
+ defaultLspWrapper.setSelfOriginated(true);
+ result3 = defaultLspWrapper.isSelfOriginated();
+ assertThat(result3, is(true));
+ }
+
+ /**
+ * Tests binNumber() getter method.
+ */
+ @Test
+ public void testBinNumber() throws Exception {
+ defaultLspWrapper.setBinNumber(1);
+ result1 = defaultLspWrapper.binNumber();
+ assertThat(result1, is(1));
+ }
+
+ /**
+ * Tests binNumber() setter method.
+ */
+ @Test
+ public void testSetBinNumber() throws Exception {
+ defaultLspWrapper.setBinNumber(1);
+ result1 = defaultLspWrapper.binNumber();
+ assertThat(result1, is(1));
+ }
+
+ /**
+ * Tests lsPdu() getter method.
+ */
+ @Test
+ public void testLsPdu() throws Exception {
+ defaultLspWrapper.setLsPdu(pdu);
+ lsPdu = defaultLspWrapper.lsPdu();
+ assertThat(lsPdu, is(pdu));
+ }
+
+ /**
+ * Tests lsPdu() setter method.
+ */
+ @Test
+ public void testSetLsPdu() throws Exception {
+ defaultLspWrapper.setLsPdu(pdu);
+ lsPdu = defaultLspWrapper.lsPdu();
+ assertThat(lsPdu, is(pdu));
+ }
+
+ /**
+ * Tests lsdbAge() getter method.
+ */
+ @Test
+ public void testlsdbAge() throws Exception {
+ defaultLspWrapper.setLsdbAge(defaultIsisLsdbAge);
+ lsdbAge = defaultLspWrapper.lsdbAge();
+ assertThat(lsdbAge, is(defaultIsisLsdbAge));
+ }
+
+ /**
+ * Tests lsdbAge() setter method.
+ */
+ @Test
+ public void testSetLsdbAge() throws Exception {
+ defaultLspWrapper.setLsdbAge(defaultIsisLsdbAge);
+ lsdbAge = defaultLspWrapper.lsdbAge();
+ assertThat(lsdbAge, is(defaultIsisLsdbAge));
+ }
+
+ /**
+ * Tests remainingLifetime() getter method.
+ */
+ @Test
+ public void testRemainingLifetime() throws Exception {
+ defaultLspWrapper.setLsdbAge(defaultIsisLsdbAge);
+ defaultLspWrapper.setAgeCounterWhenReceived(1);
+ defaultLspWrapper.currentAge();
+ defaultLspWrapper.setRemainingLifetime(1);
+ result1 = defaultLspWrapper.remainingLifetime();
+ assertThat(result1, is(1));
+ }
+
+ /**
+ * Tests remainingLifetime() setter method.
+ */
+ @Test
+ public void testSetRemainingLifetime() throws Exception {
+ defaultLspWrapper.setLsdbAge(defaultIsisLsdbAge);
+ defaultLspWrapper.setAgeCounterWhenReceived(1);
+ defaultLspWrapper.currentAge();
+ defaultLspWrapper.setRemainingLifetime(1);
+ result1 = defaultLspWrapper.remainingLifetime();
+ assertThat(result1, is(1));
+ }
}
\ 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
index 2e592af..b47bd3b 100644
--- 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
@@ -18,7 +18,11 @@
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.onosproject.isis.controller.impl.DefaultIsisInterface;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import static org.hamcrest.CoreMatchers.is;
@@ -31,10 +35,22 @@
public class IsisLspQueueConsumerTest {
private IsisLspQueueConsumer isisLspQueueConsumer;
- private BlockingQueue blockingQueue;
+ private BlockingQueue blockingQueue = new ArrayBlockingQueue(1024);
+ private DefaultLspWrapper lspWrapper;
+ private DefaultLspWrapper lspWrapper1;
+ private SocketAddress socketAddress = InetSocketAddress.createUnresolved("127.0.0.1", 7000);
@Before
public void setUp() throws Exception {
+ lspWrapper = new DefaultLspWrapper();
+ lspWrapper.setLspProcessing("refreshLsp");
+ lspWrapper.setSelfOriginated(true);
+ lspWrapper.setIsisInterface(new DefaultIsisInterface());
+ lspWrapper1 = new DefaultLspWrapper();
+ lspWrapper1.setLspProcessing("maxAgeLsp");
+ lspWrapper1.setIsisInterface(new DefaultIsisInterface());
+ blockingQueue.add(lspWrapper);
+ blockingQueue.add(lspWrapper1);
isisLspQueueConsumer = new IsisLspQueueConsumer(blockingQueue);
}