"Added more deserialization factories & their unit tests"
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / deserialization / factories / EchoRequestMessageFactoryTest.java
1 /* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
2 package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
3 \r
4 import io.netty.buffer.ByteBuf;\r
5 \r
6 import org.junit.Assert;\r
7 import org.junit.Test;\r
8 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoRequestMessageFactory;\r
9 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage;\r
11 \r
12 /**\r
13  * @author michal.polkorab\r
14  * @author timotej.kubas\r
15  */\r
16 public class EchoRequestMessageFactoryTest {\r
17 \r
18     /**\r
19      * Testing {@link EchoRequestMessageFactory} for correct translation into POJO\r
20      */\r
21     @Test\r
22     public void testWithEmptyDataField() {\r
23         ByteBuf bb = BufferHelper.buildBuffer();\r
24         EchoRequestMessage builtByFactory = BufferHelper.decodeV13(\r
25                 EchoRequestMessageFactory.getInstance(), bb);\r
26 \r
27         BufferHelper.checkHeaderV13(builtByFactory);\r
28     }\r
29     \r
30     /**\r
31      * Testing {@link EchoRequestMessageFactory} for correct translation into POJO\r
32      */\r
33     @Test\r
34     public void testWithDataFieldSet() {\r
35         byte[] data = new byte[]{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};\r
36         ByteBuf bb = BufferHelper.buildBuffer(data);\r
37         EchoRequestMessage builtByFactory = BufferHelper.decodeV13(\r
38                 EchoRequestMessageFactory.getInstance(), bb);\r
39 \r
40         BufferHelper.checkHeaderV13(builtByFactory);\r
41         Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData());\r
42     }\r
43 \r
44 }\r