Extensibility support (deserialization part)
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / util / ActionsDeserializerTest.java
index a63edea95735bf90c54ff2624fd5b25cf1e71df5..02aaabb2aaa07e3e28cb3acdcaa5d80045be5f25 100644 (file)
@@ -12,9 +12,13 @@ import io.netty.buffer.ByteBuf;
 import java.util.List;\r
 \r
 import org.junit.Assert;\r
+import org.junit.Before;\r
 import org.junit.Test;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;\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.ExperimenterAction;\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
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction;\r
@@ -36,6 +40,20 @@ public class ActionsDeserializerTest {
 \r
     private static final Logger LOGGER = LoggerFactory\r
             .getLogger(ActionsDeserializerTest.class);\r
+    private OFDeserializer<Action> actionDeserializer;\r
+\r
+    /**\r
+     * Initializes deserializer registry and lookups correct deserializer\r
+     */\r
+    @Before\r
+    public void startUp() {\r
+        DeserializerRegistry registry = new DeserializerRegistryImpl();\r
+        registry.init();\r
+        actionDeserializer = registry.getDeserializer(\r
+                new MessageCodeKey(EncodeConstants.OF13_VERSION_ID,\r
+                        EncodeConstants.EMPTY_VALUE, Action.class));\r
+    }\r
+\r
     /**\r
      * Testing actions deserialization\r
      */\r
@@ -56,12 +74,14 @@ public class ActionsDeserializerTest {
                 + "00 18 00 08 00 00 00 00 "\r
                 + "00 19 00 10 80 00 02 04 00 00 00 0B 00 00 00 00 "\r
                 + "00 1A 00 08 00 0A 00 00 "\r
-                + "00 1B 00 08 00 00 00 00 "\r
-                + "FF FF 00 10 00 00 00 08 00 01 02 03 04 05 06 07");\r
+                + "00 1B 00 08 00 00 00 00");\r
         \r
         message.skipBytes(4); // skip XID\r
         LOGGER.info("bytes: " + message.readableBytes());\r
-        List<Action> actions = ActionsDeserializer.createActions(message, message.readableBytes());\r
+        \r
+        \r
+        List<Action> actions = DecodingUtils.deserializeList(message.readableBytes(),\r
+                message, actionDeserializer);\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", 1,\r
@@ -123,12 +143,6 @@ public class ActionsDeserializerTest {
                 actions.get(14).getAugmentation(EthertypeAction.class).getEthertype().getValue().intValue());\r
         Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight."\r
                 + "openflow.common.action.rev130731.PopPbb", actions.get(15).getType().getName());\r
-        Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight."\r
-                + "openflow.common.action.rev130731.Experimenter", actions.get(16).getType().getName());\r
-        Assert.assertEquals("Wrong experimenter", 8, actions.get(16).getAugmentation(ExperimenterAction.class)\r
-                .getExperimenter().intValue());\r
-        Assert.assertArrayEquals("Wrong data", new byte[]{0, 1, 2, 3, 4, 5, 6, 7}, actions.get(16)\r
-                .getAugmentation(ExperimenterAction.class).getData());\r
         Assert.assertTrue("Unread data in message", message.readableBytes() == 0);\r
     }\r
 \r