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.Before;
17 import org.junit.Test;
18 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
19 import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
20 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
21 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
22 import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
23 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
24 import org.opendaylight.openflowjava.util.ByteBufUtils;
25 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCase;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCase;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDrop;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemark;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCase;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDescCase;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCase;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigCase;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCase;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCase;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregate;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDesc;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroup;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDesc;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.MultipartReplyMeter;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfig;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDesc;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueue;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable;
90 import org.slf4j.Logger;
91 import org.slf4j.LoggerFactory;
94 * @author timotej.kubas
95 * @author michal.polkorab
97 public class MultipartReplyMessageFactoryTest {
99 private OFDeserializer<MultipartReplyMessage> multipartFactory;
102 * Initializes deserializer registry and lookups correct deserializer
105 public void startUp() {
106 DeserializerRegistry registry = new DeserializerRegistryImpl();
108 multipartFactory = registry.getDeserializer(
109 new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 19, MultipartReplyMessage.class));
112 private static final Logger LOGGER = LoggerFactory
113 .getLogger(MultipartReplyMessageFactoryTest.class);
116 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
119 public void testMultipartReplyDescBody(){
120 final int DESC_STR_LEN = 256;
121 final int SERIAL_NUM_LEN = 32;
122 ByteBuf bb = BufferHelper.buildBuffer("00 00 00 01 00 00 00 00");
124 String mfrDesc = "Manufacturer description";
125 byte[] mfrDescBytes = new byte[256];
126 mfrDescBytes = mfrDesc.getBytes();
127 bb.writeBytes(mfrDescBytes);
128 ByteBufUtils.padBuffer((DESC_STR_LEN - mfrDescBytes.length), bb);
130 String hwDesc = "Hardware description";
131 byte[] hwDescBytes = new byte[256];
132 hwDescBytes = hwDesc.getBytes();
133 bb.writeBytes(hwDescBytes);
134 ByteBufUtils.padBuffer((DESC_STR_LEN - hwDescBytes.length), bb);
136 String swDesc = "Software description";
137 byte[] swDescBytes = new byte[256];
138 swDescBytes = swDesc.getBytes();
139 bb.writeBytes(swDescBytes);
140 ByteBufUtils.padBuffer((DESC_STR_LEN - swDescBytes.length), bb);
142 String serialNum = "SN0123456789";
143 byte[] serialNumBytes = new byte[32];
144 serialNumBytes = serialNum.getBytes();
145 bb.writeBytes(serialNumBytes);
146 ByteBufUtils.padBuffer((SERIAL_NUM_LEN - serialNumBytes.length), bb);
148 String dpDesc = "switch3 in room 3120";
149 byte[] dpDescBytes = new byte[256];
150 dpDescBytes = dpDesc.getBytes();
151 bb.writeBytes(dpDescBytes);
152 ByteBufUtils.padBuffer((DESC_STR_LEN - dpDescBytes.length), bb);
154 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
156 BufferHelper.checkHeaderV13(builtByFactory);
157 Assert.assertEquals("Wrong type", 0x00, builtByFactory.getType().getIntValue());
158 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
159 MultipartReplyDescCase messageCase = (MultipartReplyDescCase) builtByFactory.getMultipartReplyBody();
160 MultipartReplyDesc message = messageCase.getMultipartReplyDesc();
161 Assert.assertEquals("Wrong mfrDesc", "Manufacturer description", message.getMfrDesc());
162 Assert.assertEquals("Wrong hwDesc", "Hardware description", message.getHwDesc());
163 Assert.assertEquals("Wrong swDesc", "Software description", message.getSwDesc());
164 Assert.assertEquals("Wrong serialNum", "SN0123456789", message.getSerialNum());
165 Assert.assertEquals("Wrong dpDesc", "switch3 in room 3120", message.getDpDesc());
169 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
172 public void testMultipartReplyFlowBody(){
173 ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 00 00 00 "+
177 "00 00 00 09 "+//durationSec
178 "00 00 00 07 "+//durationNsec
180 "00 0E "+//idleTimeout
181 "00 0F "+//hardTimeout
183 "00 00 00 00 "+//pad_02
184 "FF 01 01 01 01 01 01 01 "+//cookie
185 "EF 01 01 01 01 01 01 01 "+//packetCount
186 "7F 01 01 01 01 01 01 01 "+//byteCount
187 "00 01 00 04 00 00 00 00 "+//empty match
188 "00 01 00 08 06 00 00 00 "+
189 "00 01 00 08 06 00 00 00 "+
193 "00 00 00 09 "+//durationSec
194 "00 00 00 07 "+//durationNsec
196 "00 0E "+//idleTimeout
197 "00 0F "+//hardTimeout
199 "00 00 00 00 "+//pad_02
200 "FF 01 01 01 01 01 01 01 "+//cookie
201 "EF 01 01 01 01 01 01 01 "+//packetCount
202 "7F 01 01 01 01 01 01 01 "+//byteCount
203 "00 01 00 04 00 00 00 00 "+//empty match
204 "00 01 00 08 06 00 00 00 "+
205 "00 01 00 08 06 00 00 00");
207 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
209 BufferHelper.checkHeaderV13(builtByFactory);
210 Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue());
211 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
212 MultipartReplyFlowCase messageCase = (MultipartReplyFlowCase) builtByFactory.getMultipartReplyBody();
213 MultipartReplyFlow message = messageCase.getMultipartReplyFlow();
214 FlowStats flowStats1 = message.getFlowStats().get(0);
215 Assert.assertEquals("Wrong tableId", 8, flowStats1.getTableId().intValue());
216 Assert.assertEquals("Wrong durationSec", 9, flowStats1.getDurationSec().intValue());
217 Assert.assertEquals("Wrong durationNsec", 7, flowStats1.getDurationNsec().intValue());
218 Assert.assertEquals("Wrong priority", 12, flowStats1.getPriority().intValue());
219 Assert.assertEquals("Wrong idleTimeOut", 14, flowStats1.getIdleTimeout().intValue());
220 Assert.assertEquals("Wrong hardTimeOut", 15, flowStats1.getHardTimeout().intValue());
221 Assert.assertEquals("Wrong flags", new FlowModFlags(true, false, true, false, true),
222 flowStats1.getFlags());
223 Assert.assertEquals("Wrong cookie",
224 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
225 flowStats1.getCookie());
226 Assert.assertEquals("Wrong packetCount",
227 new BigInteger(1, new byte[]{(byte) 0xEF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
228 flowStats1.getPacketCount());
229 Assert.assertEquals("Wrong byteCount",
230 new BigInteger(1, new byte[]{(byte) 0x7F, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
231 flowStats1.getByteCount());
232 Assert.assertEquals("Wrong match type", OxmMatchType.class, flowStats1.getMatch().getType());
236 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
239 public void testMultipartReplyAggregateBody(){
240 ByteBuf bb = BufferHelper.buildBuffer("00 02 00 01 00 00 00 00 "+
241 "FF 01 01 01 01 01 01 01 "+//packetCount
242 "0F 01 01 01 01 01 01 01 "+//byteCount
243 "00 00 00 08 "+//flowCount
247 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
249 BufferHelper.checkHeaderV13(builtByFactory);
250 Assert.assertEquals("Wrong type", 0x02, builtByFactory.getType().getIntValue());
251 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
252 MultipartReplyAggregateCase messageCase = (MultipartReplyAggregateCase) builtByFactory.getMultipartReplyBody();
253 MultipartReplyAggregate message = messageCase.getMultipartReplyAggregate();
254 Assert.assertEquals("Wrong packetCount",
255 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
256 message.getPacketCount());
257 Assert.assertEquals("Wrong byteCount",
258 new BigInteger(1, new byte[]{(byte) 0x0F, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
259 message.getByteCount());
260 Assert.assertEquals("Wrong flowCount",
262 message.getFlowCount().intValue());
266 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
269 public void testMultipartReplyTableBody(){
270 ByteBuf bb = BufferHelper.buildBuffer("00 03 00 01 00 00 00 00 "+
273 "00 00 00 10 "+//activeCount
274 "FF 01 01 01 01 01 01 01 "+//lookupCount
275 "AF 01 01 01 01 01 01 01"//matchedCount
278 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
280 BufferHelper.checkHeaderV13(builtByFactory);
281 Assert.assertEquals("Wrong type", 0x03, builtByFactory.getType().getIntValue());
282 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
284 MultipartReplyTableCase messageCase = (MultipartReplyTableCase) builtByFactory.getMultipartReplyBody();
285 MultipartReplyTable message = messageCase.getMultipartReplyTable();
286 Assert.assertEquals("Wrong tableId", 8, message.getTableStats().get(0).getTableId().intValue());
287 Assert.assertEquals("Wrong activeCount", 16, message.getTableStats().get(0).getActiveCount().longValue());
288 Assert.assertEquals("Wrong lookupCount",
289 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
290 message.getTableStats().get(0).getLookupCount());
291 Assert.assertEquals("Wrong matchedCount",
292 new BigInteger(1, new byte[]{(byte) 0xAF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
293 message.getTableStats().get(0).getMatchedCount());
297 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
300 public void testMultipartReplyPortStatsBody(){
301 ByteBuf bb = BufferHelper.buildBuffer("00 04 00 01 00 00 00 00 "+
302 "00 00 00 FF "+//portNo
304 "FF 01 01 01 01 01 01 01 "+//rxPackets
305 "FF 02 02 02 02 02 02 02 "+//txPackets
306 "FF 02 03 02 03 02 03 02 "+//rxBytes
307 "FF 02 03 02 03 02 03 02 "+//txBytes
308 "FF 02 03 02 03 02 03 02 "+//rxDropped
309 "FF 02 03 02 03 02 03 02 "+//txDropped
310 "FF 02 03 02 03 02 03 02 "+//rxErrors
311 "FF 02 03 02 03 02 03 02 "+//txErrors
312 "FF 02 03 02 03 02 03 02 "+//rxFrameErr
313 "FF 02 03 02 03 02 03 02 "+//rxOverErr
314 "FF 02 03 02 03 02 03 02 "+//rxCrcErr
315 "FF 02 03 02 03 02 03 02 "+//collisions
316 "00 00 00 02 "+//durationSec
317 "00 00 00 04"//durationNsec
320 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
322 BufferHelper.checkHeaderV13(builtByFactory);
323 Assert.assertEquals("Wrong type", 0x04, builtByFactory.getType().getIntValue());
324 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
325 MultipartReplyPortStatsCase messageCase = (MultipartReplyPortStatsCase) builtByFactory.getMultipartReplyBody();
326 MultipartReplyPortStats message = messageCase.getMultipartReplyPortStats();
327 Assert.assertEquals("Wrong portNo", 255, message.getPortStats().get(0).getPortNo().intValue());
328 Assert.assertEquals("Wrong rxPackets",
329 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
330 message.getPortStats().get(0).getRxPackets());
331 Assert.assertEquals("Wrong txPackets",
332 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
333 message.getPortStats().get(0).getTxPackets());
334 Assert.assertEquals("Wrong rxBytes",
335 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
336 message.getPortStats().get(0).getRxBytes());
337 Assert.assertEquals("Wrong txBytes",
338 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
339 message.getPortStats().get(0).getTxBytes());
340 Assert.assertEquals("Wrong rxDropped",
341 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
342 message.getPortStats().get(0).getRxDropped());
343 Assert.assertEquals("Wrong txDropped",
344 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
345 message.getPortStats().get(0).getTxDropped());
346 Assert.assertEquals("Wrong rxErrors",
347 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
348 message.getPortStats().get(0).getRxErrors());
349 Assert.assertEquals("Wrong txErrors",
350 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
351 message.getPortStats().get(0).getTxErrors());
352 Assert.assertEquals("Wrong rxFrameErr",
353 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
354 message.getPortStats().get(0).getRxFrameErr());
355 Assert.assertEquals("Wrong rxOverErr",
356 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
357 message.getPortStats().get(0).getRxOverErr());
358 Assert.assertEquals("Wrong rxCrcErr",
359 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
360 message.getPortStats().get(0).getRxCrcErr());
361 Assert.assertEquals("Wrong collisions",
362 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
363 message.getPortStats().get(0).getCollisions());
364 Assert.assertEquals("Wrong durationSec", 2, message.getPortStats().get(0).getDurationSec().intValue());
365 Assert.assertEquals("Wrong durationNsec", 4, message.getPortStats().get(0).getDurationNsec().intValue());
369 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
372 public void testMultipartReplyQueueBody(){
373 ByteBuf bb = BufferHelper.buildBuffer("00 05 00 01 00 00 00 00 "+
374 "00 00 00 FF "+//portNo
375 "00 00 00 10 "+//queueId
376 "FF 02 03 02 03 02 03 02 "+//txBytes
377 "FF 02 02 02 02 02 02 02 "+//txPackets
378 "FF 02 03 02 03 02 03 02 "+//txErrors
379 "00 00 00 02 "+//durationSec
380 "00 00 00 04"//durationNsec
383 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
385 BufferHelper.checkHeaderV13(builtByFactory);
386 Assert.assertEquals("Wrong type", 0x05, builtByFactory.getType().getIntValue());
387 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
388 MultipartReplyQueueCase messageCase = (MultipartReplyQueueCase) builtByFactory.getMultipartReplyBody();
389 MultipartReplyQueue message = messageCase.getMultipartReplyQueue();
390 Assert.assertEquals("Wrong portNo", 255, message.getQueueStats().get(0).getPortNo().intValue());
391 Assert.assertEquals("Wrong queueId", 16, message.getQueueStats().get(0).getQueueId().intValue());
392 Assert.assertEquals("Wrong txBytes",
393 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
394 message.getQueueStats().get(0).getTxBytes());
395 Assert.assertEquals("Wrong txPackets",
396 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
397 message.getQueueStats().get(0).getTxPackets());
398 Assert.assertEquals("Wrong txErrors",
399 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
400 message.getQueueStats().get(0).getTxErrors());
401 Assert.assertEquals("Wrong durationSec", 2, message.getQueueStats().get(0).getDurationSec().intValue());
402 Assert.assertEquals("Wrong durationNsec", 4, message.getQueueStats().get(0).getDurationNsec().intValue());
406 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
409 public void testMultipartReplyGroupBody(){
410 ByteBuf bb = BufferHelper.buildBuffer("00 06 00 01 00 00 00 00 "+
413 "00 00 00 10 "+//groupId
414 "00 00 00 12 "+//refCount
415 "00 00 00 00 "+//pad2
416 "FF 01 01 01 01 01 01 01 "+//packetCount
417 "FF 01 01 01 01 01 01 01 "+//byteCount
418 "00 00 00 08 "+//durationSec
419 "00 00 00 09 "+//durationNsec
420 "FF 01 01 01 01 01 01 01 "+//packetCountBucket
421 "FF 01 01 01 01 01 01 01 "+//byteCountBucket
422 "FF 02 02 02 02 02 02 02 "+//packetCountBucket_2
423 "FF 02 02 02 02 02 02 02 "+//byteCountBucket_2
426 "00 00 00 10 "+//groupId_2
427 "00 00 00 12 "+//refCount_2
428 "00 00 00 00 "+//pad2.2
429 "FF 01 01 01 01 01 01 01 "+//packetCount_2
430 "FF 01 01 01 01 01 01 01 "+//byteCount_2
431 "00 00 00 08 "+//durationSec_2
432 "00 00 00 09 "+//durationNsec_2
433 "FF 01 01 01 01 01 01 01 "+//packetCountBucket_1.2
434 "FF 01 01 01 01 01 01 01 "+//byteCountBucket_1.2
435 "FF 02 02 02 02 02 02 02 "+//packetCountBucket_2.2
436 "FF 02 02 02 02 02 02 02"//byteCountBucket_2.2
439 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
441 BufferHelper.checkHeaderV13(builtByFactory);
442 Assert.assertEquals("Wrong type", 0x06, builtByFactory.getType().getIntValue());
443 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
444 MultipartReplyGroupCase messageCase = (MultipartReplyGroupCase) builtByFactory.getMultipartReplyBody();
445 MultipartReplyGroup message = messageCase.getMultipartReplyGroup();
446 Assert.assertEquals("Wrong groupId", 16, message.getGroupStats().get(0).getGroupId().getValue().intValue());
447 Assert.assertEquals("Wrong refCount", 18, message.getGroupStats().get(0).getRefCount().intValue());
448 Assert.assertEquals("Wrong packetCount",
449 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
450 message.getGroupStats().get(0).getPacketCount());
451 Assert.assertEquals("Wrong byteCount",
452 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
453 message.getGroupStats().get(0).getByteCount());
454 Assert.assertEquals("Wrong durationSec", 8, message.getGroupStats().get(0).getDurationSec().intValue());
455 Assert.assertEquals("Wrong durationNsec", 9, message.getGroupStats().get(0).getDurationNsec().intValue());
456 Assert.assertEquals("Wrong packetCountBucket",
457 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
458 message.getGroupStats().get(0).getBucketStats().get(0).getPacketCount());
459 Assert.assertEquals("Wrong byteCountBucket",
460 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
461 message.getGroupStats().get(0).getBucketStats().get(0).getByteCount());
462 Assert.assertEquals("Wrong packetCountBucket_2",
463 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
464 message.getGroupStats().get(0).getBucketStats().get(1).getPacketCount());
465 Assert.assertEquals("Wrong byteCountBucket_2",
466 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
467 message.getGroupStats().get(0).getBucketStats().get(1).getByteCount());
469 Assert.assertEquals("Wrong groupId_2", 16, message.getGroupStats().get(1).getGroupId().getValue().intValue());
470 Assert.assertEquals("Wrong refCount_2", 18, message.getGroupStats().get(1).getRefCount().intValue());
471 Assert.assertEquals("Wrong packetCount_2",
472 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
473 message.getGroupStats().get(1).getPacketCount());
474 Assert.assertEquals("Wrong byteCount_2",
475 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
476 message.getGroupStats().get(1).getByteCount());
477 Assert.assertEquals("Wrong durationSec_2", 8, message.getGroupStats().get(1).getDurationSec().intValue());
478 Assert.assertEquals("Wrong durationNsec_2", 9, message.getGroupStats().get(1).getDurationNsec().intValue());
479 Assert.assertEquals("Wrong packetCountBucket_1.2",
480 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
481 message.getGroupStats().get(1).getBucketStats().get(0).getPacketCount());
482 Assert.assertEquals("Wrong byteCountBucket_1.2",
483 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
484 message.getGroupStats().get(1).getBucketStats().get(0).getByteCount());
485 Assert.assertEquals("Wrong packetCountBucket_2.2",
486 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
487 message.getGroupStats().get(1).getBucketStats().get(1).getPacketCount());
488 Assert.assertEquals("Wrong byteCountBucket_2.2",
489 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
490 message.getGroupStats().get(1).getBucketStats().get(1).getByteCount());
494 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
497 public void testMultipartReplyMeterFeaturesBody(){
498 ByteBuf bb = BufferHelper.buildBuffer("00 0B 00 01 00 00 00 00 "+
499 "00 00 00 09 "+//maxMeter
500 "00 00 00 01 "+//bandTypes
501 "00 00 00 03 "+//capabilities
507 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
509 BufferHelper.checkHeaderV13(builtByFactory);
510 Assert.assertEquals("Wrong type", 11, builtByFactory.getType().getIntValue());
511 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
512 MultipartReplyMeterFeaturesCase messageCase = (MultipartReplyMeterFeaturesCase) builtByFactory.getMultipartReplyBody();
513 MultipartReplyMeterFeatures message = messageCase.getMultipartReplyMeterFeatures();
514 Assert.assertEquals("Wrong maxMeter", 9, message.getMaxMeter().intValue());
515 Assert.assertEquals("Wrong bandTypes", new MeterBandTypeBitmap(true, false), message.getBandTypes());
516 Assert.assertEquals("Wrong capabilities", new MeterFlags(false, true, true, false),
517 message.getCapabilities());
518 Assert.assertEquals("Wrong maxBands", 3, message.getMaxBands().intValue());
519 Assert.assertEquals("Wrong maxColor", 4, message.getMaxColor().intValue());
523 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
526 public void testMultipartReplyMeterBody(){
527 ByteBuf bb = BufferHelper.buildBuffer("00 09 00 01 00 00 00 00 "+
528 "00 00 00 09 "+//meterId
530 "00 00 00 00 00 00 "+//pad
531 "00 00 00 07 "+//flowCount
532 "FF 01 01 01 01 01 01 01 "+//packetInCount
533 "FF 01 01 01 01 01 01 01 "+//byteInCount
534 "00 00 00 05 "+//durationSec
535 "00 00 00 05 "+//durationNsec
536 "FF 01 01 01 01 01 01 01 "+//packetBandCount_01
537 "FF 01 01 01 01 01 01 01 "+//byteBandCount_01
538 "FF 02 02 02 02 02 02 02 "+//packetBandCount_02
539 "FF 02 02 02 02 02 02 02 "+//byteBandCount_02
540 "FF 03 03 03 03 03 03 03 "+//packetBandCount_03
541 "FF 03 03 03 03 03 03 03"//byteBandCount_03
544 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
546 BufferHelper.checkHeaderV13(builtByFactory);
547 Assert.assertEquals("Wrong type", 9, builtByFactory.getType().getIntValue());
548 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
549 MultipartReplyMeterCase messageCase = (MultipartReplyMeterCase) builtByFactory.getMultipartReplyBody();
550 MultipartReplyMeter message = messageCase.getMultipartReplyMeter();
551 Assert.assertEquals("Wrong meterId", 9,
552 message.getMeterStats().get(0).getMeterId().getValue().intValue());
553 Assert.assertEquals("Wrong flowCount", 7,
554 message.getMeterStats().get(0).getFlowCount().intValue());
555 Assert.assertEquals("Wrong packetInCount",
556 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
557 message.getMeterStats().get(0).getPacketInCount());
558 Assert.assertEquals("Wrong byteInCount",
559 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
560 message.getMeterStats().get(0).getByteInCount());
561 Assert.assertEquals("Wrong durationSec", 5,
562 message.getMeterStats().get(0).getDurationSec().intValue());
563 Assert.assertEquals("Wrong durationNsec", 5,
564 message.getMeterStats().get(0).getDurationNsec().intValue());
565 Assert.assertEquals("Wrong packetBandCount_01",
566 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
567 message.getMeterStats().get(0).getMeterBandStats().get(0).getPacketBandCount());
568 Assert.assertEquals("Wrong byteBandCount_01",
569 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
570 message.getMeterStats().get(0).getMeterBandStats().get(0).getByteBandCount());
571 Assert.assertEquals("Wrong packetBandCount_02",
572 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
573 message.getMeterStats().get(0).getMeterBandStats().get(1).getPacketBandCount());
574 Assert.assertEquals("Wrong byteBandCount_02",
575 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
576 message.getMeterStats().get(0).getMeterBandStats().get(1).getByteBandCount());
577 Assert.assertEquals("Wrong packetBandCount_03",
578 new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}),
579 message.getMeterStats().get(0).getMeterBandStats().get(2).getPacketBandCount());
580 Assert.assertEquals("Wrong byteBandCount_03",
581 new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}),
582 message.getMeterStats().get(0).getMeterBandStats().get(2).getByteBandCount());
586 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
589 public void testMultipartReplyMeterBodyMulti(){
590 ByteBuf bb = BufferHelper.buildBuffer("00 09 00 01 00 00 00 00 "+
591 "00 00 00 09 "+//meterId_0
593 "00 00 00 00 00 00 "+//pad_0
594 "00 00 00 07 "+//flowCount_0
595 "FF 01 01 01 01 01 01 01 "+//packetInCount_0
596 "FF 01 01 01 01 01 01 01 "+//byteInCount_0
597 "00 00 00 05 "+//durationSec_0
598 "00 00 00 05 "+//durationNsec_0
599 "FF 01 01 01 01 01 01 01 "+//packetBandCount_01
600 "FF 01 01 01 01 01 01 01 "+//byteBandCount_01
601 "FF 02 02 02 02 02 02 02 "+//packetBandCount_02
602 "FF 02 02 02 02 02 02 02 "+//byteBandCount_02
603 "FF 03 03 03 03 03 03 03 "+//packetBandCount_03
604 "FF 03 03 03 03 03 03 03 "+//byteBandCount_03
605 "00 00 00 08 "+//meterId_1
607 "00 00 00 00 00 00 "+//pad_1
608 "00 00 00 07 "+//flowCount_1
609 "FF 01 01 01 01 01 01 01 "+//packetInCount_1
610 "FF 01 01 01 01 01 01 01 "+//byteInCount_1
611 "00 00 00 05 "+//durationSec_1
612 "00 00 00 05 "+//durationNsec_1
613 "FF 01 01 01 01 01 01 01 "+//packetBandCount_11
614 "FF 01 01 01 01 01 01 01 "+//byteBandCount_11
615 "FF 02 02 02 02 02 02 02 "+//packetBandCount_12
616 "FF 02 02 02 02 02 02 02 "+//byteBandCount_12
617 "FF 03 03 03 03 03 03 03 "+//packetBandCount_13
618 "FF 03 03 03 03 03 03 03"//byteBandCount_13
621 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
623 BufferHelper.checkHeaderV13(builtByFactory);
624 Assert.assertEquals("Wrong type", 9, builtByFactory.getType().getIntValue());
625 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
626 MultipartReplyMeterCase messageCase = (MultipartReplyMeterCase) builtByFactory.getMultipartReplyBody();
627 MultipartReplyMeter message = messageCase.getMultipartReplyMeter();
628 Assert.assertEquals("Wrong meterId", 9,
629 message.getMeterStats().get(0).getMeterId().getValue().intValue());
630 Assert.assertEquals("Wrong flowCount", 7,
631 message.getMeterStats().get(0).getFlowCount().intValue());
632 Assert.assertEquals("Wrong packetInCount",
633 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
634 message.getMeterStats().get(0).getPacketInCount());
635 Assert.assertEquals("Wrong byteInCount",
636 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
637 message.getMeterStats().get(0).getByteInCount());
638 Assert.assertEquals("Wrong durationSec", 5,
639 message.getMeterStats().get(0).getDurationSec().intValue());
640 Assert.assertEquals("Wrong durationNsec", 5,
641 message.getMeterStats().get(0).getDurationNsec().intValue());
642 Assert.assertEquals("Wrong packetBandCount_01",
643 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
644 message.getMeterStats().get(0).getMeterBandStats().get(0).getPacketBandCount());
645 Assert.assertEquals("Wrong byteBandCount_01",
646 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
647 message.getMeterStats().get(0).getMeterBandStats().get(0).getByteBandCount());
648 Assert.assertEquals("Wrong packetBandCount_02",
649 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
650 message.getMeterStats().get(0).getMeterBandStats().get(1).getPacketBandCount());
651 Assert.assertEquals("Wrong byteBandCount_02",
652 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
653 message.getMeterStats().get(0).getMeterBandStats().get(1).getByteBandCount());
654 Assert.assertEquals("Wrong packetBandCount_03",
655 new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}),
656 message.getMeterStats().get(0).getMeterBandStats().get(2).getPacketBandCount());
657 Assert.assertEquals("Wrong byteBandCount_03",
658 new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}),
659 message.getMeterStats().get(0).getMeterBandStats().get(2).getByteBandCount());
661 Assert.assertEquals("Wrong meterId", 8,
662 message.getMeterStats().get(1).getMeterId().getValue().intValue());
663 Assert.assertEquals("Wrong flowCount", 7,
664 message.getMeterStats().get(1).getFlowCount().intValue());
665 Assert.assertEquals("Wrong packetInCount",
666 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
667 message.getMeterStats().get(1).getPacketInCount());
668 Assert.assertEquals("Wrong byteInCount",
669 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
670 message.getMeterStats().get(1).getByteInCount());
671 Assert.assertEquals("Wrong durationSec", 5,
672 message.getMeterStats().get(1).getDurationSec().intValue());
673 Assert.assertEquals("Wrong durationNsec", 5,
674 message.getMeterStats().get(1).getDurationNsec().intValue());
675 Assert.assertEquals("Wrong packetBandCount_01",
676 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
677 message.getMeterStats().get(1).getMeterBandStats().get(0).getPacketBandCount());
678 Assert.assertEquals("Wrong byteBandCount_01",
679 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
680 message.getMeterStats().get(1).getMeterBandStats().get(0).getByteBandCount());
681 Assert.assertEquals("Wrong packetBandCount_02",
682 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
683 message.getMeterStats().get(1).getMeterBandStats().get(1).getPacketBandCount());
684 Assert.assertEquals("Wrong byteBandCount_02",
685 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
686 message.getMeterStats().get(1).getMeterBandStats().get(1).getByteBandCount());
687 Assert.assertEquals("Wrong packetBandCount_03",
688 new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}),
689 message.getMeterStats().get(1).getMeterBandStats().get(2).getPacketBandCount());
690 Assert.assertEquals("Wrong byteBandCount_03",
691 new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}),
692 message.getMeterStats().get(1).getMeterBandStats().get(2).getByteBandCount());
696 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
699 public void testMultipartReplyMeterConfigBody(){
700 ByteBuf bb = BufferHelper.buildBuffer("00 0A 00 01 00 00 00 00 "+
703 "00 00 00 09 "+//meterId
704 "00 01 "+//meterBandDrop.type
705 "00 10 "+//meterBandDrop.len
706 "00 00 00 11 "+//meterBandDrop.rate
707 "00 00 00 20 "+//meterBandDrop.burstSize
708 "00 00 00 00 "+//meterBandDrop.pad
709 "00 02 "+//meterBandDscp.type
710 "00 10 "+//meterBandDscp.len
711 "00 00 00 11 "+//meterBandDscp.rate
712 "00 00 00 20 "+//meterBandDscp.burstSize
713 "04 "+//meterBandDscp.precLevel
714 "00 00 00");//meterBandDscp.pad
716 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
718 BufferHelper.checkHeaderV13(builtByFactory);
719 Assert.assertEquals("Wrong type", 10, builtByFactory.getType().getIntValue());
720 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
721 MultipartReplyMeterConfigCase messageCase = (MultipartReplyMeterConfigCase) builtByFactory.getMultipartReplyBody();
722 MultipartReplyMeterConfig message = messageCase.getMultipartReplyMeterConfig();
723 Assert.assertEquals("Wrong flags", new MeterFlags(false, false, true, true),
724 message.getMeterConfig().get(0).getFlags());
725 Assert.assertEquals("Wrong meterId", 9,
726 message.getMeterConfig().get(0).getMeterId().getValue().intValue());
728 MeterBandDropCase dropCase = (MeterBandDropCase) message.getMeterConfig().get(0).getBands().get(0).getMeterBand();
729 MeterBandDrop meterBandDrop = dropCase.getMeterBandDrop();
730 Assert.assertEquals("Wrong meterBandDrop.type", 1, meterBandDrop.getType().getIntValue());
731 Assert.assertEquals("Wrong meterBandDrop.rate", 17, meterBandDrop.getRate().intValue());
732 Assert.assertEquals("Wrong meterBandDrop.burstSize", 32, meterBandDrop.getBurstSize().intValue());
734 MeterBandDscpRemarkCase dscpCase = (MeterBandDscpRemarkCase) message.getMeterConfig().get(0).getBands().get(1).getMeterBand();
735 MeterBandDscpRemark meterBandDscp = dscpCase.getMeterBandDscpRemark();
736 Assert.assertEquals("Wrong meterBandDscp.type", 2, meterBandDscp.getType().getIntValue());
737 Assert.assertEquals("Wrong meterBandDscp.rate", 17, meterBandDscp.getRate().intValue());
738 Assert.assertEquals("Wrong meterBandDscp.burstSize", 32, meterBandDscp.getBurstSize().intValue());
739 Assert.assertEquals("Wrong meterBandDscp.precLevel", 4, meterBandDscp.getPrecLevel().intValue());
743 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
746 public void testMultipartReplyMeterConfigBodyMulti(){
747 ByteBuf bb = BufferHelper.buildBuffer("00 0A 00 01 00 00 00 00 "+
750 "00 00 00 09 "+//meterId
751 "00 01 "+//meterBandDrop.type
752 "00 10 "+//meterBandDrop.len
753 "00 00 00 11 "+//meterBandDrop.rate
754 "00 00 00 20 "+//meterBandDrop.burstSize
755 "00 00 00 00 "+//meterBandDrop.pad
756 "00 02 "+//meterBandDscp.type
757 "00 10 "+//meterBandDscp.len
758 "00 00 00 11 "+//meterBandDscp.rate
759 "00 00 00 20 "+//meterBandDscp.burstSize
760 "04 "+//meterBandDscp.precLevel
761 "00 00 00 "+//meterBandDscp.pad
765 "00 00 00 07 "+//meterId01
766 "00 02 "+//meterBandDscp01.type
767 "00 10 "+//meterBandDscp01.len
768 "00 00 00 11 "+//meterBandDscp01.rate
769 "00 00 00 20 "+//meterBandDscp01.burstSize
770 "04 "+//meterBandDscp01.precLevel
771 "00 00 00"//meterBandDscp01.pad
774 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
776 BufferHelper.checkHeaderV13(builtByFactory);
777 Assert.assertEquals("Wrong type", 10, builtByFactory.getType().getIntValue());
778 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
779 MultipartReplyMeterConfigCase messageCase = (MultipartReplyMeterConfigCase) builtByFactory.getMultipartReplyBody();
780 MultipartReplyMeterConfig message = messageCase.getMultipartReplyMeterConfig();
781 Assert.assertEquals("Wrong flags", new MeterFlags(true, false, true, false),
782 message.getMeterConfig().get(0).getFlags());
783 Assert.assertEquals("Wrong meterId", 9,
784 message.getMeterConfig().get(0).getMeterId().getValue().intValue());
786 MeterBandDropCase dropCase = (MeterBandDropCase) message.getMeterConfig().get(0).getBands().get(0).getMeterBand();
787 MeterBandDrop meterBandDrop = dropCase.getMeterBandDrop();
788 Assert.assertEquals("Wrong meterBandDrop.type", 1, meterBandDrop.getType().getIntValue());
789 Assert.assertEquals("Wrong meterBandDrop.rate", 17, meterBandDrop.getRate().intValue());
790 Assert.assertEquals("Wrong meterBandDrop.burstSize", 32, meterBandDrop.getBurstSize().intValue());
792 MeterBandDscpRemarkCase dscpCase = (MeterBandDscpRemarkCase) message.getMeterConfig().get(0).getBands().get(1).getMeterBand();
793 MeterBandDscpRemark meterBandDscp = dscpCase.getMeterBandDscpRemark();
794 Assert.assertEquals("Wrong meterBandDscp.type", 2, meterBandDscp.getType().getIntValue());
795 Assert.assertEquals("Wrong meterBandDscp.rate", 17, meterBandDscp.getRate().intValue());
796 Assert.assertEquals("Wrong meterBandDscp.burstSize", 32, meterBandDscp.getBurstSize().intValue());
797 Assert.assertEquals("Wrong meterBandDscp.precLevel", 4, meterBandDscp.getPrecLevel().intValue());
799 LOGGER.info(message.getMeterConfig().get(0).getFlags().toString());
800 Assert.assertEquals("Wrong flags01", new MeterFlags(false, true, true, false),
801 message.getMeterConfig().get(1).getFlags());
802 Assert.assertEquals("Wrong meterId01", 7,
803 message.getMeterConfig().get(1).getMeterId().getValue().intValue());
805 MeterBandDscpRemarkCase dscpCase01 = (MeterBandDscpRemarkCase) message.getMeterConfig().get(1).getBands().get(0).getMeterBand();
806 MeterBandDscpRemark meterBandDscp01 = dscpCase01.getMeterBandDscpRemark();
807 Assert.assertEquals("Wrong meterBandDscp01.type", 2, meterBandDscp01.getType().getIntValue());
808 Assert.assertEquals("Wrong meterBandDscp01.rate", 17, meterBandDscp01.getRate().intValue());
809 Assert.assertEquals("Wrong meterBandDscp01.burstSize", 32, meterBandDscp01.getBurstSize().intValue());
810 Assert.assertEquals("Wrong meterBandDscp01.precLevel", 4, meterBandDscp01.getPrecLevel().intValue());
815 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
818 public void testMultipartReplyPortDescBody(){
819 final byte MAX_PORT_NAME_LEN = 16;
820 ByteBuf bb = BufferHelper.buildBuffer("00 0D 00 01 00 00 00 00 "+
821 "00 01 02 03 "+ //portNo
822 "00 00 00 00 "+ //padding01
823 "08 00 27 00 B0 EB " + //mac address
824 "00 00"); //padding02
826 String portName = "SampleText";
827 byte[] portNameBytes = new byte[MAX_PORT_NAME_LEN];
828 portNameBytes = portName.getBytes();
829 bb.writeBytes(portNameBytes);
830 ByteBufUtils.padBuffer((MAX_PORT_NAME_LEN - portNameBytes.length), bb);
832 ByteBuf bb2 = BufferHelper.buildBuffer("00 00 00 41 " + //port config
833 "00 00 00 05 " + //port state
834 "00 00 00 81 " + //current features
835 "00 00 81 81 " + //advertised features
836 "00 00 C1 89 " + //supported features
837 "00 00 C5 8D " + //peer features
838 "00 00 00 81 " + //curr speed
839 "00 00 00 80" //max speed
841 bb.writeBytes(bb2.copy(4, bb2.readableBytes()-4));//excluding version and xid
843 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
845 BufferHelper.checkHeaderV13(builtByFactory);
846 Assert.assertEquals("Wrong type", 13, builtByFactory.getType().getIntValue());
847 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
848 MultipartReplyPortDescCase messageCase = (MultipartReplyPortDescCase) builtByFactory.getMultipartReplyBody();
849 MultipartReplyPortDesc message = messageCase.getMultipartReplyPortDesc();
850 Assert.assertEquals("Wrong portNo", 66051L, message.getPorts().get(0).getPortNo().longValue());
851 Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:B0:EB"),
852 message.getPorts().get(0).getHwAddr());
853 Assert.assertEquals("Wrong portName", "SampleText",
854 message.getPorts().get(0).getName());
855 Assert.assertEquals("Wrong portConfig", new PortConfig(false, true, false, true),
856 message.getPorts().get(0).getConfig());
857 Assert.assertEquals("Wrong portState", new PortState(false, true, true),
858 message.getPorts().get(0).getState());
859 Assert.assertEquals("Wrong currentFeatures", new PortFeatures(false, false, false, false,
860 false, true, false, false,
861 false, true, false, false,
862 false, false, false, false),
863 message.getPorts().get(0).getCurrentFeatures());
864 Assert.assertEquals("Wrong advertisedFeatures",
865 new PortFeatures(true, false, false, false,
866 false, true, false, false,
867 false, true, false, false,
868 false, false, false, true),
869 message.getPorts().get(0).getAdvertisedFeatures());
870 Assert.assertEquals("Wrong supportedFeatures",
871 new PortFeatures(true, true, false, false,
872 false, true, false, false,
873 false, true, false, false,
874 false, false, true, true),
875 message.getPorts().get(0).getSupportedFeatures());
876 Assert.assertEquals("Wrong peerFeatures",
877 new PortFeatures(true, true, true, false,
878 false, true, false, false,
879 false, true, false, false,
880 false, true, true, true),
881 message.getPorts().get(0).getPeerFeatures());
882 Assert.assertEquals("Wrong currSpeed", 129L, message.getPorts().get(0).getCurrSpeed().longValue());
883 Assert.assertEquals("Wrong maxSpeed", 128L, message.getPorts().get(0).getMaxSpeed().longValue());
887 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
888 * Test covers bodies of actions Output, Copy TTL Out, Copy TTL In
891 public void testMultipartReplyGroupDescBody01(){
892 ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "+
896 "00 00 00 08 "+//groupId
898 "00 06 "+//bucketWeight
899 "00 00 00 05 "+//bucketWatchPort
900 "00 00 00 04 "+//bucketWatchGroup
901 "00 00 00 00 "+//bucketPad
902 "00 00 "+//outputType
904 "00 00 10 FF "+//outputPort
905 "FF FF "+//outputMaxLen
906 "00 00 00 00 00 00 "+//outputPad
907 "00 0B "+//copyTTLOutType
908 "00 08 "+//copyTTLOutLen
909 "00 00 00 00 "+//copyTTLOutPad
910 "00 0C "+//copyTTLIntType
911 "00 08 "+//copyTTLIntLen
912 "00 00 00 00"//copyTTLInPad
914 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
916 BufferHelper.checkHeaderV13(builtByFactory);
917 Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
918 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
919 MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody();
920 MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc();
921 Assert.assertEquals("Wrong type", 1,
922 message.getGroupDesc().get(0).getType().getIntValue());
923 Assert.assertEquals("Wrong groupId", 8,
924 message.getGroupDesc().get(0).getGroupId().getValue().intValue());
925 Assert.assertEquals("Wrong bucketWeight", 6,
926 message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());
927 Assert.assertEquals("Wrong bucketWatchPort", 5,
928 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().
929 getValue().intValue());
930 Assert.assertEquals("Wrong bucketWatchGroup", 4,
931 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());
933 Assert.assertEquals("Wrong outputType", Output.class,
934 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0)
937 Assert.assertEquals("Wrong outputPort", 4351,
938 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0)
939 .getAugmentation(PortAction.class).
940 getPort().getValue().intValue());
942 Assert.assertEquals("Wrong outputMaxLen", 65535,
943 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0)
944 .getAugmentation(MaxLengthAction.class).
945 getMaxLength().intValue());
947 Assert.assertEquals("Wrong copyTtlOutType", CopyTtlOut.class,
948 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1)
951 Assert.assertEquals("Wrong copyTtlInType", CopyTtlIn.class,
952 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2)
957 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
958 * Test covers bodies of actions Set MPLS TTL , Dec MPLS TTL, Push VLAN. Push MPLS, Push PBB
961 public void testMultipartReplyGroupDescBody02(){
962 ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "+
966 "00 00 00 08 "+//groupId
968 "00 06 "+//bucketWeight
969 "00 00 00 05 "+//bucketWatchPort
970 "00 00 00 04 "+//bucketWatchGroup
971 "00 00 00 00 "+//bucketPad
972 "00 0F "+//setMplsTtlType
973 "00 08 "+//setMplsTtlLen
974 "09 "+//setMplsTtlMPLS_TTL
975 "00 00 00 "+//setMplsTtlPad
976 "00 10 "+//decMplsTtlType
977 "00 08 "+//decMplsTtlLen
978 "00 00 00 00 "+//decMplsTtlPad
979 "00 11 "+//pushVlanType
980 "00 08 "+//pushVlanLen
981 "00 20 "+//pushVlanEthertype
982 "00 00 "+//pushVlanPad
983 "00 13 "+//pushMplsType
984 "00 08 "+//pushMplsLen
985 "00 FF "+//pushMplsEthertype
986 "00 00 "+//pushMplsPad
987 "00 1A "+//pushPbbType
988 "00 08 "+//pushPbbLen
989 "0F FF "+//pushPbbEthertype
993 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
995 BufferHelper.checkHeaderV13(builtByFactory);
996 Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
997 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
998 MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody();
999 MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc();
1000 Assert.assertEquals("Wrong type", 1,
1001 message.getGroupDesc().get(0).getType().getIntValue());
1002 Assert.assertEquals("Wrong groupId", 8,
1003 message.getGroupDesc().get(0).getGroupId().getValue().intValue());
1004 Assert.assertEquals("Wrong bucketWeight", 6,
1005 message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());
1006 Assert.assertEquals("Wrong bucketWatchPort", 5,
1007 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().getValue().intValue());
1008 Assert.assertEquals("Wrong bucketWatchGroup", 4,
1009 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());
1010 Assert.assertEquals("Wrong setMplsTtlType", SetMplsTtl.class,
1011 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0)
1013 Assert.assertEquals("Wrong setMplsTtlMPLS_TTL", 9,
1014 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0)
1015 .getAugmentation(MplsTtlAction.class).
1016 getMplsTtl().intValue());
1017 Assert.assertEquals("Wrong decMplsTtlType", DecMplsTtl.class,
1018 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1)
1020 Assert.assertEquals("Wrong pushVlanType", PushVlan.class,
1021 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2)
1023 Assert.assertEquals("Wrong pushVlanEthertype", 32,
1024 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2)
1025 .getAugmentation(EthertypeAction.class).
1026 getEthertype().getValue().intValue());
1027 Assert.assertEquals("Wrong pushMplsType", PushMpls.class,
1028 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(3)
1030 Assert.assertEquals("Wrong pushMplsEthertype", 255,
1031 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(3).
1032 getAugmentation(EthertypeAction.class).
1033 getEthertype().getValue().intValue());
1034 Assert.assertEquals("Wrong pushPbbType", PushPbb.class,
1035 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(4)
1037 Assert.assertEquals("Wrong pushPbbEthertype", 4095,
1038 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(4)
1039 .getAugmentation(EthertypeAction.class).
1040 getEthertype().getValue().intValue());
1044 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
1045 * Test covers bodies of actions Pop VLAN, Pop PBB, Pop MPLS, Group, Dec NW TTL
1048 public void testMultipartReplyGroupDescBody03(){
1049 ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "+
1053 "00 00 00 08 "+//groupId
1054 "00 40 "+//bucketLen
1055 "00 06 "+//bucketWeight
1056 "00 00 00 05 "+//bucketWatchPort
1057 "00 00 00 04 "+//bucketWatchGroup
1058 "00 00 00 00 "+//bucketPad
1059 "00 12 "+//popVlanType
1060 "00 08 "+//popVlanLen
1061 "00 00 00 00 "+//popVlanPad
1062 "00 1B "+//popPbbType
1063 "00 08 "+//popPbbLen
1064 "00 00 00 00 "+//popPbbPad
1065 "00 14 "+//popMplsType
1066 "00 08 "+//popMplsLen
1067 "00 CF "+//popMplsEthertype
1068 "00 00 "+//popMplsPad
1069 "00 15 "+//setQueueType
1070 "00 08 "+//setQueueLen
1071 "00 CF 00 00 "+//setQueueQueueId
1072 "00 16 "+//groupType
1074 "00 CF 00 00 "+//groupGroupId
1075 "00 18 "+//decNwTtlType
1076 "00 08 "+//decNwTtlLen
1077 "00 00 00 00"//decNwTtlPad
1080 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
1082 BufferHelper.checkHeaderV13(builtByFactory);
1083 Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
1084 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
1085 MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody();
1086 MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc();
1087 Assert.assertEquals("Wrong type", 1, message.getGroupDesc().get(0).getType().getIntValue());
1088 Assert.assertEquals("Wrong groupId", 8, message.getGroupDesc().get(0).getGroupId().getValue().intValue());
1089 Assert.assertEquals("Wrong bucketWeight", 6,
1090 message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());
1091 Assert.assertEquals("Wrong bucketWatchPort", 5,
1092 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().getValue().intValue());
1093 Assert.assertEquals("Wrong bucketWatchGroup", 4,
1094 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());
1095 Assert.assertEquals("Wrong popVlanType", PopVlan.class,
1096 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0)
1098 Assert.assertEquals("Wrong popPbbType", PopPbb.class,
1099 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1)
1101 Assert.assertEquals("Wrong popMplsType", PopMpls.class,
1102 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2)
1104 Assert.assertEquals("Wrong popMplsEthertype", 207,
1105 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2)
1106 .getAugmentation(EthertypeAction.class).
1107 getEthertype().getValue().intValue());
1108 Assert.assertEquals("Wrong setQueueType", SetQueue.class,
1109 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(3)
1111 Assert.assertEquals("Wrong setQueueQueueId", 13565952,
1112 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(3)
1113 .getAugmentation(QueueIdAction.class).
1114 getQueueId().intValue());
1115 Assert.assertEquals("Wrong groupType", Group.class,
1116 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(4)
1118 Assert.assertEquals("Wrong groupGroupId", 13565952,
1119 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(4)
1120 .getAugmentation(GroupIdAction.class).
1121 getGroupId().intValue());
1122 Assert.assertEquals("Wrong decNwTtlType", DecNwTtl.class,
1123 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(5)
1128 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
1129 * Test covers bodies of actions NW TTL, Experimenter
1132 public void testMultipartReplyGroupDescBody04(){
1133 ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "+
1137 "00 00 00 08 "+//groupId
1138 "00 28 "+//bucketLen
1139 "00 06 "+//bucketWeight
1140 "00 00 00 05 "+//bucketWatchPort
1141 "00 00 00 04 "+//bucketWatchGroup
1142 "00 00 00 00 "+//bucketPad
1143 "00 17 "+//nwTTlType
1146 "00 00 00 "+//nwTTlPad
1147 "00 19 "+//setFieldType
1148 "00 10 "+//setFieldLen
1149 "80 00 "+//setFieldOXMClass
1150 "00 "+//setFieldOXMField
1151 "04 "+//setFieldOXMLength
1152 "00 00 00 FF "+ //setFieldPort
1156 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
1158 BufferHelper.checkHeaderV13(builtByFactory);
1159 Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
1160 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
1161 MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody();
1162 MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc();
1163 Assert.assertEquals("Wrong type", 1,
1164 message.getGroupDesc().get(0).getType().getIntValue());
1165 Assert.assertEquals("Wrong groupId", 8,
1166 message.getGroupDesc().get(0).getGroupId().getValue().intValue());
1167 Assert.assertEquals("Wrong bucketWeight", 6,
1168 message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());
1169 Assert.assertEquals("Wrong bucketWatchPort", 5,
1170 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().
1171 getValue().intValue());
1172 Assert.assertEquals("Wrong bucketWatchGroup", 4,
1173 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());
1175 Assert.assertEquals("Wrong nwTTlType", SetNwTtl.class,
1176 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0)
1179 Assert.assertEquals("Wrong nwTTlnwTTL", 14,
1180 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0)
1181 .getAugmentation(NwTtlAction.class).getNwTtl().intValue());
1183 Assert.assertEquals("Wrong setFieldType", SetField.class,
1184 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1)
1187 Assert.assertEquals("Wrong setFieldOXMClass", OpenflowBasicClass.class,
1188 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1)
1189 .getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0).getOxmClass());
1191 Assert.assertEquals("Wrong setFieldOXMField", InPort.class,
1192 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1)
1193 .getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0).getOxmMatchField());
1195 Assert.assertEquals("Wrong setFieldOXMValue", 255,
1196 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1)
1197 .getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0).
1198 getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue());