Merge pull request #471 from jonohart/fixtests
Fixed unit tests that failed after recent link discovery bug fix
diff --git a/src/test/java/net/floodlightcontroller/core/internal/ControllerTest.java b/src/test/java/net/floodlightcontroller/core/internal/ControllerTest.java
index 21788af..4c9c340 100644
--- a/src/test/java/net/floodlightcontroller/core/internal/ControllerTest.java
+++ b/src/test/java/net/floodlightcontroller/core/internal/ControllerTest.java
@@ -72,6 +72,8 @@
import net.onrc.onos.ofcontroller.core.IOFSwitchPortListener;
import net.onrc.onos.ofcontroller.flowmanager.FlowManager;
import net.onrc.onos.ofcontroller.flowmanager.IFlowService;
+import net.onrc.onos.ofcontroller.linkdiscovery.ILinkDiscoveryService;
+import net.onrc.onos.ofcontroller.linkdiscovery.internal.LinkDiscoveryManager;
import net.onrc.onos.ofcontroller.topology.ITopologyNetService;
import net.onrc.onos.ofcontroller.topology.TopologyManager;
import net.onrc.onos.registry.controller.IControllerRegistryService;
@@ -142,6 +144,8 @@
fmc.addService(ITopologyNetService.class, new TopologyManager() );
StandaloneRegistry sr = new StandaloneRegistry();
fmc.addService(IControllerRegistryService.class, sr );
+ LinkDiscoveryManager linkDiscovery = new LinkDiscoveryManager();
+ fmc.addService(ILinkDiscoveryService.class, linkDiscovery);
ppt.init(fmc);
@@ -150,12 +154,14 @@
cm.init(fmc);
tp.init(fmc);
sr.init(fmc);
+ linkDiscovery.init(fmc);
ppt.startUp(fmc);
restApi.startUp(fmc);
memstorage.startUp(fmc);
cm.startUp(fmc);
tp.startUp(fmc);
sr.startUp(fmc);
+ linkDiscovery.startUp(fmc);
}
public Controller getController() {
@@ -407,7 +413,7 @@
Channel channel2 = createMock(Channel.class);
expect(newsw.getChannel()).andReturn(channel2);
expect(channel2.getRemoteAddress()).andReturn(null);
- expect(newsw.getPorts()).andReturn(new ArrayList<OFPhysicalPort>());
+ expect(newsw.getPorts()).andReturn(new ArrayList<OFPhysicalPort>()).times(2);
expect(newsw.getCapabilities()).andReturn(0).anyTimes();
expect(newsw.getBuffers()).andReturn(0).anyTimes();
expect(newsw.getTables()).andReturn((byte)0).anyTimes();
@@ -460,6 +466,10 @@
}
DummySwitchListener switchListener = new DummySwitchListener();
IOFSwitch sw = createMock(IOFSwitch.class);
+ expect(sw.getId()).andReturn(1L).anyTimes();
+ expect(sw.getEnabledPorts()).andReturn(null);
+ expect(sw.getChannel()).andReturn(null).anyTimes();
+ replay(sw);
ControllerRunThread t = new ControllerRunThread();
t.start();
@@ -1153,6 +1163,7 @@
@Test
public void testHandlePortStatus() throws Exception {
IOFSwitch sw = createMock(IOFSwitch.class);
+ expect(sw.getId()).andReturn(1L).anyTimes();
OFPhysicalPort port = new OFPhysicalPort();
port.setName("myPortName1");
port.setPortNumber((short)42);