X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=openflow-protocol-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowjava%2Fprotocol%2Fimpl%2Fdeserialization%2Ffactories%2FMultipartReplyMessageFactoryTest.java;h=5e6017a9c07e8e05a348cb55892238bf47178cf9;hb=60ad94454217d7d1f6f9e65f39f72ae111ecc845;hp=821da87ec2a899503be27fe5d7e43ead3aa3ec24;hpb=0d942e8fb70b2c21f97eea3ed8904336ab5c54a4;p=openflowjava.git diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java index 821da87e..5e6017a9 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java @@ -13,9 +13,15 @@ import io.netty.buffer.ByteBuf; import java.math.BigInteger; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; 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.EthertypeAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction; @@ -50,23 +56,41 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; 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.protocol.rev130731.MultipartReplyMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDrop; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemark; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregate; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDesc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlow; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroup; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDesc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfig; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeatures; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDesc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStats; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueue; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTable; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDrop; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemark; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDescCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregate; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDesc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.experimenter._case.MultipartReplyExperimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroup; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDesc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.MultipartReplyMeter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfig; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDesc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueue; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -76,24 +100,22 @@ import org.slf4j.LoggerFactory; */ public class MultipartReplyMessageFactoryTest { + private OFDeserializer multipartFactory; + + /** + * Initializes deserializer registry and lookups correct deserializer + */ + @Before + public void startUp() { + DeserializerRegistry registry = new DeserializerRegistryImpl(); + registry.init(); + multipartFactory = registry.getDeserializer( + new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 19, MultipartReplyMessage.class)); + } + private static final Logger LOGGER = LoggerFactory .getLogger(MultipartReplyMessageFactoryTest.class); - /** - * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO - *//* - @Test - public void test(){ - ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 01 02 03 04"); - MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb); - - BufferHelper.checkHeaderV13(builtByFactory); - - Assert.assertEquals("Wrong type", 0x07, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - //Assert.assertArrayEquals("Wrong body", new byte[]{0x01, 0x02, 0x03, 0x04}, builtByFactory.getBody()); - }*/ - /** * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO */ @@ -133,12 +155,13 @@ public class MultipartReplyMessageFactoryTest { bb.writeBytes(dpDescBytes); ByteBufUtils.padBuffer((DESC_STR_LEN - dpDescBytes.length), bb); - MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 0x00, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyDesc message = (MultipartReplyDesc) builtByFactory.getMultipartReplyBody(); + MultipartReplyDescCase messageCase = (MultipartReplyDescCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyDesc message = messageCase.getMultipartReplyDesc(); Assert.assertEquals("Wrong mfrDesc", "Manufacturer description", message.getMfrDesc()); Assert.assertEquals("Wrong hwDesc", "Hardware description", message.getHwDesc()); Assert.assertEquals("Wrong swDesc", "Software description", message.getSwDesc()); @@ -152,7 +175,7 @@ public class MultipartReplyMessageFactoryTest { @Test public void testMultipartReplyFlowBody(){ ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 00 00 00 "+ - "00 0C "+//length + "00 48 "+//length "08 "+//tableId "00 "+//pad_01 "00 00 00 09 "+//durationSec @@ -162,34 +185,55 @@ public class MultipartReplyMessageFactoryTest { "00 0F "+//hardTimeout "00 0B "+//flags "00 00 00 00 "+//pad_02 - "00 01 01 01 01 01 01 01 "+//cookie - "00 01 01 01 01 01 01 01 "+//packetCount - "00 01 01 01 01 01 01 01"//byteCount - ); + "FF 01 01 01 01 01 01 01 "+//cookie + "EF 01 01 01 01 01 01 01 "+//packetCount + "7F 01 01 01 01 01 01 01 "+//byteCount + "00 01 00 04 00 00 00 00 "+//empty match + "00 01 00 08 06 00 00 00 "+ + "00 01 00 08 06 00 00 00 "+ + "00 48 "+//length + "08 "+//tableId + "00 "+//pad_01 + "00 00 00 09 "+//durationSec + "00 00 00 07 "+//durationNsec + "00 0C "+//priority + "00 0E "+//idleTimeout + "00 0F "+//hardTimeout + "00 0B "+//flags + "00 00 00 00 "+//pad_02 + "FF 01 01 01 01 01 01 01 "+//cookie + "EF 01 01 01 01 01 01 01 "+//packetCount + "7F 01 01 01 01 01 01 01 "+//byteCount + "00 01 00 04 00 00 00 00 "+//empty match + "00 01 00 08 06 00 00 00 "+ + "00 01 00 08 06 00 00 00"); - MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyFlow message = (MultipartReplyFlow) builtByFactory.getMultipartReplyBody(); - Assert.assertEquals("Wrong tableId", 8, message.getFlowStats().get(0).getTableId().intValue()); - Assert.assertEquals("Wrong durationSec", 9, message.getFlowStats().get(0).getDurationSec().intValue()); - Assert.assertEquals("Wrong durationNsec", 7, message.getFlowStats().get(0).getDurationNsec().intValue()); - Assert.assertEquals("Wrong priority", 12, message.getFlowStats().get(0).getPriority().intValue()); - Assert.assertEquals("Wrong idleTimeOut", 14, message.getFlowStats().get(0).getIdleTimeout().intValue()); - Assert.assertEquals("Wrong hardTimeOut", 15, message.getFlowStats().get(0).getHardTimeout().intValue()); + MultipartReplyFlowCase messageCase = (MultipartReplyFlowCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyFlow message = messageCase.getMultipartReplyFlow(); + FlowStats flowStats1 = message.getFlowStats().get(0); + Assert.assertEquals("Wrong tableId", 8, flowStats1.getTableId().intValue()); + Assert.assertEquals("Wrong durationSec", 9, flowStats1.getDurationSec().intValue()); + Assert.assertEquals("Wrong durationNsec", 7, flowStats1.getDurationNsec().intValue()); + Assert.assertEquals("Wrong priority", 12, flowStats1.getPriority().intValue()); + Assert.assertEquals("Wrong idleTimeOut", 14, flowStats1.getIdleTimeout().intValue()); + Assert.assertEquals("Wrong hardTimeOut", 15, flowStats1.getHardTimeout().intValue()); Assert.assertEquals("Wrong flags", new FlowModFlags(true, false, true, false, true), - message.getFlowStats().get(0).getFlags()); + flowStats1.getFlags()); Assert.assertEquals("Wrong cookie", - new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), - message.getFlowStats().get(0).getCookie()); + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + flowStats1.getCookie()); Assert.assertEquals("Wrong packetCount", - new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), - message.getFlowStats().get(0).getPacketCount()); + new BigInteger(1, new byte[]{(byte) 0xEF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + flowStats1.getPacketCount()); Assert.assertEquals("Wrong byteCount", - new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), - message.getFlowStats().get(0).getByteCount()); + new BigInteger(1, new byte[]{(byte) 0x7F, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + flowStats1.getByteCount()); + Assert.assertEquals("Wrong match type", OxmMatchType.class, flowStats1.getMatch().getType()); } /** @@ -198,23 +242,24 @@ public class MultipartReplyMessageFactoryTest { @Test public void testMultipartReplyAggregateBody(){ ByteBuf bb = BufferHelper.buildBuffer("00 02 00 01 00 00 00 00 "+ - "00 01 01 01 01 01 01 01 "+//packetCount - "00 01 01 01 01 01 01 01 "+//byteCount + "FF 01 01 01 01 01 01 01 "+//packetCount + "0F 01 01 01 01 01 01 01 "+//byteCount "00 00 00 08 "+//flowCount "00 00 00 00"//pad ); - MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 0x02, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyAggregate message = (MultipartReplyAggregate) builtByFactory.getMultipartReplyBody(); + MultipartReplyAggregateCase messageCase = (MultipartReplyAggregateCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyAggregate message = messageCase.getMultipartReplyAggregate(); Assert.assertEquals("Wrong packetCount", - new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getPacketCount()); Assert.assertEquals("Wrong byteCount", - new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + new BigInteger(1, new byte[]{(byte) 0x0F, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getByteCount()); Assert.assertEquals("Wrong flowCount", 8, @@ -230,24 +275,25 @@ public class MultipartReplyMessageFactoryTest { "08 "+//tableId "00 00 00 "+//pad "00 00 00 10 "+//activeCount - "00 01 01 01 01 01 01 01 "+//lookupCount - "00 01 01 01 01 01 01 01"//matchedCount + "FF 01 01 01 01 01 01 01 "+//lookupCount + "AF 01 01 01 01 01 01 01"//matchedCount ); - MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 0x03, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyTable message = (MultipartReplyTable) builtByFactory.getMultipartReplyBody(); + MultipartReplyTableCase messageCase = (MultipartReplyTableCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyTable message = messageCase.getMultipartReplyTable(); Assert.assertEquals("Wrong tableId", 8, message.getTableStats().get(0).getTableId().intValue()); Assert.assertEquals("Wrong activeCount", 16, message.getTableStats().get(0).getActiveCount().longValue()); Assert.assertEquals("Wrong lookupCount", - new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getTableStats().get(0).getLookupCount()); Assert.assertEquals("Wrong matchedCount", - new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + new BigInteger(1, new byte[]{(byte) 0xAF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getTableStats().get(0).getMatchedCount()); } @@ -259,66 +305,65 @@ public class MultipartReplyMessageFactoryTest { ByteBuf bb = BufferHelper.buildBuffer("00 04 00 01 00 00 00 00 "+ "00 00 00 FF "+//portNo "00 00 00 00 "+//pad - "00 01 01 01 01 01 01 01 "+//rxPackets - "00 02 02 02 02 02 02 02 "+//txPackets - "00 02 03 02 03 02 03 02 "+//rxBytes - "00 02 03 02 03 02 03 02 "+//txBytes - "00 02 03 02 03 02 03 02 "+//rxDropped - "00 02 03 02 03 02 03 02 "+//txDropped - "00 02 03 02 03 02 03 02 "+//rxErrors - "00 02 03 02 03 02 03 02 "+//txErrors - "00 02 03 02 03 02 03 02 "+//rxFrameErr - "00 02 03 02 03 02 03 02 "+//rxOverErr - "00 02 03 02 03 02 03 02 "+//rxCrcErr - "00 02 03 02 03 02 03 02 "+//collisions + "FF 01 01 01 01 01 01 01 "+//rxPackets + "FF 02 02 02 02 02 02 02 "+//txPackets + "FF 02 03 02 03 02 03 02 "+//rxBytes + "FF 02 03 02 03 02 03 02 "+//txBytes + "FF 02 03 02 03 02 03 02 "+//rxDropped + "FF 02 03 02 03 02 03 02 "+//txDropped + "FF 02 03 02 03 02 03 02 "+//rxErrors + "FF 02 03 02 03 02 03 02 "+//txErrors + "FF 02 03 02 03 02 03 02 "+//rxFrameErr + "FF 02 03 02 03 02 03 02 "+//rxOverErr + "FF 02 03 02 03 02 03 02 "+//rxCrcErr + "FF 02 03 02 03 02 03 02 "+//collisions "00 00 00 02 "+//durationSec "00 00 00 04"//durationNsec ); - MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 0x04, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - - MultipartReplyPortStats message = (MultipartReplyPortStats) builtByFactory.getMultipartReplyBody(); - + MultipartReplyPortStatsCase messageCase = (MultipartReplyPortStatsCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyPortStats message = messageCase.getMultipartReplyPortStats(); Assert.assertEquals("Wrong portNo", 255, message.getPortStats().get(0).getPortNo().intValue()); Assert.assertEquals("Wrong rxPackets", - new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getPortStats().get(0).getRxPackets()); Assert.assertEquals("Wrong txPackets", - new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), message.getPortStats().get(0).getTxPackets()); Assert.assertEquals("Wrong rxBytes", - new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getPortStats().get(0).getRxBytes()); Assert.assertEquals("Wrong txBytes", - new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getPortStats().get(0).getTxBytes()); Assert.assertEquals("Wrong rxDropped", - new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getPortStats().get(0).getRxDropped()); Assert.assertEquals("Wrong txDropped", - new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getPortStats().get(0).getTxDropped()); Assert.assertEquals("Wrong rxErrors", - new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getPortStats().get(0).getRxErrors()); Assert.assertEquals("Wrong txErrors", - new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getPortStats().get(0).getTxErrors()); Assert.assertEquals("Wrong rxFrameErr", - new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getPortStats().get(0).getRxFrameErr()); Assert.assertEquals("Wrong rxOverErr", - new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getPortStats().get(0).getRxOverErr()); Assert.assertEquals("Wrong rxCrcErr", - new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getPortStats().get(0).getRxCrcErr()); Assert.assertEquals("Wrong collisions", - new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getPortStats().get(0).getCollisions()); Assert.assertEquals("Wrong durationSec", 2, message.getPortStats().get(0).getDurationSec().intValue()); Assert.assertEquals("Wrong durationNsec", 4, message.getPortStats().get(0).getDurationNsec().intValue()); @@ -332,31 +377,30 @@ public class MultipartReplyMessageFactoryTest { ByteBuf bb = BufferHelper.buildBuffer("00 05 00 01 00 00 00 00 "+ "00 00 00 FF "+//portNo "00 00 00 10 "+//queueId - "00 02 03 02 03 02 03 02 "+//txBytes - "00 02 02 02 02 02 02 02 "+//txPackets - "00 02 03 02 03 02 03 02 "+//txErrors + "FF 02 03 02 03 02 03 02 "+//txBytes + "FF 02 02 02 02 02 02 02 "+//txPackets + "FF 02 03 02 03 02 03 02 "+//txErrors "00 00 00 02 "+//durationSec "00 00 00 04"//durationNsec ); - MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 0x05, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - - MultipartReplyQueue message = (MultipartReplyQueue) builtByFactory.getMultipartReplyBody(); - + MultipartReplyQueueCase messageCase = (MultipartReplyQueueCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyQueue message = messageCase.getMultipartReplyQueue(); Assert.assertEquals("Wrong portNo", 255, message.getQueueStats().get(0).getPortNo().intValue()); Assert.assertEquals("Wrong queueId", 16, message.getQueueStats().get(0).getQueueId().intValue()); Assert.assertEquals("Wrong txBytes", - new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getQueueStats().get(0).getTxBytes()); Assert.assertEquals("Wrong txPackets", - new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), message.getQueueStats().get(0).getTxPackets()); Assert.assertEquals("Wrong txErrors", - new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getQueueStats().get(0).getTxErrors()); Assert.assertEquals("Wrong durationSec", 2, message.getQueueStats().get(0).getDurationSec().intValue()); Assert.assertEquals("Wrong durationNsec", 4, message.getQueueStats().get(0).getDurationNsec().intValue()); @@ -373,81 +417,80 @@ public class MultipartReplyMessageFactoryTest { "00 00 00 10 "+//groupId "00 00 00 12 "+//refCount "00 00 00 00 "+//pad2 - "00 01 01 01 01 01 01 01 "+//packetCount - "00 01 01 01 01 01 01 01 "+//byteCount + "FF 01 01 01 01 01 01 01 "+//packetCount + "FF 01 01 01 01 01 01 01 "+//byteCount "00 00 00 08 "+//durationSec "00 00 00 09 "+//durationNsec - "00 01 01 01 01 01 01 01 "+//packetCountBucket - "00 01 01 01 01 01 01 01 "+//byteCountBucket - "00 02 02 02 02 02 02 02 "+//packetCountBucket_2 - "00 02 02 02 02 02 02 02 "+//byteCountBucket_2 + "FF 01 01 01 01 01 01 01 "+//packetCountBucket + "FF 01 01 01 01 01 01 01 "+//byteCountBucket + "FF 02 02 02 02 02 02 02 "+//packetCountBucket_2 + "FF 02 02 02 02 02 02 02 "+//byteCountBucket_2 "00 48 "+//length_2 "00 00 "+//pad1.2 "00 00 00 10 "+//groupId_2 "00 00 00 12 "+//refCount_2 "00 00 00 00 "+//pad2.2 - "00 01 01 01 01 01 01 01 "+//packetCount_2 - "00 01 01 01 01 01 01 01 "+//byteCount_2 + "FF 01 01 01 01 01 01 01 "+//packetCount_2 + "FF 01 01 01 01 01 01 01 "+//byteCount_2 "00 00 00 08 "+//durationSec_2 "00 00 00 09 "+//durationNsec_2 - "00 01 01 01 01 01 01 01 "+//packetCountBucket_1.2 - "00 01 01 01 01 01 01 01 "+//byteCountBucket_1.2 - "00 02 02 02 02 02 02 02 "+//packetCountBucket_2.2 - "00 02 02 02 02 02 02 02"//byteCountBucket_2.2 + "FF 01 01 01 01 01 01 01 "+//packetCountBucket_1.2 + "FF 01 01 01 01 01 01 01 "+//byteCountBucket_1.2 + "FF 02 02 02 02 02 02 02 "+//packetCountBucket_2.2 + "FF 02 02 02 02 02 02 02"//byteCountBucket_2.2 ); - MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 0x06, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - - MultipartReplyGroup message = (MultipartReplyGroup) builtByFactory.getMultipartReplyBody(); - + MultipartReplyGroupCase messageCase = (MultipartReplyGroupCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyGroup message = messageCase.getMultipartReplyGroup(); Assert.assertEquals("Wrong groupId", 16, message.getGroupStats().get(0).getGroupId().getValue().intValue()); Assert.assertEquals("Wrong refCount", 18, message.getGroupStats().get(0).getRefCount().intValue()); Assert.assertEquals("Wrong packetCount", - new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getGroupStats().get(0).getPacketCount()); Assert.assertEquals("Wrong byteCount", - new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getGroupStats().get(0).getByteCount()); Assert.assertEquals("Wrong durationSec", 8, message.getGroupStats().get(0).getDurationSec().intValue()); Assert.assertEquals("Wrong durationNsec", 9, message.getGroupStats().get(0).getDurationNsec().intValue()); Assert.assertEquals("Wrong packetCountBucket", - new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getGroupStats().get(0).getBucketStats().get(0).getPacketCount()); Assert.assertEquals("Wrong byteCountBucket", - new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getGroupStats().get(0).getBucketStats().get(0).getByteCount()); Assert.assertEquals("Wrong packetCountBucket_2", - new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), message.getGroupStats().get(0).getBucketStats().get(1).getPacketCount()); Assert.assertEquals("Wrong byteCountBucket_2", - new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), message.getGroupStats().get(0).getBucketStats().get(1).getByteCount()); Assert.assertEquals("Wrong groupId_2", 16, message.getGroupStats().get(1).getGroupId().getValue().intValue()); Assert.assertEquals("Wrong refCount_2", 18, message.getGroupStats().get(1).getRefCount().intValue()); Assert.assertEquals("Wrong packetCount_2", - new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getGroupStats().get(1).getPacketCount()); Assert.assertEquals("Wrong byteCount_2", - new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getGroupStats().get(1).getByteCount()); Assert.assertEquals("Wrong durationSec_2", 8, message.getGroupStats().get(1).getDurationSec().intValue()); Assert.assertEquals("Wrong durationNsec_2", 9, message.getGroupStats().get(1).getDurationNsec().intValue()); Assert.assertEquals("Wrong packetCountBucket_1.2", - new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getGroupStats().get(1).getBucketStats().get(0).getPacketCount()); Assert.assertEquals("Wrong byteCountBucket_1.2", - new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getGroupStats().get(1).getBucketStats().get(0).getByteCount()); Assert.assertEquals("Wrong packetCountBucket_2.2", - new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), message.getGroupStats().get(1).getBucketStats().get(1).getPacketCount()); Assert.assertEquals("Wrong byteCountBucket_2.2", - new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), message.getGroupStats().get(1).getBucketStats().get(1).getByteCount()); } @@ -465,14 +508,13 @@ public class MultipartReplyMessageFactoryTest { "00 00"//pad ); - MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 11, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - - MultipartReplyMeterFeatures message = (MultipartReplyMeterFeatures) builtByFactory.getMultipartReplyBody(); - + MultipartReplyMeterFeaturesCase messageCase = (MultipartReplyMeterFeaturesCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyMeterFeatures message = messageCase.getMultipartReplyMeterFeatures(); Assert.assertEquals("Wrong maxMeter", 9, message.getMaxMeter().intValue()); Assert.assertEquals("Wrong bandTypes", new MeterBandTypeBitmap(true, false), message.getBandTypes()); Assert.assertEquals("Wrong capabilities", new MeterFlags(false, true, true, false), @@ -491,57 +533,56 @@ public class MultipartReplyMessageFactoryTest { "00 58 "+//len "00 00 00 00 00 00 "+//pad "00 00 00 07 "+//flowCount - "00 01 01 01 01 01 01 01 "+//packetInCount - "00 01 01 01 01 01 01 01 "+//byteInCount + "FF 01 01 01 01 01 01 01 "+//packetInCount + "FF 01 01 01 01 01 01 01 "+//byteInCount "00 00 00 05 "+//durationSec "00 00 00 05 "+//durationNsec - "00 01 01 01 01 01 01 01 "+//packetBandCount_01 - "00 01 01 01 01 01 01 01 "+//byteBandCount_01 - "00 02 02 02 02 02 02 02 "+//packetBandCount_02 - "00 02 02 02 02 02 02 02 "+//byteBandCount_02 - "00 03 03 03 03 03 03 03 "+//packetBandCount_03 - "00 03 03 03 03 03 03 03"//byteBandCount_03 + "FF 01 01 01 01 01 01 01 "+//packetBandCount_01 + "FF 01 01 01 01 01 01 01 "+//byteBandCount_01 + "FF 02 02 02 02 02 02 02 "+//packetBandCount_02 + "FF 02 02 02 02 02 02 02 "+//byteBandCount_02 + "FF 03 03 03 03 03 03 03 "+//packetBandCount_03 + "FF 03 03 03 03 03 03 03"//byteBandCount_03 ); - MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 9, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - - MultipartReplyMeter message = (MultipartReplyMeter) builtByFactory.getMultipartReplyBody(); - + MultipartReplyMeterCase messageCase = (MultipartReplyMeterCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyMeter message = messageCase.getMultipartReplyMeter(); Assert.assertEquals("Wrong meterId", 9, message.getMeterStats().get(0).getMeterId().getValue().intValue()); Assert.assertEquals("Wrong flowCount", 7, message.getMeterStats().get(0).getFlowCount().intValue()); Assert.assertEquals("Wrong packetInCount", - new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getMeterStats().get(0).getPacketInCount()); Assert.assertEquals("Wrong byteInCount", - new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getMeterStats().get(0).getByteInCount()); Assert.assertEquals("Wrong durationSec", 5, message.getMeterStats().get(0).getDurationSec().intValue()); Assert.assertEquals("Wrong durationNsec", 5, message.getMeterStats().get(0).getDurationNsec().intValue()); Assert.assertEquals("Wrong packetBandCount_01", - new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getMeterStats().get(0).getMeterBandStats().get(0).getPacketBandCount()); Assert.assertEquals("Wrong byteBandCount_01", - new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getMeterStats().get(0).getMeterBandStats().get(0).getByteBandCount()); Assert.assertEquals("Wrong packetBandCount_02", - new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), message.getMeterStats().get(0).getMeterBandStats().get(1).getPacketBandCount()); Assert.assertEquals("Wrong byteBandCount_02", - new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), message.getMeterStats().get(0).getMeterBandStats().get(1).getByteBandCount()); Assert.assertEquals("Wrong packetBandCount_03", - new BigInteger(new byte[]{0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), message.getMeterStats().get(0).getMeterBandStats().get(2).getPacketBandCount()); Assert.assertEquals("Wrong byteBandCount_03", - new BigInteger(new byte[]{0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), message.getMeterStats().get(0).getMeterBandStats().get(2).getByteBandCount()); } @@ -555,71 +596,70 @@ public class MultipartReplyMessageFactoryTest { "00 58 "+//len_0 "00 00 00 00 00 00 "+//pad_0 "00 00 00 07 "+//flowCount_0 - "00 01 01 01 01 01 01 01 "+//packetInCount_0 - "00 01 01 01 01 01 01 01 "+//byteInCount_0 + "FF 01 01 01 01 01 01 01 "+//packetInCount_0 + "FF 01 01 01 01 01 01 01 "+//byteInCount_0 "00 00 00 05 "+//durationSec_0 "00 00 00 05 "+//durationNsec_0 - "00 01 01 01 01 01 01 01 "+//packetBandCount_01 - "00 01 01 01 01 01 01 01 "+//byteBandCount_01 - "00 02 02 02 02 02 02 02 "+//packetBandCount_02 - "00 02 02 02 02 02 02 02 "+//byteBandCount_02 - "00 03 03 03 03 03 03 03 "+//packetBandCount_03 - "00 03 03 03 03 03 03 03 "+//byteBandCount_03 + "FF 01 01 01 01 01 01 01 "+//packetBandCount_01 + "FF 01 01 01 01 01 01 01 "+//byteBandCount_01 + "FF 02 02 02 02 02 02 02 "+//packetBandCount_02 + "FF 02 02 02 02 02 02 02 "+//byteBandCount_02 + "FF 03 03 03 03 03 03 03 "+//packetBandCount_03 + "FF 03 03 03 03 03 03 03 "+//byteBandCount_03 "00 00 00 08 "+//meterId_1 "00 58 "+//len_1 "00 00 00 00 00 00 "+//pad_1 "00 00 00 07 "+//flowCount_1 - "00 01 01 01 01 01 01 01 "+//packetInCount_1 - "00 01 01 01 01 01 01 01 "+//byteInCount_1 + "FF 01 01 01 01 01 01 01 "+//packetInCount_1 + "FF 01 01 01 01 01 01 01 "+//byteInCount_1 "00 00 00 05 "+//durationSec_1 "00 00 00 05 "+//durationNsec_1 - "00 01 01 01 01 01 01 01 "+//packetBandCount_11 - "00 01 01 01 01 01 01 01 "+//byteBandCount_11 - "00 02 02 02 02 02 02 02 "+//packetBandCount_12 - "00 02 02 02 02 02 02 02 "+//byteBandCount_12 - "00 03 03 03 03 03 03 03 "+//packetBandCount_13 - "00 03 03 03 03 03 03 03"//byteBandCount_13 + "FF 01 01 01 01 01 01 01 "+//packetBandCount_11 + "FF 01 01 01 01 01 01 01 "+//byteBandCount_11 + "FF 02 02 02 02 02 02 02 "+//packetBandCount_12 + "FF 02 02 02 02 02 02 02 "+//byteBandCount_12 + "FF 03 03 03 03 03 03 03 "+//packetBandCount_13 + "FF 03 03 03 03 03 03 03"//byteBandCount_13 ); - MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 9, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - - MultipartReplyMeter message = (MultipartReplyMeter) builtByFactory.getMultipartReplyBody(); - + MultipartReplyMeterCase messageCase = (MultipartReplyMeterCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyMeter message = messageCase.getMultipartReplyMeter(); Assert.assertEquals("Wrong meterId", 9, message.getMeterStats().get(0).getMeterId().getValue().intValue()); Assert.assertEquals("Wrong flowCount", 7, message.getMeterStats().get(0).getFlowCount().intValue()); Assert.assertEquals("Wrong packetInCount", - new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getMeterStats().get(0).getPacketInCount()); Assert.assertEquals("Wrong byteInCount", - new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getMeterStats().get(0).getByteInCount()); Assert.assertEquals("Wrong durationSec", 5, message.getMeterStats().get(0).getDurationSec().intValue()); Assert.assertEquals("Wrong durationNsec", 5, message.getMeterStats().get(0).getDurationNsec().intValue()); Assert.assertEquals("Wrong packetBandCount_01", - new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getMeterStats().get(0).getMeterBandStats().get(0).getPacketBandCount()); Assert.assertEquals("Wrong byteBandCount_01", - new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getMeterStats().get(0).getMeterBandStats().get(0).getByteBandCount()); Assert.assertEquals("Wrong packetBandCount_02", - new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), message.getMeterStats().get(0).getMeterBandStats().get(1).getPacketBandCount()); Assert.assertEquals("Wrong byteBandCount_02", - new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), message.getMeterStats().get(0).getMeterBandStats().get(1).getByteBandCount()); Assert.assertEquals("Wrong packetBandCount_03", - new BigInteger(new byte[]{0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), message.getMeterStats().get(0).getMeterBandStats().get(2).getPacketBandCount()); Assert.assertEquals("Wrong byteBandCount_03", - new BigInteger(new byte[]{0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), message.getMeterStats().get(0).getMeterBandStats().get(2).getByteBandCount()); Assert.assertEquals("Wrong meterId", 8, @@ -627,32 +667,32 @@ public class MultipartReplyMessageFactoryTest { Assert.assertEquals("Wrong flowCount", 7, message.getMeterStats().get(1).getFlowCount().intValue()); Assert.assertEquals("Wrong packetInCount", - new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getMeterStats().get(1).getPacketInCount()); Assert.assertEquals("Wrong byteInCount", - new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getMeterStats().get(1).getByteInCount()); Assert.assertEquals("Wrong durationSec", 5, message.getMeterStats().get(1).getDurationSec().intValue()); Assert.assertEquals("Wrong durationNsec", 5, message.getMeterStats().get(1).getDurationNsec().intValue()); Assert.assertEquals("Wrong packetBandCount_01", - new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getMeterStats().get(1).getMeterBandStats().get(0).getPacketBandCount()); Assert.assertEquals("Wrong byteBandCount_01", - new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getMeterStats().get(1).getMeterBandStats().get(0).getByteBandCount()); Assert.assertEquals("Wrong packetBandCount_02", - new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), message.getMeterStats().get(1).getMeterBandStats().get(1).getPacketBandCount()); Assert.assertEquals("Wrong byteBandCount_02", - new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), message.getMeterStats().get(1).getMeterBandStats().get(1).getByteBandCount()); Assert.assertEquals("Wrong packetBandCount_03", - new BigInteger(new byte[]{0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), message.getMeterStats().get(1).getMeterBandStats().get(2).getPacketBandCount()); Assert.assertEquals("Wrong byteBandCount_03", - new BigInteger(new byte[]{0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), message.getMeterStats().get(1).getMeterBandStats().get(2).getByteBandCount()); } @@ -683,31 +723,33 @@ public class MultipartReplyMessageFactoryTest { "00 00 00 04"//meterBandExperimenter.experimenter ); - MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 10, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - - MultipartReplyMeterConfig message = (MultipartReplyMeterConfig) builtByFactory.getMultipartReplyBody(); - + MultipartReplyMeterConfigCase messageCase = (MultipartReplyMeterConfigCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyMeterConfig message = messageCase.getMultipartReplyMeterConfig(); Assert.assertEquals("Wrong flags", new MeterFlags(false, false, true, true), message.getMeterConfig().get(0).getFlags()); Assert.assertEquals("Wrong meterId", 9, message.getMeterConfig().get(0).getMeterId().getValue().intValue()); - MeterBandDrop meterBandDrop = (MeterBandDrop) message.getMeterConfig().get(0).getBands().get(0).getMeterBand(); + MeterBandDropCase dropCase = (MeterBandDropCase) message.getMeterConfig().get(0).getBands().get(0).getMeterBand(); + MeterBandDrop meterBandDrop = dropCase.getMeterBandDrop(); Assert.assertEquals("Wrong meterBandDrop.type", 1, meterBandDrop.getType().getIntValue()); Assert.assertEquals("Wrong meterBandDrop.rate", 17, meterBandDrop.getRate().intValue()); Assert.assertEquals("Wrong meterBandDrop.burstSize", 32, meterBandDrop.getBurstSize().intValue()); - MeterBandDscpRemark meterBandDscp = (MeterBandDscpRemark) message.getMeterConfig().get(0).getBands().get(1).getMeterBand(); + MeterBandDscpRemarkCase dscpCase = (MeterBandDscpRemarkCase) message.getMeterConfig().get(0).getBands().get(1).getMeterBand(); + MeterBandDscpRemark meterBandDscp = dscpCase.getMeterBandDscpRemark(); Assert.assertEquals("Wrong meterBandDscp.type", 2, meterBandDscp.getType().getIntValue()); Assert.assertEquals("Wrong meterBandDscp.rate", 17, meterBandDscp.getRate().intValue()); Assert.assertEquals("Wrong meterBandDscp.burstSize", 32, meterBandDscp.getBurstSize().intValue()); Assert.assertEquals("Wrong meterBandDscp.precLevel", 4, meterBandDscp.getPrecLevel().intValue()); - MeterBandExperimenter meterBandExperimenter = (MeterBandExperimenter) message.getMeterConfig().get(0).getBands().get(2).getMeterBand(); + MeterBandExperimenterCase experimenterCase = (MeterBandExperimenterCase) message.getMeterConfig().get(0).getBands().get(2).getMeterBand(); + MeterBandExperimenter meterBandExperimenter = experimenterCase.getMeterBandExperimenter(); Assert.assertEquals("Wrong meterBandExperimenter.type", 0xFFFF, meterBandExperimenter.getType().getIntValue()); Assert.assertEquals("Wrong meterBandExperimenter.rate", 17, meterBandExperimenter.getRate().intValue()); Assert.assertEquals("Wrong meterBandExperimenter.burstSize", 32, meterBandExperimenter.getBurstSize().intValue()); @@ -751,31 +793,33 @@ public class MultipartReplyMessageFactoryTest { "00 00 00"//meterBandDscp01.pad ); - MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 10, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - - MultipartReplyMeterConfig message = (MultipartReplyMeterConfig) builtByFactory.getMultipartReplyBody(); - + MultipartReplyMeterConfigCase messageCase = (MultipartReplyMeterConfigCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyMeterConfig message = messageCase.getMultipartReplyMeterConfig(); Assert.assertEquals("Wrong flags", new MeterFlags(true, false, true, false), message.getMeterConfig().get(0).getFlags()); Assert.assertEquals("Wrong meterId", 9, message.getMeterConfig().get(0).getMeterId().getValue().intValue()); - MeterBandDrop meterBandDrop = (MeterBandDrop) message.getMeterConfig().get(0).getBands().get(0).getMeterBand(); + MeterBandDropCase dropCase = (MeterBandDropCase) message.getMeterConfig().get(0).getBands().get(0).getMeterBand(); + MeterBandDrop meterBandDrop = dropCase.getMeterBandDrop(); Assert.assertEquals("Wrong meterBandDrop.type", 1, meterBandDrop.getType().getIntValue()); Assert.assertEquals("Wrong meterBandDrop.rate", 17, meterBandDrop.getRate().intValue()); Assert.assertEquals("Wrong meterBandDrop.burstSize", 32, meterBandDrop.getBurstSize().intValue()); - MeterBandDscpRemark meterBandDscp = (MeterBandDscpRemark) message.getMeterConfig().get(0).getBands().get(1).getMeterBand(); + MeterBandDscpRemarkCase dscpCase = (MeterBandDscpRemarkCase) message.getMeterConfig().get(0).getBands().get(1).getMeterBand(); + MeterBandDscpRemark meterBandDscp = dscpCase.getMeterBandDscpRemark(); Assert.assertEquals("Wrong meterBandDscp.type", 2, meterBandDscp.getType().getIntValue()); Assert.assertEquals("Wrong meterBandDscp.rate", 17, meterBandDscp.getRate().intValue()); Assert.assertEquals("Wrong meterBandDscp.burstSize", 32, meterBandDscp.getBurstSize().intValue()); Assert.assertEquals("Wrong meterBandDscp.precLevel", 4, meterBandDscp.getPrecLevel().intValue()); - MeterBandExperimenter meterBandExperimenter = (MeterBandExperimenter) message.getMeterConfig().get(0).getBands().get(2).getMeterBand(); + MeterBandExperimenterCase experimenterCase = (MeterBandExperimenterCase) message.getMeterConfig().get(0).getBands().get(2).getMeterBand(); + MeterBandExperimenter meterBandExperimenter = experimenterCase.getMeterBandExperimenter(); Assert.assertEquals("Wrong meterBandExperimenter.type", 0xFFFF, meterBandExperimenter.getType().getIntValue()); Assert.assertEquals("Wrong meterBandExperimenter.rate", 17, meterBandExperimenter.getRate().intValue()); Assert.assertEquals("Wrong meterBandExperimenter.burstSize", 32, meterBandExperimenter.getBurstSize().intValue()); @@ -787,7 +831,8 @@ public class MultipartReplyMessageFactoryTest { Assert.assertEquals("Wrong meterId01", 7, message.getMeterConfig().get(1).getMeterId().getValue().intValue()); - MeterBandDscpRemark meterBandDscp01 = (MeterBandDscpRemark) message.getMeterConfig().get(1).getBands().get(0).getMeterBand(); + MeterBandDscpRemarkCase dscpCase01 = (MeterBandDscpRemarkCase) message.getMeterConfig().get(1).getBands().get(0).getMeterBand(); + MeterBandDscpRemark meterBandDscp01 = dscpCase01.getMeterBandDscpRemark(); Assert.assertEquals("Wrong meterBandDscp01.type", 2, meterBandDscp01.getType().getIntValue()); Assert.assertEquals("Wrong meterBandDscp01.rate", 17, meterBandDscp01.getRate().intValue()); Assert.assertEquals("Wrong meterBandDscp01.burstSize", 32, meterBandDscp01.getBurstSize().intValue()); @@ -806,14 +851,13 @@ public class MultipartReplyMessageFactoryTest { "00 00 01 01 00 00 01 01" ); - MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 0xFFFF, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - - MultipartReplyExperimenter message = (MultipartReplyExperimenter) builtByFactory.getMultipartReplyBody(); - + MultipartReplyExperimenterCase messageCase = (MultipartReplyExperimenterCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyExperimenter message = messageCase.getMultipartReplyExperimenter(); Assert.assertEquals("Wrong experimenterId", 15, message.getExperimenter().intValue()); Assert.assertEquals("Wrong expType", 255, message.getExpType().intValue()); Assert.assertArrayEquals("Wrong data", new byte[]{0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01}, @@ -830,7 +874,7 @@ public class MultipartReplyMessageFactoryTest { "00 01 02 03 "+ //portNo "00 00 00 00 "+ //padding01 "08 00 27 00 B0 EB " + //mac address - "00 00 "); //padding02 + "00 00"); //padding02 //port name String portName = "SampleText"; byte[] portNameBytes = new byte[MAX_PORT_NAME_LEN]; @@ -841,22 +885,21 @@ public class MultipartReplyMessageFactoryTest { ByteBuf bb2 = BufferHelper.buildBuffer("00 00 00 41 " + //port config "00 00 00 05 " + //port state "00 00 00 81 " + //current features - "00 00 00 81 " + //advertised features - "00 00 00 81 " + //supported features - "00 00 00 81 " + //peer features + "00 00 81 81 " + //advertised features + "00 00 C1 89 " + //supported features + "00 00 C5 8D " + //peer features "00 00 00 81 " + //curr speed "00 00 00 80" //max speed ); bb.writeBytes(bb2.copy(4, bb2.readableBytes()-4));//excluding version and xid - MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 13, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - - MultipartReplyPortDesc message = (MultipartReplyPortDesc) builtByFactory.getMultipartReplyBody(); - + MultipartReplyPortDescCase messageCase = (MultipartReplyPortDescCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyPortDesc message = messageCase.getMultipartReplyPortDesc(); Assert.assertEquals("Wrong portNo", 66051L, message.getPorts().get(0).getPortNo().longValue()); Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:B0:EB"), message.getPorts().get(0).getHwAddr()); @@ -866,28 +909,28 @@ public class MultipartReplyMessageFactoryTest { message.getPorts().get(0).getConfig()); Assert.assertEquals("Wrong portState", new PortState(false, true, true), message.getPorts().get(0).getState()); - Assert.assertEquals("Wrong currentFeatures", new PortFeatures(true, false, false, false, - false, false, false, true, - false, false, false, false, + Assert.assertEquals("Wrong currentFeatures", new PortFeatures(false, false, false, false, + false, true, false, false, + false, true, false, false, false, false, false, false), message.getPorts().get(0).getCurrentFeatures()); Assert.assertEquals("Wrong advertisedFeatures", - new PortFeatures(true, false, false, false, - false, false, false, true, - false, false, false, false, - false, false, false, false), + new PortFeatures(true, false, false, false, + false, true, false, false, + false, true, false, false, + false, false, false, true), message.getPorts().get(0).getAdvertisedFeatures()); Assert.assertEquals("Wrong supportedFeatures", - new PortFeatures(true, false, false, false, - false, false, false, true, - false, false, false, false, - false, false, false, false), + new PortFeatures(true, true, false, false, + false, true, false, false, + false, true, false, false, + false, false, true, true), message.getPorts().get(0).getSupportedFeatures()); Assert.assertEquals("Wrong peerFeatures", - new PortFeatures(true, false, false, false, - false, false, false, true, - false, false, false, false, - false, false, false, false), + new PortFeatures(true, true, true, false, + false, true, false, false, + false, true, false, false, + false, true, true, true), message.getPorts().get(0).getPeerFeatures()); Assert.assertEquals("Wrong currSpeed", 129L, message.getPorts().get(0).getCurrSpeed().longValue()); Assert.assertEquals("Wrong maxSpeed", 128L, message.getPorts().get(0).getMaxSpeed().longValue()); @@ -921,14 +964,13 @@ public class MultipartReplyMessageFactoryTest { "00 08 "+//copyTTLIntLen "00 00 00 00"//copyTTLInPad ); - MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - - MultipartReplyGroupDesc message = (MultipartReplyGroupDesc) builtByFactory.getMultipartReplyBody(); - + MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc(); Assert.assertEquals("Wrong type", 1, message.getGroupDesc().get(0).getType().getIntValue()); Assert.assertEquals("Wrong groupId", 8, @@ -942,26 +984,26 @@ public class MultipartReplyMessageFactoryTest { message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue()); Assert.assertEquals("Wrong outputType", Output.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0). - getAction().getType()); + message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0) + .getType()); Assert.assertEquals("Wrong outputPort", 4351, - message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0). - getAction().getAugmentation(PortAction.class). + message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0) + .getAugmentation(PortAction.class). getPort().getValue().intValue()); Assert.assertEquals("Wrong outputMaxLen", 65535, - message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0). - getAction().getAugmentation(MaxLengthAction.class). + message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0) + .getAugmentation(MaxLengthAction.class). getMaxLength().intValue()); Assert.assertEquals("Wrong copyTtlOutType", CopyTtlOut.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1). - getAction().getType()); + message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) + .getType()); Assert.assertEquals("Wrong copyTtlInType", CopyTtlIn.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(2). - getAction().getType()); + message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2) + .getType()); } /** @@ -1001,14 +1043,13 @@ public class MultipartReplyMessageFactoryTest { "00 00"//pushPbbPad ); - MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - - MultipartReplyGroupDesc message = (MultipartReplyGroupDesc) builtByFactory.getMultipartReplyBody(); - + MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc(); Assert.assertEquals("Wrong type", 1, message.getGroupDesc().get(0).getType().getIntValue()); Assert.assertEquals("Wrong groupId", 8, @@ -1016,52 +1057,40 @@ public class MultipartReplyMessageFactoryTest { Assert.assertEquals("Wrong bucketWeight", 6, message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue()); Assert.assertEquals("Wrong bucketWatchPort", 5, - message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort(). - getValue().intValue()); + message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().getValue().intValue()); Assert.assertEquals("Wrong bucketWatchGroup", 4, message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue()); - - Assert.assertEquals("Wrong setMplsTtlType", SetMplsTtl.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0). - getAction().getType()); - + message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0) + .getType()); Assert.assertEquals("Wrong setMplsTtlMPLS_TTL", 9, - message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0). - getAction().getAugmentation(MplsTtlAction.class). + message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0) + .getAugmentation(MplsTtlAction.class). getMplsTtl().intValue()); - Assert.assertEquals("Wrong decMplsTtlType", DecMplsTtl.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1). - getAction().getType()); - + message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) + .getType()); Assert.assertEquals("Wrong pushVlanType", PushVlan.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(2). - getAction().getType()); - + message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2) + .getType()); Assert.assertEquals("Wrong pushVlanEthertype", 32, - message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(2). - getAction().getAugmentation(EthertypeAction.class). + message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2) + .getAugmentation(EthertypeAction.class). getEthertype().getValue().intValue()); - Assert.assertEquals("Wrong pushMplsType", PushMpls.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(3). - getAction().getType()); - + message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(3) + .getType()); Assert.assertEquals("Wrong pushMplsEthertype", 255, - message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(3). - getAction().getAugmentation(EthertypeAction.class). + message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(3). + getAugmentation(EthertypeAction.class). getEthertype().getValue().intValue()); - Assert.assertEquals("Wrong pushPbbType", PushPbb.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(4). - getAction().getType()); - + message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(4) + .getType()); Assert.assertEquals("Wrong pushPbbEthertype", 4095, - message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(4). - getAction().getAugmentation(EthertypeAction.class). + message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(4) + .getAugmentation(EthertypeAction.class). getEthertype().getValue().intValue()); - } /** @@ -1101,64 +1130,51 @@ public class MultipartReplyMessageFactoryTest { "00 00 00 00"//decNwTtlPad ); - MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - - MultipartReplyGroupDesc message = (MultipartReplyGroupDesc) builtByFactory.getMultipartReplyBody(); - - Assert.assertEquals("Wrong type", 1, - message.getGroupDesc().get(0).getType().getIntValue()); - Assert.assertEquals("Wrong groupId", 8, - message.getGroupDesc().get(0).getGroupId().getValue().intValue()); + MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc(); + Assert.assertEquals("Wrong type", 1, message.getGroupDesc().get(0).getType().getIntValue()); + Assert.assertEquals("Wrong groupId", 8, message.getGroupDesc().get(0).getGroupId().getValue().intValue()); Assert.assertEquals("Wrong bucketWeight", 6, message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue()); Assert.assertEquals("Wrong bucketWatchPort", 5, - message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort(). - getValue().intValue()); + message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().getValue().intValue()); Assert.assertEquals("Wrong bucketWatchGroup", 4, message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue()); - Assert.assertEquals("Wrong popVlanType", PopVlan.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0). - getAction().getType()); - + message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0) + .getType()); Assert.assertEquals("Wrong popPbbType", PopPbb.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1). - getAction().getType()); - + message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) + .getType()); Assert.assertEquals("Wrong popMplsType", PopMpls.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(2). - getAction().getType()); - + message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2) + .getType()); Assert.assertEquals("Wrong popMplsEthertype", 207, - message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(2). - getAction().getAugmentation(EthertypeAction.class). + message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2) + .getAugmentation(EthertypeAction.class). getEthertype().getValue().intValue()); - Assert.assertEquals("Wrong setQueueType", SetQueue.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(3). - getAction().getType()); - + message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(3) + .getType()); Assert.assertEquals("Wrong setQueueQueueId", 13565952, - message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(3). - getAction().getAugmentation(QueueIdAction.class). + message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(3) + .getAugmentation(QueueIdAction.class). getQueueId().intValue()); - Assert.assertEquals("Wrong groupType", Group.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(4). - getAction().getType()); - + message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(4) + .getType()); Assert.assertEquals("Wrong groupGroupId", 13565952, - message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(4). - getAction().getAugmentation(GroupIdAction.class). + message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(4) + .getAugmentation(GroupIdAction.class). getGroupId().intValue()); - Assert.assertEquals("Wrong decNwTtlType", DecNwTtl.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(5). - getAction().getType()); + message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(5) + .getType()); } /** @@ -1190,14 +1206,13 @@ public class MultipartReplyMessageFactoryTest { "00 00 00 00" ); - MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - - MultipartReplyGroupDesc message = (MultipartReplyGroupDesc) builtByFactory.getMultipartReplyBody(); - + MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc(); Assert.assertEquals("Wrong type", 1, message.getGroupDesc().get(0).getType().getIntValue()); Assert.assertEquals("Wrong groupId", 8, @@ -1211,28 +1226,28 @@ public class MultipartReplyMessageFactoryTest { message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue()); Assert.assertEquals("Wrong nwTTlType", SetNwTtl.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0). - getAction().getType()); + message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0) + .getType()); Assert.assertEquals("Wrong nwTTlnwTTL", 14, - message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0). - getAction().getAugmentation(NwTtlAction.class).getNwTtl().intValue()); + message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0) + .getAugmentation(NwTtlAction.class).getNwTtl().intValue()); Assert.assertEquals("Wrong setFieldType", SetField.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1). - getAction().getType()); + message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) + .getType()); Assert.assertEquals("Wrong setFieldOXMClass", OpenflowBasicClass.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1). - getAction().getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0).getOxmClass()); + message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) + .getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0).getOxmClass()); Assert.assertEquals("Wrong setFieldOXMField", InPort.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1). - getAction().getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0).getOxmMatchField()); + message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) + .getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0).getOxmMatchField()); Assert.assertEquals("Wrong setFieldOXMValue", 255, - message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1). - getAction().getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0). + message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) + .getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0). getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue()); } }