X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflow-protocol-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowjava%2Fprotocol%2Fimpl%2Futil%2FOF10MatchSerializerTest.java;h=db16f9c58b87a44d6768a808394515f209d8d1f5;hb=29a2a074c78708f6d18583779ece96bb6573f0c6;hp=19d745be585af48feb30fbf1b18a3e66590da45f;hpb=df99e165d75ba6d890c31690172f249fa7b519e7;p=openflowjava.git diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java index 19d745be..db16f9c5 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java @@ -8,16 +8,23 @@ 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.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.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10Builder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder; /** * @author michal.polkorab @@ -25,6 +32,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.matc */ public class OF10MatchSerializerTest { + private SerializerRegistry registry; + private OFSerializer 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 +70,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 +92,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 +117,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];