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 org.junit.Assert;
14 import org.junit.Test;
15 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueueProperty;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues;
22 * @author michal.polkorab
25 public class OF10QueueGetConfigReplyMessageFactoryTest {
28 * Testing of {@link OF10QueueGetConfigReplyMessageFactory} for correct
29 * translation into POJO
33 ByteBuf bb = BufferHelper.buildBuffer("00 01 00 00 00 00 00 00 "
34 + "00 00 00 08 00 10 00 00 00 00 00 08 00 00 00 00 "
35 + "00 00 00 02 00 28 00 00 00 01 00 10 00 00 00 00 00 20 00 00 00 00 00 00 "
36 + "00 01 00 10 00 00 00 00 00 30 00 00 00 00 00 00");
37 GetQueueConfigOutput builtByFactory = BufferHelper.decodeV10(
38 OF10QueueGetConfigReplyMessageFactory.getInstance(), bb);
40 BufferHelper.checkHeaderV10(builtByFactory);
41 Assert.assertEquals("Wrong port", 1, builtByFactory.getPort().getValue().intValue());
42 Assert.assertEquals("Wrong queues size", 2, builtByFactory.getQueues().size());
43 Queues queue1 = builtByFactory.getQueues().get(0);
44 Queues queue2 = builtByFactory.getQueues().get(1);
45 Assert.assertEquals("Wrong queueId", 8, queue1.getQueueId().getValue().intValue());
46 Assert.assertEquals("Wrong queue - # properties", 1, queue1.getQueueProperty().size());
47 Assert.assertEquals("Wrong queue - wrong property", QueueProperties.OFPQTNONE,
48 queue1.getQueueProperty().get(0).getProperty());
49 Assert.assertEquals("Wrong queueId", 2, queue2.getQueueId().getValue().intValue());
50 Assert.assertEquals("Wrong queue - # properties", 2, queue2.getQueueProperty().size());
51 Assert.assertEquals("Wrong queue - wrong property", QueueProperties.OFPQTMINRATE,
52 queue2.getQueueProperty().get(0).getProperty());
53 Assert.assertEquals("Wrong queue - wrong property", QueueProperties.OFPQTMINRATE,
54 queue2.getQueueProperty().get(1).getProperty());
55 RateQueueProperty rate1 = queue2.getQueueProperty().get(0).getAugmentation(RateQueueProperty.class);
56 RateQueueProperty rate2 = queue2.getQueueProperty().get(1).getAugmentation(RateQueueProperty.class);
57 Assert.assertEquals("Wrong queue - wrong property rate", 32, rate1.getRate().intValue());
58 Assert.assertEquals("Wrong queue - wrong property rate", 48, rate2.getRate().intValue());