Bug 1277 - Move ByteBuffUtils to separate bundle
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / util / OF10ActionsDeserializerTest.java
index 62b00a8fd60d2d8259626a527af575bbf2a7eadb..5e304dc984f6f4f8b7b6f54decb7350ac3d3dba7 100644 (file)
@@ -12,10 +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.util.EncodeConstants;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;\r
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction;\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.IpAddressAction;\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.NwTosAction;\r
@@ -31,6 +34,17 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev1
  */\r
 public class OF10ActionsDeserializerTest {\r
 \r
+    private DeserializerRegistry registry;\r
+\r
+    /**\r
+     * Initializes deserializer registry and lookups correct deserializer\r
+     */\r
+    @Before\r
+    public void startUp() {\r
+        registry = new DeserializerRegistryImpl();\r
+        registry.init();\r
+    }\r
+\r
     /**\r
      * Testing correct deserialization of actions (OF v1.0)\r
      */\r
@@ -47,12 +61,13 @@ public class OF10ActionsDeserializerTest {
                 + "00 08 00 08 01 00 00 00 "\r
                 + "00 09 00 08 00 02 00 00 "\r
                 + "00 0A 00 08 00 03 00 00 "\r
-                + "00 0B 00 10 00 04 00 00 00 00 00 00 00 00 00 30 "\r
-                + "FF FF 00 08 00 00 12 34");\r
+                + "00 0B 00 10 00 04 00 00 00 00 00 00 00 00 00 30");\r
         \r
         message.skipBytes(4); // skip XID\r
-        List<Action> actions = OF10ActionsDeserializer.createActionsList(message);\r
-        Assert.assertEquals("Wrong number of actions", 13, actions.size());\r
+        CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF10_VERSION_ID);\r
+        List<Action> actions = ListDeserializer.deserializeList(EncodeConstants.OF10_VERSION_ID,\r
+                message.readableBytes(), message, keyMaker, registry);\r
+        Assert.assertEquals("Wrong number of actions", 12, actions.size());\r
         Action action1 = actions.get(0);\r
         Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight"\r
                 + ".openflow.common.action.rev130731.Output", action1.getType().getName());\r
@@ -114,11 +129,6 @@ public class OF10ActionsDeserializerTest {
                 .getPort().getValue().intValue());\r
         Assert.assertEquals("Wrong queue-id", 48,\r
                 action12.getAugmentation(QueueIdAction.class).getQueueId().intValue());\r
-        Action action13 = actions.get(12);\r
-        Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight"\r
-                + ".openflow.common.action.rev130731.Experimenter", action13.getType().getName());\r
-        Assert.assertEquals("Wrong port", 4660, action13.getAugmentation(ExperimenterAction.class)\r
-                .getExperimenter().intValue());\r
     }\r
 \r
 }\r