Error code support for ErrorMessage
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / serialization / factories / GetConfigInputMessageFactoryTest.java
1 /* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
2 package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
3 \r
4 import io.netty.buffer.ByteBuf;\r
5 import io.netty.buffer.UnpooledByteBufAllocator;\r
6 \r
7 import org.junit.Test;\r
8 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
9 import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput;\r
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInputBuilder;\r
12 \r
13 /**\r
14  * @author michal.polkorab\r
15  *\r
16  */\r
17 public class GetConfigInputMessageFactoryTest {\r
18 \r
19     private static final byte GET_CONFIG_REQUEST_MESSAGE_CODE_TYPE = GetConfigInputMessageFactory.MESSAGE_TYPE;\r
20     \r
21     /**\r
22      * Testing of {@link GetConfigInputMessageFactory} for correct translation from POJO\r
23      * @throws Exception \r
24      */\r
25     @Test\r
26     public void testV13() throws Exception {\r
27         GetConfigInputBuilder gcib = new GetConfigInputBuilder();\r
28         BufferHelper.setupHeader(gcib, EncodeConstants.OF13_VERSION_ID);\r
29         GetConfigInput gci = gcib.build();\r
30         \r
31         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
32         GetConfigInputMessageFactory gcimf = GetConfigInputMessageFactory.getInstance();\r
33         gcimf.messageToBuffer(EncodeConstants.OF13_VERSION_ID, out, gci);\r
34         \r
35         BufferHelper.checkHeaderV13(out, GET_CONFIG_REQUEST_MESSAGE_CODE_TYPE, 8);\r
36     }\r
37     \r
38     /**\r
39      * Testing of {@link GetConfigInputMessageFactory} for correct translation from POJO\r
40      * @throws Exception \r
41      */\r
42     @Test\r
43     public void testV10() throws Exception {\r
44         GetConfigInputBuilder gcib = new GetConfigInputBuilder();\r
45         BufferHelper.setupHeader(gcib, EncodeConstants.OF10_VERSION_ID);\r
46         GetConfigInput gci = gcib.build();\r
47         \r
48         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
49         GetConfigInputMessageFactory gcimf = GetConfigInputMessageFactory.getInstance();\r
50         gcimf.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, gci);\r
51         \r
52         BufferHelper.checkHeaderV10(out, GET_CONFIG_REQUEST_MESSAGE_CODE_TYPE, 8);\r
53     }\r
54 \r
55 }\r