Remove trailing whitespace
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / util / OF10MatchSerializerTest.java
index 19d745be585af48feb30fbf1b18a3e66590da45f..e19ede8ceaf5f8f23e0b96055f441e1f010db7a0 100644 (file)
@@ -8,11 +8,17 @@
 
 package org.opendaylight.openflowjava.protocol.impl.util;
 
-import junit.framework.Assert;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.UnpooledByteBufAllocator;
-
+import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
 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;
@@ -25,6 +31,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.matc
  */
 public class OF10MatchSerializerTest {
 
+    private SerializerRegistry registry;
+    private OFSerializer<MatchV10> matchSerializer;
+
+    /**
+     * Initializes serializer table and stores correct factory in field
+     */
+    @Before
+    public void startUp() {
+        registry = new SerializerRegistryImpl();
+        registry.init();
+        matchSerializer = registry.getSerializer(
+                new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, MatchV10.class));
+    }
+
     /**
      * Testing correct serialization of ofp_match
      */
@@ -49,8 +69,8 @@ public class OF10MatchSerializerTest {
         builder.setTpSrc(2048);
         builder.setTpDst(4096);
         MatchV10 match = builder.build();
-        OF10MatchSerializer.encodeMatchV10(out, match);
-        
+        matchSerializer.serialize(match, out);
+
         Assert.assertEquals("Wrong wildcards", 2361553, out.readUnsignedInt());
         Assert.assertEquals("Wrong in-port", 6653, out.readUnsignedShort());
         byte[] dlSrc = new byte[6];
@@ -71,7 +91,7 @@ public class OF10MatchSerializerTest {
         Assert.assertEquals("Wrong tp-src", 2048, out.readUnsignedShort());
         Assert.assertEquals("Wrong tp-dst", 4096, out.readUnsignedShort());
     }
-    
+
     /**
      * Testing correct serialization of ofp_match
      */
@@ -96,8 +116,8 @@ public class OF10MatchSerializerTest {
         builder.setTpSrc(2048);
         builder.setTpDst(4096);
         MatchV10 match = builder.build();
-        OF10MatchSerializer.encodeMatchV10(out, match);
-        
+        matchSerializer.serialize(match, out);
+
         Assert.assertEquals("Wrong wildcards", 3678463, out.readUnsignedInt());
         Assert.assertEquals("Wrong in-port", 6653, out.readUnsignedShort());
         byte[] dlSrc = new byte[6];