Unit Test framework for Device Manager and with UT cases
add two more testing cases and handle code review comments
Change-Id: I2ea20b16da6e9c349045d5ee1f9c91b2137ccd7e
diff --git a/src/main/java/net/onrc/onos/core/devicemanager/OnosDeviceManager.java b/src/main/java/net/onrc/onos/core/devicemanager/OnosDeviceManager.java
index 38a8746..f1cc8f7 100644
--- a/src/main/java/net/onrc/onos/core/devicemanager/OnosDeviceManager.java
+++ b/src/main/java/net/onrc/onos/core/devicemanager/OnosDeviceManager.java
@@ -58,7 +58,7 @@
private IDatagridService datagrid;
private IEventChannel<Long, OnosDevice> eventChannel;
private static final String DEVICE_CHANNEL_NAME = "onos.device";
- private Map<Long, OnosDevice> mapDevice = new ConcurrentHashMap<Long, OnosDevice>();
+ private final Map<Long, OnosDevice> mapDevice = new ConcurrentHashMap<Long, OnosDevice>();
private ITopologyService topologyService;
private Topology topology;
@@ -67,8 +67,8 @@
}
private class OnosDeviceUpdate implements IUpdate {
- private OnosDevice device;
- private OnosDeviceUpdateType type;
+ private final OnosDevice device;
+ private final OnosDeviceUpdateType type;
public OnosDeviceUpdate(OnosDevice device, OnosDeviceUpdateType type) {
this.device = device;
@@ -110,7 +110,7 @@
@Override
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
if (msg.getType().equals(OFType.PACKET_IN) &&
- (msg instanceof OFPacketIn)) {
+ (msg instanceof OFPacketIn)) {
OFPacketIn pi = (OFPacketIn) msg;
Ethernet eth = IFloodlightProviderService.bcStore.
@@ -250,14 +250,16 @@
* @param pi the original packetin
* @return the entity from the packet
*/
- private OnosDevice getSourceDeviceFromPacket(Ethernet eth,
- long swdpid,
- short port) {
+ protected OnosDevice getSourceDeviceFromPacket(Ethernet eth,
+ long swdpid,
+ short port) {
byte[] dlAddrArr = eth.getSourceMACAddress();
long dlAddr = Ethernet.toLong(dlAddrArr);
- // Ignore broadcast/multicast source
- if ((dlAddrArr[0] & 0x1) != 0) {
+ /*
+ * Ignore broadcast/multicast source
+ */
+ if (eth.isMulticast() || eth.isBroadcast()) {
return null;
}