Bug 2756 - Match model update
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / util / OF10MatchDeserializerTest.java
index 61da809fe65e3e8b6705dfe071de7e31b67c223c..83242ce4c4a6c45da568a3d0089870cbd55686b1 100644 (file)
@@ -11,11 +11,17 @@ package org.opendaylight.openflowjava.protocol.impl.util;
 import io.netty.buffer.ByteBuf;
 
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10;
 
 /**
  * @author michal.polkorab
@@ -23,6 +29,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.matc
  */
 public class OF10MatchDeserializerTest {
 
+    private OFDeserializer<MatchV10> matchDeserializer;
+
+    /**
+     * Initializes deserializer registry and lookups correct deserializer
+     */
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        matchDeserializer = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, EncodeConstants.EMPTY_VALUE, MatchV10.class));
+    }
+
     /**
      * Testing correct deserialization of ofp_match
      */
@@ -32,7 +51,7 @@ public class OF10MatchDeserializerTest {
                 + "AA BB CC DD EE FF 00 05 10 00 00 08 07 06 00 00 10 11 12 13 01 02 03 04 "
                 + "50 50 20 20");
         message.skipBytes(4); // skip XID
-        MatchV10 match = OF10MatchDeserializer.createMatchV10(message);
+        MatchV10 match = matchDeserializer.deserialize(message);
         Assert.assertEquals("Wrong wildcards", new FlowWildcardsV10(false, false, true, false,
                 false, true, false, true, true, false), match.getWildcards());
         Assert.assertEquals("Wrong srcMask", 24, match.getNwSrcMask().shortValue());
@@ -50,7 +69,7 @@ public class OF10MatchDeserializerTest {
         Assert.assertEquals("Wrong tp-src", 20560, match.getTpSrc().shortValue());
         Assert.assertEquals("Wrong tp-dst", 8224, match.getTpDst().shortValue());
     }
-    
+
     /**
      * Testing correct deserialization of ofp_match
      */
@@ -60,7 +79,7 @@ public class OF10MatchDeserializerTest {
                 + "AA BB CC DD EE FF 00 05 10 00 00 08 07 06 00 00 10 11 12 13 01 02 03 04 "
                 + "50 50 20 20");
         message.skipBytes(4); // skip XID
-        MatchV10 match = OF10MatchDeserializer.createMatchV10(message);
+        MatchV10 match = matchDeserializer.deserialize(message);
         Assert.assertEquals("Wrong wildcards", new FlowWildcardsV10(true, true, true, true,
                 true, true, true, true, true, true), match.getWildcards());
         Assert.assertEquals("Wrong srcMask", 0, match.getNwSrcMask().shortValue());