use of net.floodlightcontroller.core.IOFSwitch in project open-kilda by telstra.
the class ReplaceInstallFlowTest method prepareMocks.
/**
* Prepares test mocks for run.
*
* @param flowAddCapture Capture for FlowAdd command
* @param meterAddCapture Capture for MeterMod<Add> command
*/
private void prepareMocks(Capture<OFFlowAdd> flowAddCapture, Capture<OFMeterMod> meterAddCapture, boolean needCheckReverseFlow, boolean needCheckReverseMeter) {
IOFSwitch iofSwitch = createMock(IOFSwitch.class);
expect(ofSwitchService.getSwitch(anyObject(DatapathId.class))).andStubReturn(iofSwitch);
expect(iofSwitch.getOFFactory()).andStubReturn(ofFactory);
expect(iofSwitch.getSwitchDescription()).andStubReturn(switchDescription);
if (meterAddCapture != null) {
expect(iofSwitch.write(capture(meterAddCapture))).andReturn(true);
if (flowAddCapture != null) {
expect(iofSwitch.write(capture(flowAddCapture))).andReturn(true);
}
if (needCheckReverseMeter) {
expect(iofSwitch.write(capture(meterAddCapture))).andReturn(true);
}
if (needCheckReverseFlow) {
expect(iofSwitch.write(capture(flowAddCapture))).andReturn(true);
}
} else if (flowAddCapture != null) {
expect(iofSwitch.write(capture(flowAddCapture))).andReturn(true).times(needCheckReverseFlow ? 2 : 1);
}
replay(ofSwitchService);
replay(iofSwitch);
}
use of net.floodlightcontroller.core.IOFSwitch in project open-kilda by telstra.
the class PathVerificationPacketSignTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
OFPacketOut packetOut = pvs.generateVerificationPacket(sw1, OFPort.of(1));
ofPacketIn = EasyMock.createMock(OFPacketIn.class);
context = new FloodlightContext();
expect(ofPacketIn.getType()).andReturn(OFType.PACKET_IN).anyTimes();
expect(ofPacketIn.getXid()).andReturn(0L).anyTimes();
expect(ofPacketIn.getVersion()).andReturn(packetOut.getVersion()).anyTimes();
Match match = EasyMock.createMock(Match.class);
expect(match.get(MatchField.IN_PORT)).andReturn(OFPort.of(1)).anyTimes();
replay(match);
expect(ofPacketIn.getMatch()).andReturn(match).anyTimes();
replay(ofPacketIn);
IPacket expected = new Ethernet().deserialize(packetOut.getData(), 0, packetOut.getData().length);
context.getStorage().put(IFloodlightProviderService.CONTEXT_PI_PAYLOAD, expected);
HashMap<DatapathId, IOFSwitch> switches = new HashMap<>();
switches.put(sw1.getId(), sw1);
switches.put(sw2.getId(), sw2);
mockSwitchManager.setSwitches(switches);
reset(producer);
pvs.setKafkaProducer(producer);
}
use of net.floodlightcontroller.core.IOFSwitch in project open-kilda by telstra.
the class FloodlightTestCase method buildMockIOFSwitch.
public IOFSwitch buildMockIOFSwitch(Long id, OFPortDesc portDesc, OFFactory factory, OFDescStatsReply swDesc, InetSocketAddress inetAddr) {
IOFSwitch sw = EasyMock.createMock(IOFSwitch.class);
expect(sw.getId()).andReturn(DatapathId.of(id)).anyTimes();
expect(sw.getPort(OFPort.of(1))).andReturn(portDesc).anyTimes();
expect(sw.getOFFactory()).andReturn(factory).anyTimes();
expect(sw.getBuffers()).andReturn(swFeatures.getNBuffers()).anyTimes();
expect(sw.hasAttribute(IOFSwitch.PROP_SUPPORTS_OFPP_TABLE)).andReturn(true).anyTimes();
expect(sw.getSwitchDescription()).andReturn(new SwitchDescription(swDesc)).anyTimes();
expect(sw.isActive()).andReturn(true).anyTimes();
expect(sw.getLatency()).andReturn(U64.of(10L)).anyTimes();
expect(sw.getInetAddress()).andReturn(inetAddr).anyTimes();
return sw;
}
Aggregations