2 * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
11 import io.netty.buffer.ByteBuf;
13 import java.math.BigInteger;
15 import org.junit.Assert;
16 import org.junit.Test;
17 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
18 import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCase;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCase;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDrop;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemark;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenter;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCase;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCase;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDescCase;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCase;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigCase;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCase;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCase;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregate;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDesc;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.experimenter._case.MultipartReplyExperimenter;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroup;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDesc;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.MultipartReplyMeter;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfig;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDesc;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueue;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable;
86 import org.slf4j.Logger;
87 import org.slf4j.LoggerFactory;
90 * @author timotej.kubas
91 * @author michal.polkorab
93 public class MultipartReplyMessageFactoryTest {
95 private static final Logger LOGGER = LoggerFactory
96 .getLogger(MultipartReplyMessageFactoryTest.class);
99 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
102 public void testMultipartReplyDescBody(){
103 final int DESC_STR_LEN = 256;
104 final int SERIAL_NUM_LEN = 32;
105 ByteBuf bb = BufferHelper.buildBuffer("00 00 00 01 00 00 00 00");
107 String mfrDesc = "Manufacturer description";
108 byte[] mfrDescBytes = new byte[256];
109 mfrDescBytes = mfrDesc.getBytes();
110 bb.writeBytes(mfrDescBytes);
111 ByteBufUtils.padBuffer((DESC_STR_LEN - mfrDescBytes.length), bb);
113 String hwDesc = "Hardware description";
114 byte[] hwDescBytes = new byte[256];
115 hwDescBytes = hwDesc.getBytes();
116 bb.writeBytes(hwDescBytes);
117 ByteBufUtils.padBuffer((DESC_STR_LEN - hwDescBytes.length), bb);
119 String swDesc = "Software description";
120 byte[] swDescBytes = new byte[256];
121 swDescBytes = swDesc.getBytes();
122 bb.writeBytes(swDescBytes);
123 ByteBufUtils.padBuffer((DESC_STR_LEN - swDescBytes.length), bb);
125 String serialNum = "SN0123456789";
126 byte[] serialNumBytes = new byte[32];
127 serialNumBytes = serialNum.getBytes();
128 bb.writeBytes(serialNumBytes);
129 ByteBufUtils.padBuffer((SERIAL_NUM_LEN - serialNumBytes.length), bb);
131 String dpDesc = "switch3 in room 3120";
132 byte[] dpDescBytes = new byte[256];
133 dpDescBytes = dpDesc.getBytes();
134 bb.writeBytes(dpDescBytes);
135 ByteBufUtils.padBuffer((DESC_STR_LEN - dpDescBytes.length), bb);
137 MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
139 BufferHelper.checkHeaderV13(builtByFactory);
140 Assert.assertEquals("Wrong type", 0x00, builtByFactory.getType().getIntValue());
141 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
142 MultipartReplyDescCase messageCase = (MultipartReplyDescCase) builtByFactory.getMultipartReplyBody();
143 MultipartReplyDesc message = messageCase.getMultipartReplyDesc();
144 Assert.assertEquals("Wrong mfrDesc", "Manufacturer description", message.getMfrDesc());
145 Assert.assertEquals("Wrong hwDesc", "Hardware description", message.getHwDesc());
146 Assert.assertEquals("Wrong swDesc", "Software description", message.getSwDesc());
147 Assert.assertEquals("Wrong serialNum", "SN0123456789", message.getSerialNum());
148 Assert.assertEquals("Wrong dpDesc", "switch3 in room 3120", message.getDpDesc());
152 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
155 public void testMultipartReplyFlowBody(){
156 ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 00 00 00 "+
160 "00 00 00 09 "+//durationSec
161 "00 00 00 07 "+//durationNsec
163 "00 0E "+//idleTimeout
164 "00 0F "+//hardTimeout
166 "00 00 00 00 "+//pad_02
167 "00 01 01 01 01 01 01 01 "+//cookie
168 "00 01 01 01 01 01 01 01 "+//packetCount
169 "00 01 01 01 01 01 01 01"//byteCount
172 MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
174 BufferHelper.checkHeaderV13(builtByFactory);
175 Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue());
176 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
177 MultipartReplyFlowCase messageCase = (MultipartReplyFlowCase) builtByFactory.getMultipartReplyBody();
178 MultipartReplyFlow message = messageCase.getMultipartReplyFlow();
179 Assert.assertEquals("Wrong tableId", 8, message.getFlowStats().get(0).getTableId().intValue());
180 Assert.assertEquals("Wrong durationSec", 9, message.getFlowStats().get(0).getDurationSec().intValue());
181 Assert.assertEquals("Wrong durationNsec", 7, message.getFlowStats().get(0).getDurationNsec().intValue());
182 Assert.assertEquals("Wrong priority", 12, message.getFlowStats().get(0).getPriority().intValue());
183 Assert.assertEquals("Wrong idleTimeOut", 14, message.getFlowStats().get(0).getIdleTimeout().intValue());
184 Assert.assertEquals("Wrong hardTimeOut", 15, message.getFlowStats().get(0).getHardTimeout().intValue());
185 Assert.assertEquals("Wrong flags", new FlowModFlags(true, false, true, false, true),
186 message.getFlowStats().get(0).getFlags());
187 Assert.assertEquals("Wrong cookie",
188 new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
189 message.getFlowStats().get(0).getCookie());
190 Assert.assertEquals("Wrong packetCount",
191 new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
192 message.getFlowStats().get(0).getPacketCount());
193 Assert.assertEquals("Wrong byteCount",
194 new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
195 message.getFlowStats().get(0).getByteCount());
199 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
202 public void testMultipartReplyAggregateBody(){
203 ByteBuf bb = BufferHelper.buildBuffer("00 02 00 01 00 00 00 00 "+
204 "00 01 01 01 01 01 01 01 "+//packetCount
205 "00 01 01 01 01 01 01 01 "+//byteCount
206 "00 00 00 08 "+//flowCount
210 MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
212 BufferHelper.checkHeaderV13(builtByFactory);
213 Assert.assertEquals("Wrong type", 0x02, builtByFactory.getType().getIntValue());
214 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
215 MultipartReplyAggregateCase messageCase = (MultipartReplyAggregateCase) builtByFactory.getMultipartReplyBody();
216 MultipartReplyAggregate message = messageCase.getMultipartReplyAggregate();
217 Assert.assertEquals("Wrong packetCount",
218 new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
219 message.getPacketCount());
220 Assert.assertEquals("Wrong byteCount",
221 new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
222 message.getByteCount());
223 Assert.assertEquals("Wrong flowCount",
225 message.getFlowCount().intValue());
229 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
232 public void testMultipartReplyTableBody(){
233 ByteBuf bb = BufferHelper.buildBuffer("00 03 00 01 00 00 00 00 "+
236 "00 00 00 10 "+//activeCount
237 "00 01 01 01 01 01 01 01 "+//lookupCount
238 "00 01 01 01 01 01 01 01"//matchedCount
241 MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
243 BufferHelper.checkHeaderV13(builtByFactory);
244 Assert.assertEquals("Wrong type", 0x03, builtByFactory.getType().getIntValue());
245 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
247 MultipartReplyTableCase messageCase = (MultipartReplyTableCase) builtByFactory.getMultipartReplyBody();
248 MultipartReplyTable message = messageCase.getMultipartReplyTable();
249 Assert.assertEquals("Wrong tableId", 8, message.getTableStats().get(0).getTableId().intValue());
250 Assert.assertEquals("Wrong activeCount", 16, message.getTableStats().get(0).getActiveCount().longValue());
251 Assert.assertEquals("Wrong lookupCount",
252 new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
253 message.getTableStats().get(0).getLookupCount());
254 Assert.assertEquals("Wrong matchedCount",
255 new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
256 message.getTableStats().get(0).getMatchedCount());
260 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
263 public void testMultipartReplyPortStatsBody(){
264 ByteBuf bb = BufferHelper.buildBuffer("00 04 00 01 00 00 00 00 "+
265 "00 00 00 FF "+//portNo
267 "00 01 01 01 01 01 01 01 "+//rxPackets
268 "00 02 02 02 02 02 02 02 "+//txPackets
269 "00 02 03 02 03 02 03 02 "+//rxBytes
270 "00 02 03 02 03 02 03 02 "+//txBytes
271 "00 02 03 02 03 02 03 02 "+//rxDropped
272 "00 02 03 02 03 02 03 02 "+//txDropped
273 "00 02 03 02 03 02 03 02 "+//rxErrors
274 "00 02 03 02 03 02 03 02 "+//txErrors
275 "00 02 03 02 03 02 03 02 "+//rxFrameErr
276 "00 02 03 02 03 02 03 02 "+//rxOverErr
277 "00 02 03 02 03 02 03 02 "+//rxCrcErr
278 "00 02 03 02 03 02 03 02 "+//collisions
279 "00 00 00 02 "+//durationSec
280 "00 00 00 04"//durationNsec
283 MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
285 BufferHelper.checkHeaderV13(builtByFactory);
286 Assert.assertEquals("Wrong type", 0x04, builtByFactory.getType().getIntValue());
287 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
288 MultipartReplyPortStatsCase messageCase = (MultipartReplyPortStatsCase) builtByFactory.getMultipartReplyBody();
289 MultipartReplyPortStats message = messageCase.getMultipartReplyPortStats();
290 Assert.assertEquals("Wrong portNo", 255, message.getPortStats().get(0).getPortNo().intValue());
291 Assert.assertEquals("Wrong rxPackets",
292 new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
293 message.getPortStats().get(0).getRxPackets());
294 Assert.assertEquals("Wrong txPackets",
295 new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
296 message.getPortStats().get(0).getTxPackets());
297 Assert.assertEquals("Wrong rxBytes",
298 new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
299 message.getPortStats().get(0).getRxBytes());
300 Assert.assertEquals("Wrong txBytes",
301 new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
302 message.getPortStats().get(0).getTxBytes());
303 Assert.assertEquals("Wrong rxDropped",
304 new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
305 message.getPortStats().get(0).getRxDropped());
306 Assert.assertEquals("Wrong txDropped",
307 new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
308 message.getPortStats().get(0).getTxDropped());
309 Assert.assertEquals("Wrong rxErrors",
310 new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
311 message.getPortStats().get(0).getRxErrors());
312 Assert.assertEquals("Wrong txErrors",
313 new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
314 message.getPortStats().get(0).getTxErrors());
315 Assert.assertEquals("Wrong rxFrameErr",
316 new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
317 message.getPortStats().get(0).getRxFrameErr());
318 Assert.assertEquals("Wrong rxOverErr",
319 new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
320 message.getPortStats().get(0).getRxOverErr());
321 Assert.assertEquals("Wrong rxCrcErr",
322 new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
323 message.getPortStats().get(0).getRxCrcErr());
324 Assert.assertEquals("Wrong collisions",
325 new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
326 message.getPortStats().get(0).getCollisions());
327 Assert.assertEquals("Wrong durationSec", 2, message.getPortStats().get(0).getDurationSec().intValue());
328 Assert.assertEquals("Wrong durationNsec", 4, message.getPortStats().get(0).getDurationNsec().intValue());
332 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
335 public void testMultipartReplyQueueBody(){
336 ByteBuf bb = BufferHelper.buildBuffer("00 05 00 01 00 00 00 00 "+
337 "00 00 00 FF "+//portNo
338 "00 00 00 10 "+//queueId
339 "00 02 03 02 03 02 03 02 "+//txBytes
340 "00 02 02 02 02 02 02 02 "+//txPackets
341 "00 02 03 02 03 02 03 02 "+//txErrors
342 "00 00 00 02 "+//durationSec
343 "00 00 00 04"//durationNsec
346 MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
348 BufferHelper.checkHeaderV13(builtByFactory);
349 Assert.assertEquals("Wrong type", 0x05, builtByFactory.getType().getIntValue());
350 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
351 MultipartReplyQueueCase messageCase = (MultipartReplyQueueCase) builtByFactory.getMultipartReplyBody();
352 MultipartReplyQueue message = messageCase.getMultipartReplyQueue();
353 Assert.assertEquals("Wrong portNo", 255, message.getQueueStats().get(0).getPortNo().intValue());
354 Assert.assertEquals("Wrong queueId", 16, message.getQueueStats().get(0).getQueueId().intValue());
355 Assert.assertEquals("Wrong txBytes",
356 new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
357 message.getQueueStats().get(0).getTxBytes());
358 Assert.assertEquals("Wrong txPackets",
359 new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
360 message.getQueueStats().get(0).getTxPackets());
361 Assert.assertEquals("Wrong txErrors",
362 new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
363 message.getQueueStats().get(0).getTxErrors());
364 Assert.assertEquals("Wrong durationSec", 2, message.getQueueStats().get(0).getDurationSec().intValue());
365 Assert.assertEquals("Wrong durationNsec", 4, message.getQueueStats().get(0).getDurationNsec().intValue());
369 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
372 public void testMultipartReplyGroupBody(){
373 ByteBuf bb = BufferHelper.buildBuffer("00 06 00 01 00 00 00 00 "+
376 "00 00 00 10 "+//groupId
377 "00 00 00 12 "+//refCount
378 "00 00 00 00 "+//pad2
379 "00 01 01 01 01 01 01 01 "+//packetCount
380 "00 01 01 01 01 01 01 01 "+//byteCount
381 "00 00 00 08 "+//durationSec
382 "00 00 00 09 "+//durationNsec
383 "00 01 01 01 01 01 01 01 "+//packetCountBucket
384 "00 01 01 01 01 01 01 01 "+//byteCountBucket
385 "00 02 02 02 02 02 02 02 "+//packetCountBucket_2
386 "00 02 02 02 02 02 02 02 "+//byteCountBucket_2
389 "00 00 00 10 "+//groupId_2
390 "00 00 00 12 "+//refCount_2
391 "00 00 00 00 "+//pad2.2
392 "00 01 01 01 01 01 01 01 "+//packetCount_2
393 "00 01 01 01 01 01 01 01 "+//byteCount_2
394 "00 00 00 08 "+//durationSec_2
395 "00 00 00 09 "+//durationNsec_2
396 "00 01 01 01 01 01 01 01 "+//packetCountBucket_1.2
397 "00 01 01 01 01 01 01 01 "+//byteCountBucket_1.2
398 "00 02 02 02 02 02 02 02 "+//packetCountBucket_2.2
399 "00 02 02 02 02 02 02 02"//byteCountBucket_2.2
402 MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
404 BufferHelper.checkHeaderV13(builtByFactory);
405 Assert.assertEquals("Wrong type", 0x06, builtByFactory.getType().getIntValue());
406 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
407 MultipartReplyGroupCase messageCase = (MultipartReplyGroupCase) builtByFactory.getMultipartReplyBody();
408 MultipartReplyGroup message = messageCase.getMultipartReplyGroup();
409 Assert.assertEquals("Wrong groupId", 16, message.getGroupStats().get(0).getGroupId().getValue().intValue());
410 Assert.assertEquals("Wrong refCount", 18, message.getGroupStats().get(0).getRefCount().intValue());
411 Assert.assertEquals("Wrong packetCount",
412 new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
413 message.getGroupStats().get(0).getPacketCount());
414 Assert.assertEquals("Wrong byteCount",
415 new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
416 message.getGroupStats().get(0).getByteCount());
417 Assert.assertEquals("Wrong durationSec", 8, message.getGroupStats().get(0).getDurationSec().intValue());
418 Assert.assertEquals("Wrong durationNsec", 9, message.getGroupStats().get(0).getDurationNsec().intValue());
419 Assert.assertEquals("Wrong packetCountBucket",
420 new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
421 message.getGroupStats().get(0).getBucketStats().get(0).getPacketCount());
422 Assert.assertEquals("Wrong byteCountBucket",
423 new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
424 message.getGroupStats().get(0).getBucketStats().get(0).getByteCount());
425 Assert.assertEquals("Wrong packetCountBucket_2",
426 new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
427 message.getGroupStats().get(0).getBucketStats().get(1).getPacketCount());
428 Assert.assertEquals("Wrong byteCountBucket_2",
429 new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
430 message.getGroupStats().get(0).getBucketStats().get(1).getByteCount());
432 Assert.assertEquals("Wrong groupId_2", 16, message.getGroupStats().get(1).getGroupId().getValue().intValue());
433 Assert.assertEquals("Wrong refCount_2", 18, message.getGroupStats().get(1).getRefCount().intValue());
434 Assert.assertEquals("Wrong packetCount_2",
435 new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
436 message.getGroupStats().get(1).getPacketCount());
437 Assert.assertEquals("Wrong byteCount_2",
438 new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
439 message.getGroupStats().get(1).getByteCount());
440 Assert.assertEquals("Wrong durationSec_2", 8, message.getGroupStats().get(1).getDurationSec().intValue());
441 Assert.assertEquals("Wrong durationNsec_2", 9, message.getGroupStats().get(1).getDurationNsec().intValue());
442 Assert.assertEquals("Wrong packetCountBucket_1.2",
443 new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
444 message.getGroupStats().get(1).getBucketStats().get(0).getPacketCount());
445 Assert.assertEquals("Wrong byteCountBucket_1.2",
446 new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
447 message.getGroupStats().get(1).getBucketStats().get(0).getByteCount());
448 Assert.assertEquals("Wrong packetCountBucket_2.2",
449 new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
450 message.getGroupStats().get(1).getBucketStats().get(1).getPacketCount());
451 Assert.assertEquals("Wrong byteCountBucket_2.2",
452 new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
453 message.getGroupStats().get(1).getBucketStats().get(1).getByteCount());
457 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
460 public void testMultipartReplyMeterFeaturesBody(){
461 ByteBuf bb = BufferHelper.buildBuffer("00 0B 00 01 00 00 00 00 "+
462 "00 00 00 09 "+//maxMeter
463 "00 00 00 01 "+//bandTypes
464 "00 00 00 03 "+//capabilities
470 MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
472 BufferHelper.checkHeaderV13(builtByFactory);
473 Assert.assertEquals("Wrong type", 11, builtByFactory.getType().getIntValue());
474 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
475 MultipartReplyMeterFeaturesCase messageCase = (MultipartReplyMeterFeaturesCase) builtByFactory.getMultipartReplyBody();
476 MultipartReplyMeterFeatures message = messageCase.getMultipartReplyMeterFeatures();
477 Assert.assertEquals("Wrong maxMeter", 9, message.getMaxMeter().intValue());
478 Assert.assertEquals("Wrong bandTypes", new MeterBandTypeBitmap(true, false), message.getBandTypes());
479 Assert.assertEquals("Wrong capabilities", new MeterFlags(false, true, true, false),
480 message.getCapabilities());
481 Assert.assertEquals("Wrong maxBands", 3, message.getMaxBands().intValue());
482 Assert.assertEquals("Wrong maxColor", 4, message.getMaxColor().intValue());
486 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
489 public void testMultipartReplyMeterBody(){
490 ByteBuf bb = BufferHelper.buildBuffer("00 09 00 01 00 00 00 00 "+
491 "00 00 00 09 "+//meterId
493 "00 00 00 00 00 00 "+//pad
494 "00 00 00 07 "+//flowCount
495 "00 01 01 01 01 01 01 01 "+//packetInCount
496 "00 01 01 01 01 01 01 01 "+//byteInCount
497 "00 00 00 05 "+//durationSec
498 "00 00 00 05 "+//durationNsec
499 "00 01 01 01 01 01 01 01 "+//packetBandCount_01
500 "00 01 01 01 01 01 01 01 "+//byteBandCount_01
501 "00 02 02 02 02 02 02 02 "+//packetBandCount_02
502 "00 02 02 02 02 02 02 02 "+//byteBandCount_02
503 "00 03 03 03 03 03 03 03 "+//packetBandCount_03
504 "00 03 03 03 03 03 03 03"//byteBandCount_03
507 MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
509 BufferHelper.checkHeaderV13(builtByFactory);
510 Assert.assertEquals("Wrong type", 9, builtByFactory.getType().getIntValue());
511 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
512 MultipartReplyMeterCase messageCase = (MultipartReplyMeterCase) builtByFactory.getMultipartReplyBody();
513 MultipartReplyMeter message = messageCase.getMultipartReplyMeter();
514 Assert.assertEquals("Wrong meterId", 9,
515 message.getMeterStats().get(0).getMeterId().getValue().intValue());
516 Assert.assertEquals("Wrong flowCount", 7,
517 message.getMeterStats().get(0).getFlowCount().intValue());
518 Assert.assertEquals("Wrong packetInCount",
519 new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
520 message.getMeterStats().get(0).getPacketInCount());
521 Assert.assertEquals("Wrong byteInCount",
522 new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
523 message.getMeterStats().get(0).getByteInCount());
524 Assert.assertEquals("Wrong durationSec", 5,
525 message.getMeterStats().get(0).getDurationSec().intValue());
526 Assert.assertEquals("Wrong durationNsec", 5,
527 message.getMeterStats().get(0).getDurationNsec().intValue());
528 Assert.assertEquals("Wrong packetBandCount_01",
529 new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
530 message.getMeterStats().get(0).getMeterBandStats().get(0).getPacketBandCount());
531 Assert.assertEquals("Wrong byteBandCount_01",
532 new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
533 message.getMeterStats().get(0).getMeterBandStats().get(0).getByteBandCount());
534 Assert.assertEquals("Wrong packetBandCount_02",
535 new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
536 message.getMeterStats().get(0).getMeterBandStats().get(1).getPacketBandCount());
537 Assert.assertEquals("Wrong byteBandCount_02",
538 new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
539 message.getMeterStats().get(0).getMeterBandStats().get(1).getByteBandCount());
540 Assert.assertEquals("Wrong packetBandCount_03",
541 new BigInteger(new byte[]{0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}),
542 message.getMeterStats().get(0).getMeterBandStats().get(2).getPacketBandCount());
543 Assert.assertEquals("Wrong byteBandCount_03",
544 new BigInteger(new byte[]{0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}),
545 message.getMeterStats().get(0).getMeterBandStats().get(2).getByteBandCount());
549 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
552 public void testMultipartReplyMeterBodyMulti(){
553 ByteBuf bb = BufferHelper.buildBuffer("00 09 00 01 00 00 00 00 "+
554 "00 00 00 09 "+//meterId_0
556 "00 00 00 00 00 00 "+//pad_0
557 "00 00 00 07 "+//flowCount_0
558 "00 01 01 01 01 01 01 01 "+//packetInCount_0
559 "00 01 01 01 01 01 01 01 "+//byteInCount_0
560 "00 00 00 05 "+//durationSec_0
561 "00 00 00 05 "+//durationNsec_0
562 "00 01 01 01 01 01 01 01 "+//packetBandCount_01
563 "00 01 01 01 01 01 01 01 "+//byteBandCount_01
564 "00 02 02 02 02 02 02 02 "+//packetBandCount_02
565 "00 02 02 02 02 02 02 02 "+//byteBandCount_02
566 "00 03 03 03 03 03 03 03 "+//packetBandCount_03
567 "00 03 03 03 03 03 03 03 "+//byteBandCount_03
568 "00 00 00 08 "+//meterId_1
570 "00 00 00 00 00 00 "+//pad_1
571 "00 00 00 07 "+//flowCount_1
572 "00 01 01 01 01 01 01 01 "+//packetInCount_1
573 "00 01 01 01 01 01 01 01 "+//byteInCount_1
574 "00 00 00 05 "+//durationSec_1
575 "00 00 00 05 "+//durationNsec_1
576 "00 01 01 01 01 01 01 01 "+//packetBandCount_11
577 "00 01 01 01 01 01 01 01 "+//byteBandCount_11
578 "00 02 02 02 02 02 02 02 "+//packetBandCount_12
579 "00 02 02 02 02 02 02 02 "+//byteBandCount_12
580 "00 03 03 03 03 03 03 03 "+//packetBandCount_13
581 "00 03 03 03 03 03 03 03"//byteBandCount_13
584 MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
586 BufferHelper.checkHeaderV13(builtByFactory);
587 Assert.assertEquals("Wrong type", 9, builtByFactory.getType().getIntValue());
588 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
589 MultipartReplyMeterCase messageCase = (MultipartReplyMeterCase) builtByFactory.getMultipartReplyBody();
590 MultipartReplyMeter message = messageCase.getMultipartReplyMeter();
591 Assert.assertEquals("Wrong meterId", 9,
592 message.getMeterStats().get(0).getMeterId().getValue().intValue());
593 Assert.assertEquals("Wrong flowCount", 7,
594 message.getMeterStats().get(0).getFlowCount().intValue());
595 Assert.assertEquals("Wrong packetInCount",
596 new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
597 message.getMeterStats().get(0).getPacketInCount());
598 Assert.assertEquals("Wrong byteInCount",
599 new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
600 message.getMeterStats().get(0).getByteInCount());
601 Assert.assertEquals("Wrong durationSec", 5,
602 message.getMeterStats().get(0).getDurationSec().intValue());
603 Assert.assertEquals("Wrong durationNsec", 5,
604 message.getMeterStats().get(0).getDurationNsec().intValue());
605 Assert.assertEquals("Wrong packetBandCount_01",
606 new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
607 message.getMeterStats().get(0).getMeterBandStats().get(0).getPacketBandCount());
608 Assert.assertEquals("Wrong byteBandCount_01",
609 new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
610 message.getMeterStats().get(0).getMeterBandStats().get(0).getByteBandCount());
611 Assert.assertEquals("Wrong packetBandCount_02",
612 new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
613 message.getMeterStats().get(0).getMeterBandStats().get(1).getPacketBandCount());
614 Assert.assertEquals("Wrong byteBandCount_02",
615 new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
616 message.getMeterStats().get(0).getMeterBandStats().get(1).getByteBandCount());
617 Assert.assertEquals("Wrong packetBandCount_03",
618 new BigInteger(new byte[]{0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}),
619 message.getMeterStats().get(0).getMeterBandStats().get(2).getPacketBandCount());
620 Assert.assertEquals("Wrong byteBandCount_03",
621 new BigInteger(new byte[]{0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}),
622 message.getMeterStats().get(0).getMeterBandStats().get(2).getByteBandCount());
624 Assert.assertEquals("Wrong meterId", 8,
625 message.getMeterStats().get(1).getMeterId().getValue().intValue());
626 Assert.assertEquals("Wrong flowCount", 7,
627 message.getMeterStats().get(1).getFlowCount().intValue());
628 Assert.assertEquals("Wrong packetInCount",
629 new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
630 message.getMeterStats().get(1).getPacketInCount());
631 Assert.assertEquals("Wrong byteInCount",
632 new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
633 message.getMeterStats().get(1).getByteInCount());
634 Assert.assertEquals("Wrong durationSec", 5,
635 message.getMeterStats().get(1).getDurationSec().intValue());
636 Assert.assertEquals("Wrong durationNsec", 5,
637 message.getMeterStats().get(1).getDurationNsec().intValue());
638 Assert.assertEquals("Wrong packetBandCount_01",
639 new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
640 message.getMeterStats().get(1).getMeterBandStats().get(0).getPacketBandCount());
641 Assert.assertEquals("Wrong byteBandCount_01",
642 new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
643 message.getMeterStats().get(1).getMeterBandStats().get(0).getByteBandCount());
644 Assert.assertEquals("Wrong packetBandCount_02",
645 new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
646 message.getMeterStats().get(1).getMeterBandStats().get(1).getPacketBandCount());
647 Assert.assertEquals("Wrong byteBandCount_02",
648 new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
649 message.getMeterStats().get(1).getMeterBandStats().get(1).getByteBandCount());
650 Assert.assertEquals("Wrong packetBandCount_03",
651 new BigInteger(new byte[]{0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}),
652 message.getMeterStats().get(1).getMeterBandStats().get(2).getPacketBandCount());
653 Assert.assertEquals("Wrong byteBandCount_03",
654 new BigInteger(new byte[]{0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}),
655 message.getMeterStats().get(1).getMeterBandStats().get(2).getByteBandCount());
659 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
662 public void testMultipartReplyMeterConfigBody(){
663 ByteBuf bb = BufferHelper.buildBuffer("00 0A 00 01 00 00 00 00 "+
666 "00 00 00 09 "+//meterId
667 "00 01 "+//meterBandDrop.type
668 "00 10 "+//meterBandDrop.len
669 "00 00 00 11 "+//meterBandDrop.rate
670 "00 00 00 20 "+//meterBandDrop.burstSize
671 "00 00 00 00 "+//meterBandDrop.pad
672 "00 02 "+//meterBandDscp.type
673 "00 10 "+//meterBandDscp.len
674 "00 00 00 11 "+//meterBandDscp.rate
675 "00 00 00 20 "+//meterBandDscp.burstSize
676 "04 "+//meterBandDscp.precLevel
677 "00 00 00 "+//meterBandDscp.pad
678 "FF FF "+//meterBandExperimenter.type
679 "00 10 "+//meterBandExperimenter.len
680 "00 00 00 11 "+//meterBandExperimenter.rate
681 "00 00 00 20 "+//meterBandExperimenter.burstSize
682 "00 00 00 04"//meterBandExperimenter.experimenter
685 MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
687 BufferHelper.checkHeaderV13(builtByFactory);
688 Assert.assertEquals("Wrong type", 10, builtByFactory.getType().getIntValue());
689 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
690 MultipartReplyMeterConfigCase messageCase = (MultipartReplyMeterConfigCase) builtByFactory.getMultipartReplyBody();
691 MultipartReplyMeterConfig message = messageCase.getMultipartReplyMeterConfig();
692 Assert.assertEquals("Wrong flags", new MeterFlags(false, false, true, true),
693 message.getMeterConfig().get(0).getFlags());
694 Assert.assertEquals("Wrong meterId", 9,
695 message.getMeterConfig().get(0).getMeterId().getValue().intValue());
697 MeterBandDropCase dropCase = (MeterBandDropCase) message.getMeterConfig().get(0).getBands().get(0).getMeterBand();
698 MeterBandDrop meterBandDrop = dropCase.getMeterBandDrop();
699 Assert.assertEquals("Wrong meterBandDrop.type", 1, meterBandDrop.getType().getIntValue());
700 Assert.assertEquals("Wrong meterBandDrop.rate", 17, meterBandDrop.getRate().intValue());
701 Assert.assertEquals("Wrong meterBandDrop.burstSize", 32, meterBandDrop.getBurstSize().intValue());
703 MeterBandDscpRemarkCase dscpCase = (MeterBandDscpRemarkCase) message.getMeterConfig().get(0).getBands().get(1).getMeterBand();
704 MeterBandDscpRemark meterBandDscp = dscpCase.getMeterBandDscpRemark();
705 Assert.assertEquals("Wrong meterBandDscp.type", 2, meterBandDscp.getType().getIntValue());
706 Assert.assertEquals("Wrong meterBandDscp.rate", 17, meterBandDscp.getRate().intValue());
707 Assert.assertEquals("Wrong meterBandDscp.burstSize", 32, meterBandDscp.getBurstSize().intValue());
708 Assert.assertEquals("Wrong meterBandDscp.precLevel", 4, meterBandDscp.getPrecLevel().intValue());
710 MeterBandExperimenterCase experimenterCase = (MeterBandExperimenterCase) message.getMeterConfig().get(0).getBands().get(2).getMeterBand();
711 MeterBandExperimenter meterBandExperimenter = experimenterCase.getMeterBandExperimenter();
712 Assert.assertEquals("Wrong meterBandExperimenter.type", 0xFFFF, meterBandExperimenter.getType().getIntValue());
713 Assert.assertEquals("Wrong meterBandExperimenter.rate", 17, meterBandExperimenter.getRate().intValue());
714 Assert.assertEquals("Wrong meterBandExperimenter.burstSize", 32, meterBandExperimenter.getBurstSize().intValue());
715 Assert.assertEquals("Wrong meterBandExperimenter.experimenter", 4, meterBandExperimenter.getExperimenter().intValue());
719 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
722 public void testMultipartReplyMeterConfigBodyMulti(){
723 ByteBuf bb = BufferHelper.buildBuffer("00 0A 00 01 00 00 00 00 "+
726 "00 00 00 09 "+//meterId
727 "00 01 "+//meterBandDrop.type
728 "00 10 "+//meterBandDrop.len
729 "00 00 00 11 "+//meterBandDrop.rate
730 "00 00 00 20 "+//meterBandDrop.burstSize
731 "00 00 00 00 "+//meterBandDrop.pad
732 "00 02 "+//meterBandDscp.type
733 "00 10 "+//meterBandDscp.len
734 "00 00 00 11 "+//meterBandDscp.rate
735 "00 00 00 20 "+//meterBandDscp.burstSize
736 "04 "+//meterBandDscp.precLevel
737 "00 00 00 "+//meterBandDscp.pad
738 "FF FF "+//meterBandExperimenter.type
739 "00 10 "+//meterBandExperimenter.len
740 "00 00 00 11 "+//meterBandExperimenter.rate
741 "00 00 00 20 "+//meterBandExperimenter.burstSize
742 "00 00 00 04 "+//meterBandExperimenter.experimenter
746 "00 00 00 07 "+//meterId01
747 "00 02 "+//meterBandDscp01.type
748 "00 10 "+//meterBandDscp01.len
749 "00 00 00 11 "+//meterBandDscp01.rate
750 "00 00 00 20 "+//meterBandDscp01.burstSize
751 "04 "+//meterBandDscp01.precLevel
752 "00 00 00"//meterBandDscp01.pad
755 MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
757 BufferHelper.checkHeaderV13(builtByFactory);
758 Assert.assertEquals("Wrong type", 10, builtByFactory.getType().getIntValue());
759 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
760 MultipartReplyMeterConfigCase messageCase = (MultipartReplyMeterConfigCase) builtByFactory.getMultipartReplyBody();
761 MultipartReplyMeterConfig message = messageCase.getMultipartReplyMeterConfig();
762 Assert.assertEquals("Wrong flags", new MeterFlags(true, false, true, false),
763 message.getMeterConfig().get(0).getFlags());
764 Assert.assertEquals("Wrong meterId", 9,
765 message.getMeterConfig().get(0).getMeterId().getValue().intValue());
767 MeterBandDropCase dropCase = (MeterBandDropCase) message.getMeterConfig().get(0).getBands().get(0).getMeterBand();
768 MeterBandDrop meterBandDrop = dropCase.getMeterBandDrop();
769 Assert.assertEquals("Wrong meterBandDrop.type", 1, meterBandDrop.getType().getIntValue());
770 Assert.assertEquals("Wrong meterBandDrop.rate", 17, meterBandDrop.getRate().intValue());
771 Assert.assertEquals("Wrong meterBandDrop.burstSize", 32, meterBandDrop.getBurstSize().intValue());
773 MeterBandDscpRemarkCase dscpCase = (MeterBandDscpRemarkCase) message.getMeterConfig().get(0).getBands().get(1).getMeterBand();
774 MeterBandDscpRemark meterBandDscp = dscpCase.getMeterBandDscpRemark();
775 Assert.assertEquals("Wrong meterBandDscp.type", 2, meterBandDscp.getType().getIntValue());
776 Assert.assertEquals("Wrong meterBandDscp.rate", 17, meterBandDscp.getRate().intValue());
777 Assert.assertEquals("Wrong meterBandDscp.burstSize", 32, meterBandDscp.getBurstSize().intValue());
778 Assert.assertEquals("Wrong meterBandDscp.precLevel", 4, meterBandDscp.getPrecLevel().intValue());
780 MeterBandExperimenterCase experimenterCase = (MeterBandExperimenterCase) message.getMeterConfig().get(0).getBands().get(2).getMeterBand();
781 MeterBandExperimenter meterBandExperimenter = experimenterCase.getMeterBandExperimenter();
782 Assert.assertEquals("Wrong meterBandExperimenter.type", 0xFFFF, meterBandExperimenter.getType().getIntValue());
783 Assert.assertEquals("Wrong meterBandExperimenter.rate", 17, meterBandExperimenter.getRate().intValue());
784 Assert.assertEquals("Wrong meterBandExperimenter.burstSize", 32, meterBandExperimenter.getBurstSize().intValue());
785 Assert.assertEquals("Wrong meterBandExperimenter.experimenter", 4, meterBandExperimenter.getExperimenter().intValue());
787 LOGGER.info(message.getMeterConfig().get(0).getFlags().toString());
788 Assert.assertEquals("Wrong flags01", new MeterFlags(false, true, true, false),
789 message.getMeterConfig().get(1).getFlags());
790 Assert.assertEquals("Wrong meterId01", 7,
791 message.getMeterConfig().get(1).getMeterId().getValue().intValue());
793 MeterBandDscpRemarkCase dscpCase01 = (MeterBandDscpRemarkCase) message.getMeterConfig().get(1).getBands().get(0).getMeterBand();
794 MeterBandDscpRemark meterBandDscp01 = dscpCase01.getMeterBandDscpRemark();
795 Assert.assertEquals("Wrong meterBandDscp01.type", 2, meterBandDscp01.getType().getIntValue());
796 Assert.assertEquals("Wrong meterBandDscp01.rate", 17, meterBandDscp01.getRate().intValue());
797 Assert.assertEquals("Wrong meterBandDscp01.burstSize", 32, meterBandDscp01.getBurstSize().intValue());
798 Assert.assertEquals("Wrong meterBandDscp01.precLevel", 4, meterBandDscp01.getPrecLevel().intValue());
803 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
806 public void testMultipartReplyExperimenterBody(){
807 ByteBuf bb = BufferHelper.buildBuffer("FF FF 00 01 00 00 00 00 "+
808 "00 00 00 0F "+//experimenterId
809 "00 00 00 FF "+//expType
810 "00 00 01 01 00 00 01 01"
813 MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
815 BufferHelper.checkHeaderV13(builtByFactory);
816 Assert.assertEquals("Wrong type", 0xFFFF, builtByFactory.getType().getIntValue());
817 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
818 MultipartReplyExperimenterCase messageCase = (MultipartReplyExperimenterCase) builtByFactory.getMultipartReplyBody();
819 MultipartReplyExperimenter message = messageCase.getMultipartReplyExperimenter();
820 Assert.assertEquals("Wrong experimenterId", 15, message.getExperimenter().intValue());
821 Assert.assertEquals("Wrong expType", 255, message.getExpType().intValue());
822 Assert.assertArrayEquals("Wrong data", new byte[]{0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01},
827 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
830 public void testMultipartReplyPortDescBody(){
831 final byte MAX_PORT_NAME_LEN = 16;
832 ByteBuf bb = BufferHelper.buildBuffer("00 0D 00 01 00 00 00 00 "+
833 "00 01 02 03 "+ //portNo
834 "00 00 00 00 "+ //padding01
835 "08 00 27 00 B0 EB " + //mac address
836 "00 00 "); //padding02
838 String portName = "SampleText";
839 byte[] portNameBytes = new byte[MAX_PORT_NAME_LEN];
840 portNameBytes = portName.getBytes();
841 bb.writeBytes(portNameBytes);
842 ByteBufUtils.padBuffer((MAX_PORT_NAME_LEN - portNameBytes.length), bb);
844 ByteBuf bb2 = BufferHelper.buildBuffer("00 00 00 41 " + //port config
845 "00 00 00 05 " + //port state
846 "00 00 00 81 " + //current features
847 "00 00 81 81 " + //advertised features
848 "00 00 C1 89 " + //supported features
849 "00 00 C5 8D " + //peer features
850 "00 00 00 81 " + //curr speed
851 "00 00 00 80" //max speed
853 bb.writeBytes(bb2.copy(4, bb2.readableBytes()-4));//excluding version and xid
855 MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
857 BufferHelper.checkHeaderV13(builtByFactory);
858 Assert.assertEquals("Wrong type", 13, builtByFactory.getType().getIntValue());
859 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
860 MultipartReplyPortDescCase messageCase = (MultipartReplyPortDescCase) builtByFactory.getMultipartReplyBody();
861 MultipartReplyPortDesc message = messageCase.getMultipartReplyPortDesc();
862 Assert.assertEquals("Wrong portNo", 66051L, message.getPorts().get(0).getPortNo().longValue());
863 Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:B0:EB"),
864 message.getPorts().get(0).getHwAddr());
865 Assert.assertEquals("Wrong portName", "SampleText",
866 message.getPorts().get(0).getName());
867 Assert.assertEquals("Wrong portConfig", new PortConfig(false, true, false, true),
868 message.getPorts().get(0).getConfig());
869 Assert.assertEquals("Wrong portState", new PortState(false, true, true),
870 message.getPorts().get(0).getState());
871 Assert.assertEquals("Wrong currentFeatures", new PortFeatures(false, false, false, false,
872 false, true, false, false,
873 false, true, false, false,
874 false, false, false, false),
875 message.getPorts().get(0).getCurrentFeatures());
876 Assert.assertEquals("Wrong advertisedFeatures",
877 new PortFeatures(true, false, false, false,
878 false, true, false, false,
879 false, true, false, false,
880 false, false, false, true),
881 message.getPorts().get(0).getAdvertisedFeatures());
882 Assert.assertEquals("Wrong supportedFeatures",
883 new PortFeatures(true, true, false, false,
884 false, true, false, false,
885 false, true, false, false,
886 false, false, true, true),
887 message.getPorts().get(0).getSupportedFeatures());
888 Assert.assertEquals("Wrong peerFeatures",
889 new PortFeatures(true, true, true, false,
890 false, true, false, false,
891 false, true, false, false,
892 false, true, true, true),
893 message.getPorts().get(0).getPeerFeatures());
894 Assert.assertEquals("Wrong currSpeed", 129L, message.getPorts().get(0).getCurrSpeed().longValue());
895 Assert.assertEquals("Wrong maxSpeed", 128L, message.getPorts().get(0).getMaxSpeed().longValue());
899 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
900 * Test covers bodies of actions Output, Copy TTL Out, Copy TTL In
903 public void testMultipartReplyGroupDescBody01(){
904 ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "+
908 "00 00 00 08 "+//groupId
910 "00 06 "+//bucketWeight
911 "00 00 00 05 "+//bucketWatchPort
912 "00 00 00 04 "+//bucketWatchGroup
913 "00 00 00 00 "+//bucketPad
914 "00 00 "+//outputType
916 "00 00 10 FF "+//outputPort
917 "FF FF "+//outputMaxLen
918 "00 00 00 00 00 00 "+//outputPad
919 "00 0B "+//copyTTLOutType
920 "00 08 "+//copyTTLOutLen
921 "00 00 00 00 "+//copyTTLOutPad
922 "00 0C "+//copyTTLIntType
923 "00 08 "+//copyTTLIntLen
924 "00 00 00 00"//copyTTLInPad
926 MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
928 BufferHelper.checkHeaderV13(builtByFactory);
929 Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
930 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
931 MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody();
932 MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc();
933 Assert.assertEquals("Wrong type", 1,
934 message.getGroupDesc().get(0).getType().getIntValue());
935 Assert.assertEquals("Wrong groupId", 8,
936 message.getGroupDesc().get(0).getGroupId().getValue().intValue());
937 Assert.assertEquals("Wrong bucketWeight", 6,
938 message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());
939 Assert.assertEquals("Wrong bucketWatchPort", 5,
940 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().
941 getValue().intValue());
942 Assert.assertEquals("Wrong bucketWatchGroup", 4,
943 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());
945 Assert.assertEquals("Wrong outputType", Output.class,
946 message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).
947 getAction().getType());
949 Assert.assertEquals("Wrong outputPort", 4351,
950 message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).
951 getAction().getAugmentation(PortAction.class).
952 getPort().getValue().intValue());
954 Assert.assertEquals("Wrong outputMaxLen", 65535,
955 message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).
956 getAction().getAugmentation(MaxLengthAction.class).
957 getMaxLength().intValue());
959 Assert.assertEquals("Wrong copyTtlOutType", CopyTtlOut.class,
960 message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1).
961 getAction().getType());
963 Assert.assertEquals("Wrong copyTtlInType", CopyTtlIn.class,
964 message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(2).
965 getAction().getType());
969 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
970 * Test covers bodies of actions Set MPLS TTL , Dec MPLS TTL, Push VLAN. Push MPLS, Push PBB
973 public void testMultipartReplyGroupDescBody02(){
974 ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "+
978 "00 00 00 08 "+//groupId
980 "00 06 "+//bucketWeight
981 "00 00 00 05 "+//bucketWatchPort
982 "00 00 00 04 "+//bucketWatchGroup
983 "00 00 00 00 "+//bucketPad
984 "00 0F "+//setMplsTtlType
985 "00 08 "+//setMplsTtlLen
986 "09 "+//setMplsTtlMPLS_TTL
987 "00 00 00 "+//setMplsTtlPad
988 "00 10 "+//decMplsTtlType
989 "00 08 "+//decMplsTtlLen
990 "00 00 00 00 "+//decMplsTtlPad
991 "00 11 "+//pushVlanType
992 "00 08 "+//pushVlanLen
993 "00 20 "+//pushVlanEthertype
994 "00 00 "+//pushVlanPad
995 "00 13 "+//pushMplsType
996 "00 08 "+//pushMplsLen
997 "00 FF "+//pushMplsEthertype
998 "00 00 "+//pushMplsPad
999 "00 1A "+//pushPbbType
1000 "00 08 "+//pushPbbLen
1001 "0F FF "+//pushPbbEthertype
1005 MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
1007 BufferHelper.checkHeaderV13(builtByFactory);
1008 Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
1009 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
1010 MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody();
1011 MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc();
1012 Assert.assertEquals("Wrong type", 1,
1013 message.getGroupDesc().get(0).getType().getIntValue());
1014 Assert.assertEquals("Wrong groupId", 8,
1015 message.getGroupDesc().get(0).getGroupId().getValue().intValue());
1016 Assert.assertEquals("Wrong bucketWeight", 6,
1017 message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());
1018 Assert.assertEquals("Wrong bucketWatchPort", 5,
1019 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().getValue().intValue());
1020 Assert.assertEquals("Wrong bucketWatchGroup", 4,
1021 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());
1022 Assert.assertEquals("Wrong setMplsTtlType", SetMplsTtl.class,
1023 message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).
1024 getAction().getType());
1025 Assert.assertEquals("Wrong setMplsTtlMPLS_TTL", 9,
1026 message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).
1027 getAction().getAugmentation(MplsTtlAction.class).
1028 getMplsTtl().intValue());
1029 Assert.assertEquals("Wrong decMplsTtlType", DecMplsTtl.class,
1030 message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1).
1031 getAction().getType());
1032 Assert.assertEquals("Wrong pushVlanType", PushVlan.class,
1033 message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(2).
1034 getAction().getType());
1035 Assert.assertEquals("Wrong pushVlanEthertype", 32,
1036 message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(2).
1037 getAction().getAugmentation(EthertypeAction.class).
1038 getEthertype().getValue().intValue());
1039 Assert.assertEquals("Wrong pushMplsType", PushMpls.class,
1040 message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(3).
1041 getAction().getType());
1042 Assert.assertEquals("Wrong pushMplsEthertype", 255,
1043 message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(3).
1044 getAction().getAugmentation(EthertypeAction.class).
1045 getEthertype().getValue().intValue());
1046 Assert.assertEquals("Wrong pushPbbType", PushPbb.class,
1047 message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(4).
1048 getAction().getType());
1049 Assert.assertEquals("Wrong pushPbbEthertype", 4095,
1050 message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(4).
1051 getAction().getAugmentation(EthertypeAction.class).
1052 getEthertype().getValue().intValue());
1056 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
1057 * Test covers bodies of actions Pop VLAN, Pop PBB, Pop MPLS, Group, Dec NW TTL
1060 public void testMultipartReplyGroupDescBody03(){
1061 ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "+
1065 "00 00 00 08 "+//groupId
1066 "00 40 "+//bucketLen
1067 "00 06 "+//bucketWeight
1068 "00 00 00 05 "+//bucketWatchPort
1069 "00 00 00 04 "+//bucketWatchGroup
1070 "00 00 00 00 "+//bucketPad
1071 "00 12 "+//popVlanType
1072 "00 08 "+//popVlanLen
1073 "00 00 00 00 "+//popVlanPad
1074 "00 1B "+//popPbbType
1075 "00 08 "+//popPbbLen
1076 "00 00 00 00 "+//popPbbPad
1077 "00 14 "+//popMplsType
1078 "00 08 "+//popMplsLen
1079 "00 CF "+//popMplsEthertype
1080 "00 00 "+//popMplsPad
1081 "00 15 "+//setQueueType
1082 "00 08 "+//setQueueLen
1083 "00 CF 00 00 "+//setQueueQueueId
1084 "00 16 "+//groupType
1086 "00 CF 00 00 "+//groupGroupId
1087 "00 18 "+//decNwTtlType
1088 "00 08 "+//decNwTtlLen
1089 "00 00 00 00"//decNwTtlPad
1092 MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
1094 BufferHelper.checkHeaderV13(builtByFactory);
1095 Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
1096 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
1097 MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody();
1098 MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc();
1099 Assert.assertEquals("Wrong type", 1, message.getGroupDesc().get(0).getType().getIntValue());
1100 Assert.assertEquals("Wrong groupId", 8, message.getGroupDesc().get(0).getGroupId().getValue().intValue());
1101 Assert.assertEquals("Wrong bucketWeight", 6,
1102 message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());
1103 Assert.assertEquals("Wrong bucketWatchPort", 5,
1104 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().getValue().intValue());
1105 Assert.assertEquals("Wrong bucketWatchGroup", 4,
1106 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());
1107 Assert.assertEquals("Wrong popVlanType", PopVlan.class,
1108 message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).
1109 getAction().getType());
1110 Assert.assertEquals("Wrong popPbbType", PopPbb.class,
1111 message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1).
1112 getAction().getType());
1113 Assert.assertEquals("Wrong popMplsType", PopMpls.class,
1114 message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(2).
1115 getAction().getType());
1116 Assert.assertEquals("Wrong popMplsEthertype", 207,
1117 message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(2).
1118 getAction().getAugmentation(EthertypeAction.class).
1119 getEthertype().getValue().intValue());
1120 Assert.assertEquals("Wrong setQueueType", SetQueue.class,
1121 message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(3).
1122 getAction().getType());
1123 Assert.assertEquals("Wrong setQueueQueueId", 13565952,
1124 message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(3).
1125 getAction().getAugmentation(QueueIdAction.class).
1126 getQueueId().intValue());
1127 Assert.assertEquals("Wrong groupType", Group.class,
1128 message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(4).
1129 getAction().getType());
1130 Assert.assertEquals("Wrong groupGroupId", 13565952,
1131 message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(4).
1132 getAction().getAugmentation(GroupIdAction.class).
1133 getGroupId().intValue());
1134 Assert.assertEquals("Wrong decNwTtlType", DecNwTtl.class,
1135 message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(5).
1136 getAction().getType());
1140 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
1141 * Test covers bodies of actions NW TTL, Experimenter
1144 public void testMultipartReplyGroupDescBody04(){
1145 ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "+
1149 "00 00 00 08 "+//groupId
1150 "00 28 "+//bucketLen
1151 "00 06 "+//bucketWeight
1152 "00 00 00 05 "+//bucketWatchPort
1153 "00 00 00 04 "+//bucketWatchGroup
1154 "00 00 00 00 "+//bucketPad
1155 "00 17 "+//nwTTlType
1158 "00 00 00 "+//nwTTlPad
1159 "00 19 "+//setFieldType
1160 "00 10 "+//setFieldLen
1161 "80 00 "+//setFieldOXMClass
1162 "00 "+//setFieldOXMField
1163 "04 "+//setFieldOXMLength
1164 "00 00 00 FF "+ //setFieldPort
1168 MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
1170 BufferHelper.checkHeaderV13(builtByFactory);
1171 Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
1172 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
1173 MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody();
1174 MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc();
1175 Assert.assertEquals("Wrong type", 1,
1176 message.getGroupDesc().get(0).getType().getIntValue());
1177 Assert.assertEquals("Wrong groupId", 8,
1178 message.getGroupDesc().get(0).getGroupId().getValue().intValue());
1179 Assert.assertEquals("Wrong bucketWeight", 6,
1180 message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());
1181 Assert.assertEquals("Wrong bucketWatchPort", 5,
1182 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().
1183 getValue().intValue());
1184 Assert.assertEquals("Wrong bucketWatchGroup", 4,
1185 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());
1187 Assert.assertEquals("Wrong nwTTlType", SetNwTtl.class,
1188 message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).
1189 getAction().getType());
1191 Assert.assertEquals("Wrong nwTTlnwTTL", 14,
1192 message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(0).
1193 getAction().getAugmentation(NwTtlAction.class).getNwTtl().intValue());
1195 Assert.assertEquals("Wrong setFieldType", SetField.class,
1196 message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1).
1197 getAction().getType());
1199 Assert.assertEquals("Wrong setFieldOXMClass", OpenflowBasicClass.class,
1200 message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1).
1201 getAction().getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0).getOxmClass());
1203 Assert.assertEquals("Wrong setFieldOXMField", InPort.class,
1204 message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1).
1205 getAction().getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0).getOxmMatchField());
1207 Assert.assertEquals("Wrong setFieldOXMValue", 255,
1208 message.getGroupDesc().get(0).getBucketsList().get(0).getActionsList().get(1).
1209 getAction().getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0).
1210 getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue());