Merge "add basic lib - plugin communication"
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / deserialization / factories / HelloMessageFactoryTest.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.HelloMessageFactory;\r
9 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage;\r
11 \r
12 /**\r
13  * @author michal.polkorab\r
14  *\r
15  */\r
16 public class HelloMessageFactoryTest {\r
17     \r
18     /** Number of currently supported version / codec */\r
19     public static final short VERSION_YET_SUPPORTED = 0x04;\r
20     /** Index of Xid in OpenFlow 1.3 header */\r
21     public static final byte INDEX_OF_XID_IN_HEADER = 4;\r
22 \r
23     /**\r
24      * Testing {@link HelloMessageFactory} for correct translation into POJO\r
25      */\r
26     @Test\r
27     public void test() {\r
28         ByteBuf bb = BufferHelper.buildBuffer(new byte[0]);\r
29         HelloMessage builtByFactory = HelloMessageFactory.getInstance().bufferToMessage(bb, VERSION_YET_SUPPORTED);\r
30 \r
31         Assert.assertTrue(builtByFactory.getVersion() == VERSION_YET_SUPPORTED);\r
32         Assert.assertEquals(builtByFactory.getXid().longValue(), 16909060L);\r
33     }\r
34 }\r