From fc0b1a0759f77d64cb097c4a88dc99a31eca07ea Mon Sep 17 00:00:00 2001 From: Kanzhe Jiang <kanzhe.jiang@bigswitch.com> Date: Wed, 5 Sep 2012 15:05:34 -0700 Subject: [PATCH] Add logic to select device APs in mockDevice for ease of unit-tests --- .../devicemanager/internal/DeviceManagerImpl.java | 2 +- .../floodlightcontroller/devicemanager/test/MockDevice.java | 4 ++-- .../net/floodlightcontroller/forwarding/ForwardingTest.java | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java b/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java index ec1dd169a..bb7ebd2b9 100755 --- a/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java +++ b/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java @@ -790,7 +790,7 @@ IFlowReconcileListener, IInfoProvider, IHAListener { * @param switchPort the port * @return true if it's a valid attachment point */ - protected boolean isValidAttachmentPoint(long switchDPID, + public boolean isValidAttachmentPoint(long switchDPID, int switchPort) { if (topology.isAttachmentPointPort(switchDPID, (short)switchPort) == false) diff --git a/src/test/java/net/floodlightcontroller/devicemanager/test/MockDevice.java b/src/test/java/net/floodlightcontroller/devicemanager/test/MockDevice.java index 913a136e0..32dba7b14 100644 --- a/src/test/java/net/floodlightcontroller/devicemanager/test/MockDevice.java +++ b/src/test/java/net/floodlightcontroller/devicemanager/test/MockDevice.java @@ -70,7 +70,8 @@ public class MockDevice extends Device { new ArrayList<SwitchPort>(entities.length); for (Entity e : entities) { if (e.getSwitchDPID() != null && - e.getSwitchPort() != null) { + e.getSwitchPort() != null && + deviceManager.isValidAttachmentPoint(e.getSwitchDPID(), e.getSwitchPort())) { SwitchPort sp = new SwitchPort(e.getSwitchDPID(), e.getSwitchPort()); vals.add(sp); @@ -78,5 +79,4 @@ public class MockDevice extends Device { } return vals.toArray(new SwitchPort[vals.size()]); } - } diff --git a/src/test/java/net/floodlightcontroller/forwarding/ForwardingTest.java b/src/test/java/net/floodlightcontroller/forwarding/ForwardingTest.java index 65d8f607b..e2f1e7d31 100644 --- a/src/test/java/net/floodlightcontroller/forwarding/ForwardingTest.java +++ b/src/test/java/net/floodlightcontroller/forwarding/ForwardingTest.java @@ -330,6 +330,8 @@ public class ForwardingTest extends FloodlightTestCase { reset(topology); expect(topology.getL2DomainId(1L)).andReturn(1L).anyTimes(); expect(topology.getL2DomainId(2L)).andReturn(1L).anyTimes(); + expect(topology.isAttachmentPointPort(1L, (short)1)).andReturn(true).anyTimes(); + expect(topology.isAttachmentPointPort(2L, (short)3)).andReturn(true).anyTimes(); expect(topology.isIncomingBroadcastAllowed(anyLong(), anyShort())).andReturn(true).anyTimes(); // Reset mocks, trigger the packet in, and validate results @@ -418,6 +420,8 @@ public class ForwardingTest extends FloodlightTestCase { reset(topology); expect(topology.isIncomingBroadcastAllowed(anyLong(), anyShort())).andReturn(true).anyTimes(); expect(topology.getL2DomainId(1L)).andReturn(1L).anyTimes(); + expect(topology.isAttachmentPointPort(1L, (short)1)).andReturn(true).anyTimes(); + expect(topology.isAttachmentPointPort(1L, (short)3)).andReturn(true).anyTimes(); // Reset mocks, trigger the packet in, and validate results replay(sw1, sw2, routingEngine, topology); -- GitLab