import io.netty.buffer.UnpooledByteBufAllocator;
import junit.framework.Assert;
+import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;
+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;
private static final byte PADDING_IN_PORT_MOD_MESSAGE_02 = 2;
private static final byte PADDING_IN_PORT_MOD_MESSAGE_03 = 4;
private static final int MESSAGE_LENGTH = 40;
-
+ private SerializerRegistry registry;
+ private OFSerializer<PortModInput> portModFactory;
+
+ /**
+ * Initializes serializer registry and stores correct factory in field
+ */
+ @Before
+ public void startUp() {
+ registry = new SerializerRegistryImpl();
+ registry.init();
+ portModFactory = registry.getSerializer(
+ new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, PortModInput.class));
+ }
+
/**
* Testing of {@link PortModInputMessageFactory} for correct translation from POJO
* @throws Exception
PortModInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
- PortModInputMessageFactory factory = PortModInputMessageFactory.getInstance();
- factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
+ portModFactory.serialize(message, out);
BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH);
Assert.assertEquals("Wrong PortNo", message.getPortNo().getValue().longValue(), out.readUnsignedInt());