@Test public void testGroupSerialize() { builder.setType(MultipartType.forValue(6)); MultipartReplyGroupCaseBuilder groupCase = new MultipartReplyGroupCaseBuilder(); MultipartReplyGroupBuilder group = new MultipartReplyGroupBuilder(); group.setGroupStats(createGroupStats()); groupCase.setMultipartReplyGroup(group.build()); builder.setMultipartReplyBody(groupCase.build()); message = builder.build(); ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); serializer.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()); }
@Override public void serialize(MultipartReplyMessage message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeShort(message.getType().getIntValue()); writeFlags(message.getFlags(), outBuffer); outBuffer.writeZero(PADDING); switch (message.getType()) { case OFPMPDESC: serializeDescBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPFLOW: serializeFlowBody(message.getMultipartReplyBody(), outBuffer, message); break; case OFPMPAGGREGATE: serializeAggregateBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPTABLE: serializeTableBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPPORTSTATS: serializePortStatsBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPQUEUE: serializeQueueBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPGROUP: serializeGroupBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPGROUPDESC: serializeGroupDescBody(message.getMultipartReplyBody(), outBuffer, message); break; case OFPMPGROUPFEATURES: serializeGroupFeaturesBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPMETER: serializeMeterBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPMETERCONFIG: serializeMeterConfigBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPMETERFEATURES: serializeMeterFeaturesBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPTABLEFEATURES: serializeTableFeaturesBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPPORTDESC: serializePortDescBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPEXPERIMENTER: serializeExperimenterBody(message.getMultipartReplyBody(), outBuffer); break; } ByteBufUtils.updateOFHeaderLength(outBuffer); }
MultipartReplyMessageFactory implements OFSerializer<MultipartReplyMessage>, SerializerRegistryInjector { @Override public void serialize(MultipartReplyMessage message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeShort(message.getType().getIntValue()); writeFlags(message.getFlags(), outBuffer); outBuffer.writeZero(PADDING); switch (message.getType()) { case OFPMPDESC: serializeDescBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPFLOW: serializeFlowBody(message.getMultipartReplyBody(), outBuffer, message); break; case OFPMPAGGREGATE: serializeAggregateBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPTABLE: serializeTableBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPPORTSTATS: serializePortStatsBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPQUEUE: serializeQueueBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPGROUP: serializeGroupBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPGROUPDESC: serializeGroupDescBody(message.getMultipartReplyBody(), outBuffer, message); break; case OFPMPGROUPFEATURES: serializeGroupFeaturesBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPMETER: serializeMeterBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPMETERCONFIG: serializeMeterConfigBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPMETERFEATURES: serializeMeterFeaturesBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPTABLEFEATURES: serializeTableFeaturesBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPPORTDESC: serializePortDescBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPEXPERIMENTER: serializeExperimenterBody(message.getMultipartReplyBody(), outBuffer); break; } ByteBufUtils.updateOFHeaderLength(outBuffer); } }
MultipartReplyMessageFactory implements OFSerializer<MultipartReplyMessage>, SerializerRegistryInjector { @Override public void serialize(MultipartReplyMessage message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeShort(message.getType().getIntValue()); writeFlags(message.getFlags(), outBuffer); outBuffer.writeZero(PADDING); switch (message.getType()) { case OFPMPDESC: serializeDescBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPFLOW: serializeFlowBody(message.getMultipartReplyBody(), outBuffer, message); break; case OFPMPAGGREGATE: serializeAggregateBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPTABLE: serializeTableBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPPORTSTATS: serializePortStatsBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPQUEUE: serializeQueueBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPGROUP: serializeGroupBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPGROUPDESC: serializeGroupDescBody(message.getMultipartReplyBody(), outBuffer, message); break; case OFPMPGROUPFEATURES: serializeGroupFeaturesBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPMETER: serializeMeterBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPMETERCONFIG: serializeMeterConfigBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPMETERFEATURES: serializeMeterFeaturesBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPTABLEFEATURES: serializeTableFeaturesBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPPORTDESC: serializePortDescBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPEXPERIMENTER: serializeExperimenterBody(message.getMultipartReplyBody(), outBuffer); break; } ByteBufUtils.updateOFHeaderLength(outBuffer); }  }
MultipartReplyMessageFactory implements OFSerializer<MultipartReplyMessage>, SerializerRegistryInjector { @Override public void serialize(MultipartReplyMessage message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeShort(message.getType().getIntValue()); writeFlags(message.getFlags(), outBuffer); outBuffer.writeZero(PADDING); switch (message.getType()) { case OFPMPDESC: serializeDescBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPFLOW: serializeFlowBody(message.getMultipartReplyBody(), outBuffer, message); break; case OFPMPAGGREGATE: serializeAggregateBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPTABLE: serializeTableBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPPORTSTATS: serializePortStatsBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPQUEUE: serializeQueueBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPGROUP: serializeGroupBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPGROUPDESC: serializeGroupDescBody(message.getMultipartReplyBody(), outBuffer, message); break; case OFPMPGROUPFEATURES: serializeGroupFeaturesBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPMETER: serializeMeterBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPMETERCONFIG: serializeMeterConfigBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPMETERFEATURES: serializeMeterFeaturesBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPTABLEFEATURES: serializeTableFeaturesBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPPORTDESC: serializePortDescBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPEXPERIMENTER: serializeExperimenterBody(message.getMultipartReplyBody(), outBuffer); break; } ByteBufUtils.updateOFHeaderLength(outBuffer); }  @Override void injectSerializerRegistry(SerializerRegistry serializerRegistry); @Override void serialize(MultipartReplyMessage message, ByteBuf outBuffer); }
MultipartReplyMessageFactory implements OFSerializer<MultipartReplyMessage>, SerializerRegistryInjector { @Override public void serialize(MultipartReplyMessage message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeShort(message.getType().getIntValue()); writeFlags(message.getFlags(), outBuffer); outBuffer.writeZero(PADDING); switch (message.getType()) { case OFPMPDESC: serializeDescBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPFLOW: serializeFlowBody(message.getMultipartReplyBody(), outBuffer, message); break; case OFPMPAGGREGATE: serializeAggregateBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPTABLE: serializeTableBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPPORTSTATS: serializePortStatsBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPQUEUE: serializeQueueBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPGROUP: serializeGroupBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPGROUPDESC: serializeGroupDescBody(message.getMultipartReplyBody(), outBuffer, message); break; case OFPMPGROUPFEATURES: serializeGroupFeaturesBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPMETER: serializeMeterBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPMETERCONFIG: serializeMeterConfigBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPMETERFEATURES: serializeMeterFeaturesBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPTABLEFEATURES: serializeTableFeaturesBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPPORTDESC: serializePortDescBody(message.getMultipartReplyBody(), outBuffer); break; case OFPMPEXPERIMENTER: serializeExperimenterBody(message.getMultipartReplyBody(), outBuffer); break; } ByteBufUtils.updateOFHeaderLength(outBuffer); }  @Override void injectSerializerRegistry(SerializerRegistry serializerRegistry); @Override void serialize(MultipartReplyMessage message, ByteBuf outBuffer);  }