From 99aeda78e5068b664c81dd93ccc9e4566cec5bc8 Mon Sep 17 00:00:00 2001
From: Ryan Izard <rizard@g.clemson.edu>
Date: Mon, 5 Oct 2015 14:23:34 -0400
Subject: [PATCH] src/main

---
 .../forwarding/ForwardingTest.java            | 36 +++++++++++++------
 .../topology/TopologyInstanceTest.java        |  6 ++--
 2 files changed, 29 insertions(+), 13 deletions(-)

diff --git a/src/test/java/net/floodlightcontroller/forwarding/ForwardingTest.java b/src/test/java/net/floodlightcontroller/forwarding/ForwardingTest.java
index 51f1faefb..f95bbd522 100644
--- a/src/test/java/net/floodlightcontroller/forwarding/ForwardingTest.java
+++ b/src/test/java/net/floodlightcontroller/forwarding/ForwardingTest.java
@@ -23,8 +23,10 @@ import static org.junit.Assert.*;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import net.floodlightcontroller.core.FloodlightContext;
 import net.floodlightcontroller.core.IFloodlightProviderService;
@@ -269,9 +271,9 @@ public class ForwardingTest extends FloodlightTestCase {
 				.setXid(15)
 				.build();
 
-		// Mock Packet-out with OFPP_FLOOD action
+		// Mock Packet-out with OFPP_FLOOD action (list of ports to flood)
 		poactions = new ArrayList<OFAction>();
-		poactions.add(factory.actions().output(OFPort.FLOOD, Integer.MAX_VALUE));
+		poactions.add(factory.actions().output(OFPort.of(10), Integer.MAX_VALUE));
 		packetOutFlooded = factory.buildPacketOut()
 				.setBufferId(this.packetIn.getBufferId())
 				.setInPort(packetIn.getMatch().get(MatchField.IN_PORT))
@@ -459,6 +461,8 @@ public class ForwardingTest extends FloodlightTestCase {
 		expect(topology.isAttachmentPointPort(DatapathId.of(1L),  OFPort.of(1))).andReturn(true).anyTimes();
 		expect(topology.isAttachmentPointPort(DatapathId.of(2L),  OFPort.of(3))).andReturn(true).anyTimes();
 		expect(topology.isIncomingBroadcastAllowed(DatapathId.of(anyLong()), OFPort.of(anyShort()))).andReturn(true).anyTimes();
+		expect(topology.isEdge(DatapathId.of(1L), OFPort.of(1))).andReturn(true).anyTimes();
+		expect(topology.isEdge(DatapathId.of(2L), OFPort.of(3))).andReturn(true).anyTimes();
 
 		// Reset mocks, trigger the packet in, and validate results
 		replay(sw1, sw2, routingEngine, topology);
@@ -529,7 +533,9 @@ public class ForwardingTest extends FloodlightTestCase {
 		expect(topology.isAttachmentPointPort(DatapathId.of(1L),  OFPort.of(1))).andReturn(true).anyTimes();
 		expect(topology.isAttachmentPointPort(DatapathId.of(2L),  OFPort.of(3))).andReturn(true).anyTimes();
 		expect(topology.isIncomingBroadcastAllowed(DatapathId.of(anyLong()), OFPort.of(anyShort()))).andReturn(true).anyTimes();
-
+		expect(topology.isEdge(DatapathId.of(1L), OFPort.of(1))).andReturn(true).anyTimes();
+		expect(topology.isEdge(DatapathId.of(2L), OFPort.of(3))).andReturn(true).anyTimes();
+		
 		// Reset mocks, trigger the packet in, and validate results
 		replay(sw1, sw2, routingEngine, topology);
 		forwarding.receive(sw1, this.packetInIPv6, cntx);
@@ -592,8 +598,10 @@ public class ForwardingTest extends FloodlightTestCase {
 		reset(topology);
 		expect(topology.isIncomingBroadcastAllowed(DatapathId.of(anyLong()), OFPort.of(anyShort()))).andReturn(true).anyTimes();
 		expect(topology.getL2DomainId(DatapathId.of(1L))).andReturn(DatapathId.of(1L)).anyTimes();
-		expect(topology.isAttachmentPointPort(DatapathId.of(1L),  OFPort.of(1))).andReturn(true).anyTimes();
-		expect(topology.isAttachmentPointPort(DatapathId.of(1L),  OFPort.of(3))).andReturn(true).anyTimes();
+		expect(topology.isAttachmentPointPort(DatapathId.of(1L), OFPort.of(1))).andReturn(true).anyTimes();
+		expect(topology.isAttachmentPointPort(DatapathId.of(1L), OFPort.of(3))).andReturn(true).anyTimes();
+		expect(topology.isEdge(DatapathId.of(1L), OFPort.of(1))).andReturn(true).anyTimes();
+		expect(topology.isEdge(DatapathId.of(1L), OFPort.of(3))).andReturn(true).anyTimes();
 
 		// Reset mocks, trigger the packet in, and validate results
 		replay(sw1, sw2, routingEngine, topology);
@@ -648,7 +656,9 @@ public class ForwardingTest extends FloodlightTestCase {
 		expect(topology.getL2DomainId(DatapathId.of(1L))).andReturn(DatapathId.of(1L)).anyTimes();
 		expect(topology.isAttachmentPointPort(DatapathId.of(1L),  OFPort.of(1))).andReturn(true).anyTimes();
 		expect(topology.isAttachmentPointPort(DatapathId.of(1L),  OFPort.of(3))).andReturn(true).anyTimes();
-
+		expect(topology.isEdge(DatapathId.of(1L), OFPort.of(1))).andReturn(true).anyTimes();
+		expect(topology.isEdge(DatapathId.of(1L), OFPort.of(3))).andReturn(true).anyTimes();
+		
 		// Reset mocks, trigger the packet in, and validate results
 		replay(sw1, sw2, routingEngine, topology);
 		forwarding.receive(sw1, this.packetInIPv6, cntx);
@@ -729,17 +739,18 @@ public class ForwardingTest extends FloodlightTestCase {
 		// expect no Flow-mod but expect the packet to be flooded
 
 		Capture<OFMessage> wc1 = new Capture<OFMessage>(CaptureType.ALL);
+		
+		Set<OFPort> bcastPorts = new HashSet<OFPort>();
+		bcastPorts.add(OFPort.of(10));
 
 		// Reset mocks, trigger the packet in, and validate results
 		reset(topology);
-		expect(topology.isIncomingBroadcastAllowed(DatapathId.of(1L), OFPort.of(1))).andReturn(true).anyTimes();
+		expect(topology.getSwitchBroadcastPorts(DatapathId.of(1L))).andReturn(bcastPorts).once();
 		expect(topology.isAttachmentPointPort(DatapathId.of(anyLong()),
 				OFPort.of(anyShort())))
 				.andReturn(true)
 				.anyTimes();
-		expect(sw1.hasAttribute(IOFSwitch.PROP_SUPPORTS_OFPP_FLOOD))
-		.andReturn(true).anyTimes();
-		// Reset XID to expected (dependent on prior unit tests)
+		expect(sw1.hasAttribute(IOFSwitch.PROP_SUPPORTS_OFPP_FLOOD)).andReturn(true).anyTimes();
 		sw1.write(capture(wc1));
 		expectLastCall().once();
 		replay(sw1, sw2, routingEngine, topology);
@@ -760,10 +771,13 @@ public class ForwardingTest extends FloodlightTestCase {
 		// expect no Flow-mod but expect the packet to be flooded
 
 		Capture<OFMessage> wc1 = new Capture<OFMessage>(CaptureType.ALL);
+		
+		Set<OFPort> bcastPorts = new HashSet<OFPort>();
+		bcastPorts.add(OFPort.of(10));
 
 		// Reset mocks, trigger the packet in, and validate results
 		reset(topology);
-		expect(topology.isIncomingBroadcastAllowed(DatapathId.of(1L), OFPort.of(1))).andReturn(true).anyTimes();
+		expect(topology.getSwitchBroadcastPorts(DatapathId.of(1L))).andReturn(bcastPorts).once();
 		expect(topology.isAttachmentPointPort(DatapathId.of(anyLong()),
 				OFPort.of(anyShort())))
 				.andReturn(true)
diff --git a/src/test/java/net/floodlightcontroller/topology/TopologyInstanceTest.java b/src/test/java/net/floodlightcontroller/topology/TopologyInstanceTest.java
index 445e4c00c..634ebf689 100644
--- a/src/test/java/net/floodlightcontroller/topology/TopologyInstanceTest.java
+++ b/src/test/java/net/floodlightcontroller/topology/TopologyInstanceTest.java
@@ -24,8 +24,10 @@ import java.util.Set;
 
 import static org.junit.Assert.*;
 import net.floodlightcontroller.core.IFloodlightProviderService;
+import net.floodlightcontroller.core.internal.IOFSwitchService;
 import net.floodlightcontroller.core.module.FloodlightModuleContext;
 import net.floodlightcontroller.core.test.MockFloodlightProvider;
+import net.floodlightcontroller.core.test.MockSwitchManager;
 import net.floodlightcontroller.core.test.MockThreadPoolService;
 import net.floodlightcontroller.debugcounter.IDebugCounterService;
 import net.floodlightcontroller.debugcounter.MockDebugCounterService;
@@ -64,11 +66,12 @@ public class TopologyInstanceTest {
         linkDiscovery = EasyMock.createMock(ILinkDiscoveryService.class);
         mockFloodlightProvider = new MockFloodlightProvider();
         fmc.addService(IFloodlightProviderService.class, mockFloodlightProvider);
+        fmc.addService(IOFSwitchService.class, new MockSwitchManager());
         fmc.addService(ILinkDiscoveryService.class, linkDiscovery);
         fmc.addService(IDebugCounterService.class, new MockDebugCounterService());
         fmc.addService(IDebugEventService.class, new MockDebugEventService());
         MockThreadPoolService tp = new MockThreadPoolService();
-        topologyManager  = new TopologyManager();
+        topologyManager = new TopologyManager();
         fmc.addService(IThreadPoolService.class, tp);
         topologyManager.init(fmc);
         tp.init(fmc);
@@ -178,7 +181,6 @@ public class TopologyInstanceTest {
                                          {1,2,3}, 
                                          {4}
             };
-            //tm.recompute();
             createTopologyFromLinks(linkArray);
             verifyClusters(expectedClusters);
         }
-- 
GitLab