X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflow-protocol-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowjava%2Fprotocol%2Fimpl%2Fdeserialization%2Ffactories%2FMultipartReplyMessageFactoryTest.java;h=00785418ce93912f0ef9f0f5fa32f136039a23c2;hb=5f5622e79402f70a944fa93fd7ee2d84d1776b08;hp=fc27d1e54d53faaf84e97a26bafffff448cfbe16;hpb=1a13b24590d2ff8c57204b8d6c8a8f4597d3fed5;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 fc27d1e5..00785418 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 @@ -16,45 +16,32 @@ 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.keys.MessageCodeKey; 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.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; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecMplsTtlCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecNwTtlCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopMplsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopPbbCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushMplsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushPbbCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures; -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.oxm.rev150225.InPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +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.entry.value.grouping.match.entry.value.InPortCase; 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.MeterBandDropCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCase; @@ -62,24 +49,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 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.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.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.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.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.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; @@ -107,7 +89,7 @@ public class MultipartReplyMessageFactoryTest { private static final Logger LOGGER = LoggerFactory .getLogger(MultipartReplyMessageFactoryTest.class); - + /** * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO */ @@ -116,39 +98,39 @@ public class MultipartReplyMessageFactoryTest { final int DESC_STR_LEN = 256; final int SERIAL_NUM_LEN = 32; ByteBuf bb = BufferHelper.buildBuffer("00 00 00 01 00 00 00 00"); - + String mfrDesc = "Manufacturer description"; byte[] mfrDescBytes = new byte[256]; mfrDescBytes = mfrDesc.getBytes(); bb.writeBytes(mfrDescBytes); bb.writeZero(DESC_STR_LEN - mfrDescBytes.length); - + String hwDesc = "Hardware description"; byte[] hwDescBytes = new byte[256]; hwDescBytes = hwDesc.getBytes(); bb.writeBytes(hwDescBytes); bb.writeZero(DESC_STR_LEN - hwDescBytes.length); - + String swDesc = "Software description"; byte[] swDescBytes = new byte[256]; swDescBytes = swDesc.getBytes(); bb.writeBytes(swDescBytes); bb.writeZero(DESC_STR_LEN - swDescBytes.length); - + String serialNum = "SN0123456789"; byte[] serialNumBytes = new byte[32]; serialNumBytes = serialNum.getBytes(); bb.writeBytes(serialNumBytes); bb.writeZero(SERIAL_NUM_LEN - serialNumBytes.length); - + String dpDesc = "switch3 in room 3120"; byte[] dpDescBytes = new byte[256]; dpDescBytes = dpDesc.getBytes(); bb.writeBytes(dpDescBytes); bb.writeZero(DESC_STR_LEN - dpDescBytes.length); - + 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()); @@ -160,74 +142,7 @@ public class MultipartReplyMessageFactoryTest { Assert.assertEquals("Wrong serialNum", "SN0123456789", message.getSerialNum()); Assert.assertEquals("Wrong dpDesc", "switch3 in room 3120", message.getDpDesc()); } - - /** - * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO - */ - @Test - public void testMultipartReplyFlowBody(){ - ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 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 "+ - "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.deserialize(multipartFactory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - 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), - flowStats1.getFlags()); - Assert.assertEquals("Wrong cookie", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), - flowStats1.getCookie()); - Assert.assertEquals("Wrong packetCount", - new BigInteger(1, new byte[]{(byte) 0xEF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), - flowStats1.getPacketCount()); - Assert.assertEquals("Wrong byteCount", - 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()); - } - + /** * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO */ @@ -239,25 +154,25 @@ public class MultipartReplyMessageFactoryTest { "00 00 00 08 "+//flowCount "00 00 00 00"//pad ); - + 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()); MultipartReplyAggregateCase messageCase = (MultipartReplyAggregateCase) builtByFactory.getMultipartReplyBody(); MultipartReplyAggregate message = messageCase.getMultipartReplyAggregate(); - Assert.assertEquals("Wrong packetCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetCount", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getPacketCount()); - Assert.assertEquals("Wrong byteCount", - new BigInteger(1, new byte[]{(byte) 0x0F, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteCount", + new BigInteger(1, new byte[]{(byte) 0x0F, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getByteCount()); - Assert.assertEquals("Wrong flowCount", - 8, + Assert.assertEquals("Wrong flowCount", + 8, message.getFlowCount().intValue()); } - + /** * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO */ @@ -270,25 +185,25 @@ public class MultipartReplyMessageFactoryTest { "FF 01 01 01 01 01 01 01 "+//lookupCount "AF 01 01 01 01 01 01 01"//matchedCount ); - + 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()); - + 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(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong lookupCount", + 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(1, new byte[]{(byte) 0xAF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong matchedCount", + new BigInteger(1, new byte[]{(byte) 0xAF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getTableStats().get(0).getMatchedCount()); } - + /** * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO */ @@ -312,55 +227,55 @@ public class MultipartReplyMessageFactoryTest { "00 00 00 02 "+//durationSec "00 00 00 04"//durationNsec ); - + 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()); 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(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong rxPackets", + 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(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong txPackets", + 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(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong rxBytes", + 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(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong txBytes", + 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(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong rxDropped", + 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(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong txDropped", + 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(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong rxErrors", + 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(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong txErrors", + 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(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong rxFrameErr", + 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(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong rxOverErr", + 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(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong rxCrcErr", + 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(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong collisions", + 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()); } - + /** * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO */ @@ -375,9 +290,9 @@ public class MultipartReplyMessageFactoryTest { "00 00 00 02 "+//durationSec "00 00 00 04"//durationNsec ); - + 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()); @@ -385,19 +300,19 @@ public class MultipartReplyMessageFactoryTest { 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(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong txBytes", + 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(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong txPackets", + 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(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong txErrors", + 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()); } - + /** * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO */ @@ -431,9 +346,9 @@ public class MultipartReplyMessageFactoryTest { "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.deserialize(multipartFactory, bb); - + BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 0x06, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); @@ -441,48 +356,48 @@ public class MultipartReplyMessageFactoryTest { 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(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetCount", + 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(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteCount", + 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(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetCountBucket", + 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(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteCountBucket", + 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(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong packetCountBucket_2", + 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(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong byteCountBucket_2", + 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(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetCount_2", + 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(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteCount_2", + 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(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetCountBucket_1.2", + 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(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteCountBucket_1.2", + 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(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong packetCountBucket_2.2", + 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(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong byteCountBucket_2.2", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), message.getGroupStats().get(1).getBucketStats().get(1).getByteCount()); } @@ -507,48 +422,48 @@ public class MultipartReplyMessageFactoryTest { "FF 03 03 03 03 03 03 03 "+//packetBandCount_03 "FF 03 03 03 03 03 03 03"//byteBandCount_03 ); - + 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()); MultipartReplyMeterCase messageCase = (MultipartReplyMeterCase) builtByFactory.getMultipartReplyBody(); MultipartReplyMeter message = messageCase.getMultipartReplyMeter(); - Assert.assertEquals("Wrong meterId", 9, + Assert.assertEquals("Wrong meterId", 9, message.getMeterStats().get(0).getMeterId().getValue().intValue()); - Assert.assertEquals("Wrong flowCount", 7, + Assert.assertEquals("Wrong flowCount", 7, message.getMeterStats().get(0).getFlowCount().intValue()); - Assert.assertEquals("Wrong packetInCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetInCount", + 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(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteInCount", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getMeterStats().get(0).getByteInCount()); - Assert.assertEquals("Wrong durationSec", 5, + Assert.assertEquals("Wrong durationSec", 5, message.getMeterStats().get(0).getDurationSec().intValue()); - Assert.assertEquals("Wrong durationNsec", 5, + Assert.assertEquals("Wrong durationNsec", 5, message.getMeterStats().get(0).getDurationNsec().intValue()); - Assert.assertEquals("Wrong packetBandCount_01", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetBandCount_01", + 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(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteBandCount_01", + 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(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong packetBandCount_02", + 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(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong byteBandCount_02", + 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(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), + Assert.assertEquals("Wrong packetBandCount_03", + 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(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), + Assert.assertEquals("Wrong byteBandCount_03", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), message.getMeterStats().get(0).getMeterBandStats().get(2).getByteBandCount()); } - + /** * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO */ @@ -584,81 +499,81 @@ public class MultipartReplyMessageFactoryTest { "FF 03 03 03 03 03 03 03 "+//packetBandCount_13 "FF 03 03 03 03 03 03 03"//byteBandCount_13 ); - + 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()); MultipartReplyMeterCase messageCase = (MultipartReplyMeterCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyMeter message = messageCase.getMultipartReplyMeter(); - Assert.assertEquals("Wrong meterId", 9, + MultipartReplyMeter message = messageCase.getMultipartReplyMeter(); + Assert.assertEquals("Wrong meterId", 9, message.getMeterStats().get(0).getMeterId().getValue().intValue()); - Assert.assertEquals("Wrong flowCount", 7, + Assert.assertEquals("Wrong flowCount", 7, message.getMeterStats().get(0).getFlowCount().intValue()); - Assert.assertEquals("Wrong packetInCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetInCount", + 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(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteInCount", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getMeterStats().get(0).getByteInCount()); - Assert.assertEquals("Wrong durationSec", 5, + Assert.assertEquals("Wrong durationSec", 5, message.getMeterStats().get(0).getDurationSec().intValue()); - Assert.assertEquals("Wrong durationNsec", 5, + Assert.assertEquals("Wrong durationNsec", 5, message.getMeterStats().get(0).getDurationNsec().intValue()); - Assert.assertEquals("Wrong packetBandCount_01", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetBandCount_01", + 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(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteBandCount_01", + 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(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong packetBandCount_02", + 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(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong byteBandCount_02", + 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(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), + Assert.assertEquals("Wrong packetBandCount_03", + 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(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), + Assert.assertEquals("Wrong byteBandCount_03", + 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, + + Assert.assertEquals("Wrong meterId", 8, message.getMeterStats().get(1).getMeterId().getValue().intValue()); - Assert.assertEquals("Wrong flowCount", 7, + Assert.assertEquals("Wrong flowCount", 7, message.getMeterStats().get(1).getFlowCount().intValue()); - Assert.assertEquals("Wrong packetInCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetInCount", + 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(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteInCount", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getMeterStats().get(1).getByteInCount()); - Assert.assertEquals("Wrong durationSec", 5, + Assert.assertEquals("Wrong durationSec", 5, message.getMeterStats().get(1).getDurationSec().intValue()); - Assert.assertEquals("Wrong durationNsec", 5, + Assert.assertEquals("Wrong durationNsec", 5, message.getMeterStats().get(1).getDurationNsec().intValue()); - Assert.assertEquals("Wrong packetBandCount_01", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetBandCount_01", + 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(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteBandCount_01", + 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(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong packetBandCount_02", + 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(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong byteBandCount_02", + 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(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), + Assert.assertEquals("Wrong packetBandCount_03", + 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(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), + Assert.assertEquals("Wrong byteBandCount_03", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), message.getMeterStats().get(1).getMeterBandStats().get(2).getByteBandCount()); } - + /** * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO */ @@ -679,33 +594,33 @@ public class MultipartReplyMessageFactoryTest { "00 00 00 20 "+//meterBandDscp.burstSize "04 "+//meterBandDscp.precLevel "00 00 00");//meterBandDscp.pad - + 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()); MultipartReplyMeterConfigCase messageCase = (MultipartReplyMeterConfigCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyMeterConfig message = messageCase.getMultipartReplyMeterConfig(); + MultipartReplyMeterConfig message = messageCase.getMultipartReplyMeterConfig(); Assert.assertEquals("Wrong flags", new MeterFlags(false, false, true, true), message.getMeterConfig().get(0).getFlags()); - Assert.assertEquals("Wrong meterId", 9, + Assert.assertEquals("Wrong meterId", 9, message.getMeterConfig().get(0).getMeterId().getValue().intValue()); - - MeterBandDropCase dropCase = (MeterBandDropCase) 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.type", 1, meterBandDrop.getType().getIntValue()); Assert.assertEquals("Wrong meterBandDrop.rate", 17, meterBandDrop.getRate().intValue()); Assert.assertEquals("Wrong meterBandDrop.burstSize", 32, meterBandDrop.getBurstSize().intValue()); - - MeterBandDscpRemarkCase dscpCase = (MeterBandDscpRemarkCase) 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.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()); } - + /** * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO */ @@ -726,7 +641,7 @@ public class MultipartReplyMessageFactoryTest { "00 00 00 20 "+//meterBandDscp.burstSize "04 "+//meterBandDscp.precLevel "00 00 00 "+//meterBandDscp.pad - + "00 18 "+//len01 "00 03 "+//flags01 "00 00 00 07 "+//meterId01 @@ -737,119 +652,47 @@ public class MultipartReplyMessageFactoryTest { "04 "+//meterBandDscp01.precLevel "00 00 00"//meterBandDscp01.pad ); - + 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()); MultipartReplyMeterConfigCase messageCase = (MultipartReplyMeterConfigCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyMeterConfig message = messageCase.getMultipartReplyMeterConfig(); - Assert.assertEquals("Wrong flags", new MeterFlags(true, false, true, false), + MultipartReplyMeterConfig message = messageCase.getMultipartReplyMeterConfig(); + Assert.assertEquals("Wrong flags", new MeterFlags(true, false, true, false), message.getMeterConfig().get(0).getFlags()); - Assert.assertEquals("Wrong meterId", 9, + Assert.assertEquals("Wrong meterId", 9, message.getMeterConfig().get(0).getMeterId().getValue().intValue()); - - MeterBandDropCase dropCase = (MeterBandDropCase) message.getMeterConfig().get(0).getBands().get(0).getMeterBand(); - MeterBandDrop meterBandDrop = dropCase.getMeterBandDrop(); - Assert.assertEquals("Wrong meterBandDrop.type", 1, meterBandDrop.getType().getIntValue()); + + 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()); - - MeterBandDscpRemarkCase dscpCase = (MeterBandDscpRemarkCase) 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.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()); - + LOGGER.info(message.getMeterConfig().get(0).getFlags().toString()); Assert.assertEquals("Wrong flags01", new MeterFlags(false, true, true, false), message.getMeterConfig().get(1).getFlags()); - Assert.assertEquals("Wrong meterId01", 7, + Assert.assertEquals("Wrong meterId01", 7, message.getMeterConfig().get(1).getMeterId().getValue().intValue()); - - MeterBandDscpRemarkCase dscpCase01 = (MeterBandDscpRemarkCase) 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.type", 2, meterBandDscp01.getType().getIntValue()); Assert.assertEquals("Wrong meterBandDscp01.rate", 17, meterBandDscp01.getRate().intValue()); Assert.assertEquals("Wrong meterBandDscp01.burstSize", 32, meterBandDscp01.getBurstSize().intValue()); Assert.assertEquals("Wrong meterBandDscp01.precLevel", 4, meterBandDscp01.getPrecLevel().intValue()); - - } - /** - * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO - */ - @Test - public void testMultipartReplyPortDescBody(){ - final byte MAX_PORT_NAME_LEN = 16; - ByteBuf bb = BufferHelper.buildBuffer("00 0D 00 01 00 00 00 00 "+ - "00 01 02 03 "+ //portNo - "00 00 00 00 "+ //padding01 - "08 00 27 00 B0 EB " + //mac address - "00 00"); //padding02 - //port name - String portName = "SampleText"; - byte[] portNameBytes = new byte[MAX_PORT_NAME_LEN]; - portNameBytes = portName.getBytes(); - bb.writeBytes(portNameBytes); - bb.writeZero(MAX_PORT_NAME_LEN - portNameBytes.length); - - ByteBuf bb2 = BufferHelper.buildBuffer("00 00 00 41 " + //port config - "00 00 00 05 " + //port state - "00 00 00 81 " + //current 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.deserialize(multipartFactory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong type", 13, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - 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()); - Assert.assertEquals("Wrong portName", "SampleText", - message.getPorts().get(0).getName()); - Assert.assertEquals("Wrong portConfig", new PortConfig(false, true, false, true), - 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(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, true, false, false, - false, true, false, false, - false, false, false, true), - message.getPorts().get(0).getAdvertisedFeatures()); - Assert.assertEquals("Wrong supportedFeatures", - 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, 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()); } - + /** * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO * Test covers bodies of actions Output, Copy TTL Out, Copy TTL In @@ -879,47 +722,42 @@ public class MultipartReplyMessageFactoryTest { "00 00 00 00"//copyTTLInPad ); 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()); MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody(); MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc(); - Assert.assertEquals("Wrong type", 1, + Assert.assertEquals("Wrong type", 1, message.getGroupDesc().get(0).getType().getIntValue()); - Assert.assertEquals("Wrong groupId", 8, + Assert.assertEquals("Wrong groupId", 8, message.getGroupDesc().get(0).getGroupId().getValue().intValue()); - Assert.assertEquals("Wrong bucketWeight", 6, + Assert.assertEquals("Wrong bucketWeight", 6, message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue()); - Assert.assertEquals("Wrong bucketWatchPort", 5, + Assert.assertEquals("Wrong bucketWatchPort", 5, message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort(). getValue().intValue()); - Assert.assertEquals("Wrong bucketWatchGroup", 4, + Assert.assertEquals("Wrong bucketWatchGroup", 4, message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue()); - - Assert.assertEquals("Wrong outputType", Output.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0) - .getType()); - - Assert.assertEquals("Wrong outputPort", 4351, - 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).getAction().get(0) - .getAugmentation(MaxLengthAction.class). - getMaxLength().intValue()); - - Assert.assertEquals("Wrong copyTtlOutType", CopyTtlOut.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) - .getType()); - - Assert.assertEquals("Wrong copyTtlInType", CopyTtlIn.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2) - .getType()); + + Assert.assertTrue("Wrong outputType",message.getGroupDesc().get(0).getBucketsList().get(0) + .getAction().get(0).getActionChoice() instanceof OutputActionCase); + + Assert.assertEquals("Wrong outputPort", 4351, ((OutputActionCase) message.getGroupDesc().get(0) + .getBucketsList().get(0).getAction().get(0).getActionChoice()) + .getOutputAction().getPort().getValue().intValue()); + + Assert.assertEquals("Wrong outputMaxLen", 65535, ((OutputActionCase) message.getGroupDesc().get(0) + .getBucketsList().get(0).getAction().get(0).getActionChoice()) + .getOutputAction().getMaxLength().intValue()); + + Assert.assertTrue("Wrong copyTtlOutType", message.getGroupDesc().get(0).getBucketsList() + .get(0).getAction().get(1).getActionChoice() instanceof CopyTtlOutCase); + + Assert.assertTrue("Wrong copyTtlInType", message.getGroupDesc().get(0).getBucketsList() + .get(0).getAction().get(2).getActionChoice() instanceof CopyTtlInCase); } - + /** * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO * Test covers bodies of actions Set MPLS TTL , Dec MPLS TTL, Push VLAN. Push MPLS, Push PBB @@ -956,57 +794,48 @@ public class MultipartReplyMessageFactoryTest { "0F FF "+//pushPbbEthertype "00 00"//pushPbbPad ); - + 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()); MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc(); - Assert.assertEquals("Wrong type", 1, + MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc(); + Assert.assertEquals("Wrong type", 1, message.getGroupDesc().get(0).getType().getIntValue()); - Assert.assertEquals("Wrong groupId", 8, + Assert.assertEquals("Wrong groupId", 8, message.getGroupDesc().get(0).getGroupId().getValue().intValue()); - Assert.assertEquals("Wrong bucketWeight", 6, + Assert.assertEquals("Wrong bucketWeight", 6, message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue()); - Assert.assertEquals("Wrong bucketWatchPort", 5, + Assert.assertEquals("Wrong bucketWatchPort", 5, message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().getValue().intValue()); - Assert.assertEquals("Wrong bucketWatchGroup", 4, + 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).getAction().get(0) - .getType()); - Assert.assertEquals("Wrong setMplsTtlMPLS_TTL", 9, - 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).getAction().get(1) - .getType()); - Assert.assertEquals("Wrong pushVlanType", PushVlan.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2) - .getType()); - Assert.assertEquals("Wrong pushVlanEthertype", 32, - 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).getAction().get(3) - .getType()); - Assert.assertEquals("Wrong pushMplsEthertype", 255, - 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).getAction().get(4) - .getType()); - Assert.assertEquals("Wrong pushPbbEthertype", 4095, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(4) - .getAugmentation(EthertypeAction.class). - getEthertype().getValue().intValue()); + Assert.assertTrue("Wrong setMplsTtlType", message.getGroupDesc().get(0).getBucketsList().get(0) + .getAction().get(0).getActionChoice() instanceof SetMplsTtlCase); + Assert.assertEquals("Wrong setMplsTtlMPLS_TTL", 9, ((SetMplsTtlCase) message.getGroupDesc().get(0) + .getBucketsList().get(0).getAction().get(0).getActionChoice()).getSetMplsTtlAction() + .getMplsTtl().intValue()); + Assert.assertTrue("Wrong decMplsTtlType", message.getGroupDesc().get(0).getBucketsList().get(0) + .getAction().get(1).getActionChoice() instanceof DecMplsTtlCase); + Assert.assertTrue("Wrong pushVlanType", message.getGroupDesc().get(0).getBucketsList().get(0) + .getAction().get(2).getActionChoice() instanceof PushVlanCase); + Assert.assertEquals("Wrong pushVlanEthertype", 32,((PushVlanCase) message.getGroupDesc().get(0) + .getBucketsList().get(0).getAction().get(2).getActionChoice()) + .getPushVlanAction().getEthertype().getValue().intValue()); + Assert.assertTrue("Wrong pushMplsType", message.getGroupDesc().get(0).getBucketsList().get(0) + .getAction().get(3).getActionChoice() instanceof PushMplsCase); + Assert.assertEquals("Wrong pushMplsEthertype", 255, ((PushMplsCase) message.getGroupDesc().get(0) + .getBucketsList().get(0).getAction().get(3).getActionChoice()) + .getPushMplsAction().getEthertype().getValue().intValue()); + Assert.assertTrue("Wrong pushPbbType", message.getGroupDesc().get(0).getBucketsList().get(0) + .getAction().get(4).getActionChoice() instanceof PushPbbCase); + Assert.assertEquals("Wrong pushPbbEthertype", 4095, ((PushPbbCase) message.getGroupDesc().get(0) + .getBucketsList().get(0).getAction().get(4).getActionChoice()) + .getPushPbbAction().getEthertype().getValue().intValue()); } - + /** * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO * Test covers bodies of actions Pop VLAN, Pop PBB, Pop MPLS, Group, Dec NW TTL @@ -1043,54 +872,45 @@ public class MultipartReplyMessageFactoryTest { "00 08 "+//decNwTtlLen "00 00 00 00"//decNwTtlPad ); - + 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()); MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc(); + 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, + Assert.assertEquals("Wrong bucketWeight", 6, message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue()); - Assert.assertEquals("Wrong bucketWatchPort", 5, + Assert.assertEquals("Wrong bucketWatchPort", 5, message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().getValue().intValue()); - Assert.assertEquals("Wrong bucketWatchGroup", 4, + 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).getAction().get(0) - .getType()); - Assert.assertEquals("Wrong popPbbType", PopPbb.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) - .getType()); - Assert.assertEquals("Wrong popMplsType", PopMpls.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2) - .getType()); - Assert.assertEquals("Wrong popMplsEthertype", 207, - 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).getAction().get(3) - .getType()); - Assert.assertEquals("Wrong setQueueQueueId", 13565952, - 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).getAction().get(4) - .getType()); - Assert.assertEquals("Wrong groupGroupId", 13565952, - 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).getAction().get(5) - .getType()); + Assert.assertTrue("Wrong popVlanType", message.getGroupDesc().get(0).getBucketsList().get(0) + .getAction().get(0).getActionChoice() instanceof PopVlanCase); + Assert.assertTrue("Wrong popPbbType", message.getGroupDesc().get(0).getBucketsList().get(0) + .getAction().get(1).getActionChoice() instanceof PopPbbCase); + Assert.assertTrue("Wrong popMplsType", message.getGroupDesc().get(0).getBucketsList().get(0) + .getAction().get(2).getActionChoice() instanceof PopMplsCase); + Assert.assertEquals("Wrong popMplsEthertype", 207, ((PopMplsCase) message.getGroupDesc().get(0) + .getBucketsList().get(0).getAction().get(2).getActionChoice()) + .getPopMplsAction().getEthertype().getValue().intValue()); + Assert.assertTrue("Wrong setQueueType", message.getGroupDesc().get(0).getBucketsList().get(0) + .getAction().get(3).getActionChoice() instanceof SetQueueCase); + Assert.assertEquals("Wrong setQueueQueueId", 13565952, ((SetQueueCase) message.getGroupDesc().get(0) + .getBucketsList().get(0).getAction().get(3).getActionChoice()) + .getSetQueueAction().getQueueId().intValue()); + Assert.assertTrue("Wrong groupType", message.getGroupDesc().get(0).getBucketsList().get(0) + .getAction().get(4).getActionChoice() instanceof GroupCase); + Assert.assertEquals("Wrong groupGroupId", 13565952, ((GroupCase) message.getGroupDesc().get(0) + .getBucketsList().get(0).getAction().get(4).getActionChoice()) + .getGroupAction().getGroupId().intValue()); + Assert.assertTrue("Wrong decNwTtlType", message.getGroupDesc().get(0).getBucketsList().get(0) + .getAction().get(5).getActionChoice() instanceof DecNwTtlCase); } - + /** * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO * Test covers bodies of actions NW TTL, Experimenter @@ -1119,49 +939,47 @@ public class MultipartReplyMessageFactoryTest { "00 00 00 FF "+ //setFieldPort "00 00 00 00" ); - + 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()); MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody(); MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc(); - Assert.assertEquals("Wrong type", 1, + Assert.assertEquals("Wrong type", 1, message.getGroupDesc().get(0).getType().getIntValue()); - Assert.assertEquals("Wrong groupId", 8, + Assert.assertEquals("Wrong groupId", 8, message.getGroupDesc().get(0).getGroupId().getValue().intValue()); - Assert.assertEquals("Wrong bucketWeight", 6, + Assert.assertEquals("Wrong bucketWeight", 6, message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue()); - Assert.assertEquals("Wrong bucketWatchPort", 5, + Assert.assertEquals("Wrong bucketWatchPort", 5, message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort(). getValue().intValue()); - Assert.assertEquals("Wrong bucketWatchGroup", 4, + Assert.assertEquals("Wrong bucketWatchGroup", 4, message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue()); - - Assert.assertEquals("Wrong nwTTlType", SetNwTtl.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0) - .getType()); - - Assert.assertEquals("Wrong nwTTlnwTTL", 14, - 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).getAction().get(1) - .getType()); - - Assert.assertEquals("Wrong setFieldOXMClass", OpenflowBasicClass.class, - 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).getAction().get(1) - .getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0).getOxmMatchField()); - - Assert.assertEquals("Wrong setFieldOXMValue", 255, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) - .getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0). - getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue()); + + Assert.assertTrue("Wrong nwTTlType", message.getGroupDesc().get(0).getBucketsList().get(0) + .getAction().get(0).getActionChoice() instanceof SetNwTtlCase); + + Assert.assertEquals("Wrong nwTTlnwTTL", 14, ((SetNwTtlCase) message.getGroupDesc().get(0) + .getBucketsList().get(0).getAction().get(0).getActionChoice()) + .getSetNwTtlAction().getNwTtl().intValue()); + + Assert.assertTrue("Wrong setFieldType", message.getGroupDesc().get(0).getBucketsList().get(0) + .getAction().get(1).getActionChoice() instanceof SetFieldCase); + + Assert.assertEquals("Wrong setFieldOXMClass", OpenflowBasicClass.class, + ((SetFieldCase) message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) + .getActionChoice()).getSetFieldAction().getMatchEntry().get(0).getOxmClass()); + + Assert.assertEquals("Wrong setFieldOXMField", InPort.class, + ((SetFieldCase) message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) + .getActionChoice()).getSetFieldAction().getMatchEntry().get(0).getOxmMatchField()); + + MatchEntry entry = ((SetFieldCase) message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) + .getActionChoice()).getSetFieldAction().getMatchEntry().get(0); + Assert.assertEquals("Wrong setFieldOXMValue", 255, ((InPortCase) entry.getMatchEntryValue()) + .getInPort().getPortNumber().getValue().intValue()); } }