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;
12 import org.junit.Assert;
13 import org.junit.Before;
14 import org.junit.Test;
15 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
16 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
17 import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
18 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
19 import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
20 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueueProperty;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues;
27 * Unit tests for OF10QueueGetConfigReplyMessageFactory.
29 * @author michal.polkorab
31 public class OF10QueueGetConfigReplyMessageFactoryTest {
33 private OFDeserializer<GetQueueConfigOutput> queueFactory;
36 * Initializes deserializer registry and lookups correct deserializer.
39 public void startUp() {
40 DeserializerRegistry registry = new DeserializerRegistryImpl();
42 queueFactory = registry.getDeserializer(
43 new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 21, GetQueueConfigOutput.class));
47 * Testing of {@link OF10QueueGetConfigReplyMessageFactory} for correct
48 * translation into POJO.
52 ByteBuf bb = BufferHelper.buildBuffer("00 01 00 00 00 00 00 00 "
53 + "00 00 00 08 00 10 00 00 00 00 00 08 00 00 00 00 "
54 + "00 00 00 02 00 28 00 00 00 01 00 10 00 00 00 00 00 20 00 00 00 00 00 00 "
55 + "00 01 00 10 00 00 00 00 00 30 00 00 00 00 00 00");
56 GetQueueConfigOutput builtByFactory = BufferHelper.deserialize(
59 BufferHelper.checkHeaderV10(builtByFactory);
60 Assert.assertEquals("Wrong port", 1, builtByFactory.getPort().getValue().intValue());
61 Assert.assertEquals("Wrong queues size", 2, builtByFactory.getQueues().size());
62 Queues queue1 = builtByFactory.getQueues().get(0);
63 Queues queue2 = builtByFactory.getQueues().get(1);
64 Assert.assertEquals("Wrong queueId", 8, queue1.getQueueId().getValue().intValue());
65 Assert.assertEquals("Wrong queue - # properties", 1, queue1.getQueueProperty().size());
66 Assert.assertEquals("Wrong queue - wrong property", QueueProperties.OFPQTNONE,
67 queue1.getQueueProperty().get(0).getProperty());
68 Assert.assertEquals("Wrong queueId", 2, queue2.getQueueId().getValue().intValue());
69 Assert.assertEquals("Wrong queue - # properties", 2, queue2.getQueueProperty().size());
70 Assert.assertEquals("Wrong queue - wrong property", QueueProperties.OFPQTMINRATE,
71 queue2.getQueueProperty().get(0).getProperty());
72 Assert.assertEquals("Wrong queue - wrong property", QueueProperties.OFPQTMINRATE,
73 queue2.getQueueProperty().get(1).getProperty());
74 RateQueueProperty rate1 = queue2.getQueueProperty().get(0).augmentation(RateQueueProperty.class);
75 RateQueueProperty rate2 = queue2.getQueueProperty().get(1).augmentation(RateQueueProperty.class);
76 Assert.assertEquals("Wrong queue - wrong property rate", 32, rate1.getRate().intValue());
77 Assert.assertEquals("Wrong queue - wrong property rate", 48, rate2.getRate().intValue());