Bug 5895 - Support of Ext109 openflow tcp flag matching
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / util / OF13MatchSerializerTest.java
index 453662e52b6ce74bdd748647713d5d4f6968917b..0c2a6aa0dd4193650661bfe4b328393da772d790 100644 (file)
@@ -17,34 +17,44 @@ 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.api.keys.MessageTypeKey;
 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.inet.types.rev100924.Ipv6Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Src;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6FlowLabel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.oxm.container.match.entry.value.experimenter.id._case.TcpFlagsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.experimenter.id._case.ExperimenterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.StandardMatchType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Src;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Dst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Flabel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdTarget;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Src;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmMatchType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4SrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6DstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6FlabelCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdTargetCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6SrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.src._case.Ipv4SrcBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.dst._case.Ipv6DstBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.flabel._case.Ipv6FlabelBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.nd.target._case.Ipv6NdTargetBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.src._case.Ipv6SrcBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -77,21 +87,23 @@ public class OF13MatchSerializerTest {
     public void testIpv4Src() {
         MatchBuilder builder = new MatchBuilder();
         builder.setType(OxmMatchType.class);
-        List<MatchEntries> entries = new ArrayList<>();
-        MatchEntriesBuilder entriesBuilder = new MatchEntriesBuilder();
+        List<MatchEntry> entries = new ArrayList<>();
+        MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);
         entriesBuilder.setOxmMatchField(Ipv4Src.class);
         entriesBuilder.setHasMask(false);
-        Ipv4AddressMatchEntryBuilder addressBuilder = new Ipv4AddressMatchEntryBuilder();
-        addressBuilder.setIpv4Address(new Ipv4Address("1.2.3.4"));
-        entriesBuilder.addAugmentation(Ipv4AddressMatchEntry.class, addressBuilder.build());
+        Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();
+        Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
+        ipv4SrcBuilder.setIpv4Address(new Ipv4Address("1.2.3.4"));
+        ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());
+        entriesBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());
         entries.add(entriesBuilder.build());
-        builder.setMatchEntries(entries);
+        builder.setMatchEntry(entries);
         Match match = builder.build();
-        
+
         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
         matchSerializer.serialize(match, out);
-        
+
         Assert.assertEquals("Wrong type", 1, out.readUnsignedShort());
         out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
         Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort());
@@ -102,83 +114,75 @@ public class OF13MatchSerializerTest {
         Assert.assertEquals("Wrong ip address (third number)", 3, out.readUnsignedByte());
         Assert.assertEquals("Wrong ip address (fourth number)", 4, out.readUnsignedByte());
     }
-    
+
     /**
      * Test for correct serialization of Ipv6Address match entry
      */
-    @Test(expected=IllegalStateException.class)
+    @Test
     public void testIpv6Various() {
         MatchBuilder builder = new MatchBuilder();
         builder.setType(OxmMatchType.class);
-        List<MatchEntries> entries = new ArrayList<>();
+        List<MatchEntry> entries = new ArrayList<>();
         // ipv6 match entry with correct Ipv6 address
-        MatchEntriesBuilder entriesBuilder = new MatchEntriesBuilder();
+        MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);
         entriesBuilder.setOxmMatchField(Ipv6Src.class);
         entriesBuilder.setHasMask(false);
-        Ipv6AddressMatchEntryBuilder addressBuilder = new Ipv6AddressMatchEntryBuilder();
-        addressBuilder.setIpv6Address(new Ipv6Address("1:2:3:4:5:6:7:8"));
-        entriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, addressBuilder.build());
+        Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();
+        Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();
+        ipv6SrcBuilder.setIpv6Address(new Ipv6Address("1:2:3:4:5:6:7:8"));
+        ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build());
+        entriesBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());
         entries.add(entriesBuilder.build());
         // ipv6 match entry with abbreviated Ipv6 address
-        entriesBuilder = new MatchEntriesBuilder();
+        entriesBuilder = new MatchEntryBuilder();
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);
         entriesBuilder.setOxmMatchField(Ipv6NdTarget.class);
         entriesBuilder.setHasMask(false);
-        addressBuilder = new Ipv6AddressMatchEntryBuilder();
-        addressBuilder.setIpv6Address(new Ipv6Address("1:2::6:7:8"));
-        entriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, addressBuilder.build());
+        Ipv6NdTargetCaseBuilder ipv6NdTargetCaseBuilder = new Ipv6NdTargetCaseBuilder();
+        Ipv6NdTargetBuilder ipv6NdTargetBuilder = new Ipv6NdTargetBuilder();
+        ipv6NdTargetBuilder.setIpv6Address(new Ipv6Address("1:2::6:7:8"));
+        ipv6NdTargetCaseBuilder.setIpv6NdTarget(ipv6NdTargetBuilder.build());
+        entriesBuilder.setMatchEntryValue(ipv6NdTargetCaseBuilder.build());
         entries.add(entriesBuilder.build());
         // ipv6 match entry with abbreviated Ipv6 address
-        entriesBuilder = new MatchEntriesBuilder();
+        entriesBuilder = new MatchEntryBuilder();
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);
         entriesBuilder.setOxmMatchField(Ipv6Dst.class);
         entriesBuilder.setHasMask(false);
-        addressBuilder = new Ipv6AddressMatchEntryBuilder();
-        addressBuilder.setIpv6Address(new Ipv6Address("1::8"));
-        entriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, addressBuilder.build());
+        Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();
+        Ipv6DstBuilder ipv6DstBuilder = new Ipv6DstBuilder();
+        ipv6DstBuilder.setIpv6Address(new Ipv6Address("1::8"));
+        ipv6DstCaseBuilder.setIpv6Dst(ipv6DstBuilder.build());
+        entriesBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());
         entries.add(entriesBuilder.build());
         // ipv6 match entry with abbreviated Ipv6 address
-        entriesBuilder = new MatchEntriesBuilder();
+        entriesBuilder = new MatchEntryBuilder();
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);
         entriesBuilder.setOxmMatchField(Ipv6Dst.class);
         entriesBuilder.setHasMask(false);
-        addressBuilder = new Ipv6AddressMatchEntryBuilder();
-        addressBuilder.setIpv6Address(new Ipv6Address("::1"));
-        entriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, addressBuilder.build());
+        ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();
+        ipv6DstBuilder = new Ipv6DstBuilder();
+        ipv6DstBuilder.setIpv6Address(new Ipv6Address("::1"));
+        ipv6DstCaseBuilder.setIpv6Dst(ipv6DstBuilder.build());
+        entriesBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());
         entries.add(entriesBuilder.build());
         // ipv6 match entry with abbreviated Ipv6 address
-        entriesBuilder = new MatchEntriesBuilder();
-        entriesBuilder.setOxmClass(OpenflowBasicClass.class);
-        entriesBuilder.setOxmMatchField(Ipv6Dst.class);
-        entriesBuilder.setHasMask(false);
-        addressBuilder = new Ipv6AddressMatchEntryBuilder();
-        addressBuilder.setIpv6Address(new Ipv6Address("::"));
-        entriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, addressBuilder.build());
-        entries.add(entriesBuilder.build());
-        // ipv6 match entry with incorrect Ipv6 address (longer)
-        entriesBuilder = new MatchEntriesBuilder();
+        entriesBuilder = new MatchEntryBuilder();
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);
         entriesBuilder.setOxmMatchField(Ipv6Dst.class);
         entriesBuilder.setHasMask(false);
-        addressBuilder = new Ipv6AddressMatchEntryBuilder();
-        addressBuilder.setIpv6Address(new Ipv6Address("1:2:3:4:5:6:7:8:9"));
-        entriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, addressBuilder.build());
+        ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();
+        ipv6DstBuilder = new Ipv6DstBuilder();
+        ipv6DstBuilder.setIpv6Address(new Ipv6Address("::"));
+        ipv6DstCaseBuilder.setIpv6Dst(ipv6DstBuilder.build());
+        entriesBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());
         entries.add(entriesBuilder.build());
-        // ipv6 match entry with too abbreviated Ipv6 address
-        entriesBuilder = new MatchEntriesBuilder();
-        entriesBuilder.setOxmClass(OpenflowBasicClass.class);
-        entriesBuilder.setOxmMatchField(Ipv6NdTarget.class);
-        entriesBuilder.setHasMask(false);
-        addressBuilder = new Ipv6AddressMatchEntryBuilder();
-        addressBuilder.setIpv6Address(new Ipv6Address("1:2::::8"));
-        entriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, addressBuilder.build());
-        entries.add(entriesBuilder.build());
-        builder.setMatchEntries(entries);
+        builder.setMatchEntry(entries);
         Match match = builder.build();
         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
         matchSerializer.serialize(match, out);
-        
+
         Assert.assertEquals("Wrong type", 1, out.readUnsignedShort());
         out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
         Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort());
@@ -236,72 +240,86 @@ public class OF13MatchSerializerTest {
         Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
         Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
         Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort());
-        Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort());
-        Assert.assertEquals("Wrong field and mask", 54, out.readUnsignedByte());
-        Assert.assertEquals("Wrong entry length", 16, out.readUnsignedByte());
-        Assert.assertEquals("Wrong ipv6 address", 1, out.readUnsignedShort());
-        Assert.assertEquals("Wrong ipv6 address", 2, out.readUnsignedShort());
-        Assert.assertEquals("Wrong ipv6 address", 3, out.readUnsignedShort());
-        Assert.assertEquals("Wrong ipv6 address", 4, out.readUnsignedShort());
-        Assert.assertEquals("Wrong ipv6 address", 5, out.readUnsignedShort());
-        Assert.assertEquals("Wrong ipv6 address", 6, out.readUnsignedShort());
-        Assert.assertEquals("Wrong ipv6 address", 7, out.readUnsignedShort());
-        Assert.assertEquals("Wrong ipv6 address", 8, out.readUnsignedShort());
     }
-    
+
+    /**
+     * Test for correct serialization of incorrect Ipv6Address match entry
+     */
+    @Test(expected=IllegalArgumentException.class)
+    public void testIpv6Incorrect() {
+        MatchBuilder builder = new MatchBuilder();
+        builder.setType(OxmMatchType.class);
+        List<MatchEntry> entries = new ArrayList<>();
+        // ipv6 match entry with incorrect Ipv6 address
+        MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
+        entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+        entriesBuilder.setOxmMatchField(Ipv6Src.class);
+        entriesBuilder.setHasMask(false);
+        Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();
+        Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();
+        ipv6SrcBuilder.setIpv6Address(new Ipv6Address("1:2::::8"));
+        ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build());
+        entriesBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());
+        entries.add(entriesBuilder.build());
+        builder.setMatchEntry(entries);
+        Match match = builder.build();
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        matchSerializer.serialize(match, out);
+    }
+
     /**
      * Test for correct serialization of Ipv4Address match entry
      */
     @Test
     public void testIpv6Flabel() {
         Match match = buildIpv6FLabelMatch(0x0f9e8dL, false, null);
-        
+
         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
         matchSerializer.serialize(match, out);
-        
+
         Assert.assertEquals("Wrong type", 1, out.readUnsignedShort());
         out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
         Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort());
-        Assert.assertEquals("Wrong field and mask", 28<<1, out.readUnsignedByte());
+        Assert.assertEquals("Wrong field and mask", 56, out.readUnsignedByte());
         out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
         byte[] label = new byte[4];
         out.readBytes(label);
-        
-        LOG.debug("label: "+ ByteBufUtils.bytesToHexString(label));
+
+        LOG.debug("label: {}", ByteBufUtils.bytesToHexString(label));
         Assert.assertArrayEquals("Wrong ipv6FLabel", new byte[]{0, 0x0f, (byte) 0x9e, (byte) 0x8d}, label);
     }
-    
+
     /**
-     * Test for correct serialization of Ipv4Address match entry with mask
+     * Test for correct serialization of Ipv4Address match entry
      */
     @Test
     public void testIpv6FlabelWithMask() {
-        Match match = buildIpv6FLabelMatch(0x0f9e8dL, true, new byte[]{0, 0x0c, 0x7b, 0x6a});
-        
+        Match match = buildIpv6FLabelMatch(0x0f9e8dL, true, new byte[]{0, 1, 2, 3});
+
         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
         matchSerializer.serialize(match, out);
-        
+
         Assert.assertEquals("Wrong type", 1, out.readUnsignedShort());
         out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
         Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort());
-        Assert.assertEquals("Wrong field and mask", 28<<1 | 1, out.readUnsignedByte());
+        Assert.assertEquals("Wrong field and mask", 57, out.readUnsignedByte());
         out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
-        byte[] labelAndMask = new byte[8];
-        out.readBytes(labelAndMask);
-        
-        LOG.debug("label: "+ByteBufUtils.bytesToHexString(labelAndMask));
-        Assert.assertArrayEquals("Wrong ipv6FLabel", new byte[]{0, 0x0f, (byte) 0x9e, (byte) 0x8d, 0, 0x0c, 0x7b, 0x6a}, labelAndMask);
+        byte[] label = new byte[4];
+        out.readBytes(label);
+        Assert.assertArrayEquals("Wrong ipv6FLabel", new byte[]{0, 0x0f, (byte) 0x9e, (byte) 0x8d}, label);
+        byte[] mask = new byte[4];
+        out.readBytes(mask);
+        Assert.assertArrayEquals("Wrong ipv6FLabel mask", new byte[]{0, 1, 2, 3}, mask);
     }
-    
+
     /**
      * Test for correct serialization of Ipv4Address match entry with wrong mask
      */
     @Test
     public void testIpv6FlabelWithMaskBad() {
         Match match = buildIpv6FLabelMatch(0x0f9e8dL, true, new byte[]{0x0c, 0x7b, 0x6a});
-        
         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
-        
+
         try {
             matchSerializer.serialize(match, out);
             Assert.fail("incorrect length of mask ignored");
@@ -319,23 +337,64 @@ public class OF13MatchSerializerTest {
     private static Match buildIpv6FLabelMatch(long labelValue, boolean hasMask, byte[] mask) {
         MatchBuilder builder = new MatchBuilder();
         builder.setType(OxmMatchType.class);
-        List<MatchEntries> entries = new ArrayList<>();
-        MatchEntriesBuilder entriesBuilder = new MatchEntriesBuilder();
+        List<MatchEntry> entries = new ArrayList<>();
+        MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
         entriesBuilder.setOxmClass(OpenflowBasicClass.class);
         entriesBuilder.setOxmMatchField(Ipv6Flabel.class);
         entriesBuilder.setHasMask(hasMask);
-        Ipv6FlabelMatchEntryBuilder ip6FLabelBuilder = new Ipv6FlabelMatchEntryBuilder();
-        ip6FLabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(labelValue));
-        entriesBuilder.addAugmentation(Ipv6FlabelMatchEntry.class, ip6FLabelBuilder.build());
-        MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder();
-        maskBuilder.setMask(mask);
-        entriesBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build());
+        Ipv6FlabelCaseBuilder ipv6FlabelCaseBuilder = new Ipv6FlabelCaseBuilder();
+        Ipv6FlabelBuilder ipv6FlabelBuilder = new Ipv6FlabelBuilder();
+        ipv6FlabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(labelValue));
+        ipv6FlabelBuilder.setMask(mask);
+        ipv6FlabelCaseBuilder.setIpv6Flabel(ipv6FlabelBuilder.build());
+        entriesBuilder.setMatchEntryValue(ipv6FlabelCaseBuilder.build());
         entries.add(entriesBuilder.build());
-        builder.setMatchEntries(entries);
+        builder.setMatchEntry(entries);
         Match match = builder.build();
         return match;
     }
-    
-    
 
+    /**
+     * Test Standard match type
+     */
+    @Test
+    public void testStandardMatchType() {
+        MatchBuilder builder = new MatchBuilder();
+        builder.setType(StandardMatchType.class);
+        Match match = builder.build();
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+
+        matchSerializer.serialize(match, out);
+
+        Assert.assertEquals("Wrong match type", 0, out.readUnsignedShort());
+        Assert.assertEquals("Wrong match length", 4, out.readUnsignedShort());
+        Assert.assertEquals("Wrong padding", 0, out.readUnsignedInt());
+        Assert.assertEquals("Unexpected data", 0, out.readableBytes());
+    }
+
+    /**
+     * Test serialize experimenter match entry - with no experimenter
+     * match entry serializer registered
+     */
+    @Test(expected=IllegalStateException.class)
+    public void testSerializeExperimenterMatchEntry() {
+        List<MatchEntry> entries = new ArrayList<>();
+        MatchEntryBuilder builder = new MatchEntryBuilder();
+        builder.setOxmClass(ExperimenterClass.class);
+        builder.setOxmMatchField(OxmMatchFieldClass.class);
+        builder.setHasMask(true);
+        ExperimenterIdCaseBuilder caseBuilder = new ExperimenterIdCaseBuilder();
+        ExperimenterBuilder expBuilder = new ExperimenterBuilder();
+        expBuilder.setExperimenter(new ExperimenterId(42L));
+        caseBuilder.setExperimenter(expBuilder.build());
+        builder.setMatchEntryValue(caseBuilder.build());
+        entries.add(builder.build());
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+
+        ((OF13MatchSerializer) matchSerializer).serializeMatchEntries(entries, out);
+    }
+
+    private class OxmMatchFieldClass extends MatchField {
+        // only for testing purposes
+    }
 }