Default experimenters moved to separate bundle + unit tests
[openflowjava.git] / openflow-protocol-ext / src / test / java / org / opendaylight / openflowjava / protocol / ext / deserialization / OF10StatsReplyVendorDeserializerTest.java
1 /*\r
2  * Copyright (c) 2013 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 OF10StatsReplyVendorDeserializerTest {\r
23 \r
24     /**\r
25      * Testing of {@link OF10StatsReplyVendorDeserializer} 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(42);\r
32         byte[] data = new byte[]{0, 1, 2, 3, 3, 2, 1, 0};\r
33         buffer.writeBytes(data);\r
34 \r
35         OF10StatsReplyVendorDeserializer deserializer =\r
36                 new OF10StatsReplyVendorDeserializer();\r
37         MultipartReplyExperimenter message = deserializer.deserialize(buffer);\r
38 \r
39         Assert.assertEquals("Wrong experimenter", 42, message.getExperimenter().intValue());\r
40         Assert.assertArrayEquals("Wrong data", data, message.getData());\r
41     }\r
42 \r
43     /**\r
44      * Testing of {@link OF10StatsReplyVendorDeserializer} for correct translation into POJO\r
45      * @throws Exception\r
46      */\r
47     @Test\r
48     public void testWithoutData() {\r
49         ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();\r
50         buffer.writeInt(42);\r
51 \r
52         OF10StatsReplyVendorDeserializer deserializer =\r
53                 new OF10StatsReplyVendorDeserializer();\r
54         MultipartReplyExperimenter message = deserializer.deserialize(buffer);\r
55 \r
56         Assert.assertEquals("Wrong experimenter", 42, message.getExperimenter().intValue());\r
57         Assert.assertNull("Unexpected data", message.getData());\r
58     }\r
59 }\r