Default experimenter bundle migrated to ConfigSubsystem
[openflowjava.git] / openflow-protocol-ext / src / test / java / org / opendaylight / openflowjava / protocol / ext / deserialization / OF13QueueGetConfigReplyExperimenterDeserializerTest.java
1 /*\r
2  * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 \r
9 package org.opendaylight.openflowjava.protocol.ext.deserialization;\r
10 \r
11 import io.netty.buffer.ByteBuf;\r
12 import io.netty.buffer.UnpooledByteBufAllocator;\r
13 \r
14 import org.junit.Assert;\r
15 import org.junit.Test;\r
16 import org.opendaylight.openflowjava.protocol.ext.util.ExtBufferUtils;\r
17 import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants;\r
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterQueueProperty;\r
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties;\r
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty;\r
21 \r
22 /**\r
23  * @author michal.polkorab\r
24  *\r
25  */\r
26 public class OF13QueueGetConfigReplyExperimenterDeserializerTest {\r
27 \r
28     /**\r
29      * Testing of {@link OF13QueueGetConfigReplyExperimenterDeserializer} for correct translation into POJO\r
30      * @throws Exception \r
31      */\r
32     @Test\r
33     public void test() {\r
34         ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();\r
35         buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE);\r
36         buffer.writeShort(24);\r
37         ExtBufferUtils.padBuffer(4, buffer);\r
38         buffer.writeInt(128);\r
39         ExtBufferUtils.padBuffer(4, buffer);\r
40         byte[] data = new byte[]{0, 0, 1, 1, 2, 2, 3, 3};\r
41         buffer.writeBytes(data);\r
42 \r
43         OF13QueueGetConfigReplyExperimenterDeserializer deserializer =\r
44                 new OF13QueueGetConfigReplyExperimenterDeserializer();\r
45         QueueProperty message = deserializer.deserialize(buffer);\r
46 \r
47         Assert.assertEquals("Wrong property", QueueProperties.OFPQTEXPERIMENTER, message.getProperty());\r
48         ExperimenterQueueProperty exp = message.getAugmentation(ExperimenterQueueProperty.class);\r
49         Assert.assertEquals("Wrong experimenter", 128, exp.getExperimenter().intValue());\r
50         Assert.assertArrayEquals("Wrong data", data, exp.getData());\r
51     }\r
52 \r
53     /**\r
54      * Testing of {@link OF13QueueGetConfigReplyExperimenterDeserializer} for correct translation into POJO\r
55      * @throws Exception \r
56      */\r
57     @Test\r
58     public void testWithoutData() {\r
59         ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();\r
60         buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE);\r
61         buffer.writeShort(16);\r
62         ExtBufferUtils.padBuffer(4, buffer);\r
63         buffer.writeInt(128);\r
64         ExtBufferUtils.padBuffer(4, buffer);\r
65 \r
66         OF13QueueGetConfigReplyExperimenterDeserializer deserializer =\r
67                 new OF13QueueGetConfigReplyExperimenterDeserializer();\r
68         QueueProperty message = deserializer.deserialize(buffer);\r
69 \r
70         Assert.assertEquals("Wrong property", QueueProperties.OFPQTEXPERIMENTER, message.getProperty());\r
71         ExperimenterQueueProperty exp = message.getAugmentation(ExperimenterQueueProperty.class);\r
72         Assert.assertEquals("Wrong experimenter", 128, exp.getExperimenter().intValue());\r
73         Assert.assertNull("Unexpected data", exp.getData());\r
74     }\r
75 }\r