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.opendaylight.openflow.augments.rev131002.EthertypeAction;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCase;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCase;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDrop;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemark;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCase;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDescCase;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCase;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigCase;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCase;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregate;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDesc;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroup;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDesc;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.MultipartReplyMeter;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfig;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueue;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable;
75 import org.slf4j.Logger;
76 import org.slf4j.LoggerFactory;
79 * @author timotej.kubas
80 * @author michal.polkorab
82 public class MultipartReplyMessageFactoryTest {
84 private OFDeserializer<MultipartReplyMessage> multipartFactory;
87 * Initializes deserializer registry and lookups correct deserializer
90 public void startUp() {
91 DeserializerRegistry registry = new DeserializerRegistryImpl();
93 multipartFactory = registry.getDeserializer(
94 new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 19, MultipartReplyMessage.class));
97 private static final Logger LOGGER = LoggerFactory
98 .getLogger(MultipartReplyMessageFactoryTest.class);
101 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
104 public void testMultipartReplyDescBody(){
105 final int DESC_STR_LEN = 256;
106 final int SERIAL_NUM_LEN = 32;
107 ByteBuf bb = BufferHelper.buildBuffer("00 00 00 01 00 00 00 00");
109 String mfrDesc = "Manufacturer description";
110 byte[] mfrDescBytes = new byte[256];
111 mfrDescBytes = mfrDesc.getBytes();
112 bb.writeBytes(mfrDescBytes);
113 bb.writeZero(DESC_STR_LEN - mfrDescBytes.length);
115 String hwDesc = "Hardware description";
116 byte[] hwDescBytes = new byte[256];
117 hwDescBytes = hwDesc.getBytes();
118 bb.writeBytes(hwDescBytes);
119 bb.writeZero(DESC_STR_LEN - hwDescBytes.length);
121 String swDesc = "Software description";
122 byte[] swDescBytes = new byte[256];
123 swDescBytes = swDesc.getBytes();
124 bb.writeBytes(swDescBytes);
125 bb.writeZero(DESC_STR_LEN - swDescBytes.length);
127 String serialNum = "SN0123456789";
128 byte[] serialNumBytes = new byte[32];
129 serialNumBytes = serialNum.getBytes();
130 bb.writeBytes(serialNumBytes);
131 bb.writeZero(SERIAL_NUM_LEN - serialNumBytes.length);
133 String dpDesc = "switch3 in room 3120";
134 byte[] dpDescBytes = new byte[256];
135 dpDescBytes = dpDesc.getBytes();
136 bb.writeBytes(dpDescBytes);
137 bb.writeZero(DESC_STR_LEN - dpDescBytes.length);
139 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
141 BufferHelper.checkHeaderV13(builtByFactory);
142 Assert.assertEquals("Wrong type", 0x00, builtByFactory.getType().getIntValue());
143 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
144 MultipartReplyDescCase messageCase = (MultipartReplyDescCase) builtByFactory.getMultipartReplyBody();
145 MultipartReplyDesc message = messageCase.getMultipartReplyDesc();
146 Assert.assertEquals("Wrong mfrDesc", "Manufacturer description", message.getMfrDesc());
147 Assert.assertEquals("Wrong hwDesc", "Hardware description", message.getHwDesc());
148 Assert.assertEquals("Wrong swDesc", "Software description", message.getSwDesc());
149 Assert.assertEquals("Wrong serialNum", "SN0123456789", message.getSerialNum());
150 Assert.assertEquals("Wrong dpDesc", "switch3 in room 3120", message.getDpDesc());
154 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
157 public void testMultipartReplyAggregateBody(){
158 ByteBuf bb = BufferHelper.buildBuffer("00 02 00 01 00 00 00 00 "+
159 "FF 01 01 01 01 01 01 01 "+//packetCount
160 "0F 01 01 01 01 01 01 01 "+//byteCount
161 "00 00 00 08 "+//flowCount
165 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
167 BufferHelper.checkHeaderV13(builtByFactory);
168 Assert.assertEquals("Wrong type", 0x02, builtByFactory.getType().getIntValue());
169 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
170 MultipartReplyAggregateCase messageCase = (MultipartReplyAggregateCase) builtByFactory.getMultipartReplyBody();
171 MultipartReplyAggregate message = messageCase.getMultipartReplyAggregate();
172 Assert.assertEquals("Wrong packetCount",
173 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
174 message.getPacketCount());
175 Assert.assertEquals("Wrong byteCount",
176 new BigInteger(1, new byte[]{(byte) 0x0F, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
177 message.getByteCount());
178 Assert.assertEquals("Wrong flowCount",
180 message.getFlowCount().intValue());
184 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
187 public void testMultipartReplyTableBody(){
188 ByteBuf bb = BufferHelper.buildBuffer("00 03 00 01 00 00 00 00 "+
191 "00 00 00 10 "+//activeCount
192 "FF 01 01 01 01 01 01 01 "+//lookupCount
193 "AF 01 01 01 01 01 01 01"//matchedCount
196 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
198 BufferHelper.checkHeaderV13(builtByFactory);
199 Assert.assertEquals("Wrong type", 0x03, builtByFactory.getType().getIntValue());
200 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
202 MultipartReplyTableCase messageCase = (MultipartReplyTableCase) builtByFactory.getMultipartReplyBody();
203 MultipartReplyTable message = messageCase.getMultipartReplyTable();
204 Assert.assertEquals("Wrong tableId", 8, message.getTableStats().get(0).getTableId().intValue());
205 Assert.assertEquals("Wrong activeCount", 16, message.getTableStats().get(0).getActiveCount().longValue());
206 Assert.assertEquals("Wrong lookupCount",
207 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
208 message.getTableStats().get(0).getLookupCount());
209 Assert.assertEquals("Wrong matchedCount",
210 new BigInteger(1, new byte[]{(byte) 0xAF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
211 message.getTableStats().get(0).getMatchedCount());
215 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
218 public void testMultipartReplyPortStatsBody(){
219 ByteBuf bb = BufferHelper.buildBuffer("00 04 00 01 00 00 00 00 "+
220 "00 00 00 FF "+//portNo
222 "FF 01 01 01 01 01 01 01 "+//rxPackets
223 "FF 02 02 02 02 02 02 02 "+//txPackets
224 "FF 02 03 02 03 02 03 02 "+//rxBytes
225 "FF 02 03 02 03 02 03 02 "+//txBytes
226 "FF 02 03 02 03 02 03 02 "+//rxDropped
227 "FF 02 03 02 03 02 03 02 "+//txDropped
228 "FF 02 03 02 03 02 03 02 "+//rxErrors
229 "FF 02 03 02 03 02 03 02 "+//txErrors
230 "FF 02 03 02 03 02 03 02 "+//rxFrameErr
231 "FF 02 03 02 03 02 03 02 "+//rxOverErr
232 "FF 02 03 02 03 02 03 02 "+//rxCrcErr
233 "FF 02 03 02 03 02 03 02 "+//collisions
234 "00 00 00 02 "+//durationSec
235 "00 00 00 04"//durationNsec
238 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
240 BufferHelper.checkHeaderV13(builtByFactory);
241 Assert.assertEquals("Wrong type", 0x04, builtByFactory.getType().getIntValue());
242 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
243 MultipartReplyPortStatsCase messageCase = (MultipartReplyPortStatsCase) builtByFactory.getMultipartReplyBody();
244 MultipartReplyPortStats message = messageCase.getMultipartReplyPortStats();
245 Assert.assertEquals("Wrong portNo", 255, message.getPortStats().get(0).getPortNo().intValue());
246 Assert.assertEquals("Wrong rxPackets",
247 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
248 message.getPortStats().get(0).getRxPackets());
249 Assert.assertEquals("Wrong txPackets",
250 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
251 message.getPortStats().get(0).getTxPackets());
252 Assert.assertEquals("Wrong rxBytes",
253 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
254 message.getPortStats().get(0).getRxBytes());
255 Assert.assertEquals("Wrong txBytes",
256 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
257 message.getPortStats().get(0).getTxBytes());
258 Assert.assertEquals("Wrong rxDropped",
259 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
260 message.getPortStats().get(0).getRxDropped());
261 Assert.assertEquals("Wrong txDropped",
262 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
263 message.getPortStats().get(0).getTxDropped());
264 Assert.assertEquals("Wrong rxErrors",
265 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
266 message.getPortStats().get(0).getRxErrors());
267 Assert.assertEquals("Wrong txErrors",
268 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
269 message.getPortStats().get(0).getTxErrors());
270 Assert.assertEquals("Wrong rxFrameErr",
271 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
272 message.getPortStats().get(0).getRxFrameErr());
273 Assert.assertEquals("Wrong rxOverErr",
274 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
275 message.getPortStats().get(0).getRxOverErr());
276 Assert.assertEquals("Wrong rxCrcErr",
277 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
278 message.getPortStats().get(0).getRxCrcErr());
279 Assert.assertEquals("Wrong collisions",
280 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
281 message.getPortStats().get(0).getCollisions());
282 Assert.assertEquals("Wrong durationSec", 2, message.getPortStats().get(0).getDurationSec().intValue());
283 Assert.assertEquals("Wrong durationNsec", 4, message.getPortStats().get(0).getDurationNsec().intValue());
287 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
290 public void testMultipartReplyQueueBody(){
291 ByteBuf bb = BufferHelper.buildBuffer("00 05 00 01 00 00 00 00 "+
292 "00 00 00 FF "+//portNo
293 "00 00 00 10 "+//queueId
294 "FF 02 03 02 03 02 03 02 "+//txBytes
295 "FF 02 02 02 02 02 02 02 "+//txPackets
296 "FF 02 03 02 03 02 03 02 "+//txErrors
297 "00 00 00 02 "+//durationSec
298 "00 00 00 04"//durationNsec
301 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
303 BufferHelper.checkHeaderV13(builtByFactory);
304 Assert.assertEquals("Wrong type", 0x05, builtByFactory.getType().getIntValue());
305 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
306 MultipartReplyQueueCase messageCase = (MultipartReplyQueueCase) builtByFactory.getMultipartReplyBody();
307 MultipartReplyQueue message = messageCase.getMultipartReplyQueue();
308 Assert.assertEquals("Wrong portNo", 255, message.getQueueStats().get(0).getPortNo().intValue());
309 Assert.assertEquals("Wrong queueId", 16, message.getQueueStats().get(0).getQueueId().intValue());
310 Assert.assertEquals("Wrong txBytes",
311 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
312 message.getQueueStats().get(0).getTxBytes());
313 Assert.assertEquals("Wrong txPackets",
314 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
315 message.getQueueStats().get(0).getTxPackets());
316 Assert.assertEquals("Wrong txErrors",
317 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}),
318 message.getQueueStats().get(0).getTxErrors());
319 Assert.assertEquals("Wrong durationSec", 2, message.getQueueStats().get(0).getDurationSec().intValue());
320 Assert.assertEquals("Wrong durationNsec", 4, message.getQueueStats().get(0).getDurationNsec().intValue());
324 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
327 public void testMultipartReplyGroupBody(){
328 ByteBuf bb = BufferHelper.buildBuffer("00 06 00 01 00 00 00 00 "+
331 "00 00 00 10 "+//groupId
332 "00 00 00 12 "+//refCount
333 "00 00 00 00 "+//pad2
334 "FF 01 01 01 01 01 01 01 "+//packetCount
335 "FF 01 01 01 01 01 01 01 "+//byteCount
336 "00 00 00 08 "+//durationSec
337 "00 00 00 09 "+//durationNsec
338 "FF 01 01 01 01 01 01 01 "+//packetCountBucket
339 "FF 01 01 01 01 01 01 01 "+//byteCountBucket
340 "FF 02 02 02 02 02 02 02 "+//packetCountBucket_2
341 "FF 02 02 02 02 02 02 02 "+//byteCountBucket_2
344 "00 00 00 10 "+//groupId_2
345 "00 00 00 12 "+//refCount_2
346 "00 00 00 00 "+//pad2.2
347 "FF 01 01 01 01 01 01 01 "+//packetCount_2
348 "FF 01 01 01 01 01 01 01 "+//byteCount_2
349 "00 00 00 08 "+//durationSec_2
350 "00 00 00 09 "+//durationNsec_2
351 "FF 01 01 01 01 01 01 01 "+//packetCountBucket_1.2
352 "FF 01 01 01 01 01 01 01 "+//byteCountBucket_1.2
353 "FF 02 02 02 02 02 02 02 "+//packetCountBucket_2.2
354 "FF 02 02 02 02 02 02 02"//byteCountBucket_2.2
357 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
359 BufferHelper.checkHeaderV13(builtByFactory);
360 Assert.assertEquals("Wrong type", 0x06, builtByFactory.getType().getIntValue());
361 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
362 MultipartReplyGroupCase messageCase = (MultipartReplyGroupCase) builtByFactory.getMultipartReplyBody();
363 MultipartReplyGroup message = messageCase.getMultipartReplyGroup();
364 Assert.assertEquals("Wrong groupId", 16, message.getGroupStats().get(0).getGroupId().getValue().intValue());
365 Assert.assertEquals("Wrong refCount", 18, message.getGroupStats().get(0).getRefCount().intValue());
366 Assert.assertEquals("Wrong packetCount",
367 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
368 message.getGroupStats().get(0).getPacketCount());
369 Assert.assertEquals("Wrong byteCount",
370 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
371 message.getGroupStats().get(0).getByteCount());
372 Assert.assertEquals("Wrong durationSec", 8, message.getGroupStats().get(0).getDurationSec().intValue());
373 Assert.assertEquals("Wrong durationNsec", 9, message.getGroupStats().get(0).getDurationNsec().intValue());
374 Assert.assertEquals("Wrong packetCountBucket",
375 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
376 message.getGroupStats().get(0).getBucketStats().get(0).getPacketCount());
377 Assert.assertEquals("Wrong byteCountBucket",
378 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
379 message.getGroupStats().get(0).getBucketStats().get(0).getByteCount());
380 Assert.assertEquals("Wrong packetCountBucket_2",
381 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
382 message.getGroupStats().get(0).getBucketStats().get(1).getPacketCount());
383 Assert.assertEquals("Wrong byteCountBucket_2",
384 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
385 message.getGroupStats().get(0).getBucketStats().get(1).getByteCount());
387 Assert.assertEquals("Wrong groupId_2", 16, message.getGroupStats().get(1).getGroupId().getValue().intValue());
388 Assert.assertEquals("Wrong refCount_2", 18, message.getGroupStats().get(1).getRefCount().intValue());
389 Assert.assertEquals("Wrong packetCount_2",
390 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
391 message.getGroupStats().get(1).getPacketCount());
392 Assert.assertEquals("Wrong byteCount_2",
393 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
394 message.getGroupStats().get(1).getByteCount());
395 Assert.assertEquals("Wrong durationSec_2", 8, message.getGroupStats().get(1).getDurationSec().intValue());
396 Assert.assertEquals("Wrong durationNsec_2", 9, message.getGroupStats().get(1).getDurationNsec().intValue());
397 Assert.assertEquals("Wrong packetCountBucket_1.2",
398 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
399 message.getGroupStats().get(1).getBucketStats().get(0).getPacketCount());
400 Assert.assertEquals("Wrong byteCountBucket_1.2",
401 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
402 message.getGroupStats().get(1).getBucketStats().get(0).getByteCount());
403 Assert.assertEquals("Wrong packetCountBucket_2.2",
404 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
405 message.getGroupStats().get(1).getBucketStats().get(1).getPacketCount());
406 Assert.assertEquals("Wrong byteCountBucket_2.2",
407 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
408 message.getGroupStats().get(1).getBucketStats().get(1).getByteCount());
412 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
415 public void testMultipartReplyMeterBody(){
416 ByteBuf bb = BufferHelper.buildBuffer("00 09 00 01 00 00 00 00 "+
417 "00 00 00 09 "+//meterId
419 "00 00 00 00 00 00 "+//pad
420 "00 00 00 07 "+//flowCount
421 "FF 01 01 01 01 01 01 01 "+//packetInCount
422 "FF 01 01 01 01 01 01 01 "+//byteInCount
423 "00 00 00 05 "+//durationSec
424 "00 00 00 05 "+//durationNsec
425 "FF 01 01 01 01 01 01 01 "+//packetBandCount_01
426 "FF 01 01 01 01 01 01 01 "+//byteBandCount_01
427 "FF 02 02 02 02 02 02 02 "+//packetBandCount_02
428 "FF 02 02 02 02 02 02 02 "+//byteBandCount_02
429 "FF 03 03 03 03 03 03 03 "+//packetBandCount_03
430 "FF 03 03 03 03 03 03 03"//byteBandCount_03
433 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
435 BufferHelper.checkHeaderV13(builtByFactory);
436 Assert.assertEquals("Wrong type", 9, builtByFactory.getType().getIntValue());
437 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
438 MultipartReplyMeterCase messageCase = (MultipartReplyMeterCase) builtByFactory.getMultipartReplyBody();
439 MultipartReplyMeter message = messageCase.getMultipartReplyMeter();
440 Assert.assertEquals("Wrong meterId", 9,
441 message.getMeterStats().get(0).getMeterId().getValue().intValue());
442 Assert.assertEquals("Wrong flowCount", 7,
443 message.getMeterStats().get(0).getFlowCount().intValue());
444 Assert.assertEquals("Wrong packetInCount",
445 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
446 message.getMeterStats().get(0).getPacketInCount());
447 Assert.assertEquals("Wrong byteInCount",
448 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
449 message.getMeterStats().get(0).getByteInCount());
450 Assert.assertEquals("Wrong durationSec", 5,
451 message.getMeterStats().get(0).getDurationSec().intValue());
452 Assert.assertEquals("Wrong durationNsec", 5,
453 message.getMeterStats().get(0).getDurationNsec().intValue());
454 Assert.assertEquals("Wrong packetBandCount_01",
455 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
456 message.getMeterStats().get(0).getMeterBandStats().get(0).getPacketBandCount());
457 Assert.assertEquals("Wrong byteBandCount_01",
458 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
459 message.getMeterStats().get(0).getMeterBandStats().get(0).getByteBandCount());
460 Assert.assertEquals("Wrong packetBandCount_02",
461 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
462 message.getMeterStats().get(0).getMeterBandStats().get(1).getPacketBandCount());
463 Assert.assertEquals("Wrong byteBandCount_02",
464 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
465 message.getMeterStats().get(0).getMeterBandStats().get(1).getByteBandCount());
466 Assert.assertEquals("Wrong packetBandCount_03",
467 new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}),
468 message.getMeterStats().get(0).getMeterBandStats().get(2).getPacketBandCount());
469 Assert.assertEquals("Wrong byteBandCount_03",
470 new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}),
471 message.getMeterStats().get(0).getMeterBandStats().get(2).getByteBandCount());
475 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
478 public void testMultipartReplyMeterBodyMulti(){
479 ByteBuf bb = BufferHelper.buildBuffer("00 09 00 01 00 00 00 00 "+
480 "00 00 00 09 "+//meterId_0
482 "00 00 00 00 00 00 "+//pad_0
483 "00 00 00 07 "+//flowCount_0
484 "FF 01 01 01 01 01 01 01 "+//packetInCount_0
485 "FF 01 01 01 01 01 01 01 "+//byteInCount_0
486 "00 00 00 05 "+//durationSec_0
487 "00 00 00 05 "+//durationNsec_0
488 "FF 01 01 01 01 01 01 01 "+//packetBandCount_01
489 "FF 01 01 01 01 01 01 01 "+//byteBandCount_01
490 "FF 02 02 02 02 02 02 02 "+//packetBandCount_02
491 "FF 02 02 02 02 02 02 02 "+//byteBandCount_02
492 "FF 03 03 03 03 03 03 03 "+//packetBandCount_03
493 "FF 03 03 03 03 03 03 03 "+//byteBandCount_03
494 "00 00 00 08 "+//meterId_1
496 "00 00 00 00 00 00 "+//pad_1
497 "00 00 00 07 "+//flowCount_1
498 "FF 01 01 01 01 01 01 01 "+//packetInCount_1
499 "FF 01 01 01 01 01 01 01 "+//byteInCount_1
500 "00 00 00 05 "+//durationSec_1
501 "00 00 00 05 "+//durationNsec_1
502 "FF 01 01 01 01 01 01 01 "+//packetBandCount_11
503 "FF 01 01 01 01 01 01 01 "+//byteBandCount_11
504 "FF 02 02 02 02 02 02 02 "+//packetBandCount_12
505 "FF 02 02 02 02 02 02 02 "+//byteBandCount_12
506 "FF 03 03 03 03 03 03 03 "+//packetBandCount_13
507 "FF 03 03 03 03 03 03 03"//byteBandCount_13
510 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
512 BufferHelper.checkHeaderV13(builtByFactory);
513 Assert.assertEquals("Wrong type", 9, builtByFactory.getType().getIntValue());
514 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
515 MultipartReplyMeterCase messageCase = (MultipartReplyMeterCase) builtByFactory.getMultipartReplyBody();
516 MultipartReplyMeter message = messageCase.getMultipartReplyMeter();
517 Assert.assertEquals("Wrong meterId", 9,
518 message.getMeterStats().get(0).getMeterId().getValue().intValue());
519 Assert.assertEquals("Wrong flowCount", 7,
520 message.getMeterStats().get(0).getFlowCount().intValue());
521 Assert.assertEquals("Wrong packetInCount",
522 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
523 message.getMeterStats().get(0).getPacketInCount());
524 Assert.assertEquals("Wrong byteInCount",
525 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
526 message.getMeterStats().get(0).getByteInCount());
527 Assert.assertEquals("Wrong durationSec", 5,
528 message.getMeterStats().get(0).getDurationSec().intValue());
529 Assert.assertEquals("Wrong durationNsec", 5,
530 message.getMeterStats().get(0).getDurationNsec().intValue());
531 Assert.assertEquals("Wrong packetBandCount_01",
532 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
533 message.getMeterStats().get(0).getMeterBandStats().get(0).getPacketBandCount());
534 Assert.assertEquals("Wrong byteBandCount_01",
535 new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}),
536 message.getMeterStats().get(0).getMeterBandStats().get(0).getByteBandCount());
537 Assert.assertEquals("Wrong packetBandCount_02",
538 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
539 message.getMeterStats().get(0).getMeterBandStats().get(1).getPacketBandCount());
540 Assert.assertEquals("Wrong byteBandCount_02",
541 new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}),
542 message.getMeterStats().get(0).getMeterBandStats().get(1).getByteBandCount());
543 Assert.assertEquals("Wrong packetBandCount_03",
544 new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}),
545 message.getMeterStats().get(0).getMeterBandStats().get(2).getPacketBandCount());
546 Assert.assertEquals("Wrong byteBandCount_03",
547 new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}),
548 message.getMeterStats().get(0).getMeterBandStats().get(2).getByteBandCount());
550 Assert.assertEquals("Wrong meterId", 8,
551 message.getMeterStats().get(1).getMeterId().getValue().intValue());
552 Assert.assertEquals("Wrong flowCount", 7,
553 message.getMeterStats().get(1).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(1).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(1).getByteInCount());
560 Assert.assertEquals("Wrong durationSec", 5,
561 message.getMeterStats().get(1).getDurationSec().intValue());
562 Assert.assertEquals("Wrong durationNsec", 5,
563 message.getMeterStats().get(1).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(1).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(1).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(1).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(1).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(1).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(1).getMeterBandStats().get(2).getByteBandCount());
585 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
588 public void testMultipartReplyMeterConfigBody(){
589 ByteBuf bb = BufferHelper.buildBuffer("00 0A 00 01 00 00 00 00 "+
592 "00 00 00 09 "+//meterId
593 "00 01 "+//meterBandDrop.type
594 "00 10 "+//meterBandDrop.len
595 "00 00 00 11 "+//meterBandDrop.rate
596 "00 00 00 20 "+//meterBandDrop.burstSize
597 "00 00 00 00 "+//meterBandDrop.pad
598 "00 02 "+//meterBandDscp.type
599 "00 10 "+//meterBandDscp.len
600 "00 00 00 11 "+//meterBandDscp.rate
601 "00 00 00 20 "+//meterBandDscp.burstSize
602 "04 "+//meterBandDscp.precLevel
603 "00 00 00");//meterBandDscp.pad
605 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
607 BufferHelper.checkHeaderV13(builtByFactory);
608 Assert.assertEquals("Wrong type", 10, builtByFactory.getType().getIntValue());
609 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
610 MultipartReplyMeterConfigCase messageCase = (MultipartReplyMeterConfigCase) builtByFactory.getMultipartReplyBody();
611 MultipartReplyMeterConfig message = messageCase.getMultipartReplyMeterConfig();
612 Assert.assertEquals("Wrong flags", new MeterFlags(false, false, true, true),
613 message.getMeterConfig().get(0).getFlags());
614 Assert.assertEquals("Wrong meterId", 9,
615 message.getMeterConfig().get(0).getMeterId().getValue().intValue());
617 MeterBandDropCase dropCase = (MeterBandDropCase) message.getMeterConfig().get(0).getBands().get(0).getMeterBand();
618 MeterBandDrop meterBandDrop = dropCase.getMeterBandDrop();
619 Assert.assertEquals("Wrong meterBandDrop.type", 1, meterBandDrop.getType().getIntValue());
620 Assert.assertEquals("Wrong meterBandDrop.rate", 17, meterBandDrop.getRate().intValue());
621 Assert.assertEquals("Wrong meterBandDrop.burstSize", 32, meterBandDrop.getBurstSize().intValue());
623 MeterBandDscpRemarkCase dscpCase = (MeterBandDscpRemarkCase) message.getMeterConfig().get(0).getBands().get(1).getMeterBand();
624 MeterBandDscpRemark meterBandDscp = dscpCase.getMeterBandDscpRemark();
625 Assert.assertEquals("Wrong meterBandDscp.type", 2, meterBandDscp.getType().getIntValue());
626 Assert.assertEquals("Wrong meterBandDscp.rate", 17, meterBandDscp.getRate().intValue());
627 Assert.assertEquals("Wrong meterBandDscp.burstSize", 32, meterBandDscp.getBurstSize().intValue());
628 Assert.assertEquals("Wrong meterBandDscp.precLevel", 4, meterBandDscp.getPrecLevel().intValue());
632 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
635 public void testMultipartReplyMeterConfigBodyMulti(){
636 ByteBuf bb = BufferHelper.buildBuffer("00 0A 00 01 00 00 00 00 "+
639 "00 00 00 09 "+//meterId
640 "00 01 "+//meterBandDrop.type
641 "00 10 "+//meterBandDrop.len
642 "00 00 00 11 "+//meterBandDrop.rate
643 "00 00 00 20 "+//meterBandDrop.burstSize
644 "00 00 00 00 "+//meterBandDrop.pad
645 "00 02 "+//meterBandDscp.type
646 "00 10 "+//meterBandDscp.len
647 "00 00 00 11 "+//meterBandDscp.rate
648 "00 00 00 20 "+//meterBandDscp.burstSize
649 "04 "+//meterBandDscp.precLevel
650 "00 00 00 "+//meterBandDscp.pad
654 "00 00 00 07 "+//meterId01
655 "00 02 "+//meterBandDscp01.type
656 "00 10 "+//meterBandDscp01.len
657 "00 00 00 11 "+//meterBandDscp01.rate
658 "00 00 00 20 "+//meterBandDscp01.burstSize
659 "04 "+//meterBandDscp01.precLevel
660 "00 00 00"//meterBandDscp01.pad
663 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
665 BufferHelper.checkHeaderV13(builtByFactory);
666 Assert.assertEquals("Wrong type", 10, builtByFactory.getType().getIntValue());
667 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
668 MultipartReplyMeterConfigCase messageCase = (MultipartReplyMeterConfigCase) builtByFactory.getMultipartReplyBody();
669 MultipartReplyMeterConfig message = messageCase.getMultipartReplyMeterConfig();
670 Assert.assertEquals("Wrong flags", new MeterFlags(true, false, true, false),
671 message.getMeterConfig().get(0).getFlags());
672 Assert.assertEquals("Wrong meterId", 9,
673 message.getMeterConfig().get(0).getMeterId().getValue().intValue());
675 MeterBandDropCase dropCase = (MeterBandDropCase) message.getMeterConfig().get(0).getBands().get(0).getMeterBand();
676 MeterBandDrop meterBandDrop = dropCase.getMeterBandDrop();
677 Assert.assertEquals("Wrong meterBandDrop.type", 1, meterBandDrop.getType().getIntValue());
678 Assert.assertEquals("Wrong meterBandDrop.rate", 17, meterBandDrop.getRate().intValue());
679 Assert.assertEquals("Wrong meterBandDrop.burstSize", 32, meterBandDrop.getBurstSize().intValue());
681 MeterBandDscpRemarkCase dscpCase = (MeterBandDscpRemarkCase) message.getMeterConfig().get(0).getBands().get(1).getMeterBand();
682 MeterBandDscpRemark meterBandDscp = dscpCase.getMeterBandDscpRemark();
683 Assert.assertEquals("Wrong meterBandDscp.type", 2, meterBandDscp.getType().getIntValue());
684 Assert.assertEquals("Wrong meterBandDscp.rate", 17, meterBandDscp.getRate().intValue());
685 Assert.assertEquals("Wrong meterBandDscp.burstSize", 32, meterBandDscp.getBurstSize().intValue());
686 Assert.assertEquals("Wrong meterBandDscp.precLevel", 4, meterBandDscp.getPrecLevel().intValue());
688 LOGGER.info(message.getMeterConfig().get(0).getFlags().toString());
689 Assert.assertEquals("Wrong flags01", new MeterFlags(false, true, true, false),
690 message.getMeterConfig().get(1).getFlags());
691 Assert.assertEquals("Wrong meterId01", 7,
692 message.getMeterConfig().get(1).getMeterId().getValue().intValue());
694 MeterBandDscpRemarkCase dscpCase01 = (MeterBandDscpRemarkCase) message.getMeterConfig().get(1).getBands().get(0).getMeterBand();
695 MeterBandDscpRemark meterBandDscp01 = dscpCase01.getMeterBandDscpRemark();
696 Assert.assertEquals("Wrong meterBandDscp01.type", 2, meterBandDscp01.getType().getIntValue());
697 Assert.assertEquals("Wrong meterBandDscp01.rate", 17, meterBandDscp01.getRate().intValue());
698 Assert.assertEquals("Wrong meterBandDscp01.burstSize", 32, meterBandDscp01.getBurstSize().intValue());
699 Assert.assertEquals("Wrong meterBandDscp01.precLevel", 4, meterBandDscp01.getPrecLevel().intValue());
704 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
705 * Test covers bodies of actions Output, Copy TTL Out, Copy TTL In
708 public void testMultipartReplyGroupDescBody01(){
709 ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "+
713 "00 00 00 08 "+//groupId
715 "00 06 "+//bucketWeight
716 "00 00 00 05 "+//bucketWatchPort
717 "00 00 00 04 "+//bucketWatchGroup
718 "00 00 00 00 "+//bucketPad
719 "00 00 "+//outputType
721 "00 00 10 FF "+//outputPort
722 "FF FF "+//outputMaxLen
723 "00 00 00 00 00 00 "+//outputPad
724 "00 0B "+//copyTTLOutType
725 "00 08 "+//copyTTLOutLen
726 "00 00 00 00 "+//copyTTLOutPad
727 "00 0C "+//copyTTLIntType
728 "00 08 "+//copyTTLIntLen
729 "00 00 00 00"//copyTTLInPad
731 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
733 BufferHelper.checkHeaderV13(builtByFactory);
734 Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
735 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
736 MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody();
737 MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc();
738 Assert.assertEquals("Wrong type", 1,
739 message.getGroupDesc().get(0).getType().getIntValue());
740 Assert.assertEquals("Wrong groupId", 8,
741 message.getGroupDesc().get(0).getGroupId().getValue().intValue());
742 Assert.assertEquals("Wrong bucketWeight", 6,
743 message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());
744 Assert.assertEquals("Wrong bucketWatchPort", 5,
745 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().
746 getValue().intValue());
747 Assert.assertEquals("Wrong bucketWatchGroup", 4,
748 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());
750 Assert.assertEquals("Wrong outputType", Output.class,
751 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0)
754 Assert.assertEquals("Wrong outputPort", 4351,
755 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0)
756 .getAugmentation(PortAction.class).
757 getPort().getValue().intValue());
759 Assert.assertEquals("Wrong outputMaxLen", 65535,
760 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0)
761 .getAugmentation(MaxLengthAction.class).
762 getMaxLength().intValue());
764 Assert.assertEquals("Wrong copyTtlOutType", CopyTtlOut.class,
765 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1)
768 Assert.assertEquals("Wrong copyTtlInType", CopyTtlIn.class,
769 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2)
774 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
775 * Test covers bodies of actions Set MPLS TTL , Dec MPLS TTL, Push VLAN. Push MPLS, Push PBB
778 public void testMultipartReplyGroupDescBody02(){
779 ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "+
783 "00 00 00 08 "+//groupId
785 "00 06 "+//bucketWeight
786 "00 00 00 05 "+//bucketWatchPort
787 "00 00 00 04 "+//bucketWatchGroup
788 "00 00 00 00 "+//bucketPad
789 "00 0F "+//setMplsTtlType
790 "00 08 "+//setMplsTtlLen
791 "09 "+//setMplsTtlMPLS_TTL
792 "00 00 00 "+//setMplsTtlPad
793 "00 10 "+//decMplsTtlType
794 "00 08 "+//decMplsTtlLen
795 "00 00 00 00 "+//decMplsTtlPad
796 "00 11 "+//pushVlanType
797 "00 08 "+//pushVlanLen
798 "00 20 "+//pushVlanEthertype
799 "00 00 "+//pushVlanPad
800 "00 13 "+//pushMplsType
801 "00 08 "+//pushMplsLen
802 "00 FF "+//pushMplsEthertype
803 "00 00 "+//pushMplsPad
804 "00 1A "+//pushPbbType
805 "00 08 "+//pushPbbLen
806 "0F FF "+//pushPbbEthertype
810 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
812 BufferHelper.checkHeaderV13(builtByFactory);
813 Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
814 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
815 MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody();
816 MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc();
817 Assert.assertEquals("Wrong type", 1,
818 message.getGroupDesc().get(0).getType().getIntValue());
819 Assert.assertEquals("Wrong groupId", 8,
820 message.getGroupDesc().get(0).getGroupId().getValue().intValue());
821 Assert.assertEquals("Wrong bucketWeight", 6,
822 message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());
823 Assert.assertEquals("Wrong bucketWatchPort", 5,
824 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().getValue().intValue());
825 Assert.assertEquals("Wrong bucketWatchGroup", 4,
826 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());
827 Assert.assertEquals("Wrong setMplsTtlType", SetMplsTtl.class,
828 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0)
830 Assert.assertEquals("Wrong setMplsTtlMPLS_TTL", 9,
831 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0)
832 .getAugmentation(MplsTtlAction.class).
833 getMplsTtl().intValue());
834 Assert.assertEquals("Wrong decMplsTtlType", DecMplsTtl.class,
835 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1)
837 Assert.assertEquals("Wrong pushVlanType", PushVlan.class,
838 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2)
840 Assert.assertEquals("Wrong pushVlanEthertype", 32,
841 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2)
842 .getAugmentation(EthertypeAction.class).
843 getEthertype().getValue().intValue());
844 Assert.assertEquals("Wrong pushMplsType", PushMpls.class,
845 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(3)
847 Assert.assertEquals("Wrong pushMplsEthertype", 255,
848 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(3).
849 getAugmentation(EthertypeAction.class).
850 getEthertype().getValue().intValue());
851 Assert.assertEquals("Wrong pushPbbType", PushPbb.class,
852 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(4)
854 Assert.assertEquals("Wrong pushPbbEthertype", 4095,
855 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(4)
856 .getAugmentation(EthertypeAction.class).
857 getEthertype().getValue().intValue());
861 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
862 * Test covers bodies of actions Pop VLAN, Pop PBB, Pop MPLS, Group, Dec NW TTL
865 public void testMultipartReplyGroupDescBody03(){
866 ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "+
870 "00 00 00 08 "+//groupId
872 "00 06 "+//bucketWeight
873 "00 00 00 05 "+//bucketWatchPort
874 "00 00 00 04 "+//bucketWatchGroup
875 "00 00 00 00 "+//bucketPad
876 "00 12 "+//popVlanType
877 "00 08 "+//popVlanLen
878 "00 00 00 00 "+//popVlanPad
879 "00 1B "+//popPbbType
881 "00 00 00 00 "+//popPbbPad
882 "00 14 "+//popMplsType
883 "00 08 "+//popMplsLen
884 "00 CF "+//popMplsEthertype
885 "00 00 "+//popMplsPad
886 "00 15 "+//setQueueType
887 "00 08 "+//setQueueLen
888 "00 CF 00 00 "+//setQueueQueueId
891 "00 CF 00 00 "+//groupGroupId
892 "00 18 "+//decNwTtlType
893 "00 08 "+//decNwTtlLen
894 "00 00 00 00"//decNwTtlPad
897 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
899 BufferHelper.checkHeaderV13(builtByFactory);
900 Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
901 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
902 MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody();
903 MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc();
904 Assert.assertEquals("Wrong type", 1, message.getGroupDesc().get(0).getType().getIntValue());
905 Assert.assertEquals("Wrong groupId", 8, message.getGroupDesc().get(0).getGroupId().getValue().intValue());
906 Assert.assertEquals("Wrong bucketWeight", 6,
907 message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());
908 Assert.assertEquals("Wrong bucketWatchPort", 5,
909 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().getValue().intValue());
910 Assert.assertEquals("Wrong bucketWatchGroup", 4,
911 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());
912 Assert.assertEquals("Wrong popVlanType", PopVlan.class,
913 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0)
915 Assert.assertEquals("Wrong popPbbType", PopPbb.class,
916 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1)
918 Assert.assertEquals("Wrong popMplsType", PopMpls.class,
919 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2)
921 Assert.assertEquals("Wrong popMplsEthertype", 207,
922 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2)
923 .getAugmentation(EthertypeAction.class).
924 getEthertype().getValue().intValue());
925 Assert.assertEquals("Wrong setQueueType", SetQueue.class,
926 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(3)
928 Assert.assertEquals("Wrong setQueueQueueId", 13565952,
929 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(3)
930 .getAugmentation(QueueIdAction.class).
931 getQueueId().intValue());
932 Assert.assertEquals("Wrong groupType", Group.class,
933 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(4)
935 Assert.assertEquals("Wrong groupGroupId", 13565952,
936 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(4)
937 .getAugmentation(GroupIdAction.class).
938 getGroupId().intValue());
939 Assert.assertEquals("Wrong decNwTtlType", DecNwTtl.class,
940 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(5)
945 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
946 * Test covers bodies of actions NW TTL, Experimenter
949 public void testMultipartReplyGroupDescBody04(){
950 ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "+
954 "00 00 00 08 "+//groupId
956 "00 06 "+//bucketWeight
957 "00 00 00 05 "+//bucketWatchPort
958 "00 00 00 04 "+//bucketWatchGroup
959 "00 00 00 00 "+//bucketPad
963 "00 00 00 "+//nwTTlPad
964 "00 19 "+//setFieldType
965 "00 10 "+//setFieldLen
966 "80 00 "+//setFieldOXMClass
967 "00 "+//setFieldOXMField
968 "04 "+//setFieldOXMLength
969 "00 00 00 FF "+ //setFieldPort
973 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
975 BufferHelper.checkHeaderV13(builtByFactory);
976 Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
977 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
978 MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody();
979 MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc();
980 Assert.assertEquals("Wrong type", 1,
981 message.getGroupDesc().get(0).getType().getIntValue());
982 Assert.assertEquals("Wrong groupId", 8,
983 message.getGroupDesc().get(0).getGroupId().getValue().intValue());
984 Assert.assertEquals("Wrong bucketWeight", 6,
985 message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());
986 Assert.assertEquals("Wrong bucketWatchPort", 5,
987 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().
988 getValue().intValue());
989 Assert.assertEquals("Wrong bucketWatchGroup", 4,
990 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());
992 Assert.assertEquals("Wrong nwTTlType", SetNwTtl.class,
993 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0)
996 Assert.assertEquals("Wrong nwTTlnwTTL", 14,
997 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0)
998 .getAugmentation(NwTtlAction.class).getNwTtl().intValue());
1000 Assert.assertEquals("Wrong setFieldType", SetField.class,
1001 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1)
1004 Assert.assertEquals("Wrong setFieldOXMClass", OpenflowBasicClass.class,
1005 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1)
1006 .getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0).getOxmClass());
1008 Assert.assertEquals("Wrong setFieldOXMField", InPort.class,
1009 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1)
1010 .getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0).getOxmMatchField());
1012 Assert.assertEquals("Wrong setFieldOXMValue", 255,
1013 message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1)
1014 .getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0).
1015 getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue());