use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder in project openflowplugin by opendaylight.
the class OF13DeviceInitializerTest method initializeMultiLayer.
@Test
public void initializeMultiLayer() throws Exception {
when(deviceContext.canUseSingleLayerSerialization()).thenReturn(false);
when(requestContext.getFuture()).thenReturn(RpcResultBuilder.success(Collections.singletonList(new MultipartReplyMessageBuilder().setType(MultipartType.OFPMPDESC).setMultipartReplyBody(new MultipartReplyDescCaseBuilder().setMultipartReplyDesc(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDescBuilder().build()).build()).build())).buildFuture());
final Future<Void> initialize = deviceInitializer.initialize(deviceContext, true, false, multipartWriterProvider, convertorExecutor);
initialize.get();
verify(messageSpy, times(5)).spyMessage(eq(MultipartType.class), any());
verify(requestContext, times(5)).getFuture();
verify(featuresReply).getCapabilities();
verify(deviceContext).writeToTransaction(eq(LogicalDatastoreType.OPERATIONAL), any(), any());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder in project openflowplugin by opendaylight.
the class SalTableServiceImplTest method testUpdateTableSuccess.
@Test
public void testUpdateTableSuccess() throws ExecutionException, InterruptedException {
Mockito.doAnswer((Answer<Void>) invocation -> {
TableFeaturesBuilder tableFeaturesBld = new TableFeaturesBuilder().setTableId((short) 0).setName("Zafod").setMaxEntries(42L).setTableFeatureProperties(Collections.<TableFeatureProperties>emptyList());
MultipartReplyTableFeaturesBuilder mpTableFeaturesBld = new MultipartReplyTableFeaturesBuilder().setTableFeatures(Collections.singletonList(tableFeaturesBld.build()));
MultipartReplyTableFeaturesCaseBuilder mpBodyBld = new MultipartReplyTableFeaturesCaseBuilder().setMultipartReplyTableFeatures(mpTableFeaturesBld.build());
MultipartReplyMessageBuilder mpResultBld = new MultipartReplyMessageBuilder().setType(MultipartType.OFPMPTABLEFEATURES).setMultipartReplyBody(mpBodyBld.build()).setXid(21L);
final RpcResult<List<MultipartReply>> rpcResult = RpcResultBuilder.success(Collections.singletonList((MultipartReply) mpResultBld.build())).build();
handleResultFuture.set(rpcResult);
return null;
}).when(multiMessageCollector).endCollecting(Matchers.<EventIdentifier>any());
final Future<RpcResult<UpdateTableOutput>> rpcResultFuture = salTableService.updateTable(prepareUpdateTable());
Assert.assertNotNull(rpcResultFuture);
verify(mockedRequestContextStack).createRequestContext();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder in project openflowplugin by opendaylight.
the class MultipartRequestOnTheFlyCallbackTest method testOnSuccessWithValidMultipart1.
/**
* Not the last reply.
*/
@Test
public void testOnSuccessWithValidMultipart1() throws Exception {
final MatchBuilder matchBuilder = new MatchBuilder().setMatchEntry(Collections.<MatchEntry>emptyList());
final FlowStatsBuilder flowStatsBuilder = new FlowStatsBuilder().setTableId(tableId).setPriority(2).setCookie(BigInteger.ZERO).setByteCount(BigInteger.TEN).setPacketCount(BigInteger.ONE).setDurationSec(11L).setDurationNsec(12L).setMatch(matchBuilder.build()).setFlags(new FlowModFlags(true, false, false, false, false));
final MultipartReplyFlowBuilder multipartReplyFlowBuilder = new MultipartReplyFlowBuilder().setFlowStats(Collections.singletonList(flowStatsBuilder.build()));
final MultipartReplyFlowCaseBuilder multipartReplyFlowCaseBuilder = new MultipartReplyFlowCaseBuilder().setMultipartReplyFlow(multipartReplyFlowBuilder.build());
final MultipartReplyMessageBuilder mpReplyMessage = new MultipartReplyMessageBuilder().setType(MultipartType.OFPMPFLOW).setFlags(new MultipartRequestFlags(true)).setMultipartReplyBody(multipartReplyFlowCaseBuilder.build()).setXid(21L);
final InstanceIdentifier<FlowCapableNode> nodePath = mockedDeviceInfo.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
final FlowCapableNodeBuilder flowNodeBuilder = new FlowCapableNodeBuilder();
final TableBuilder tableDataBld = new TableBuilder();
tableDataBld.setId(tableId);
flowNodeBuilder.setTable(Collections.singletonList(tableDataBld.build()));
final Optional<FlowCapableNode> flowNodeOpt = Optional.of(flowNodeBuilder.build());
final CheckedFuture<Optional<FlowCapableNode>, ReadFailedException> flowNodeFuture = Futures.immediateCheckedFuture(flowNodeOpt);
when(mockedReadOnlyTx.read(LogicalDatastoreType.OPERATIONAL, nodePath)).thenReturn(flowNodeFuture);
when(mockedDeviceContext.getReadTransaction()).thenReturn(mockedReadOnlyTx);
multipartRequestOnTheFlyCallback.onSuccess(mpReplyMessage.build());
verify(mockedReadOnlyTx, times(0)).read(LogicalDatastoreType.OPERATIONAL, nodePath);
verify(mockedReadOnlyTx, times(0)).close();
verify(mockedDeviceContext, times(1)).writeToTransaction(eq(LogicalDatastoreType.OPERATIONAL), Matchers.any(), Matchers.any());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder in project openflowplugin by opendaylight.
the class MultipartRequestOnTheFlyCallbackTest method testOnSuccessWithValidMultipart2.
/**
* The last reply.
*/
@Test
public void testOnSuccessWithValidMultipart2() throws Exception {
final MultipartReplyMessageBuilder mpReplyMessage = new MultipartReplyMessageBuilder().setType(MultipartType.OFPMPDESC).setFlags(new MultipartRequestFlags(false));
multipartRequestOnTheFlyCallback.onSuccess(mpReplyMessage.build());
final RpcResult<List<MultipartReply>> actualResult = dummyRequestContext.getFuture().get();
// Nothing else than flow is supported by on the fly callback
assertNotNull(actualResult.getErrors());
assertFalse(actualResult.getErrors().isEmpty());
Mockito.verify(mockedFlowRegistry, Mockito.never()).store(Matchers.any());
Mockito.verify(mockedDeviceContext, Mockito.never()).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.<InstanceIdentifier>any(), Matchers.<DataObject>any());
}
Aggregations