use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags in project openflowplugin by opendaylight.
the class MultipartRequestExperimenterTest method testExperimenter.
/**
* Testing OF10StatsRequestInputFactory (Experimenter) for correct serialization.
*/
@Test
public void testExperimenter() throws Exception {
Mockito.when(mockRegistry.getSerializer(Matchers.<ExperimenterIdTypeSerializerKey<ExperimenterDataOfChoice>>any())).thenReturn(serializer);
MultipartRequestInputFactory multipartFactory = new MultipartRequestInputFactory();
multipartFactory.injectSerializerRegistry(mockRegistry);
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setType(MultipartType.OFPMPEXPERIMENTER);
builder.setFlags(new MultipartRequestFlags(false));
final MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder();
MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder();
expBuilder.setExperimenter(new ExperimenterId(42L));
expBuilder.setExpType(21L);
expBuilder.setExperimenterDataOfChoice(vendorData);
caseBuilder.setMultipartRequestExperimenter(expBuilder.build());
builder.setMultipartRequestBody(caseBuilder.build());
MultipartRequestInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
multipartFactory.serialize(message, out);
BufferHelper.checkHeaderV13(out, (byte) 18, 24);
Assert.assertEquals("Wrong type", 65535, out.readUnsignedShort());
Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
Mockito.verify(serializer, Mockito.times(1)).serialize(vendorData, out);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags in project openflowplugin by opendaylight.
the class MultipartRequestGroupFeaturesTest method test.
/**
* Tests {@link MultipartRequestInputFactory} - GroupFeatures case.
*/
@Test
public void test() throws Exception {
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setType(MultipartType.OFPMPGROUPFEATURES);
builder.setFlags(new MultipartRequestFlags(false));
MultipartRequestGroupFeaturesCaseBuilder caseBuilder = new MultipartRequestGroupFeaturesCaseBuilder();
MultipartRequestGroupFeaturesBuilder featuresBuilder = new MultipartRequestGroupFeaturesBuilder();
featuresBuilder.setEmpty(true);
caseBuilder.setMultipartRequestGroupFeatures(featuresBuilder.build());
builder.setMultipartRequestBody(caseBuilder.build());
MultipartRequestInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
multipartFactory.serialize(message, out);
BufferHelper.checkHeaderV13(out, (byte) 18, 16);
Assert.assertEquals("Wrong type", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
// skip padding
out.skipBytes(4);
Assert.assertTrue("Unexpected data", out.readableBytes() == 0);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags in project openflowplugin by opendaylight.
the class MsgGeneratorTestUtils method makeMultipartDescReply.
public static MultipartReplyMessageBuilder makeMultipartDescReply(final long xid, final String value, final boolean hasNext) {
final MultipartReplyDesc descValue = new MultipartReplyDescBuilder().setHwDesc(value).build();
final MultipartReplyDescCase replyBody = new MultipartReplyDescCaseBuilder().setMultipartReplyDesc(descValue).build();
MultipartReplyMessageBuilder messageBuilder = new MultipartReplyMessageBuilder().setMultipartReplyBody(replyBody).setXid(xid).setFlags(new MultipartRequestFlags(hasNext)).setType(MultipartType.OFPMPDESC);
return messageBuilder;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags in project openflowplugin by opendaylight.
the class RequestInputUtils method createMultipartHeader.
public static MultipartRequestInputBuilder createMultipartHeader(MultipartType multipart, Long xid, Short version) {
MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
mprInput.setType(multipart);
mprInput.setVersion(version);
mprInput.setXid(xid);
mprInput.setFlags(new MultipartRequestFlags(false));
return mprInput;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags 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());
}
Aggregations