Extensibility support (deserialization part)
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / deserialization / factories / FlowRemovedMessageFactoryTest.java
index 4682c14760a817b6dc46b3dd60ea1c7a1876aac5..cc5709d15a0ac7420c68df0fe46c4906fe476f87 100644 (file)
@@ -11,8 +11,14 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 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.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;
 
@@ -22,6 +28,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */
 public class FlowRemovedMessageFactoryTest {
 
+    private OFDeserializer<FlowRemovedMessage> flowFactory;
+
+    /**
+     * Initializes deserializer registry and lookups correct deserializer
+     */
+    @Before
+    public void startUp() {
+        DeserializerRegistry registry = new DeserializerRegistryImpl();
+        registry.init();
+        flowFactory = registry.getDeserializer(
+                new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 11, FlowRemovedMessage.class));
+    }
+
     /**
      * Testing {@link FlowRemovedMessageFactory} for correct translation into POJO
      */
@@ -29,7 +48,7 @@ public class FlowRemovedMessageFactoryTest {
     public void test(){
         ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 03 02 04 00 00 00 02"
                 + " 00 00 00 05 00 01 00 03 00 01 02 03 04 05 06 07 00 01 02 03 04 05 06 07");
-        FlowRemovedMessage builtByFactory = BufferHelper.decodeV13(FlowRemovedMessageFactory.getInstance(), bb);
+        FlowRemovedMessage builtByFactory = BufferHelper.deserialize(flowFactory, bb);
 
         BufferHelper.checkHeaderV13(builtByFactory);