"Added more deserialization factories & their unit tests"
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / deserialization / factories / ErrorMessageFactoryTest.java
1 package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
2 \r
3 import io.netty.buffer.ByteBuf;\r
4 \r
5 import org.junit.Assert;\r
6 import org.junit.Test;\r
7 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
8 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;\r
9 \r
10 /**\r
11  * @author michal.polkorab\r
12  * @author timotej.kubas\r
13  */\r
14 public class ErrorMessageFactoryTest {\r
15 \r
16     /**\r
17      * Test of {@link ErrorMessageFactory} for correct translation into POJO\r
18      */\r
19     @Test\r
20     public void test() {\r
21         ByteBuf bb = BufferHelper.buildBuffer("00 04 00 03 01 02 03 04");\r
22         ErrorMessage builtByFactory = BufferHelper.decodeV13(ErrorMessageFactory.getInstance(), bb);\r
23         BufferHelper.checkHeaderV13(builtByFactory);\r
24         \r
25         Assert.assertEquals("Wrong reason", 0x04, builtByFactory.getType().getIntValue());\r
26         Assert.assertEquals("Wrong code", 3, builtByFactory.getCode().intValue());\r
27         Assert.assertArrayEquals("Wrong body", new byte[]{0x01, 0x02, 0x03, 0x04}, builtByFactory.getData());\r
28     }\r
29 }\r