Bug 2756 - Match model update
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / deserialization / factories / OF10QueueGetConfigReplyMessageFactoryTest.java
index 3ce772de911d81dff43f5fc05825ad0fa42ef139..c4ccb4e34137f6f12a390bb279f22c07a876b45e 100644 (file)
@@ -1,53 +1,79 @@
-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueueProperty;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class OF10QueueGetConfigReplyMessageFactoryTest {\r
-\r
-    /**\r
-     * Testing of {@link OF10QueueGetConfigReplyMessageFactory} for correct\r
-     * translation into POJO\r
-     */\r
-    @Test\r
-    public void test() {\r
-        ByteBuf bb = BufferHelper.buildBuffer("00 01 00 00 00 00 00 00 "\r
-                + "00 00 00 08 00 10 00 00 00 00 00 08 00 00 00 00 "\r
-                + "00 00 00 02 00 28 00 00 00 01 00 10 00 00 00 00 00 20 00 00 00 00 00 00 "\r
-                + "00 01 00 10 00 00 00 00 00 30 00 00 00 00 00 00");\r
-        GetQueueConfigOutput builtByFactory = BufferHelper.decodeV10(\r
-                OF10QueueGetConfigReplyMessageFactory.getInstance(), bb);\r
-\r
-        BufferHelper.checkHeaderV10(builtByFactory);\r
-        Assert.assertEquals("Wrong port", 1, builtByFactory.getPort().getValue().intValue());\r
-        Assert.assertEquals("Wrong queues size", 2, builtByFactory.getQueues().size());\r
-        Queues queue1 = builtByFactory.getQueues().get(0);\r
-        Queues queue2 = builtByFactory.getQueues().get(1);\r
-        Assert.assertEquals("Wrong queueId", 8, queue1.getQueueId().getValue().intValue());\r
-        Assert.assertEquals("Wrong queue - # properties", 1, queue1.getQueueProperty().size());\r
-        Assert.assertEquals("Wrong queue - wrong property", QueueProperties.OFPQTNONE,\r
-                queue1.getQueueProperty().get(0).getProperty());\r
-        Assert.assertEquals("Wrong queueId", 2, queue2.getQueueId().getValue().intValue());\r
-        Assert.assertEquals("Wrong queue - # properties", 2, queue2.getQueueProperty().size());\r
-        Assert.assertEquals("Wrong queue - wrong property", QueueProperties.OFPQTMINRATE,\r
-                queue2.getQueueProperty().get(0).getProperty());\r
-        Assert.assertEquals("Wrong queue - wrong property", QueueProperties.OFPQTMINRATE,\r
-                queue2.getQueueProperty().get(1).getProperty());\r
-        RateQueueProperty rate1 = queue2.getQueueProperty().get(0).getAugmentation(RateQueueProperty.class);\r
-        RateQueueProperty rate2 = queue2.getQueueProperty().get(1).getAugmentation(RateQueueProperty.class);\r
-        Assert.assertEquals("Wrong queue - wrong property rate", 32, rate1.getRate().intValue());\r
-        Assert.assertEquals("Wrong queue - wrong property rate", 48, rate2.getRate().intValue());\r
-    }\r
-}\r
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueueProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class OF10QueueGetConfigReplyMessageFactoryTest {
+
+    private OFDeserializer<GetQueueConfigOutput> queueFactory;
+
+    /**
+     * Initializes deserializer registry and lookups correct deserializer
+     */
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        queueFactory = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 21, GetQueueConfigOutput.class));
+    }
+
+    /**
+     * Testing of {@link OF10QueueGetConfigReplyMessageFactory} for correct
+     * translation into POJO
+     */
+    @Test
+    public void test() {
+        ByteBuf bb = BufferHelper.buildBuffer("00 01 00 00 00 00 00 00 "
+                + "00 00 00 08 00 10 00 00 00 00 00 08 00 00 00 00 "
+                + "00 00 00 02 00 28 00 00 00 01 00 10 00 00 00 00 00 20 00 00 00 00 00 00 "
+                + "00 01 00 10 00 00 00 00 00 30 00 00 00 00 00 00");
+        GetQueueConfigOutput builtByFactory = BufferHelper.deserialize(
+                queueFactory, bb);
+
+        BufferHelper.checkHeaderV10(builtByFactory);
+        Assert.assertEquals("Wrong port", 1, builtByFactory.getPort().getValue().intValue());
+        Assert.assertEquals("Wrong queues size", 2, builtByFactory.getQueues().size());
+        Queues queue1 = builtByFactory.getQueues().get(0);
+        Queues queue2 = builtByFactory.getQueues().get(1);
+        Assert.assertEquals("Wrong queueId", 8, queue1.getQueueId().getValue().intValue());
+        Assert.assertEquals("Wrong queue - # properties", 1, queue1.getQueueProperty().size());
+        Assert.assertEquals("Wrong queue - wrong property", QueueProperties.OFPQTNONE,
+                queue1.getQueueProperty().get(0).getProperty());
+        Assert.assertEquals("Wrong queueId", 2, queue2.getQueueId().getValue().intValue());
+        Assert.assertEquals("Wrong queue - # properties", 2, queue2.getQueueProperty().size());
+        Assert.assertEquals("Wrong queue - wrong property", QueueProperties.OFPQTMINRATE,
+                queue2.getQueueProperty().get(0).getProperty());
+        Assert.assertEquals("Wrong queue - wrong property", QueueProperties.OFPQTMINRATE,
+                queue2.getQueueProperty().get(1).getProperty());
+        RateQueueProperty rate1 = queue2.getQueueProperty().get(0).getAugmentation(RateQueueProperty.class);
+        RateQueueProperty rate2 = queue2.getQueueProperty().get(1).getAugmentation(RateQueueProperty.class);
+        Assert.assertEquals("Wrong queue - wrong property rate", 32, rate1.getRate().intValue());
+        Assert.assertEquals("Wrong queue - wrong property rate", 48, rate2.getRate().intValue());
+    }
+}