use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService in project openflowplugin by opendaylight.
the class FlowForwarderTest method removeTest.
@Test
public void removeTest() throws Exception {
Mockito.when(salFlowService.removeFlow(removeFlowInputCpt.capture())).thenReturn(RpcResultBuilder.success(new RemoveFlowOutputBuilder().setTransactionId(new TransactionId(BigInteger.ONE)).build()).buildFuture());
final Flow removeFlow = new FlowBuilder(flow).build();
final Future<RpcResult<RemoveFlowOutput>> removeResult = flowForwarder.remove(flowPath, removeFlow, flowCapableNodePath);
Mockito.verify(salFlowService).removeFlow(Matchers.<RemoveFlowInput>any());
final RemoveFlowInput flowInput = removeFlowInputCpt.getValue();
Assert.assertEquals(2, flowInput.getTableId().shortValue());
Assert.assertEquals(emptyMatch, flowInput.getMatch());
Assert.assertEquals(null, flowInput.getInstructions());
Assert.assertEquals(true, flowInput.isStrict());
final RpcResult<RemoveFlowOutput> removeFlowOutputRpcResult = removeResult.get(2, TimeUnit.SECONDS);
Assert.assertTrue(removeFlowOutputRpcResult.isSuccessful());
final RemoveFlowOutput resultValue = removeFlowOutputRpcResult.getResult();
Assert.assertEquals(1, resultValue.getTransactionId().getValue().intValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService in project openflowplugin by opendaylight.
the class DropTestRpcSender method processPacket.
@Override
protected void processPacket(final InstanceIdentifier<Node> node, final Match match, final Instructions instructions) {
final AddFlowInputBuilder fb = BUILDER.get();
// Finally build our flow
fb.setMatch(match);
fb.setInstructions(instructions);
// Construct the flow instance id
fb.setNode(new NodeRef(node));
// Add flow
final AddFlowInput flow = fb.build();
if (LOG.isDebugEnabled()) {
LOG.debug("onPacketReceived - About to write flow (via SalFlowService) {}", flow);
}
ListenableFuture<RpcResult<AddFlowOutput>> result = JdkFutureAdapters.listenInPoolThread(flowService.addFlow(flow));
Futures.addCallback(result, new FutureCallback<RpcResult<AddFlowOutput>>() {
@Override
public void onSuccess(final RpcResult<AddFlowOutput> result) {
countFutureSuccess();
}
@Override
public void onFailure(final Throwable throwable) {
countFutureError();
}
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService in project openflowplugin by opendaylight.
the class SalFlowServiceImplTest method removeFlow.
private void removeFlow(short version) throws Exception {
RemoveFlowInput mockedRemoveFlowInput = new RemoveFlowInputBuilder().setMatch(match).setTableId((short) 1).build();
SalFlowServiceImpl salFlowService = mockSalFlowService(version);
verifyOutput(salFlowService.removeFlow(mockedRemoveFlowInput));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService in project openflowplugin by opendaylight.
the class SalFlowServiceImplTest method updateFlow.
private void updateFlow(short version) throws Exception {
UpdateFlowInput mockedUpdateFlowInput = mock(UpdateFlowInput.class);
UpdateFlowInput mockedUpdateFlowInput1 = mock(UpdateFlowInput.class);
UpdatedFlow mockedUpdateFlow = new UpdatedFlowBuilder().setMatch(match).setTableId((short) 1).build();
UpdatedFlow mockedUpdateFlow1 = new UpdatedFlowBuilder().setMatch(match).setTableId((short) 1).setPriority(1).build();
when(mockedUpdateFlowInput.getUpdatedFlow()).thenReturn(mockedUpdateFlow);
when(mockedUpdateFlowInput1.getUpdatedFlow()).thenReturn(mockedUpdateFlow1);
FlowRef mockedFlowRef = mock(FlowRef.class);
Mockito.doReturn(TABLE_II.child(Flow.class, new FlowKey(new FlowId(DUMMY_FLOW_ID)))).when(mockedFlowRef).getValue();
when(mockedUpdateFlowInput.getFlowRef()).thenReturn(mockedFlowRef);
when(mockedUpdateFlowInput1.getFlowRef()).thenReturn(mockedFlowRef);
OriginalFlow mockedOriginalFlow = new OriginalFlowBuilder().setMatch(match).setTableId((short) 1).build();
OriginalFlow mockedOriginalFlow1 = new OriginalFlowBuilder().setMatch(match).setTableId((short) 1).setPriority(2).build();
when(mockedUpdateFlowInput.getOriginalFlow()).thenReturn(mockedOriginalFlow);
when(mockedUpdateFlowInput1.getOriginalFlow()).thenReturn(mockedOriginalFlow1);
SalFlowServiceImpl salFlowService = mockSalFlowService(version);
verifyOutput(salFlowService.updateFlow(mockedUpdateFlowInput));
verifyOutput(salFlowService.updateFlow(mockedUpdateFlowInput1));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService in project openflowplugin by opendaylight.
the class Activator method onSessionInitialized.
@Override
public void onSessionInitialized(ConsumerContext session) {
SalFlowService flowService = session.getRpcService(SalFlowService.class);
new SimpleDropFirewall(flowService).start();
}
Aggregations