1 /* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
\r
2 package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
\r
4 import io.netty.buffer.ByteBuf;
\r
6 import java.util.ArrayList;
\r
7 import java.util.List;
\r
9 import org.junit.Assert;
\r
10 import org.junit.Test;
\r
11 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
\r
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
\r
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId;
\r
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties;
\r
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput;
\r
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues;
\r
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.QueuesBuilder;
\r
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty;
\r
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueuePropertyBuilder;
\r
22 * @author timotej.kubas
\r
23 * @author michal.polkorab
\r
25 public class QueueGetConfigReplyMessageFactoryMultiTest {
\r
28 * Testing of {@link QueueGetConfigReplyMessageFactory} for correct
\r
29 * translation into POJO
\r
33 public void test() {
\r
34 ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 " + // port
\r
35 "00 00 00 00 " + // padding
\r
36 "00 00 00 01 " + // queueId
\r
37 "00 00 00 01 " + // port
\r
38 "00 00 00 00 00 00 00 00 " + // pad
\r
39 "00 01 " + // property
\r
40 "00 00 00 00 00 00 " + // pad
\r
41 "00 00 00 02 " + // queueId
\r
42 "00 00 00 02 " + // port
\r
43 "00 00 00 00 00 00 00 00 " + // pad
\r
44 "00 01 " + // property
\r
45 "00 00 00 00 00 00 " + // pad
\r
46 "00 00 00 03 " + // queueId
\r
47 "00 00 00 03 " + // port
\r
48 "00 00 00 00 00 00 00 00 " + // pad
\r
49 "00 01 " + // property
\r
50 "00 00 00 00 00 00" // pad
\r
53 GetQueueConfigOutput builtByFactory = BufferHelper.decodeV13(
\r
54 QueueGetConfigReplyMessageFactory.getInstance(), bb);
\r
56 BufferHelper.checkHeaderV13(builtByFactory);
\r
57 Assert.assertEquals("Wrong port", 66051L, builtByFactory.getPort().getValue().longValue());
\r
58 Assert.assertEquals("Wrong queues", builtByFactory.getQueues(),
\r
59 createQueuesList());
\r
62 private static List<Queues> createQueuesList() {
\r
63 List<Queues> queuesList = new ArrayList<>();
\r
64 QueuesBuilder qb = new QueuesBuilder();
\r
65 for (int i = 1; i <= 3; i++) {
\r
66 qb.setQueueId(new QueueId((long) i));
\r
67 qb.setPort(new PortNumber((long) i));
\r
68 qb.setQueueProperty(createPropertiesList());
\r
69 queuesList.add(qb.build());
\r
74 private static List<QueueProperty> createPropertiesList() {
\r
75 List<QueueProperty> propertiesList = new ArrayList<>();
\r
76 QueuePropertyBuilder pb = new QueuePropertyBuilder();
\r
77 pb.setProperty(QueueProperties.forValue(1));
\r
78 propertiesList.add(pb.build());
\r
79 return propertiesList;
\r