-/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
-package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
-\r
-import io.netty.buffer.ByteBuf;\r
-\r
-import java.math.BigInteger;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDrop;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemark;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenter;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregate;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDesc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenter;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlow;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroup;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDesc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeter;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfig;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeatures;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDesc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStats;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueue;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTable;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-/**\r
- * @author timotej.kubas\r
- * @author michal.polkorab\r
- */\r
-public class MultipartReplyMessageFactoryTest {\r
-\r
- private static final Logger LOGGER = LoggerFactory\r
- .getLogger(MultipartReplyMessageFactoryTest.class);\r
- \r
- /**\r
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
- *//*\r
- @Test\r
- public void test(){\r
- ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 01 02 03 04");\r
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
- \r
- BufferHelper.checkHeaderV13(builtByFactory);\r
- \r
- Assert.assertEquals("Wrong type", 0x07, builtByFactory.getType().getIntValue());\r
- Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
- //Assert.assertArrayEquals("Wrong body", new byte[]{0x01, 0x02, 0x03, 0x04}, builtByFactory.getBody());\r
- }*/\r
- \r
- /**\r
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
- */\r
- @Test\r
- public void testMultipartReplyDescBody(){\r
- final int DESC_STR_LEN = 256;\r
- final int SERIAL_NUM_LEN = 32;\r
- ByteBuf bb = BufferHelper.buildBuffer("00 00 00 01 00 00 00 00");\r
- \r
- String mfrDesc = "Manufacturer description";\r
- byte[] mfrDescBytes = new byte[256];\r
- mfrDescBytes = mfrDesc.getBytes();\r
- bb.writeBytes(mfrDescBytes);\r
- ByteBufUtils.padBuffer((DESC_STR_LEN - mfrDescBytes.length), bb);\r
- \r
- String hwDesc = "Hardware description";\r
- byte[] hwDescBytes = new byte[256];\r
- hwDescBytes = hwDesc.getBytes();\r
- bb.writeBytes(hwDescBytes);\r
- ByteBufUtils.padBuffer((DESC_STR_LEN - hwDescBytes.length), bb);\r
- \r
- String swDesc = "Software description";\r
- byte[] swDescBytes = new byte[256];\r
- swDescBytes = swDesc.getBytes();\r
- bb.writeBytes(swDescBytes);\r
- ByteBufUtils.padBuffer((DESC_STR_LEN - swDescBytes.length), bb);\r
- \r
- String serialNum = "SN0123456789";\r
- byte[] serialNumBytes = new byte[32];\r
- serialNumBytes = serialNum.getBytes();\r
- bb.writeBytes(serialNumBytes);\r
- ByteBufUtils.padBuffer((SERIAL_NUM_LEN - serialNumBytes.length), bb);\r
- \r
- String dpDesc = "switch3 in room 3120";\r
- byte[] dpDescBytes = new byte[256];\r
- dpDescBytes = dpDesc.getBytes();\r
- bb.writeBytes(dpDescBytes);\r
- ByteBufUtils.padBuffer((DESC_STR_LEN - dpDescBytes.length), bb);\r
- \r
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
- \r
- BufferHelper.checkHeaderV13(builtByFactory);\r
- Assert.assertEquals("Wrong type", 0x00, builtByFactory.getType().getIntValue());\r
- Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
- MultipartReplyDesc message = (MultipartReplyDesc) builtByFactory.getMultipartReplyBody();\r
- Assert.assertEquals("Wrong mfrDesc", "Manufacturer description", message.getMfrDesc());\r
- Assert.assertEquals("Wrong hwDesc", "Hardware description", message.getHwDesc());\r
- Assert.assertEquals("Wrong swDesc", "Software description", message.getSwDesc());\r
- Assert.assertEquals("Wrong serialNum", "SN0123456789", message.getSerialNum());\r
- Assert.assertEquals("Wrong dpDesc", "switch3 in room 3120", message.getDpDesc());\r
- }\r
- \r
- /**\r
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
- */\r
- @Test\r
- public void testMultipartReplyFlowBody(){\r
- ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 00 00 00 "+\r
- "00 0C "+//length\r
- "08 "+//tableId\r
- "00 "+//pad_01\r
- "00 00 00 09 "+//durationSec\r
- "00 00 00 07 "+//durationNsec\r
- "00 0C "+//priority\r
- "00 0E "+//idleTimeout\r
- "00 0F "+//hardTimeout\r
- "00 0B "+//flags\r
- "00 00 00 00 "+//pad_02\r
- "00 01 01 01 01 01 01 01 "+//cookie\r
- "00 01 01 01 01 01 01 01 "+//packetCount\r
- "00 01 01 01 01 01 01 01"//byteCount\r
- );\r
- \r
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
- \r
- BufferHelper.checkHeaderV13(builtByFactory);\r
- Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue());\r
- Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
- MultipartReplyFlow message = (MultipartReplyFlow) builtByFactory.getMultipartReplyBody();\r
- Assert.assertEquals("Wrong tableId", 8, message.getFlowStats().get(0).getTableId().intValue());\r
- Assert.assertEquals("Wrong durationSec", 9, message.getFlowStats().get(0).getDurationSec().intValue());\r
- Assert.assertEquals("Wrong durationNsec", 7, message.getFlowStats().get(0).getDurationNsec().intValue());\r
- Assert.assertEquals("Wrong priority", 12, message.getFlowStats().get(0).getPriority().intValue());\r
- Assert.assertEquals("Wrong idleTimeOut", 14, message.getFlowStats().get(0).getIdleTimeout().intValue());\r
- Assert.assertEquals("Wrong hardTimeOut", 15, message.getFlowStats().get(0).getHardTimeout().intValue());\r
- Assert.assertEquals("Wrong flags", new FlowModFlags(true, false, true, false, true), \r
- message.getFlowStats().get(0).getFlags());\r
- Assert.assertEquals("Wrong cookie", \r
- new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
- message.getFlowStats().get(0).getCookie());\r
- Assert.assertEquals("Wrong packetCount", \r
- new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
- message.getFlowStats().get(0).getPacketCount());\r
- Assert.assertEquals("Wrong byteCount", \r
- new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
- message.getFlowStats().get(0).getByteCount());\r
- }\r
- \r
- /**\r
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
- */\r
- @Test\r
- public void testMultipartReplyAggregateBody(){\r
- ByteBuf bb = BufferHelper.buildBuffer("00 02 00 01 00 00 00 00 "+\r
- "00 01 01 01 01 01 01 01 "+//packetCount\r
- "00 01 01 01 01 01 01 01 "+//byteCount\r
- "00 00 00 08 "+//flowCount\r
- "00 00 00 00"//pad\r
- );\r
- \r
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
- \r
- BufferHelper.checkHeaderV13(builtByFactory);\r
- Assert.assertEquals("Wrong type", 0x02, builtByFactory.getType().getIntValue());\r
- Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
- MultipartReplyAggregate message = (MultipartReplyAggregate) builtByFactory.getMultipartReplyBody();\r
- Assert.assertEquals("Wrong packetCount", \r
- new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
- message.getPacketCount());\r
- Assert.assertEquals("Wrong byteCount", \r
- new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
- message.getByteCount());\r
- Assert.assertEquals("Wrong flowCount", \r
- 8, \r
- message.getFlowCount().intValue());\r
- }\r
- \r
- /**\r
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
- */\r
- @Test\r
- public void testMultipartReplyTableBody(){\r
- ByteBuf bb = BufferHelper.buildBuffer("00 03 00 01 00 00 00 00 "+\r
- "08 "+//tableId\r
- "00 00 00 "+//pad\r
- "00 00 00 10 "+//activeCount\r
- "00 01 01 01 01 01 01 01 "+//lookupCount\r
- "00 01 01 01 01 01 01 01"//matchedCount\r
- );\r
- \r
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
- \r
- BufferHelper.checkHeaderV13(builtByFactory);\r
- Assert.assertEquals("Wrong type", 0x03, builtByFactory.getType().getIntValue());\r
- Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
- \r
- MultipartReplyTable message = (MultipartReplyTable) builtByFactory.getMultipartReplyBody();\r
- Assert.assertEquals("Wrong tableId", 8, message.getTableStats().get(0).getTableId().intValue());\r
- Assert.assertEquals("Wrong activeCount", 16, message.getTableStats().get(0).getActiveCount().longValue());\r
- Assert.assertEquals("Wrong lookupCount", \r
- new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
- message.getTableStats().get(0).getLookupCount());\r
- Assert.assertEquals("Wrong matchedCount", \r
- new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
- message.getTableStats().get(0).getMatchedCount());\r
- }\r
- \r
- /**\r
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
- */\r
- @Test\r
- public void testMultipartReplyPortStatsBody(){\r
- ByteBuf bb = BufferHelper.buildBuffer("00 04 00 01 00 00 00 00 "+\r
- "00 00 00 FF "+//portNo\r
- "00 00 00 00 "+//pad\r
- "00 01 01 01 01 01 01 01 "+//rxPackets\r
- "00 02 02 02 02 02 02 02 "+//txPackets\r
- "00 02 03 02 03 02 03 02 "+//rxBytes\r
- "00 02 03 02 03 02 03 02 "+//txBytes\r
- "00 02 03 02 03 02 03 02 "+//rxDropped\r
- "00 02 03 02 03 02 03 02 "+//txDropped\r
- "00 02 03 02 03 02 03 02 "+//rxErrors\r
- "00 02 03 02 03 02 03 02 "+//txErrors\r
- "00 02 03 02 03 02 03 02 "+//rxFrameErr\r
- "00 02 03 02 03 02 03 02 "+//rxOverErr\r
- "00 02 03 02 03 02 03 02 "+//rxCrcErr\r
- "00 02 03 02 03 02 03 02 "+//collisions\r
- "00 00 00 02 "+//durationSec\r
- "00 00 00 04"//durationNsec\r
- );\r
- \r
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
- \r
- BufferHelper.checkHeaderV13(builtByFactory);\r
- Assert.assertEquals("Wrong type", 0x04, builtByFactory.getType().getIntValue());\r
- Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
- \r
- MultipartReplyPortStats message = (MultipartReplyPortStats) builtByFactory.getMultipartReplyBody();\r
- \r
- Assert.assertEquals("Wrong portNo", 255, message.getPortStats().get(0).getPortNo().intValue());\r
- Assert.assertEquals("Wrong rxPackets", \r
- new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
- message.getPortStats().get(0).getRxPackets());\r
- Assert.assertEquals("Wrong txPackets", \r
- new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), \r
- message.getPortStats().get(0).getTxPackets());\r
- Assert.assertEquals("Wrong rxBytes", \r
- new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
- message.getPortStats().get(0).getRxBytes());\r
- Assert.assertEquals("Wrong txBytes", \r
- new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
- message.getPortStats().get(0).getTxBytes());\r
- Assert.assertEquals("Wrong rxDropped", \r
- new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
- message.getPortStats().get(0).getRxDropped());\r
- Assert.assertEquals("Wrong txDropped", \r
- new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
- message.getPortStats().get(0).getTxDropped());\r
- Assert.assertEquals("Wrong rxErrors", \r
- new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
- message.getPortStats().get(0).getRxErrors());\r
- Assert.assertEquals("Wrong txErrors", \r
- new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
- message.getPortStats().get(0).getTxErrors());\r
- Assert.assertEquals("Wrong rxFrameErr", \r
- new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
- message.getPortStats().get(0).getRxFrameErr());\r
- Assert.assertEquals("Wrong rxOverErr", \r
- new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
- message.getPortStats().get(0).getRxOverErr());\r
- Assert.assertEquals("Wrong rxCrcErr", \r
- new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
- message.getPortStats().get(0).getRxCrcErr());\r
- Assert.assertEquals("Wrong collisions", \r
- new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
- message.getPortStats().get(0).getCollisions());\r
- Assert.assertEquals("Wrong durationSec", 2, message.getPortStats().get(0).getDurationSec().intValue());\r
- Assert.assertEquals("Wrong durationNsec", 4, message.getPortStats().get(0).getDurationNsec().intValue());\r
- }\r
- \r
- /**\r
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
- */\r
- @Test\r
- public void testMultipartReplyQueueBody(){\r
- ByteBuf bb = BufferHelper.buildBuffer("00 05 00 01 00 00 00 00 "+\r
- "00 00 00 FF "+//portNo\r
- "00 00 00 10 "+//queueId\r
- "00 02 03 02 03 02 03 02 "+//txBytes\r
- "00 02 02 02 02 02 02 02 "+//txPackets\r
- "00 02 03 02 03 02 03 02 "+//txErrors\r
- "00 00 00 02 "+//durationSec\r
- "00 00 00 04"//durationNsec\r
- );\r
- \r
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
- \r
- BufferHelper.checkHeaderV13(builtByFactory);\r
- Assert.assertEquals("Wrong type", 0x05, builtByFactory.getType().getIntValue());\r
- Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
- \r
- MultipartReplyQueue message = (MultipartReplyQueue) builtByFactory.getMultipartReplyBody();\r
- \r
- Assert.assertEquals("Wrong portNo", 255, message.getQueueStats().get(0).getPortNo().intValue());\r
- Assert.assertEquals("Wrong queueId", 16, message.getQueueStats().get(0).getQueueId().intValue());\r
- Assert.assertEquals("Wrong txBytes", \r
- new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
- message.getQueueStats().get(0).getTxBytes());\r
- Assert.assertEquals("Wrong txPackets", \r
- new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), \r
- message.getQueueStats().get(0).getTxPackets());\r
- Assert.assertEquals("Wrong txErrors", \r
- new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
- message.getQueueStats().get(0).getTxErrors());\r
- Assert.assertEquals("Wrong durationSec", 2, message.getQueueStats().get(0).getDurationSec().intValue());\r
- Assert.assertEquals("Wrong durationNsec", 4, message.getQueueStats().get(0).getDurationNsec().intValue());\r
- }\r
- \r
- /**\r
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
- */\r
- @Test\r
- public void testMultipartReplyGroupBody(){\r
- ByteBuf bb = BufferHelper.buildBuffer("00 06 00 01 00 00 00 00 "+\r
- "00 48 "+//length\r
- "00 00 "+//pad1\r
- "00 00 00 10 "+//groupId\r
- "00 00 00 12 "+//refCount\r
- "00 00 00 00 "+//pad2\r
- "00 01 01 01 01 01 01 01 "+//packetCount\r
- "00 01 01 01 01 01 01 01 "+//byteCount\r
- "00 00 00 08 "+//durationSec\r
- "00 00 00 09 "+//durationNsec\r
- "00 01 01 01 01 01 01 01 "+//packetCountBucket\r
- "00 01 01 01 01 01 01 01 "+//byteCountBucket\r
- "00 02 02 02 02 02 02 02 "+//packetCountBucket_2\r
- "00 02 02 02 02 02 02 02 "+//byteCountBucket_2\r
- "00 48 "+//length_2\r
- "00 00 "+//pad1.2\r
- "00 00 00 10 "+//groupId_2\r
- "00 00 00 12 "+//refCount_2\r
- "00 00 00 00 "+//pad2.2\r
- "00 01 01 01 01 01 01 01 "+//packetCount_2\r
- "00 01 01 01 01 01 01 01 "+//byteCount_2\r
- "00 00 00 08 "+//durationSec_2\r
- "00 00 00 09 "+//durationNsec_2\r
- "00 01 01 01 01 01 01 01 "+//packetCountBucket_1.2\r
- "00 01 01 01 01 01 01 01 "+//byteCountBucket_1.2\r
- "00 02 02 02 02 02 02 02 "+//packetCountBucket_2.2\r
- "00 02 02 02 02 02 02 02"//byteCountBucket_2.2\r
- );\r
- \r
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
- \r
- BufferHelper.checkHeaderV13(builtByFactory);\r
- Assert.assertEquals("Wrong type", 0x06, builtByFactory.getType().getIntValue());\r
- Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
- \r
- MultipartReplyGroup message = (MultipartReplyGroup) builtByFactory.getMultipartReplyBody();\r
- \r
- Assert.assertEquals("Wrong groupId", 16, message.getGroupStats().get(0).getGroupId().getValue().intValue());\r
- Assert.assertEquals("Wrong refCount", 18, message.getGroupStats().get(0).getRefCount().intValue());\r
- Assert.assertEquals("Wrong packetCount", \r
- new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
- message.getGroupStats().get(0).getPacketCount());\r
- Assert.assertEquals("Wrong byteCount", \r
- new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
- message.getGroupStats().get(0).getByteCount());\r
- Assert.assertEquals("Wrong durationSec", 8, message.getGroupStats().get(0).getDurationSec().intValue());\r
- Assert.assertEquals("Wrong durationNsec", 9, message.getGroupStats().get(0).getDurationNsec().intValue());\r
- Assert.assertEquals("Wrong packetCountBucket", \r
- new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
- message.getGroupStats().get(0).getBucketStats().get(0).getPacketCount());\r
- Assert.assertEquals("Wrong byteCountBucket", \r
- new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
- message.getGroupStats().get(0).getBucketStats().get(0).getByteCount());\r
- Assert.assertEquals("Wrong packetCountBucket_2", \r
- new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), \r
- message.getGroupStats().get(0).getBucketStats().get(1).getPacketCount());\r
- Assert.assertEquals("Wrong byteCountBucket_2", \r
- new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), \r
- message.getGroupStats().get(0).getBucketStats().get(1).getByteCount());\r
- \r
- Assert.assertEquals("Wrong groupId_2", 16, message.getGroupStats().get(1).getGroupId().getValue().intValue());\r
- Assert.assertEquals("Wrong refCount_2", 18, message.getGroupStats().get(1).getRefCount().intValue());\r
- Assert.assertEquals("Wrong packetCount_2", \r
- new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
- message.getGroupStats().get(1).getPacketCount());\r
- Assert.assertEquals("Wrong byteCount_2", \r
- new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
- message.getGroupStats().get(1).getByteCount());\r
- Assert.assertEquals("Wrong durationSec_2", 8, message.getGroupStats().get(1).getDurationSec().intValue());\r
- Assert.assertEquals("Wrong durationNsec_2", 9, message.getGroupStats().get(1).getDurationNsec().intValue());\r
- Assert.assertEquals("Wrong packetCountBucket_1.2", \r
- new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
- message.getGroupStats().get(1).getBucketStats().get(0).getPacketCount());\r
- Assert.assertEquals("Wrong byteCountBucket_1.2", \r
- new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
- message.getGroupStats().get(1).getBucketStats().get(0).getByteCount());\r
- Assert.assertEquals("Wrong packetCountBucket_2.2", \r
- new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), \r
- message.getGroupStats().get(1).getBucketStats().get(1).getPacketCount());\r
- Assert.assertEquals("Wrong byteCountBucket_2.2", \r
- new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), \r
- message.getGroupStats().get(1).getBucketStats().get(1).getByteCount());\r
- }\r
- \r
- /**\r
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
- */\r
- @Test\r
- public void testMultipartReplyMeterFeaturesBody(){\r
- ByteBuf bb = BufferHelper.buildBuffer("00 0B 00 01 00 00 00 00 "+\r
- "00 00 00 09 "+//maxMeter\r
- "00 00 00 01 "+//bandTypes\r
- "00 00 00 03 "+//capabilities\r
- "03 "+//maxBands\r
- "04 "+//maxColor\r
- "00 00"//pad\r
- );\r
- \r
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
- \r
- BufferHelper.checkHeaderV13(builtByFactory);\r
- Assert.assertEquals("Wrong type", 11, builtByFactory.getType().getIntValue());\r
- Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
- \r
- MultipartReplyMeterFeatures message = (MultipartReplyMeterFeatures) builtByFactory.getMultipartReplyBody();\r
- \r
- Assert.assertEquals("Wrong maxMeter", 9, message.getMaxMeter().intValue());\r
- Assert.assertEquals("Wrong bandTypes", new MeterBandTypeBitmap(true, false), message.getBandTypes());\r
- Assert.assertEquals("Wrong capabilities", new MeterFlags(false, true, true, false), \r
- message.getCapabilities());\r
- Assert.assertEquals("Wrong maxBands", 3, message.getMaxBands().intValue());\r
- Assert.assertEquals("Wrong maxColor", 4, message.getMaxColor().intValue());\r
- }\r
- \r
- /**\r
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
- */\r
- @Test\r
- public void testMultipartReplyMeterBody(){\r
- ByteBuf bb = BufferHelper.buildBuffer("00 09 00 01 00 00 00 00 "+\r
- "00 00 00 09 "+//meterId\r
- "00 58 "+//len\r
- "00 00 00 00 00 00 "+//pad\r
- "00 00 00 07 "+//flowCount\r
- "00 01 01 01 01 01 01 01 "+//packetInCount\r
- "00 01 01 01 01 01 01 01 "+//byteInCount\r
- "00 00 00 05 "+//durationSec\r
- "00 00 00 05 "+//durationNsec\r
- "00 01 01 01 01 01 01 01 "+//packetBandCount_01\r
- "00 01 01 01 01 01 01 01 "+//byteBandCount_01\r
- "00 02 02 02 02 02 02 02 "+//packetBandCount_02\r
- "00 02 02 02 02 02 02 02 "+//byteBandCount_02\r
- "00 03 03 03 03 03 03 03 "+//packetBandCount_03\r
- "00 03 03 03 03 03 03 03"//byteBandCount_03\r
- );\r
- \r
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
- \r
- BufferHelper.checkHeaderV13(builtByFactory);\r
- Assert.assertEquals("Wrong type", 9, builtByFactory.getType().getIntValue());\r
- Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
- \r
- MultipartReplyMeter message = (MultipartReplyMeter) builtByFactory.getMultipartReplyBody();\r
- \r
- Assert.assertEquals("Wrong meterId", 9, \r
- message.getMeterStats().get(0).getMeterId().getValue().intValue());\r
- Assert.assertEquals("Wrong flowCount", 7, \r
- message.getMeterStats().get(0).getFlowCount().intValue());\r
- Assert.assertEquals("Wrong packetInCount", \r
- new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
- message.getMeterStats().get(0).getPacketInCount());\r
- Assert.assertEquals("Wrong byteInCount", \r
- new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
- message.getMeterStats().get(0).getByteInCount());\r
- Assert.assertEquals("Wrong durationSec", 5, \r
- message.getMeterStats().get(0).getDurationSec().intValue());\r
- Assert.assertEquals("Wrong durationNsec", 5, \r
- message.getMeterStats().get(0).getDurationNsec().intValue());\r
- Assert.assertEquals("Wrong packetBandCount_01", \r
- new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
- message.getMeterStats().get(0).getMeterBandStats().get(0).getPacketBandCount());\r
- Assert.assertEquals("Wrong byteBandCount_01", \r
- new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
- message.getMeterStats().get(0).getMeterBandStats().get(0).getByteBandCount());\r
- Assert.assertEquals("Wrong packetBandCount_02", \r
- new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), \r
- message.getMeterStats().get(0).getMeterBandStats().get(1).getPacketBandCount());\r
- Assert.assertEquals("Wrong byteBandCount_02", \r
- new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), \r
- message.getMeterStats().get(0).getMeterBandStats().get(1).getByteBandCount());\r
- Assert.assertEquals("Wrong packetBandCount_03", \r
- new BigInteger(new byte[]{0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), \r
- message.getMeterStats().get(0).getMeterBandStats().get(2).getPacketBandCount());\r
- Assert.assertEquals("Wrong byteBandCount_03", \r
- new BigInteger(new byte[]{0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), \r
- message.getMeterStats().get(0).getMeterBandStats().get(2).getByteBandCount());\r
- }\r
- \r
- /**\r
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
- */\r
- @Test\r
- public void testMultipartReplyMeterBodyMulti(){\r
- ByteBuf bb = BufferHelper.buildBuffer("00 09 00 01 00 00 00 00 "+\r
- "00 00 00 09 "+//meterId_0\r
- "00 58 "+//len_0\r
- "00 00 00 00 00 00 "+//pad_0\r
- "00 00 00 07 "+//flowCount_0\r
- "00 01 01 01 01 01 01 01 "+//packetInCount_0\r
- "00 01 01 01 01 01 01 01 "+//byteInCount_0\r
- "00 00 00 05 "+//durationSec_0\r
- "00 00 00 05 "+//durationNsec_0\r
- "00 01 01 01 01 01 01 01 "+//packetBandCount_01\r
- "00 01 01 01 01 01 01 01 "+//byteBandCount_01\r
- "00 02 02 02 02 02 02 02 "+//packetBandCount_02\r
- "00 02 02 02 02 02 02 02 "+//byteBandCount_02\r
- "00 03 03 03 03 03 03 03 "+//packetBandCount_03\r
- "00 03 03 03 03 03 03 03 "+//byteBandCount_03\r
- "00 00 00 08 "+//meterId_1\r
- "00 58 "+//len_1\r
- "00 00 00 00 00 00 "+//pad_1\r
- "00 00 00 07 "+//flowCount_1\r
- "00 01 01 01 01 01 01 01 "+//packetInCount_1\r
- "00 01 01 01 01 01 01 01 "+//byteInCount_1\r
- "00 00 00 05 "+//durationSec_1\r
- "00 00 00 05 "+//durationNsec_1\r
- "00 01 01 01 01 01 01 01 "+//packetBandCount_11\r
- "00 01 01 01 01 01 01 01 "+//byteBandCount_11\r
- "00 02 02 02 02 02 02 02 "+//packetBandCount_12\r
- "00 02 02 02 02 02 02 02 "+//byteBandCount_12\r
- "00 03 03 03 03 03 03 03 "+//packetBandCount_13\r
- "00 03 03 03 03 03 03 03"//byteBandCount_13\r
- );\r
- \r
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
- \r
- BufferHelper.checkHeaderV13(builtByFactory);\r
- Assert.assertEquals("Wrong type", 9, builtByFactory.getType().getIntValue());\r
- Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
- \r
- MultipartReplyMeter message = (MultipartReplyMeter) builtByFactory.getMultipartReplyBody();\r
- \r
- Assert.assertEquals("Wrong meterId", 9, \r
- message.getMeterStats().get(0).getMeterId().getValue().intValue());\r
- Assert.assertEquals("Wrong flowCount", 7, \r
- message.getMeterStats().get(0).getFlowCount().intValue());\r
- Assert.assertEquals("Wrong packetInCount", \r
- new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
- message.getMeterStats().get(0).getPacketInCount());\r
- Assert.assertEquals("Wrong byteInCount", \r
- new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
- message.getMeterStats().get(0).getByteInCount());\r
- Assert.assertEquals("Wrong durationSec", 5, \r
- message.getMeterStats().get(0).getDurationSec().intValue());\r
- Assert.assertEquals("Wrong durationNsec", 5, \r
- message.getMeterStats().get(0).getDurationNsec().intValue());\r
- Assert.assertEquals("Wrong packetBandCount_01", \r
- new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
- message.getMeterStats().get(0).getMeterBandStats().get(0).getPacketBandCount());\r
- Assert.assertEquals("Wrong byteBandCount_01", \r
- new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
- message.getMeterStats().get(0).getMeterBandStats().get(0).getByteBandCount());\r
- Assert.assertEquals("Wrong packetBandCount_02", \r
- new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), \r
- message.getMeterStats().get(0).getMeterBandStats().get(1).getPacketBandCount());\r
- Assert.assertEquals("Wrong byteBandCount_02", \r
- new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), \r
- message.getMeterStats().get(0).getMeterBandStats().get(1).getByteBandCount());\r
- Assert.assertEquals("Wrong packetBandCount_03", \r
- new BigInteger(new byte[]{0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), \r
- message.getMeterStats().get(0).getMeterBandStats().get(2).getPacketBandCount());\r
- Assert.assertEquals("Wrong byteBandCount_03", \r
- new BigInteger(new byte[]{0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), \r
- message.getMeterStats().get(0).getMeterBandStats().get(2).getByteBandCount());\r
- \r
- Assert.assertEquals("Wrong meterId", 8, \r
- message.getMeterStats().get(1).getMeterId().getValue().intValue());\r
- Assert.assertEquals("Wrong flowCount", 7, \r
- message.getMeterStats().get(1).getFlowCount().intValue());\r
- Assert.assertEquals("Wrong packetInCount", \r
- new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
- message.getMeterStats().get(1).getPacketInCount());\r
- Assert.assertEquals("Wrong byteInCount", \r
- new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
- message.getMeterStats().get(1).getByteInCount());\r
- Assert.assertEquals("Wrong durationSec", 5, \r
- message.getMeterStats().get(1).getDurationSec().intValue());\r
- Assert.assertEquals("Wrong durationNsec", 5, \r
- message.getMeterStats().get(1).getDurationNsec().intValue());\r
- Assert.assertEquals("Wrong packetBandCount_01", \r
- new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
- message.getMeterStats().get(1).getMeterBandStats().get(0).getPacketBandCount());\r
- Assert.assertEquals("Wrong byteBandCount_01", \r
- new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
- message.getMeterStats().get(1).getMeterBandStats().get(0).getByteBandCount());\r
- Assert.assertEquals("Wrong packetBandCount_02", \r
- new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), \r
- message.getMeterStats().get(1).getMeterBandStats().get(1).getPacketBandCount());\r
- Assert.assertEquals("Wrong byteBandCount_02", \r
- new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), \r
- message.getMeterStats().get(1).getMeterBandStats().get(1).getByteBandCount());\r
- Assert.assertEquals("Wrong packetBandCount_03", \r
- new BigInteger(new byte[]{0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), \r
- message.getMeterStats().get(1).getMeterBandStats().get(2).getPacketBandCount());\r
- Assert.assertEquals("Wrong byteBandCount_03", \r
- new BigInteger(new byte[]{0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), \r
- message.getMeterStats().get(1).getMeterBandStats().get(2).getByteBandCount());\r
- }\r
- \r
- /**\r
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
- */\r
- @Test\r
- public void testMultipartReplyMeterConfigBody(){\r
- ByteBuf bb = BufferHelper.buildBuffer("00 0A 00 01 00 00 00 00 "+\r
- "00 38 "+//len\r
- "00 0A "+//flags\r
- "00 00 00 09 "+//meterId\r
- "00 01 "+//meterBandDrop.type\r
- "00 10 "+//meterBandDrop.len\r
- "00 00 00 11 "+//meterBandDrop.rate\r
- "00 00 00 20 "+//meterBandDrop.burstSize\r
- "00 00 00 00 "+//meterBandDrop.pad\r
- "00 02 "+//meterBandDscp.type\r
- "00 10 "+//meterBandDscp.len\r
- "00 00 00 11 "+//meterBandDscp.rate\r
- "00 00 00 20 "+//meterBandDscp.burstSize\r
- "04 "+//meterBandDscp.precLevel\r
- "00 00 00 "+//meterBandDscp.pad\r
- "FF FF "+//meterBandExperimenter.type\r
- "00 10 "+//meterBandExperimenter.len\r
- "00 00 00 11 "+//meterBandExperimenter.rate\r
- "00 00 00 20 "+//meterBandExperimenter.burstSize\r
- "00 00 00 04"//meterBandExperimenter.experimenter\r
- );\r
- \r
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
- \r
- BufferHelper.checkHeaderV13(builtByFactory);\r
- Assert.assertEquals("Wrong type", 10, builtByFactory.getType().getIntValue());\r
- Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
- \r
- MultipartReplyMeterConfig message = (MultipartReplyMeterConfig) builtByFactory.getMultipartReplyBody();\r
- \r
- Assert.assertEquals("Wrong flags", new MeterFlags(false, false, true, true),\r
- message.getMeterConfig().get(0).getFlags());\r
- Assert.assertEquals("Wrong meterId", 9, \r
- message.getMeterConfig().get(0).getMeterId().getValue().intValue());\r
- \r
- MeterBandDrop meterBandDrop = (MeterBandDrop) message.getMeterConfig().get(0).getBands().get(0).getMeterBand(); \r
- Assert.assertEquals("Wrong meterBandDrop.type", 1, meterBandDrop.getType().getIntValue()); \r
- Assert.assertEquals("Wrong meterBandDrop.rate", 17, meterBandDrop.getRate().intValue());\r
- Assert.assertEquals("Wrong meterBandDrop.burstSize", 32, meterBandDrop.getBurstSize().intValue());\r
- \r
- MeterBandDscpRemark meterBandDscp = (MeterBandDscpRemark) message.getMeterConfig().get(0).getBands().get(1).getMeterBand(); \r
- Assert.assertEquals("Wrong meterBandDscp.type", 2, meterBandDscp.getType().getIntValue()); \r
- Assert.assertEquals("Wrong meterBandDscp.rate", 17, meterBandDscp.getRate().intValue());\r
- Assert.assertEquals("Wrong meterBandDscp.burstSize", 32, meterBandDscp.getBurstSize().intValue());\r
- Assert.assertEquals("Wrong meterBandDscp.precLevel", 4, meterBandDscp.getPrecLevel().intValue());\r
- \r
- MeterBandExperimenter meterBandExperimenter = (MeterBandExperimenter) message.getMeterConfig().get(0).getBands().get(2).getMeterBand(); \r
- Assert.assertEquals("Wrong meterBandExperimenter.type", 0xFFFF, meterBandExperimenter.getType().getIntValue()); \r
- Assert.assertEquals("Wrong meterBandExperimenter.rate", 17, meterBandExperimenter.getRate().intValue());\r
- Assert.assertEquals("Wrong meterBandExperimenter.burstSize", 32, meterBandExperimenter.getBurstSize().intValue());\r
- Assert.assertEquals("Wrong meterBandExperimenter.experimenter", 4, meterBandExperimenter.getExperimenter().intValue());\r
- }\r
- \r
- /**\r
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
- */\r
- @Test\r
- public void testMultipartReplyMeterConfigBodyMulti(){\r
- ByteBuf bb = BufferHelper.buildBuffer("00 0A 00 01 00 00 00 00 "+\r
- "00 38 "+//len\r
- "00 06 "+//flags\r
- "00 00 00 09 "+//meterId\r
- "00 01 "+//meterBandDrop.type\r
- "00 10 "+//meterBandDrop.len\r
- "00 00 00 11 "+//meterBandDrop.rate\r
- "00 00 00 20 "+//meterBandDrop.burstSize\r
- "00 00 00 00 "+//meterBandDrop.pad\r
- "00 02 "+//meterBandDscp.type\r
- "00 10 "+//meterBandDscp.len\r
- "00 00 00 11 "+//meterBandDscp.rate\r
- "00 00 00 20 "+//meterBandDscp.burstSize\r
- "04 "+//meterBandDscp.precLevel\r
- "00 00 00 "+//meterBandDscp.pad\r
- "FF FF "+//meterBandExperimenter.type\r
- "00 10 "+//meterBandExperimenter.len\r
- "00 00 00 11 "+//meterBandExperimenter.rate\r
- "00 00 00 20 "+//meterBandExperimenter.burstSize\r
- "00 00 00 04 "+//meterBandExperimenter.experimenter\r
- \r
- "00 18 "+//len01\r
- "00 03 "+//flags01\r
- "00 00 00 07 "+//meterId01\r
- "00 02 "+//meterBandDscp01.type\r
- "00 10 "+//meterBandDscp01.len\r
- "00 00 00 11 "+//meterBandDscp01.rate\r
- "00 00 00 20 "+//meterBandDscp01.burstSize\r
- "04 "+//meterBandDscp01.precLevel\r
- "00 00 00"//meterBandDscp01.pad\r
- );\r
- \r
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
- \r
- BufferHelper.checkHeaderV13(builtByFactory);\r
- Assert.assertEquals("Wrong type", 10, builtByFactory.getType().getIntValue());\r
- Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
- \r
- MultipartReplyMeterConfig message = (MultipartReplyMeterConfig) builtByFactory.getMultipartReplyBody();\r
- \r
- Assert.assertEquals("Wrong flags", new MeterFlags(true, false, true, false), \r
- message.getMeterConfig().get(0).getFlags());\r
- Assert.assertEquals("Wrong meterId", 9, \r
- message.getMeterConfig().get(0).getMeterId().getValue().intValue());\r
- \r
- MeterBandDrop meterBandDrop = (MeterBandDrop) message.getMeterConfig().get(0).getBands().get(0).getMeterBand(); \r
- Assert.assertEquals("Wrong meterBandDrop.type", 1, meterBandDrop.getType().getIntValue()); \r
- Assert.assertEquals("Wrong meterBandDrop.rate", 17, meterBandDrop.getRate().intValue());\r
- Assert.assertEquals("Wrong meterBandDrop.burstSize", 32, meterBandDrop.getBurstSize().intValue());\r
- \r
- MeterBandDscpRemark meterBandDscp = (MeterBandDscpRemark) message.getMeterConfig().get(0).getBands().get(1).getMeterBand(); \r
- Assert.assertEquals("Wrong meterBandDscp.type", 2, meterBandDscp.getType().getIntValue()); \r
- Assert.assertEquals("Wrong meterBandDscp.rate", 17, meterBandDscp.getRate().intValue());\r
- Assert.assertEquals("Wrong meterBandDscp.burstSize", 32, meterBandDscp.getBurstSize().intValue());\r
- Assert.assertEquals("Wrong meterBandDscp.precLevel", 4, meterBandDscp.getPrecLevel().intValue());\r
- \r
- MeterBandExperimenter meterBandExperimenter = (MeterBandExperimenter) message.getMeterConfig().get(0).getBands().get(2).getMeterBand(); \r
- Assert.assertEquals("Wrong meterBandExperimenter.type", 0xFFFF, meterBandExperimenter.getType().getIntValue()); \r
- Assert.assertEquals("Wrong meterBandExperimenter.rate", 17, meterBandExperimenter.getRate().intValue());\r
- Assert.assertEquals("Wrong meterBandExperimenter.burstSize", 32, meterBandExperimenter.getBurstSize().intValue());\r
- Assert.assertEquals("Wrong meterBandExperimenter.experimenter", 4, meterBandExperimenter.getExperimenter().intValue());\r
- \r
- LOGGER.info(message.getMeterConfig().get(0).getFlags().toString());\r
- Assert.assertEquals("Wrong flags01", new MeterFlags(false, true, true, false),\r
- message.getMeterConfig().get(1).getFlags());\r
- Assert.assertEquals("Wrong meterId01", 7, \r
- message.getMeterConfig().get(1).getMeterId().getValue().intValue());\r
- \r
- MeterBandDscpRemark meterBandDscp01 = (MeterBandDscpRemark) message.getMeterConfig().get(1).getBands().get(0).getMeterBand(); \r
- Assert.assertEquals("Wrong meterBandDscp01.type", 2, meterBandDscp01.getType().getIntValue()); \r
- Assert.assertEquals("Wrong meterBandDscp01.rate", 17, meterBandDscp01.getRate().intValue());\r
- Assert.assertEquals("Wrong meterBandDscp01.burstSize", 32, meterBandDscp01.getBurstSize().intValue());\r
- Assert.assertEquals("Wrong meterBandDscp01.precLevel", 4, meterBandDscp01.getPrecLevel().intValue());\r
- \r
- }\r
- \r
- /**\r
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
- */\r
- @Test\r
- public void testMultipartReplyExperimenterBody(){\r
- ByteBuf bb = BufferHelper.buildBuffer("FF FF 00 01 00 00 00 00 "+\r
- "00 00 00 0F "+//experimenterId\r
- "00 00 00 FF "+//expType\r
- "00 00 01 01 00 00 01 01"\r
- );\r
- \r
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
- \r
- BufferHelper.checkHeaderV13(builtByFactory);\r
- Assert.assertEquals("Wrong type", 0xFFFF, builtByFactory.getType().getIntValue());\r
- Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
- \r
- MultipartReplyExperimenter message = (MultipartReplyExperimenter) builtByFactory.getMultipartReplyBody();\r
- \r
- Assert.assertEquals("Wrong experimenterId", 15, message.getExperimenter().intValue());\r
- Assert.assertEquals("Wrong expType", 255, message.getExpType().intValue());\r
- Assert.assertArrayEquals("Wrong data", new byte[]{0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01}, \r
- message.getData());\r
- }\r
- \r
- /**\r
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
- */\r
- @Test\r
- public void testMultipartReplyPortDescBody(){\r
- final byte MAX_PORT_NAME_LEN = 16;\r
- ByteBuf bb = BufferHelper.buildBuffer("00 0D 00 01 00 00 00 00 "+\r
- "00 01 02 03 "+ //portNo\r
- "00 00 00 00 "+ //padding01\r
- "08 00 27 00 B0 EB " + //mac address\r
- "00 00 "); //padding02\r
- //port name\r
- String portName = "SampleText";\r
- byte[] portNameBytes = new byte[MAX_PORT_NAME_LEN];\r
- portNameBytes = portName.getBytes();\r
- bb.writeBytes(portNameBytes);\r
- ByteBufUtils.padBuffer((MAX_PORT_NAME_LEN - portNameBytes.length), bb);\r
- \r
- ByteBuf bb2 = BufferHelper.buildBuffer("00 00 00 41 " + //port config\r
- "00 00 00 05 " + //port state\r
- "00 00 00 81 " + //current features\r
- "00 00 00 81 " + //advertised features\r
- "00 00 00 81 " + //supported features\r
- "00 00 00 81 " + //peer features\r
- "00 00 00 81 " + //curr speed\r
- "00 00 00 80" //max speed\r
- );\r
- bb.writeBytes(bb2.copy(4, bb2.readableBytes()-4));//excluding version and xid\r
- \r
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
- \r
- BufferHelper.checkHeaderV13(builtByFactory);\r
- Assert.assertEquals("Wrong type", 13, builtByFactory.getType().getIntValue());\r
- Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
- \r
- MultipartReplyPortDesc message = (MultipartReplyPortDesc) builtByFactory.getMultipartReplyBody();\r
- \r
- Assert.assertEquals("Wrong portNo", 66051L, message.getPorts().get(0).getPortNo().longValue());\r
- Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:B0:EB"), \r
- message.getPorts().get(0).getHwAddr());\r
- Assert.assertEquals("Wrong portName", "SampleText", \r
- message.getPorts().get(0).getName());\r
- Assert.assertEquals("Wrong portConfig", new PortConfig(false, true, false, true), \r
- message.getPorts().get(0).getConfig());\r
- Assert.assertEquals("Wrong portState", new PortState(false, true, true),\r
- message.getPorts().get(0).getState());\r
- Assert.assertEquals("Wrong currentFeatures", new PortFeatures(true, false, false, false,\r
- false, false, false, true, \r
- false, false, false, false, \r
- false, false, false, false), \r
- message.getPorts().get(0).getCurrentFeatures());\r
- Assert.assertEquals("Wrong advertisedFeatures", \r
- new PortFeatures(true, false, false, false,\r
- false, false, false, true, \r
- false, false, false, false, \r
- false, false, false, false), \r
- message.getPorts().get(0).getAdvertisedFeatures());\r
- Assert.assertEquals("Wrong supportedFeatures", \r
- new PortFeatures(true, false, false, false,\r
- false, false, false, true, \r
- false, false, false, false, \r
- false, false, false, false), \r
- message.getPorts().get(0).getSupportedFeatures());\r
- Assert.assertEquals("Wrong peerFeatures", \r
- new PortFeatures(true, false, false, false,\r
- false, false, false, true, \r
- false, false, false, false, \r
- false, false, false, false), \r
- message.getPorts().get(0).getPeerFeatures());\r
- Assert.assertEquals("Wrong currSpeed", 129L, message.getPorts().get(0).getCurrSpeed().longValue());\r
- Assert.assertEquals("Wrong maxSpeed", 128L, message.getPorts().get(0).getMaxSpeed().longValue());\r
- }\r
- \r
- /**\r
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
- * Test covers bodies of actions Output, Copy TTL Out, Copy TTL In\r
- */\r
- @Test\r
- public void testMultipartReplyGroupDescBody01(){\r
- ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "+\r
- "00 38 "+//len\r
- "01 "+//type\r
- "00 "+//pad\r
- "00 00 00 08 "+//groupId\r
- "00 30 "+//bucketLen\r
- "00 06 "+//bucketWeight\r
- "00 00 00 05 "+//bucketWatchPort\r
- "00 00 00 04 "+//bucketWatchGroup\r
- "00 00 00 00 "+//bucketPad\r
- "00 00 "+//outputType\r
- "00 10 "+//outputLen\r
- "00 00 10 FF "+//outputPort\r
- "FF FF "+//outputMaxLen\r
- "00 00 00 00 00 00 "+//outputPad\r
- "00 0B "+//copyTTLOutType\r
- "00 08 "+//copyTTLOutLen\r
- "00 00 00 00 "+//copyTTLOutPad\r
- "00 0C "+//copyTTLIntType\r
- "00 08 "+//copyTTLIntLen\r
- "00 00 00 00"//copyTTLInPad\r
- );\r
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
- \r
- BufferHelper.checkHeaderV13(builtByFactory);\r
- Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());\r
- Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
- \r
- MultipartReplyGroupDesc message = (MultipartReplyGroupDesc) builtByFactory.getMultipartReplyBody();\r
- \r
- Assert.assertEquals("Wrong type", 1, \r
- message.getGroupDesc().get(0).getType().getIntValue());\r
- Assert.assertEquals("Wrong groupId", 8, \r
- message.getGroupDesc().get(0).getGroupId().getValue().intValue());\r
- Assert.assertEquals("Wrong bucketWeight", 6, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());\r
- Assert.assertEquals("Wrong bucketWatchPort", 5, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().\r
- getValue().intValue());\r
- Assert.assertEquals("Wrong bucketWatchGroup", 4, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());\r
- \r
- Assert.assertEquals("Wrong outputType", Output.class, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).\r
- getAction().getType());\r
- \r
- Assert.assertEquals("Wrong outputPort", 4351, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).\r
- getAction().getAugmentation(PortAction.class).\r
- getPort().getValue().intValue());\r
- \r
- Assert.assertEquals("Wrong outputMaxLen", 65535, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).\r
- getAction().getAugmentation(MaxLengthAction.class).\r
- getMaxLength().intValue());\r
- \r
- Assert.assertEquals("Wrong copyTtlOutType", CopyTtlOut.class, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1).\r
- getAction().getType());\r
- \r
- Assert.assertEquals("Wrong copyTtlInType", CopyTtlIn.class, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(2).\r
- getAction().getType());\r
- }\r
- \r
- /**\r
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
- * Test covers bodies of actions Set MPLS TTL , Dec MPLS TTL, Push VLAN. Push MPLS, Push PBB\r
- */\r
- @Test\r
- public void testMultipartReplyGroupDescBody02(){\r
- ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "+\r
- "00 40 "+//len\r
- "01 "+//type\r
- "00 "+//pad\r
- "00 00 00 08 "+//groupId\r
- "00 38 "+//bucketLen\r
- "00 06 "+//bucketWeight\r
- "00 00 00 05 "+//bucketWatchPort\r
- "00 00 00 04 "+//bucketWatchGroup\r
- "00 00 00 00 "+//bucketPad\r
- "00 0F "+//setMplsTtlType\r
- "00 08 "+//setMplsTtlLen\r
- "09 "+//setMplsTtlMPLS_TTL\r
- "00 00 00 "+//setMplsTtlPad\r
- "00 10 "+//decMplsTtlType\r
- "00 08 "+//decMplsTtlLen\r
- "00 00 00 00 "+//decMplsTtlPad\r
- "00 11 "+//pushVlanType\r
- "00 08 "+//pushVlanLen\r
- "00 20 "+//pushVlanEthertype\r
- "00 00 "+//pushVlanPad\r
- "00 13 "+//pushMplsType\r
- "00 08 "+//pushMplsLen\r
- "00 FF "+//pushMplsEthertype\r
- "00 00 "+//pushMplsPad\r
- "00 1A "+//pushPbbType\r
- "00 08 "+//pushPbbLen\r
- "0F FF "+//pushPbbEthertype\r
- "00 00"//pushPbbPad\r
- );\r
- \r
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
- \r
- BufferHelper.checkHeaderV13(builtByFactory);\r
- Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());\r
- Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
- \r
- MultipartReplyGroupDesc message = (MultipartReplyGroupDesc) builtByFactory.getMultipartReplyBody();\r
- \r
- Assert.assertEquals("Wrong type", 1, \r
- message.getGroupDesc().get(0).getType().getIntValue());\r
- Assert.assertEquals("Wrong groupId", 8, \r
- message.getGroupDesc().get(0).getGroupId().getValue().intValue());\r
- Assert.assertEquals("Wrong bucketWeight", 6, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());\r
- Assert.assertEquals("Wrong bucketWatchPort", 5, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().\r
- getValue().intValue());\r
- Assert.assertEquals("Wrong bucketWatchGroup", 4, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());\r
- \r
- \r
- Assert.assertEquals("Wrong setMplsTtlType", SetMplsTtl.class, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).\r
- getAction().getType());\r
- \r
- Assert.assertEquals("Wrong setMplsTtlMPLS_TTL", 9, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).\r
- getAction().getAugmentation(MplsTtlAction.class).\r
- getMplsTtl().intValue());\r
- \r
- Assert.assertEquals("Wrong decMplsTtlType", DecMplsTtl.class, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1).\r
- getAction().getType());\r
- \r
- Assert.assertEquals("Wrong pushVlanType", PushVlan.class, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(2).\r
- getAction().getType());\r
- \r
- Assert.assertEquals("Wrong pushVlanEthertype", 32, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(2).\r
- getAction().getAugmentation(EthertypeAction.class).\r
- getEthertype().getValue().intValue());\r
- \r
- Assert.assertEquals("Wrong pushMplsType", PushMpls.class, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(3).\r
- getAction().getType());\r
- \r
- Assert.assertEquals("Wrong pushMplsEthertype", 255, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(3).\r
- getAction().getAugmentation(EthertypeAction.class).\r
- getEthertype().getValue().intValue());\r
- \r
- Assert.assertEquals("Wrong pushPbbType", PushPbb.class, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(4).\r
- getAction().getType());\r
- \r
- Assert.assertEquals("Wrong pushPbbEthertype", 4095, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(4).\r
- getAction().getAugmentation(EthertypeAction.class).\r
- getEthertype().getValue().intValue());\r
- \r
- }\r
- \r
- /**\r
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
- * Test covers bodies of actions Pop VLAN, Pop PBB, Pop MPLS, Group, Dec NW TTL\r
- */\r
- @Test\r
- public void testMultipartReplyGroupDescBody03(){\r
- ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "+\r
- "00 48 "+//len\r
- "01 "+//type\r
- "00 "+//pad\r
- "00 00 00 08 "+//groupId\r
- "00 40 "+//bucketLen\r
- "00 06 "+//bucketWeight\r
- "00 00 00 05 "+//bucketWatchPort\r
- "00 00 00 04 "+//bucketWatchGroup\r
- "00 00 00 00 "+//bucketPad\r
- "00 12 "+//popVlanType\r
- "00 08 "+//popVlanLen\r
- "00 00 00 00 "+//popVlanPad\r
- "00 1B "+//popPbbType\r
- "00 08 "+//popPbbLen\r
- "00 00 00 00 "+//popPbbPad\r
- "00 14 "+//popMplsType\r
- "00 08 "+//popMplsLen\r
- "00 CF "+//popMplsEthertype\r
- "00 00 "+//popMplsPad\r
- "00 15 "+//setQueueType\r
- "00 08 "+//setQueueLen\r
- "00 CF 00 00 "+//setQueueQueueId\r
- "00 16 "+//groupType\r
- "00 08 "+//groupLen\r
- "00 CF 00 00 "+//groupGroupId\r
- "00 18 "+//decNwTtlType\r
- "00 08 "+//decNwTtlLen\r
- "00 00 00 00"//decNwTtlPad\r
- );\r
- \r
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
- \r
- BufferHelper.checkHeaderV13(builtByFactory);\r
- Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());\r
- Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
- \r
- MultipartReplyGroupDesc message = (MultipartReplyGroupDesc) builtByFactory.getMultipartReplyBody();\r
- \r
- Assert.assertEquals("Wrong type", 1, \r
- message.getGroupDesc().get(0).getType().getIntValue());\r
- Assert.assertEquals("Wrong groupId", 8, \r
- message.getGroupDesc().get(0).getGroupId().getValue().intValue());\r
- Assert.assertEquals("Wrong bucketWeight", 6, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());\r
- Assert.assertEquals("Wrong bucketWatchPort", 5, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().\r
- getValue().intValue());\r
- Assert.assertEquals("Wrong bucketWatchGroup", 4, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());\r
- \r
- Assert.assertEquals("Wrong popVlanType", PopVlan.class, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).\r
- getAction().getType());\r
- \r
- Assert.assertEquals("Wrong popPbbType", PopPbb.class, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1).\r
- getAction().getType());\r
- \r
- Assert.assertEquals("Wrong popMplsType", PopMpls.class, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(2).\r
- getAction().getType());\r
- \r
- Assert.assertEquals("Wrong popMplsEthertype", 207, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(2).\r
- getAction().getAugmentation(EthertypeAction.class).\r
- getEthertype().getValue().intValue());\r
- \r
- Assert.assertEquals("Wrong setQueueType", SetQueue.class, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(3).\r
- getAction().getType());\r
- \r
- Assert.assertEquals("Wrong setQueueQueueId", 13565952, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(3).\r
- getAction().getAugmentation(QueueIdAction.class).\r
- getQueueId().intValue());\r
- \r
- Assert.assertEquals("Wrong groupType", Group.class, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(4).\r
- getAction().getType());\r
- \r
- Assert.assertEquals("Wrong groupGroupId", 13565952, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(4).\r
- getAction().getAugmentation(GroupIdAction.class).\r
- getGroupId().intValue());\r
- \r
- Assert.assertEquals("Wrong decNwTtlType", DecNwTtl.class, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(5).\r
- getAction().getType());\r
- }\r
- \r
- /**\r
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
- * Test covers bodies of actions NW TTL, Experimenter\r
- */\r
- @Test\r
- public void testMultipartReplyGroupDescBody04(){\r
- ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "+\r
- "00 30 "+//len\r
- "01 "+//type\r
- "00 "+//pad\r
- "00 00 00 08 "+//groupId\r
- "00 28 "+//bucketLen\r
- "00 06 "+//bucketWeight\r
- "00 00 00 05 "+//bucketWatchPort\r
- "00 00 00 04 "+//bucketWatchGroup\r
- "00 00 00 00 "+//bucketPad\r
- "00 17 "+//nwTTlType\r
- "00 08 "+//nwTTlLen\r
- "0E "+//nwTTlnwTTL\r
- "00 00 00 "+//nwTTlPad\r
- "00 19 "+//setFieldType\r
- "00 10 "+//setFieldLen\r
- "80 00 "+//setFieldOXMClass\r
- "00 "+//setFieldOXMField\r
- "04 "+//setFieldOXMLength\r
- "00 00 00 FF "+ //setFieldPort\r
- "00 00 00 00"\r
- );\r
- \r
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
- \r
- BufferHelper.checkHeaderV13(builtByFactory);\r
- Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());\r
- Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
- \r
- MultipartReplyGroupDesc message = (MultipartReplyGroupDesc) builtByFactory.getMultipartReplyBody();\r
- \r
- Assert.assertEquals("Wrong type", 1, \r
- message.getGroupDesc().get(0).getType().getIntValue());\r
- Assert.assertEquals("Wrong groupId", 8, \r
- message.getGroupDesc().get(0).getGroupId().getValue().intValue());\r
- Assert.assertEquals("Wrong bucketWeight", 6, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());\r
- Assert.assertEquals("Wrong bucketWatchPort", 5, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().\r
- getValue().intValue());\r
- Assert.assertEquals("Wrong bucketWatchGroup", 4, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());\r
- \r
- Assert.assertEquals("Wrong nwTTlType", SetNwTtl.class, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).\r
- getAction().getType());\r
- \r
- Assert.assertEquals("Wrong nwTTlnwTTL", 14, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).\r
- getAction().getAugmentation(NwTtlAction.class).getNwTtl().intValue());\r
- \r
- Assert.assertEquals("Wrong setFieldType", SetField.class, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1).\r
- getAction().getType());\r
- \r
- Assert.assertEquals("Wrong setFieldOXMClass", OpenflowBasicClass.class, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1).\r
- getAction().getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0).getOxmClass());\r
- \r
- Assert.assertEquals("Wrong setFieldOXMField", InPort.class, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1).\r
- getAction().getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0).getOxmMatchField());\r
- \r
- Assert.assertEquals("Wrong setFieldOXMValue", 255, \r
- message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1).\r
- getAction().getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0).\r
- getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue());\r
- }\r
-}\r
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+
+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.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.MeterFlags;
+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.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;
+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.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.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.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.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.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;
+
+/**
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public class MultipartReplyMessageFactoryTest {
+
+ private OFDeserializer<MultipartReplyMessage> 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 testMultipartReplyDescBody(){
+ 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());
+ 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());
+ 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 testMultipartReplyAggregateBody(){
+ ByteBuf bb = BufferHelper.buildBuffer("00 02 00 01 00 00 00 00 "+
+ "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.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}),
+ message.getPacketCount());
+ 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,
+ message.getFlowCount().intValue());
+ }
+
+ /**
+ * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+ */
+ @Test
+ public void testMultipartReplyTableBody(){
+ ByteBuf bb = BufferHelper.buildBuffer("00 03 00 01 00 00 00 00 "+
+ "08 "+//tableId
+ "00 00 00 "+//pad
+ "00 00 00 10 "+//activeCount
+ "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}),
+ message.getTableStats().get(0).getLookupCount());
+ 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
+ */
+ @Test
+ public void testMultipartReplyPortStatsBody(){
+ ByteBuf bb = BufferHelper.buildBuffer("00 04 00 01 00 00 00 00 "+
+ "00 00 00 FF "+//portNo
+ "00 00 00 00 "+//pad
+ "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.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}),
+ message.getPortStats().get(0).getRxPackets());
+ 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}),
+ message.getPortStats().get(0).getRxBytes());
+ 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}),
+ message.getPortStats().get(0).getRxDropped());
+ 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}),
+ message.getPortStats().get(0).getRxErrors());
+ 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}),
+ message.getPortStats().get(0).getRxFrameErr());
+ 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}),
+ message.getPortStats().get(0).getRxCrcErr());
+ 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
+ */
+ @Test
+ public void testMultipartReplyQueueBody(){
+ ByteBuf bb = BufferHelper.buildBuffer("00 05 00 01 00 00 00 00 "+
+ "00 00 00 FF "+//portNo
+ "00 00 00 10 "+//queueId
+ "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.deserialize(multipartFactory, bb);
+
+ BufferHelper.checkHeaderV13(builtByFactory);
+ Assert.assertEquals("Wrong type", 0x05, builtByFactory.getType().getIntValue());
+ Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
+ 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(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}),
+ message.getQueueStats().get(0).getTxPackets());
+ 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
+ */
+ @Test
+ public void testMultipartReplyGroupBody(){
+ ByteBuf bb = BufferHelper.buildBuffer("00 06 00 01 00 00 00 00 "+
+ "00 48 "+//length
+ "00 00 "+//pad1
+ "00 00 00 10 "+//groupId
+ "00 00 00 12 "+//refCount
+ "00 00 00 00 "+//pad2
+ "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
+ "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
+ "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
+ "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.deserialize(multipartFactory, bb);
+
+ BufferHelper.checkHeaderV13(builtByFactory);
+ Assert.assertEquals("Wrong type", 0x06, builtByFactory.getType().getIntValue());
+ Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
+ 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(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}),
+ 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}),
+ 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}),
+ 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}),
+ 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}),
+ 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}),
+ message.getGroupStats().get(1).getPacketCount());
+ 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}),
+ 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}),
+ 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}),
+ 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}),
+ message.getGroupStats().get(1).getBucketStats().get(1).getByteCount());
+ }
+
+ /**
+ * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+ */
+ @Test
+ public void testMultipartReplyMeterBody(){
+ ByteBuf bb = BufferHelper.buildBuffer("00 09 00 01 00 00 00 00 "+
+ "00 00 00 09 "+//meterId
+ "00 58 "+//len
+ "00 00 00 00 00 00 "+//pad
+ "00 00 00 07 "+//flowCount
+ "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
+ "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.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,
+ message.getMeterStats().get(0).getMeterId().getValue().intValue());
+ 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}),
+ message.getMeterStats().get(0).getPacketInCount());
+ 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,
+ message.getMeterStats().get(0).getDurationSec().intValue());
+ 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}),
+ 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}),
+ 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}),
+ 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}),
+ 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}),
+ 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}),
+ message.getMeterStats().get(0).getMeterBandStats().get(2).getByteBandCount());
+ }
+
+ /**
+ * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+ */
+ @Test
+ public void testMultipartReplyMeterBodyMulti(){
+ ByteBuf bb = BufferHelper.buildBuffer("00 09 00 01 00 00 00 00 "+
+ "00 00 00 09 "+//meterId_0
+ "00 58 "+//len_0
+ "00 00 00 00 00 00 "+//pad_0
+ "00 00 00 07 "+//flowCount_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
+ "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
+ "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
+ "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.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,
+ message.getMeterStats().get(0).getMeterId().getValue().intValue());
+ 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}),
+ message.getMeterStats().get(0).getPacketInCount());
+ 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,
+ message.getMeterStats().get(0).getDurationSec().intValue());
+ 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}),
+ 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}),
+ 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}),
+ 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}),
+ 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}),
+ 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}),
+ message.getMeterStats().get(0).getMeterBandStats().get(2).getByteBandCount());
+
+ Assert.assertEquals("Wrong meterId", 8,
+ message.getMeterStats().get(1).getMeterId().getValue().intValue());
+ 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}),
+ message.getMeterStats().get(1).getPacketInCount());
+ 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,
+ message.getMeterStats().get(1).getDurationSec().intValue());
+ 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}),
+ 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}),
+ 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}),
+ 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}),
+ 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}),
+ 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}),
+ message.getMeterStats().get(1).getMeterBandStats().get(2).getByteBandCount());
+ }
+
+ /**
+ * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+ */
+ @Test
+ public void testMultipartReplyMeterConfigBody(){
+ ByteBuf bb = BufferHelper.buildBuffer("00 0A 00 01 00 00 00 00 "+
+ "00 28 "+//len
+ "00 0A "+//flags
+ "00 00 00 09 "+//meterId
+ "00 01 "+//meterBandDrop.type
+ "00 10 "+//meterBandDrop.len
+ "00 00 00 11 "+//meterBandDrop.rate
+ "00 00 00 20 "+//meterBandDrop.burstSize
+ "00 00 00 00 "+//meterBandDrop.pad
+ "00 02 "+//meterBandDscp.type
+ "00 10 "+//meterBandDscp.len
+ "00 00 00 11 "+//meterBandDscp.rate
+ "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();
+ 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());
+
+ 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();
+ 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());
+ }
+
+ /**
+ * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+ */
+ @Test
+ public void testMultipartReplyMeterConfigBodyMulti(){
+ ByteBuf bb = BufferHelper.buildBuffer("00 0A 00 01 00 00 00 00 "+
+ "00 28 "+//len
+ "00 06 "+//flags
+ "00 00 00 09 "+//meterId
+ "00 01 "+//meterBandDrop.type
+ "00 10 "+//meterBandDrop.len
+ "00 00 00 11 "+//meterBandDrop.rate
+ "00 00 00 20 "+//meterBandDrop.burstSize
+ "00 00 00 00 "+//meterBandDrop.pad
+ "00 02 "+//meterBandDscp.type
+ "00 10 "+//meterBandDscp.len
+ "00 00 00 11 "+//meterBandDscp.rate
+ "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
+ "00 02 "+//meterBandDscp01.type
+ "00 10 "+//meterBandDscp01.len
+ "00 00 00 11 "+//meterBandDscp01.rate
+ "00 00 00 20 "+//meterBandDscp01.burstSize
+ "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),
+ message.getMeterConfig().get(0).getFlags());
+ 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());
+ 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();
+ 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());
+
+ 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,
+ message.getMeterConfig().get(1).getMeterId().getValue().intValue());
+
+ 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());
+ Assert.assertEquals("Wrong meterBandDscp01.precLevel", 4, meterBandDscp01.getPrecLevel().intValue());
+
+ }
+
+ /**
+ * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+ * Test covers bodies of actions Output, Copy TTL Out, Copy TTL In
+ */
+ @Test
+ public void testMultipartReplyGroupDescBody01(){
+ ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "+
+ "00 38 "+//len
+ "01 "+//type
+ "00 "+//pad
+ "00 00 00 08 "+//groupId
+ "00 30 "+//bucketLen
+ "00 06 "+//bucketWeight
+ "00 00 00 05 "+//bucketWatchPort
+ "00 00 00 04 "+//bucketWatchGroup
+ "00 00 00 00 "+//bucketPad
+ "00 00 "+//outputType
+ "00 10 "+//outputLen
+ "00 00 10 FF "+//outputPort
+ "FF FF "+//outputMaxLen
+ "00 00 00 00 00 00 "+//outputPad
+ "00 0B "+//copyTTLOutType
+ "00 08 "+//copyTTLOutLen
+ "00 00 00 00 "+//copyTTLOutPad
+ "00 0C "+//copyTTLIntType
+ "00 08 "+//copyTTLIntLen
+ "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,
+ 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());
+ 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());
+ }
+
+ /**
+ * 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
+ */
+ @Test
+ public void testMultipartReplyGroupDescBody02(){
+ ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "+
+ "00 40 "+//len
+ "01 "+//type
+ "00 "+//pad
+ "00 00 00 08 "+//groupId
+ "00 38 "+//bucketLen
+ "00 06 "+//bucketWeight
+ "00 00 00 05 "+//bucketWatchPort
+ "00 00 00 04 "+//bucketWatchGroup
+ "00 00 00 00 "+//bucketPad
+ "00 0F "+//setMplsTtlType
+ "00 08 "+//setMplsTtlLen
+ "09 "+//setMplsTtlMPLS_TTL
+ "00 00 00 "+//setMplsTtlPad
+ "00 10 "+//decMplsTtlType
+ "00 08 "+//decMplsTtlLen
+ "00 00 00 00 "+//decMplsTtlPad
+ "00 11 "+//pushVlanType
+ "00 08 "+//pushVlanLen
+ "00 20 "+//pushVlanEthertype
+ "00 00 "+//pushVlanPad
+ "00 13 "+//pushMplsType
+ "00 08 "+//pushMplsLen
+ "00 FF "+//pushMplsEthertype
+ "00 00 "+//pushMplsPad
+ "00 1A "+//pushPbbType
+ "00 08 "+//pushPbbLen
+ "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,
+ 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());
+ 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());
+ }
+
+ /**
+ * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+ * Test covers bodies of actions Pop VLAN, Pop PBB, Pop MPLS, Group, Dec NW TTL
+ */
+ @Test
+ public void testMultipartReplyGroupDescBody03(){
+ ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "+
+ "00 48 "+//len
+ "01 "+//type
+ "00 "+//pad
+ "00 00 00 08 "+//groupId
+ "00 40 "+//bucketLen
+ "00 06 "+//bucketWeight
+ "00 00 00 05 "+//bucketWatchPort
+ "00 00 00 04 "+//bucketWatchGroup
+ "00 00 00 00 "+//bucketPad
+ "00 12 "+//popVlanType
+ "00 08 "+//popVlanLen
+ "00 00 00 00 "+//popVlanPad
+ "00 1B "+//popPbbType
+ "00 08 "+//popPbbLen
+ "00 00 00 00 "+//popPbbPad
+ "00 14 "+//popMplsType
+ "00 08 "+//popMplsLen
+ "00 CF "+//popMplsEthertype
+ "00 00 "+//popMplsPad
+ "00 15 "+//setQueueType
+ "00 08 "+//setQueueLen
+ "00 CF 00 00 "+//setQueueQueueId
+ "00 16 "+//groupType
+ "00 08 "+//groupLen
+ "00 CF 00 00 "+//groupGroupId
+ "00 18 "+//decNwTtlType
+ "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();
+ 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());
+ 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());
+ }
+
+ /**
+ * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+ * Test covers bodies of actions NW TTL, Experimenter
+ */
+ @Test
+ public void testMultipartReplyGroupDescBody04(){
+ ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "+
+ "00 30 "+//len
+ "01 "+//type
+ "00 "+//pad
+ "00 00 00 08 "+//groupId
+ "00 28 "+//bucketLen
+ "00 06 "+//bucketWeight
+ "00 00 00 05 "+//bucketWatchPort
+ "00 00 00 04 "+//bucketWatchGroup
+ "00 00 00 00 "+//bucketPad
+ "00 17 "+//nwTTlType
+ "00 08 "+//nwTTlLen
+ "0E "+//nwTTlnwTTL
+ "00 00 00 "+//nwTTlPad
+ "00 19 "+//setFieldType
+ "00 10 "+//setFieldLen
+ "80 00 "+//setFieldOXMClass
+ "00 "+//setFieldOXMField
+ "04 "+//setFieldOXMLength
+ "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,
+ 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());
+ 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());
+ }
+}