2 * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
11 import io.netty.buffer.ByteBuf;
13 import java.util.ArrayList;
14 import java.util.List;
16 import org.junit.Assert;
17 import org.junit.Test;
18 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueueProperty;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueuePropertyBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.QueuesBuilder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueuePropertyBuilder;
31 * @author timotej.kubas
32 * @author michal.polkorab
34 public class QueueGetConfigReplyMessageFactoryMultiTest {
37 * Testing of {@link QueueGetConfigReplyMessageFactory} for correct
38 * translation into POJO
42 ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 " + // port
43 "00 00 00 00 " + // padding
44 "00 00 00 01 " + // queueId
45 "00 00 00 01 " + // port
47 "00 00 00 00 00 00 " + // pad
48 "00 02 " + // property
50 "00 00 00 00 " + // pad
52 "00 00 00 00 00 00 " + // pad
53 "00 00 00 02 " + // queueId
54 "00 00 00 02 " + // port
56 "00 00 00 00 00 00 " + // pad
57 "00 02 " + // property
59 "00 00 00 00 " + // pad
61 "00 00 00 00 00 00 " // pad
64 GetQueueConfigOutput builtByFactory = BufferHelper.decodeV13(
65 QueueGetConfigReplyMessageFactory.getInstance(), bb);
67 BufferHelper.checkHeaderV13(builtByFactory);
68 Assert.assertEquals("Wrong port", 66051L, builtByFactory.getPort().getValue().longValue());
69 Assert.assertEquals("Wrong queues", createQueuesList(), builtByFactory.getQueues());
72 private static List<Queues> createQueuesList() {
73 List<Queues> queuesList = new ArrayList<>();
74 for (int i = 1; i < 3; i++) {
75 QueuesBuilder qb = new QueuesBuilder();
76 qb.setQueueId(new QueueId((long) i));
77 qb.setPort(new PortNumber((long) i));
78 qb.setQueueProperty(createPropertiesList());
79 queuesList.add(qb.build());
84 private static List<QueueProperty> createPropertiesList() {
85 List<QueueProperty> propertiesList = new ArrayList<>();
86 QueuePropertyBuilder pb = new QueuePropertyBuilder();
87 pb.setProperty(QueueProperties.forValue(2));
88 RateQueuePropertyBuilder rateBuilder = new RateQueuePropertyBuilder();
89 rateBuilder.setRate(5);
90 pb.addAugmentation(RateQueueProperty.class, rateBuilder.build());
91 propertiesList.add(pb.build());
92 return propertiesList;