Remove trailing whitespace
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / serialization / factories / OF10FlowModInputMessageFactoryTest.java
index 12b2a945ebbac490b82113815a531d1b21d7fb8a..e4b3af1b4066fa14d19568725338b9739decac48 100644 (file)
@@ -16,10 +16,15 @@ import java.util.ArrayList;
 import java.util.List;
 
 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.impl.serialization.SerializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 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.augments.rev131002.IpAddressAction;
@@ -44,8 +49,22 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */
 public class OF10FlowModInputMessageFactoryTest {
 
+    private SerializerRegistry registry;
+    private OFSerializer<FlowModInput> flowModFactory;
+
     /**
-     * @throws Exception 
+     * Initializes serializer registry and stores correct factory in field
+     */
+    @Before
+    public void startUp() {
+        registry = new SerializerRegistryImpl();
+        registry.init();
+        flowModFactory = registry.getSerializer(
+                new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, FlowModInput.class));
+    }
+
+    /**
+     * @throws Exception
      * Testing of {@link OF10FlowModInputMessageFactory} for correct translation from POJO
      */
     @Test
@@ -93,12 +112,11 @@ public class OF10FlowModInputMessageFactoryTest {
         actions.add(actionBuilder.build());
         builder.setAction(actions);
         FlowModInput message = builder.build();
-        
+
         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
-        OF10FlowModInputMessageFactory factory = OF10FlowModInputMessageFactory.getInstance();
-        factory.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, message);
-        
-        BufferHelper.checkHeaderV10(out, factory.getMessageType(), factory.computeLength(message));
+        flowModFactory.serialize(message, out);
+
+        BufferHelper.checkHeaderV10(out, (byte) 14, 88);
         Assert.assertEquals("Wrong wildcards", 3678463, out.readUnsignedInt());
         Assert.assertEquals("Wrong inPort", 58, out.readUnsignedShort());
         byte[] dlSrc = new byte[6];