import java.util.List;\r
\r
import org.junit.Assert;\r
+import org.junit.Before;\r
import org.junit.Test;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;\r
+import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;\r
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;\r
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;\r
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm0Class;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid;\r
* @author michal.polkorab\r
*\r
*/\r
-public class MatchSerializerTest2 {\r
+public class OF13MatchSerializerTest2 {\r
+\r
+ private SerializerRegistry registry;\r
+ private OFSerializer<Match> matchSerializer;\r
+\r
+ /**\r
+ * Initializes serializer table and stores correct factory in field\r
+ */\r
+ @Before\r
+ public void startUp() {\r
+ registry = new SerializerRegistryImpl();\r
+ registry.init();\r
+ matchSerializer = registry.getSerializer(\r
+ new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Match.class));\r
+ }\r
\r
/**\r
* Testing serialization of match\r
Match match = builder.build();\r
\r
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
- MatchSerializer.encodeMatch(match, out);\r
+ matchSerializer.serialize(match, out);\r
\r
Assert.assertEquals("Wrong match type", 1, out.readUnsignedShort());\r
Assert.assertEquals("Wrong match length", 4, out.readUnsignedShort());\r
builder.setType(OxmMatchType.class);\r
List<MatchEntries> entries = new ArrayList<>();\r
MatchEntriesBuilder entryBuilder = new MatchEntriesBuilder();\r
- entryBuilder.setOxmClass(Nxm0Class.class);\r
+ entryBuilder.setOxmClass(OpenflowBasicClass.class);\r
entryBuilder.setOxmMatchField(InPort.class);\r
entryBuilder.setHasMask(false);\r
PortNumberMatchEntryBuilder portNumberBuilder = new PortNumberMatchEntryBuilder();\r
entryBuilder.addAugmentation(PortNumberMatchEntry.class, portNumberBuilder.build());\r
entries.add(entryBuilder.build());\r
entryBuilder = new MatchEntriesBuilder();\r
- entryBuilder.setOxmClass(Nxm1Class.class);\r
+ entryBuilder.setOxmClass(OpenflowBasicClass.class);\r
entryBuilder.setOxmMatchField(InPhyPort.class);\r
entryBuilder.setHasMask(false);\r
portNumberBuilder = new PortNumberMatchEntryBuilder();\r
entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build());\r
entries.add(entryBuilder.build());\r
entryBuilder = new MatchEntriesBuilder();\r
- entryBuilder.setOxmClass(ExperimenterClass.class);\r
+ entryBuilder.setOxmClass(OpenflowBasicClass.class);\r
entryBuilder.setOxmMatchField(EthDst.class);\r
entryBuilder.setHasMask(true);\r
MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder();\r
entryBuilder = new MatchEntriesBuilder();\r
entryBuilder.setOxmClass(OpenflowBasicClass.class);\r
entryBuilder.setOxmMatchField(VlanPcp.class);\r
- entryBuilder.setHasMask(true);\r
+ entryBuilder.setHasMask(false);\r
VlanPcpMatchEntryBuilder pcpBuilder = new VlanPcpMatchEntryBuilder();\r
pcpBuilder.setVlanPcp((short) 14);\r
entryBuilder.addAugmentation(VlanPcpMatchEntry.class, pcpBuilder.build());\r
entryBuilder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6Builder.build());\r
entries.add(entryBuilder.build());\r
entryBuilder = new MatchEntriesBuilder();\r
- entryBuilder.setOxmClass(ExperimenterClass.class);\r
+ entryBuilder.setOxmClass(OpenflowBasicClass.class);\r
entryBuilder.setOxmMatchField(Ipv6NdSll.class);\r
entryBuilder.setHasMask(false);\r
macBuilder = new MacAddressMatchEntryBuilder();\r
Match match = builder.build();\r
\r
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
- MatchSerializer.encodeMatch(match, out);\r
+ matchSerializer.serialize(match, out);\r
\r
Assert.assertEquals("Wrong match type", 1, out.readUnsignedShort());\r
Assert.assertEquals("Wrong match length", 428, out.readUnsignedShort());\r
- Assert.assertEquals("Wrong match entry class", 0, out.readUnsignedShort());\r
+ Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());\r
Assert.assertEquals("Wrong match entry field & hasMask", 0, out.readUnsignedByte());\r
Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte());\r
Assert.assertEquals("Wrong match entry value", 42, out.readUnsignedInt());\r
- Assert.assertEquals("Wrong match entry class", 1, out.readUnsignedShort());\r
+ Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());\r
Assert.assertEquals("Wrong match entry field & hasMask", 2, out.readUnsignedByte());\r
Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte());\r
Assert.assertEquals("Wrong match entry value", 43, out.readUnsignedInt());\r
Assert.assertEquals("Wrong match entry length", 16, out.readUnsignedByte());\r
Assert.assertEquals("Wrong match entry value", 1L, out.readLong());\r
Assert.assertEquals("Wrong match entry mask", 2L, out.readLong());\r
- Assert.assertEquals("Wrong match entry class", 0xFFFF, out.readUnsignedShort());\r
+ Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());\r
Assert.assertEquals("Wrong match entry field & hasMask", 7, out.readUnsignedByte());\r
Assert.assertEquals("Wrong match entry length", 12, out.readUnsignedByte());\r
byte[] array = new byte[6];\r
array = new byte[16];\r
out.readBytes(array);\r
Assert.assertArrayEquals("Wrong match entry value", new byte[]{0,15,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, array);\r
- Assert.assertEquals("Wrong match entry class", 0xFFFF, out.readUnsignedShort());\r
+ Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());\r
Assert.assertEquals("Wrong match entry field & hasMask", 64, out.readUnsignedByte());\r
Assert.assertEquals("Wrong match entry length", 6, out.readUnsignedByte());\r
array = new byte[6];\r