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