use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.NoPathVectorTlv.Flags in project openflowplugin by opendaylight.
the class MultipartRequestPortDescTest method test.
/**
* Tests {@link MultipartRequestInputFactory} - PortDesc case.
*/
@Test
public void test() throws Exception {
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setType(MultipartType.OFPMPPORTDESC);
builder.setFlags(new MultipartRequestFlags(false));
MultipartRequestPortDescCaseBuilder caseBuilder = new MultipartRequestPortDescCaseBuilder();
MultipartRequestPortDescBuilder descBuilder = new MultipartRequestPortDescBuilder();
descBuilder.setEmpty(true);
caseBuilder.setMultipartRequestPortDesc(descBuilder.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", 13, 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.params.xml.ns.yang.pcep.types.rev181109.NoPathVectorTlv.Flags in project openflowplugin by opendaylight.
the class MultipartRequestTableTest method test.
/**
* Tests {@link MultipartRequestInputFactory} - Table case.
*/
@Test
public void test() throws Exception {
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setType(MultipartType.OFPMPTABLE);
builder.setFlags(new MultipartRequestFlags(false));
MultipartRequestTableCaseBuilder caseBuilder = new MultipartRequestTableCaseBuilder();
MultipartRequestTableBuilder tablesBuilder = new MultipartRequestTableBuilder();
tablesBuilder.setEmpty(true);
caseBuilder.setMultipartRequestTable(tablesBuilder.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", 3, 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.params.xml.ns.yang.pcep.types.rev181109.NoPathVectorTlv.Flags in project openflowplugin by opendaylight.
the class OF10StatsRequestExperimenterTest method testExperimenter.
/**
* Testing OF10StatsRequestInputFactory (Experimenter) for correct serialization.
*/
@Test
public void testExperimenter() throws Exception {
Mockito.when(mockRegistry.getSerializer(Matchers.<ExperimenterIdTypeSerializerKey<ExperimenterDataOfChoice>>any())).thenReturn(serializer);
OF10StatsRequestInputFactory multipartFactory = new OF10StatsRequestInputFactory();
multipartFactory.injectSerializerRegistry(mockRegistry);
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF10_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.checkHeaderV10(out, (byte) 16, 16);
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.params.xml.ns.yang.pcep.types.rev181109.NoPathVectorTlv.Flags in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method testGroupFeaturesSerialize.
@Test
public void testGroupFeaturesSerialize() throws Exception {
MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setFlags(new MultipartRequestFlags(true));
builder.setType(MultipartType.forValue(8));
final MultipartReplyGroupFeaturesCaseBuilder featureCase = new MultipartReplyGroupFeaturesCaseBuilder();
MultipartReplyGroupFeaturesBuilder feature = new MultipartReplyGroupFeaturesBuilder();
feature.setTypes(new GroupTypes(true, false, true, false));
feature.setCapabilities(new GroupCapabilities(true, false, true, true));
List<Long> maxGroups = new ArrayList<>();
maxGroups.add(1L);
maxGroups.add(2L);
maxGroups.add(3L);
maxGroups.add(4L);
feature.setMaxGroups(maxGroups);
feature.setActionsBitmap(createActionType());
featureCase.setMultipartReplyGroupFeatures(feature.build());
builder.setMultipartReplyBody(featureCase.build());
MultipartReplyMessage message = builder.build();
ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
factory.serialize(message, serializedBuffer);
BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 56);
Assert.assertEquals("Wrong type", MultipartType.OFPMPGROUPFEATURES.getIntValue(), serializedBuffer.readShort());
Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort()));
serializedBuffer.skipBytes(PADDING);
MultipartReplyGroupFeaturesCase body = (MultipartReplyGroupFeaturesCase) message.getMultipartReplyBody();
MultipartReplyGroupFeatures messageOutput = body.getMultipartReplyGroupFeatures();
Assert.assertEquals("Wrong type", messageOutput.getTypes(), createGroupTypes(serializedBuffer.readInt()));
Assert.assertEquals("Wrong capabilities", messageOutput.getCapabilities(), createGroupCapabilities(serializedBuffer.readInt()));
Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(0).intValue(), serializedBuffer.readInt());
Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(1).intValue(), serializedBuffer.readInt());
Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(2).intValue(), serializedBuffer.readInt());
Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(3).intValue(), serializedBuffer.readInt());
Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(0), createActionType(serializedBuffer.readInt()));
Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(1), createActionType(serializedBuffer.readInt()));
Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(2), createActionType(serializedBuffer.readInt()));
Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(3), createActionType(serializedBuffer.readInt()));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.NoPathVectorTlv.Flags in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method testGroupSerialize.
@Test
public void testGroupSerialize() throws Exception {
MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setFlags(new MultipartRequestFlags(true));
builder.setType(MultipartType.forValue(6));
MultipartReplyGroupCaseBuilder groupCase = new MultipartReplyGroupCaseBuilder();
MultipartReplyGroupBuilder group = new MultipartReplyGroupBuilder();
group.setGroupStats(createGroupStats());
groupCase.setMultipartReplyGroup(group.build());
builder.setMultipartReplyBody(groupCase.build());
MultipartReplyMessage message = builder.build();
ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
factory.serialize(message, serializedBuffer);
BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 72);
Assert.assertEquals("Wrong type", MultipartType.OFPMPGROUP.getIntValue(), serializedBuffer.readShort());
Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort()));
serializedBuffer.skipBytes(PADDING);
MultipartReplyGroupCase body = (MultipartReplyGroupCase) message.getMultipartReplyBody();
MultipartReplyGroup messageOutput = body.getMultipartReplyGroup();
GroupStats groupStats = messageOutput.getGroupStats().get(0);
Assert.assertEquals("Wrong length", 56, serializedBuffer.readShort());
serializedBuffer.skipBytes(2);
Assert.assertEquals("Wrong group id", groupStats.getGroupId().getValue().intValue(), serializedBuffer.readInt());
Assert.assertEquals("Wrong ref count", groupStats.getRefCount().intValue(), serializedBuffer.readInt());
serializedBuffer.skipBytes(4);
Assert.assertEquals("Wrong Packet count", groupStats.getPacketCount().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong Byte count", groupStats.getByteCount().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong duration sec", groupStats.getDurationSec().intValue(), serializedBuffer.readInt());
Assert.assertEquals("Wrong duration nsec", groupStats.getDurationNsec().intValue(), serializedBuffer.readInt());
BucketStats bucketStats = groupStats.getBucketStats().get(0);
Assert.assertEquals("Wrong Packet count", bucketStats.getPacketCount().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong Byte count", bucketStats.getByteCount().longValue(), serializedBuffer.readLong());
}
Aggregations