// The STATS_REQUEST object used when querying the switches for flows
OFStatisticsRequest req = new OFStatisticsRequest();
req.setStatisticType(OFStatisticsType.FLOW);
int requestLength = req.getLengthU();
OFFlowStatisticsRequest specificReq = new OFFlowStatisticsRequest();
specificReq.setMatch(new OFMatch().setWildcards(0xffffffff));
specificReq.setOutPort((short) 3);
specificReq.setTableId((byte) 0xff);
req.setStatistics(Collections.singletonList((OFStatistics) specificReq));
requestLength += specificReq.getLength();
req.setLengthU(requestLength);
// Actions for the STATS_REPLY object
OFActionOutput action = new OFActionOutput((short) 3, (short) 0xffff);
List<OFAction> actions = new ArrayList<OFAction>();
actions.add(action);
// Match for the STATS_REPLY object
OFMatch m = new OFMatch();
// Set the incoming port to 1 so that it will find the connected
m.setInputPort((short) 1);
// STATS_REPLY object
OFFlowStatisticsReply reply = new OFFlowStatisticsReply();
reply.setActions(actions);
reply.setMatch(m);
// Add the reply to the list of OFStatistics
statsReply.add(reply);
// Create the STATS_REPLY asynchronous reply object
Callable<List<OFStatistics>> replyFuture = new ReplyFuture();
// Assign the callable object to a Futuretask so that it will produce
// future results
FutureTask<List<OFStatistics>> futureStats = new FutureTask<List<OFStatistics>>(
replyFuture);
// Assign the results of calling the object (the asynchronous reply)
Future<List<OFStatistics>> results = getResults(futureStats);
// SW1 -- Mock switch for base and multiple switch test case
sw1 = EasyMock.createNiceMock(IOFSwitch.class);
// Expect that the switch's ID is 1
expect(sw1.getId()).andReturn(1L).anyTimes();
expect(sw1.queryStatistics(req)).andReturn(results).once();
// Captures to hold resulting flowmod delete messages
wc1 = new Capture<List<OFMessage>>(CaptureType.ALL);
bc1 = new Capture<FloodlightContext>(CaptureType.ALL);
// Capture the parameters passed when sw1.write is invoked
sw1.write(capture(wc1), capture(bc1));
expectLastCall().once();
replay(sw1);
// SW2 -- Mock switch for extended test cases
sw2 = EasyMock.createNiceMock(IOFSwitch.class);
// Expect that the switch's ID is 2
expect(sw2.getId()).andReturn(2L).anyTimes();
expect(sw2.queryStatistics(req)).andReturn(results).once();
wc2 = new Capture<List<OFMessage>>(CaptureType.ALL);
bc2 = new Capture<FloodlightContext>(CaptureType.ALL);
// Capture the parameters passwed when sw1.write is invoked
sw2.write(capture(wc2), capture(bc2));
expectLastCall().anyTimes();
replay(sw2);
// SW3 -- Mock switch for extended test cases
sw3 = EasyMock.createNiceMock(IOFSwitch.class);
// Expect that the switch's ID is 3
expect(sw3.getId()).andReturn(3L).anyTimes();
expect(sw3.queryStatistics(req)).andReturn(results).once();
wc3 = new Capture<List<OFMessage>>(CaptureType.ALL);
bc3 = new Capture<FloodlightContext>(CaptureType.ALL);
// Capture the parameters passwed when sw1.write is invoked
sw3.write(capture(wc3), capture(bc3));
expectLastCall().anyTimes();
replay(sw3);
// SW4 -- Mock switch for extended test cases
sw4 = EasyMock.createNiceMock(IOFSwitch.class);
// Expect that the switch's ID is 4
expect(sw4.getId()).andReturn(4L).anyTimes();
expect(sw4.queryStatistics(req)).andReturn(results).once();
wc4 = new Capture<List<OFMessage>>(CaptureType.ALL);
bc4 = new Capture<FloodlightContext>(CaptureType.ALL);
// Capture the parameters passed when sw1.write is invoked
sw4.write(capture(wc4), capture(bc4));
expectLastCall().anyTimes();
replay(sw4);
// Here we create the OFMatch Reconcile list we wish to pass
lofmr = new ArrayList<OFMatchReconcile>();
// Create the only OFMatch Reconcile object that will be in the list
ofmr = new OFMatchReconcile();
long affectedSwitch = sw1.getId();
OFMatchWithSwDpid ofmatchsw = new OFMatchWithSwDpid(new OFMatch().setWildcards(OFMatch.OFPFW_ALL),
affectedSwitch);
ofmr.rcAction = OFMatchReconcile.ReconcileAction.UPDATE_PATH;
ofmr.ofmWithSwDpid = ofmatchsw;
// We'll say port 3 went down
ofmr.outPort = 3;
// Add the OFMatch Reconcile object to the list
lofmr.add(ofmr);
// Expected Flow Mod Deletes Messages
// Flow Mod Delete for base switch
fm = ((OFFlowMod) mockFloodlightProvider.getOFMessageFactory()
.getMessage(OFType.FLOW_MOD)).setMatch(new OFMatch().setWildcards(OFMatch.OFPFW_ALL))
.setCommand(OFFlowMod.OFPFC_DELETE)
// Notice
// we
// specify
// an