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