use of org.openkilda.floodlight.switchmanager.MeterPool in project open-kilda by telstra.
the class ReplaceInstallFlowTest method runTest.
/**
* Runs test case.
*
* @param value data string from json resource file
* @param flowCommand OFFlowAdd instance to compare result with
* @throws InterruptedException if test was interrupted during run
*/
private void runTest(final String value, final OFFlowAdd flowCommand, final OFMeterMod meterCommand, final OFFlowAdd reverseFlowCommand, final OFMeterMod reverseMeterCommand) throws InterruptedException {
// construct kafka message
ConsumerRecord<String, String> record = new ConsumerRecord<>("", 0, 0, "", value);
// create parser instance
ConsumerContext kafkaContext = new ConsumerContext(context, collector);
RecordHandler parseRecord = new RecordHandler(kafkaContext, record, new MeterPool());
// init test mocks
Capture<OFFlowAdd> flowAddCapture = flowCommand == null ? null : newCapture(CaptureType.ALL);
Capture<OFMeterMod> meterAddCapture = meterCommand == null ? null : newCapture(CaptureType.ALL);
prepareMocks(flowAddCapture, meterAddCapture, reverseFlowCommand != null, reverseMeterCommand != null);
// run parser and wait for termination or timeout
parseRecordExecutor.execute(parseRecord);
parseRecordExecutor.shutdown();
parseRecordExecutor.awaitTermination(10, TimeUnit.SECONDS);
// verify results
if (meterCommand != null) {
assertEquals(meterCommand, meterAddCapture.getValues().get(0));
if (reverseMeterCommand != null) {
assertEquals(reverseMeterCommand, meterAddCapture.getValues().get(1));
}
}
if (flowCommand != null) {
assertEquals(flowCommand, flowAddCapture.getValues().get(0));
if (reverseFlowCommand != null) {
assertEquals(reverseFlowCommand, flowAddCapture.getValues().get(1));
}
}
}
Aggregations