Renamed packages to org.opendaylight.openflowjava.protocol.impl.*
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / deserialization / factories / HelloMessageFactoryTest.java
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..de3ce14
--- /dev/null
@@ -0,0 +1,34 @@
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class HelloMessageFactoryTest {\r
+    \r
+    /** Number of currently supported version / codec */\r
+    public static final short VERSION_YET_SUPPORTED = 0x04;\r
+    /** Index of Xid in OpenFlow 1.3 header */\r
+    public static final byte INDEX_OF_XID_IN_HEADER = 4;\r
+\r
+    /**\r
+     * Testing {@link HelloMessageFactory} for correct translation into POJO\r
+     */\r
+    @Test\r
+    public void test() {\r
+        ByteBuf bb = BufferHelper.buildBuffer(new byte[0]);\r
+        HelloMessage builtByFactory = HelloMessageFactory.getInstance().bufferToMessage(bb, VERSION_YET_SUPPORTED);\r
+\r
+        Assert.assertTrue(builtByFactory.getVersion() == VERSION_YET_SUPPORTED);\r
+        Assert.assertEquals(builtByFactory.getXid().longValue(), 16909060L);\r
+    }\r
+}\r