Added more (de)serialization factories + ByteBufUtils methods
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / serialization / factories / ExperimenterInputMessageFactoryTest.java
diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactoryTest.java
new file mode 100644 (file)
index 0000000..a7de110
--- /dev/null
@@ -0,0 +1,44 @@
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+import io.netty.buffer.UnpooledByteBufAllocator;\r
+\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;\r
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class ExperimenterInputMessageFactoryTest {\r
+\r
+    private static final byte EXPERIMENTER_REQUEST_MESSAGE_CODE_TYPE = ExperimenterInputMessageFactory.MESSAGE_TYPE;\r
+    \r
+    /**\r
+     * Testing of {@link ExperimenterInputMessageFactory} for correct translation from POJO\r
+     * @throws Exception \r
+     */\r
+    @Test\r
+    public void test() throws Exception {\r
+        ExperimenterInputBuilder eib = new ExperimenterInputBuilder();\r
+        BufferHelper.setupHeader(eib);\r
+        eib.setExperimenter(0x0001020304L);\r
+        eib.setExpType(0x0001020304L);\r
+        ExperimenterInput ei = eib.build();\r
+        \r
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
+        ExperimenterInputMessageFactory eimf = ExperimenterInputMessageFactory.getInstance();\r
+        eimf.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, ei);\r
+        \r
+        BufferHelper.checkHeaderV13(out, EXPERIMENTER_REQUEST_MESSAGE_CODE_TYPE, 16);\r
+        Assert.assertEquals("Wrong experimenter", 0x0001020304L, out.readUnsignedInt());\r
+        Assert.assertEquals("Wrong expType", 0x0001020304L, out.readUnsignedInt());\r
+    }\r
+\r
+\r
+}\r