Default experimenter bundle migrated to ConfigSubsystem
[openflowjava.git] / openflow-protocol-ext / src / test / java / org / opendaylight / openflowjava / protocol / ext / deserialization / OF13MultipartReplyExperimenterDeserializerTest.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.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.experimenter._case.MultipartReplyExperimenter;\r
17 \r
18 /**\r
19  * @author michal.polkorab\r
20  *\r
21  */\r
22 public class OF13MultipartReplyExperimenterDeserializerTest {\r
23 \r
24     /**\r
25      * Testing of {@link OF13MultipartReplyExperimenterDeserializer} for correct translation into POJO\r
26      * @throws Exception \r
27      */\r
28     @Test\r
29     public void test() {\r
30         ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();\r
31         buffer.writeInt(456654);\r
32         buffer.writeInt(888222);\r
33         byte[] data = new byte[]{0, 0, 1, 1, 2, 2, 3, 3};\r
34         buffer.writeBytes(data);\r
35 \r
36         OF13MultipartReplyExperimenterDeserializer deserializer =\r
37                 new OF13MultipartReplyExperimenterDeserializer();\r
38         MultipartReplyExperimenter message = deserializer.deserialize(buffer);\r
39 \r
40         Assert.assertEquals("Wrong experimenter", 456654, message.getExperimenter().intValue());\r
41         Assert.assertEquals("Wrong exp-type", 888222, message.getExpType().intValue());\r
42         Assert.assertArrayEquals("Wrong data", data, message.getData());\r
43     }\r
44 \r
45     /**\r
46      * Testing of {@link OF13MultipartReplyExperimenterDeserializer} for correct translation into POJO\r
47      * @throws Exception \r
48      */\r
49     @Test\r
50     public void testWithoutData() {\r
51         ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();\r
52         buffer.writeInt(456654);\r
53         buffer.writeInt(888222);\r
54 \r
55         OF13MultipartReplyExperimenterDeserializer deserializer =\r
56                 new OF13MultipartReplyExperimenterDeserializer();\r
57         MultipartReplyExperimenter message = deserializer.deserialize(buffer);\r
58 \r
59         Assert.assertEquals("Wrong experimenter", 456654, message.getExperimenter().intValue());\r
60         Assert.assertEquals("Wrong exp-type", 888222, message.getExpType().intValue());\r
61         Assert.assertNull("Unexpected data", message.getData());\r
62     }\r
63 }\r