@Test public void testSerialize() { OF10QueueGetConfigReplyMessageFactory serializer = new OF10QueueGetConfigReplyMessageFactory(); ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(message, serializedBuffer); BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 40); Assert.assertEquals("Wrong port", message.getPort().getValue().longValue(), serializedBuffer.readShort()); serializedBuffer.skipBytes(6); Assert.assertEquals("Wrong queue Id", message.getQueues().get(0).getQueueId().getValue().longValue(), serializedBuffer.readInt()); Assert.assertEquals("Wrong length", 24, serializedBuffer.readShort()); serializedBuffer.skipBytes(2); 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(4); RateQueueProperty rateQueueProperty = properties.get(0).getAugmentation(RateQueueProperty.class); Assert.assertEquals("Wrong rate", rateQueueProperty.getRate().intValue(), serializedBuffer.readShort()); serializedBuffer.skipBytes(6); }
@Override public void serialize(GetQueueConfigOutput message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeShort(message.getPort().getValue().intValue()); outBuffer.writeZero(PADDING); for (Queues queue : message.getQueues()) { ByteBuf queueBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); queueBuff.writeInt(queue.getQueueId().getValue().intValue()); queueBuff.writeShort(EncodeConstants.EMPTY_LENGTH); queueBuff.writeZero(QUEUE_PADDING); for (QueueProperty queueProperty : queue.getQueueProperty()) { ByteBuf queuePropertyBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); queuePropertyBuff.writeShort(queueProperty.getProperty().getIntValue()); queuePropertyBuff.writeShort(EncodeConstants.EMPTY_LENGTH); queuePropertyBuff.writeZero(4); if (queueProperty.getProperty() == QueueProperties.OFPQTMINRATE) { RateQueueProperty body = queueProperty.getAugmentation(RateQueueProperty.class); queuePropertyBuff.writeShort(body.getRate().intValue()); queuePropertyBuff.writeZero(QUEUE_PROPERTY_PADDING); } queuePropertyBuff.setShort(QUEUE_PROPERTY_LENGTH_INDEX, queuePropertyBuff.readableBytes()); queueBuff.writeBytes(queuePropertyBuff); } queueBuff.setShort(QUEUE_LENGTH_INDEX, queueBuff.readableBytes()); outBuffer.writeBytes(queueBuff); } ByteBufUtils.updateOFHeaderLength(outBuffer); }
OF10QueueGetConfigReplyMessageFactory implements OFSerializer<GetQueueConfigOutput> { @Override public void serialize(GetQueueConfigOutput message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeShort(message.getPort().getValue().intValue()); outBuffer.writeZero(PADDING); for (Queues queue : message.getQueues()) { ByteBuf queueBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); queueBuff.writeInt(queue.getQueueId().getValue().intValue()); queueBuff.writeShort(EncodeConstants.EMPTY_LENGTH); queueBuff.writeZero(QUEUE_PADDING); for (QueueProperty queueProperty : queue.getQueueProperty()) { ByteBuf queuePropertyBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); queuePropertyBuff.writeShort(queueProperty.getProperty().getIntValue()); queuePropertyBuff.writeShort(EncodeConstants.EMPTY_LENGTH); queuePropertyBuff.writeZero(4); if (queueProperty.getProperty() == QueueProperties.OFPQTMINRATE) { RateQueueProperty body = queueProperty.getAugmentation(RateQueueProperty.class); queuePropertyBuff.writeShort(body.getRate().intValue()); queuePropertyBuff.writeZero(QUEUE_PROPERTY_PADDING); } queuePropertyBuff.setShort(QUEUE_PROPERTY_LENGTH_INDEX, queuePropertyBuff.readableBytes()); queueBuff.writeBytes(queuePropertyBuff); } queueBuff.setShort(QUEUE_LENGTH_INDEX, queueBuff.readableBytes()); outBuffer.writeBytes(queueBuff); } ByteBufUtils.updateOFHeaderLength(outBuffer); } }
OF10QueueGetConfigReplyMessageFactory implements OFSerializer<GetQueueConfigOutput> { @Override public void serialize(GetQueueConfigOutput message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeShort(message.getPort().getValue().intValue()); outBuffer.writeZero(PADDING); for (Queues queue : message.getQueues()) { ByteBuf queueBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); queueBuff.writeInt(queue.getQueueId().getValue().intValue()); queueBuff.writeShort(EncodeConstants.EMPTY_LENGTH); queueBuff.writeZero(QUEUE_PADDING); for (QueueProperty queueProperty : queue.getQueueProperty()) { ByteBuf queuePropertyBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); queuePropertyBuff.writeShort(queueProperty.getProperty().getIntValue()); queuePropertyBuff.writeShort(EncodeConstants.EMPTY_LENGTH); queuePropertyBuff.writeZero(4); if (queueProperty.getProperty() == QueueProperties.OFPQTMINRATE) { RateQueueProperty body = queueProperty.getAugmentation(RateQueueProperty.class); queuePropertyBuff.writeShort(body.getRate().intValue()); queuePropertyBuff.writeZero(QUEUE_PROPERTY_PADDING); } queuePropertyBuff.setShort(QUEUE_PROPERTY_LENGTH_INDEX, queuePropertyBuff.readableBytes()); queueBuff.writeBytes(queuePropertyBuff); } queueBuff.setShort(QUEUE_LENGTH_INDEX, queueBuff.readableBytes()); outBuffer.writeBytes(queueBuff); } ByteBufUtils.updateOFHeaderLength(outBuffer); }  }
OF10QueueGetConfigReplyMessageFactory implements OFSerializer<GetQueueConfigOutput> { @Override public void serialize(GetQueueConfigOutput message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeShort(message.getPort().getValue().intValue()); outBuffer.writeZero(PADDING); for (Queues queue : message.getQueues()) { ByteBuf queueBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); queueBuff.writeInt(queue.getQueueId().getValue().intValue()); queueBuff.writeShort(EncodeConstants.EMPTY_LENGTH); queueBuff.writeZero(QUEUE_PADDING); for (QueueProperty queueProperty : queue.getQueueProperty()) { ByteBuf queuePropertyBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); queuePropertyBuff.writeShort(queueProperty.getProperty().getIntValue()); queuePropertyBuff.writeShort(EncodeConstants.EMPTY_LENGTH); queuePropertyBuff.writeZero(4); if (queueProperty.getProperty() == QueueProperties.OFPQTMINRATE) { RateQueueProperty body = queueProperty.getAugmentation(RateQueueProperty.class); queuePropertyBuff.writeShort(body.getRate().intValue()); queuePropertyBuff.writeZero(QUEUE_PROPERTY_PADDING); } queuePropertyBuff.setShort(QUEUE_PROPERTY_LENGTH_INDEX, queuePropertyBuff.readableBytes()); queueBuff.writeBytes(queuePropertyBuff); } queueBuff.setShort(QUEUE_LENGTH_INDEX, queueBuff.readableBytes()); outBuffer.writeBytes(queueBuff); } ByteBufUtils.updateOFHeaderLength(outBuffer); }  @Override void serialize(GetQueueConfigOutput message, ByteBuf outBuffer); }
OF10QueueGetConfigReplyMessageFactory implements OFSerializer<GetQueueConfigOutput> { @Override public void serialize(GetQueueConfigOutput message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeShort(message.getPort().getValue().intValue()); outBuffer.writeZero(PADDING); for (Queues queue : message.getQueues()) { ByteBuf queueBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); queueBuff.writeInt(queue.getQueueId().getValue().intValue()); queueBuff.writeShort(EncodeConstants.EMPTY_LENGTH); queueBuff.writeZero(QUEUE_PADDING); for (QueueProperty queueProperty : queue.getQueueProperty()) { ByteBuf queuePropertyBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); queuePropertyBuff.writeShort(queueProperty.getProperty().getIntValue()); queuePropertyBuff.writeShort(EncodeConstants.EMPTY_LENGTH); queuePropertyBuff.writeZero(4); if (queueProperty.getProperty() == QueueProperties.OFPQTMINRATE) { RateQueueProperty body = queueProperty.getAugmentation(RateQueueProperty.class); queuePropertyBuff.writeShort(body.getRate().intValue()); queuePropertyBuff.writeZero(QUEUE_PROPERTY_PADDING); } queuePropertyBuff.setShort(QUEUE_PROPERTY_LENGTH_INDEX, queuePropertyBuff.readableBytes()); queueBuff.writeBytes(queuePropertyBuff); } queueBuff.setShort(QUEUE_LENGTH_INDEX, queueBuff.readableBytes()); outBuffer.writeBytes(queueBuff); } ByteBufUtils.updateOFHeaderLength(outBuffer); }  @Override void serialize(GetQueueConfigOutput message, ByteBuf outBuffer);  }