Improved unit test coverage (covered some untested branches)
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / util / ActionsDeserializerTest.java
index 06fbe466563b18ffcddeca3b7378a6ec1b1353d3..e0dfb8f70d1261ede3a73b9da076a12da6b5c01c 100644 (file)
@@ -17,6 +17,7 @@ import org.junit.Test;
 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
 import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.action.AbstractActionDeserializer;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;\r
@@ -142,4 +143,24 @@ public class ActionsDeserializerTest {
         Assert.assertTrue("Unread data in message", message.readableBytes() == 0);\r
     }\r
 \r
+    /**\r
+     * Tests {@link AbstractActionDeserializer#deserializeHeader(ByteBuf)}\r
+     */\r
+    @Test\r
+    public void testDeserializeHeader() {\r
+        ByteBuf message = BufferHelper.buildBuffer("00 00 00 04 00 19 00 04");\r
+\r
+        message.skipBytes(4); // skip XID\r
+        CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID);\r
+        List<Action> actions = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID,\r
+                message.readableBytes(), message, keyMaker, registry);\r
+\r
+        Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight."\r
+                + "openflow.common.action.rev130731.Output", actions.get(0).getType().getName());\r
+        Assert.assertEquals("Wrong action port", null, actions.get(0).getAugmentation(PortAction.class));\r
+        Assert.assertEquals("Wrong action max-length", null, actions.get(0).getAugmentation(MaxLengthAction.class));\r
+        Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight."\r
+                + "openflow.common.action.rev130731.SetField", actions.get(1).getType().getName());\r
+        Assert.assertEquals("Wrong action oxm field", null, actions.get(1).getAugmentation(OxmFieldsAction.class));\r
+    }\r
 }\r