@Test public void testSerialize() { QueueGetConfigReplyMessageFactory serializer = new QueueGetConfigReplyMessageFactory(); SerializerRegistry registry = new NetIdeSerializerRegistryImpl(); registry.init(); ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(message, serializedBuffer); BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 80); Assert.assertEquals("Wrong port", message.getPort().getValue().longValue(), serializedBuffer.readInt()); serializedBuffer.skipBytes(PADDING); Assert.assertEquals("Wrong queue Id", message.getQueues().get(0).getQueueId().getValue().longValue(), serializedBuffer.readInt()); Assert.assertEquals("Wrong port", message.getQueues().get(0).getPort().getValue().longValue(), serializedBuffer.readInt()); Assert.assertEquals("Wrong length", 32, serializedBuffer.readShort()); serializedBuffer.skipBytes(QUEUE_PADDING); List<QueueProperty> properties = message.getQueues().get(0).getQueueProperty(); Assert.assertEquals("Wrong property", properties.get(0).getProperty().getIntValue(), serializedBuffer.readShort()); Assert.assertEquals("Wrong property length", 16, serializedBuffer.readShort()); serializedBuffer.skipBytes(PROPERTY_HEADER_PADDING); RateQueueProperty rateQueueProperty = properties.get(0).getAugmentation(RateQueueProperty.class); Assert.assertEquals("Wrong rate", rateQueueProperty.getRate().intValue(), serializedBuffer.readShort()); serializedBuffer.skipBytes(PROPERTY_RATE_PADDING); Assert.assertEquals("Wrong queue Id", message.getQueues().get(1).getQueueId().getValue().longValue(), serializedBuffer.readInt()); Assert.assertEquals("Wrong queue Id", message.getQueues().get(1).getPort().getValue().longValue(), serializedBuffer.readInt()); Assert.assertEquals("Wrong length", 32, serializedBuffer.readShort()); serializedBuffer.skipBytes(QUEUE_PADDING); List<QueueProperty> propertiesTwo = message.getQueues().get(1).getQueueProperty(); Assert.assertEquals("Wrong property", propertiesTwo.get(0).getProperty().getIntValue(), serializedBuffer.readShort()); Assert.assertEquals("Wrong property length", 16, serializedBuffer.readShort()); serializedBuffer.skipBytes(PROPERTY_HEADER_PADDING); RateQueueProperty rateQueuePropertyTwo = propertiesTwo.get(0).getAugmentation(RateQueueProperty.class); Assert.assertEquals("Wrong rate", rateQueuePropertyTwo.getRate().intValue(), serializedBuffer.readShort()); serializedBuffer.skipBytes(PROPERTY_RATE_PADDING); }
@Override public void serialize(GetQueueConfigOutput message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeInt(message.getPort().getValue().intValue()); outBuffer.writeZero(PADDING); for (Queues queue : message.getQueues()) { ByteBuf queueBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); queueBuff.writeInt(queue.getQueueId().getValue().intValue()); queueBuff.writeInt(queue.getPort().getValue().intValue()); queueBuff.writeShort(EncodeConstants.EMPTY_LENGTH); queueBuff.writeZero(QUEUE_PADDING); for (QueueProperty property : queue.getQueueProperty()) { ByteBuf propertyBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); propertyBuff.writeShort(property.getProperty().getIntValue()); propertyBuff.writeShort(EncodeConstants.EMPTY_LENGTH); propertyBuff.writeZero(PROPERTY_HEADER_PADDING); switch (property.getProperty()) { case OFPQTMINRATE: serializeRateBody(property.getAugmentation(RateQueueProperty.class), propertyBuff); break; case OFPQTMAXRATE: serializeRateBody(property.getAugmentation(RateQueueProperty.class), propertyBuff); break; case OFPQTEXPERIMENTER: serializeExperimenterBody(property.getAugmentation(ExperimenterIdQueueProperty.class), propertyBuff); break; default: break; } propertyBuff.setShort(PROPERTY_LENGTH_INDEX, propertyBuff.readableBytes()); queueBuff.writeBytes(propertyBuff); } queueBuff.setShort(QUEUE_LENGTH_INDEX, queueBuff.readableBytes()); outBuffer.writeBytes(queueBuff); } ByteBufUtils.updateOFHeaderLength(outBuffer); }
QueueGetConfigReplyMessageFactory implements OFSerializer<GetQueueConfigOutput> { @Override public void serialize(GetQueueConfigOutput message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeInt(message.getPort().getValue().intValue()); outBuffer.writeZero(PADDING); for (Queues queue : message.getQueues()) { ByteBuf queueBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); queueBuff.writeInt(queue.getQueueId().getValue().intValue()); queueBuff.writeInt(queue.getPort().getValue().intValue()); queueBuff.writeShort(EncodeConstants.EMPTY_LENGTH); queueBuff.writeZero(QUEUE_PADDING); for (QueueProperty property : queue.getQueueProperty()) { ByteBuf propertyBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); propertyBuff.writeShort(property.getProperty().getIntValue()); propertyBuff.writeShort(EncodeConstants.EMPTY_LENGTH); propertyBuff.writeZero(PROPERTY_HEADER_PADDING); switch (property.getProperty()) { case OFPQTMINRATE: serializeRateBody(property.getAugmentation(RateQueueProperty.class), propertyBuff); break; case OFPQTMAXRATE: serializeRateBody(property.getAugmentation(RateQueueProperty.class), propertyBuff); break; case OFPQTEXPERIMENTER: serializeExperimenterBody(property.getAugmentation(ExperimenterIdQueueProperty.class), propertyBuff); break; default: break; } propertyBuff.setShort(PROPERTY_LENGTH_INDEX, propertyBuff.readableBytes()); queueBuff.writeBytes(propertyBuff); } queueBuff.setShort(QUEUE_LENGTH_INDEX, queueBuff.readableBytes()); outBuffer.writeBytes(queueBuff); } ByteBufUtils.updateOFHeaderLength(outBuffer); } }
QueueGetConfigReplyMessageFactory implements OFSerializer<GetQueueConfigOutput> { @Override public void serialize(GetQueueConfigOutput message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeInt(message.getPort().getValue().intValue()); outBuffer.writeZero(PADDING); for (Queues queue : message.getQueues()) { ByteBuf queueBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); queueBuff.writeInt(queue.getQueueId().getValue().intValue()); queueBuff.writeInt(queue.getPort().getValue().intValue()); queueBuff.writeShort(EncodeConstants.EMPTY_LENGTH); queueBuff.writeZero(QUEUE_PADDING); for (QueueProperty property : queue.getQueueProperty()) { ByteBuf propertyBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); propertyBuff.writeShort(property.getProperty().getIntValue()); propertyBuff.writeShort(EncodeConstants.EMPTY_LENGTH); propertyBuff.writeZero(PROPERTY_HEADER_PADDING); switch (property.getProperty()) { case OFPQTMINRATE: serializeRateBody(property.getAugmentation(RateQueueProperty.class), propertyBuff); break; case OFPQTMAXRATE: serializeRateBody(property.getAugmentation(RateQueueProperty.class), propertyBuff); break; case OFPQTEXPERIMENTER: serializeExperimenterBody(property.getAugmentation(ExperimenterIdQueueProperty.class), propertyBuff); break; default: break; } propertyBuff.setShort(PROPERTY_LENGTH_INDEX, propertyBuff.readableBytes()); queueBuff.writeBytes(propertyBuff); } queueBuff.setShort(QUEUE_LENGTH_INDEX, queueBuff.readableBytes()); outBuffer.writeBytes(queueBuff); } ByteBufUtils.updateOFHeaderLength(outBuffer); }  }
QueueGetConfigReplyMessageFactory implements OFSerializer<GetQueueConfigOutput> { @Override public void serialize(GetQueueConfigOutput message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeInt(message.getPort().getValue().intValue()); outBuffer.writeZero(PADDING); for (Queues queue : message.getQueues()) { ByteBuf queueBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); queueBuff.writeInt(queue.getQueueId().getValue().intValue()); queueBuff.writeInt(queue.getPort().getValue().intValue()); queueBuff.writeShort(EncodeConstants.EMPTY_LENGTH); queueBuff.writeZero(QUEUE_PADDING); for (QueueProperty property : queue.getQueueProperty()) { ByteBuf propertyBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); propertyBuff.writeShort(property.getProperty().getIntValue()); propertyBuff.writeShort(EncodeConstants.EMPTY_LENGTH); propertyBuff.writeZero(PROPERTY_HEADER_PADDING); switch (property.getProperty()) { case OFPQTMINRATE: serializeRateBody(property.getAugmentation(RateQueueProperty.class), propertyBuff); break; case OFPQTMAXRATE: serializeRateBody(property.getAugmentation(RateQueueProperty.class), propertyBuff); break; case OFPQTEXPERIMENTER: serializeExperimenterBody(property.getAugmentation(ExperimenterIdQueueProperty.class), propertyBuff); break; default: break; } propertyBuff.setShort(PROPERTY_LENGTH_INDEX, propertyBuff.readableBytes()); queueBuff.writeBytes(propertyBuff); } queueBuff.setShort(QUEUE_LENGTH_INDEX, queueBuff.readableBytes()); outBuffer.writeBytes(queueBuff); } ByteBufUtils.updateOFHeaderLength(outBuffer); }  @Override void serialize(GetQueueConfigOutput message, ByteBuf outBuffer); }
QueueGetConfigReplyMessageFactory implements OFSerializer<GetQueueConfigOutput> { @Override public void serialize(GetQueueConfigOutput message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeInt(message.getPort().getValue().intValue()); outBuffer.writeZero(PADDING); for (Queues queue : message.getQueues()) { ByteBuf queueBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); queueBuff.writeInt(queue.getQueueId().getValue().intValue()); queueBuff.writeInt(queue.getPort().getValue().intValue()); queueBuff.writeShort(EncodeConstants.EMPTY_LENGTH); queueBuff.writeZero(QUEUE_PADDING); for (QueueProperty property : queue.getQueueProperty()) { ByteBuf propertyBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); propertyBuff.writeShort(property.getProperty().getIntValue()); propertyBuff.writeShort(EncodeConstants.EMPTY_LENGTH); propertyBuff.writeZero(PROPERTY_HEADER_PADDING); switch (property.getProperty()) { case OFPQTMINRATE: serializeRateBody(property.getAugmentation(RateQueueProperty.class), propertyBuff); break; case OFPQTMAXRATE: serializeRateBody(property.getAugmentation(RateQueueProperty.class), propertyBuff); break; case OFPQTEXPERIMENTER: serializeExperimenterBody(property.getAugmentation(ExperimenterIdQueueProperty.class), propertyBuff); break; default: break; } propertyBuff.setShort(PROPERTY_LENGTH_INDEX, propertyBuff.readableBytes()); queueBuff.writeBytes(propertyBuff); } queueBuff.setShort(QUEUE_LENGTH_INDEX, queueBuff.readableBytes()); outBuffer.writeBytes(queueBuff); } ByteBufUtils.updateOFHeaderLength(outBuffer); }  @Override void serialize(GetQueueConfigOutput message, ByteBuf outBuffer); static final int QUEUE_LENGTH_INDEX; static final int PROPERTY_LENGTH_INDEX; }