assertEquals(true, writeCapture.hasCaptured());
assertEquals(TotalTestRules, writeCapture.getValues().size());
// Order assumes how things are stored in hash bucket;
// should be fixed because OFMessage.hashCode() is deterministic
OFFlowMod firstFlowMod = (OFFlowMod) writeCapture.getValues().get(2);
verifyFlowMod(firstFlowMod, FlowMod1);
OFFlowMod secondFlowMod = (OFFlowMod) writeCapture.getValues().get(1);
verifyFlowMod(secondFlowMod, FlowMod2);
OFFlowMod thirdFlowMod = (OFFlowMod) writeCapture.getValues().get(0);
verifyFlowMod(thirdFlowMod, FlowMod3);
writeCapture.reset();
contextCapture.reset();
// delete two rules and verify they've been removed
// this should invoke staticFlowPusher.rowsDeleted()
storage.deleteRow(StaticFlowEntryPusher.TABLE_NAME, "TestRule1");
storage.deleteRow(StaticFlowEntryPusher.TABLE_NAME, "TestRule2");
assertEquals(1, staticFlowEntryPusher.countEntries());
assertEquals(2, writeCapture.getValues().size());
OFFlowMod firstDelete = (OFFlowMod) writeCapture.getValues().get(0);
FlowMod1.setCommand(OFFlowMod.OFPFC_DELETE_STRICT);
verifyFlowMod(firstDelete, FlowMod1);
OFFlowMod secondDelete = (OFFlowMod) writeCapture.getValues().get(1);
FlowMod2.setCommand(OFFlowMod.OFPFC_DELETE_STRICT);
verifyFlowMod(secondDelete, FlowMod2);
// add rules back to make sure that staticFlowPusher.rowsInserted() works
writeCapture.reset();
FlowMod2.setCommand(OFFlowMod.OFPFC_ADD);
storage.insertRow(StaticFlowEntryPusher.TABLE_NAME, TestRule2);
assertEquals(2, staticFlowEntryPusher.countEntries());
assertEquals(1, writeCaptureList.getValues().size());
List<OFMessage> outList =
writeCaptureList.getValues().get(0);
assertEquals(1, outList.size());
OFFlowMod firstAdd = (OFFlowMod) outList.get(0);
verifyFlowMod(firstAdd, FlowMod2);
writeCapture.reset();
contextCapture.reset();
writeCaptureList.reset();
// now try an overwriting update, calling staticFlowPusher.rowUpdated()
TestRule3.put(COLUMN_DL_VLAN, 333);
storage.updateRow(StaticFlowEntryPusher.TABLE_NAME, TestRule3);
assertEquals(2, staticFlowEntryPusher.countEntries());
assertEquals(1, writeCaptureList.getValues().size());
outList = writeCaptureList.getValues().get(0);
assertEquals(2, outList.size());
OFFlowMod removeFlowMod = (OFFlowMod) outList.get(0);
FlowMod3.setCommand(OFFlowMod.OFPFC_DELETE_STRICT);
verifyFlowMod(removeFlowMod, FlowMod3);
FlowMod3.setCommand(OFFlowMod.OFPFC_ADD);
FlowMod3.getMatch().fromString("dl_dst=00:20:30:40:50:60,dl_vlan=333");
OFFlowMod updateFlowMod = (OFFlowMod) outList.get(1);
verifyFlowMod(updateFlowMod, FlowMod3);
writeCaptureList.reset();
// now try an action modifying update, calling staticFlowPusher.rowUpdated()
TestRule3.put(COLUMN_ACTIONS, "output=controller,strip-vlan"); // added strip-vlan
storage.updateRow(StaticFlowEntryPusher.TABLE_NAME, TestRule3);
assertEquals(2, staticFlowEntryPusher.countEntries());
assertEquals(1, writeCaptureList.getValues().size());
outList = writeCaptureList.getValues().get(0);
assertEquals(1, outList.size());
OFFlowMod modifyFlowMod = (OFFlowMod) outList.get(0);
FlowMod3.setCommand(OFFlowMod.OFPFC_MODIFY_STRICT);
List<OFAction> modifiedActions = FlowMod3.getActions();
modifiedActions.add(new OFActionStripVirtualLan()); // add the new action to what we should expect
FlowMod3.setActions(modifiedActions);
FlowMod3.setLengthU(OFFlowMod.MINIMUM_LENGTH + 16); // accommodate the addition of new actions