Bump MRI upstreams
[openflowplugin.git] / openflowjava / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / deserialization / factories / MultipartReplyMessageFactoryTest.java
1 /*
2  * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
3  *
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
7  */
8 package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
9
10 import io.netty.buffer.ByteBuf;
11 import org.junit.Assert;
12 import org.junit.Before;
13 import org.junit.Test;
14 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
15 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
16 import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
17 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
18 import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
19 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCase;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCase;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecMplsTtlCase;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecNwTtlCase;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCase;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopMplsCase;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopPbbCase;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCase;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushMplsCase;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushPbbCase;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCase;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCase;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCase;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCase;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPortCase;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCase;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCase;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDrop;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemark;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCase;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDescCase;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCase;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigCase;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCase;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregate;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDesc;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroup;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDesc;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.MultipartReplyMeter;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfig;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueue;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable;
64 import org.opendaylight.yangtools.yang.common.Uint64;
65 import org.slf4j.Logger;
66 import org.slf4j.LoggerFactory;
67
68 /**
69  * Unit tests for MultipartReplyMessageFactory.
70  *
71  * @author timotej.kubas
72  * @author michal.polkorab
73  */
74 public class MultipartReplyMessageFactoryTest {
75     static final int DESC_STR_LEN = 256;
76     static final int SERIAL_NUM_LEN = 32;
77
78     private OFDeserializer<MultipartReplyMessage> multipartFactory;
79
80     /**
81      * Initializes deserializer registry and lookups correct deserializer.
82      */
83     @Before
84     public void startUp() {
85         DeserializerRegistry registry = new DeserializerRegistryImpl();
86         registry.init();
87         multipartFactory = registry.getDeserializer(
88                 new MessageCodeKey(EncodeConstants.OF_VERSION_1_3, 19, MultipartReplyMessage.class));
89     }
90
91     private static final Logger LOG = LoggerFactory.getLogger(MultipartReplyMessageFactoryTest.class);
92
93     /**
94      * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
95      */
96     @Test
97     public void testMultipartReplyDescBody() {
98         ByteBuf bb = BufferHelper.buildBuffer("00 00 00 01 00 00 00 00");
99
100         String mfrDesc = "Manufacturer description";
101         byte[] mfrDescBytes = new byte[256];
102         mfrDescBytes = mfrDesc.getBytes();
103         bb.writeBytes(mfrDescBytes);
104         bb.writeZero(DESC_STR_LEN - mfrDescBytes.length);
105
106         String hwDesc = "Hardware description";
107         byte[] hwDescBytes = new byte[256];
108         hwDescBytes = hwDesc.getBytes();
109         bb.writeBytes(hwDescBytes);
110         bb.writeZero(DESC_STR_LEN - hwDescBytes.length);
111
112         String swDesc = "Software description";
113         byte[] swDescBytes = new byte[256];
114         swDescBytes = swDesc.getBytes();
115         bb.writeBytes(swDescBytes);
116         bb.writeZero(DESC_STR_LEN - swDescBytes.length);
117
118         String serialNum = "SN0123456789";
119         byte[] serialNumBytes = new byte[32];
120         serialNumBytes = serialNum.getBytes();
121         bb.writeBytes(serialNumBytes);
122         bb.writeZero(SERIAL_NUM_LEN - serialNumBytes.length);
123
124         String dpDesc = "switch3 in room 3120";
125         byte[] dpDescBytes = new byte[256];
126         dpDescBytes = dpDesc.getBytes();
127         bb.writeBytes(dpDescBytes);
128         bb.writeZero(DESC_STR_LEN - dpDescBytes.length);
129
130         MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
131
132         BufferHelper.checkHeaderV13(builtByFactory);
133         Assert.assertEquals("Wrong type", 0x00, builtByFactory.getType().getIntValue());
134         Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().getOFPMPFREQMORE());
135         MultipartReplyDescCase messageCase = (MultipartReplyDescCase) builtByFactory.getMultipartReplyBody();
136         MultipartReplyDesc message = messageCase.getMultipartReplyDesc();
137         Assert.assertEquals("Wrong mfrDesc", "Manufacturer description", message.getMfrDesc());
138         Assert.assertEquals("Wrong hwDesc", "Hardware description", message.getHwDesc());
139         Assert.assertEquals("Wrong swDesc", "Software description", message.getSwDesc());
140         Assert.assertEquals("Wrong serialNum", "SN0123456789", message.getSerialNum());
141         Assert.assertEquals("Wrong dpDesc", "switch3 in room 3120", message.getDpDesc());
142     }
143
144     /**
145      * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
146      */
147     @Test
148     public void testMultipartReplyAggregateBody() {
149         ByteBuf bb = BufferHelper.buildBuffer("00 02 00 01 00 00 00 00 "
150                                             + "FF 01 01 01 01 01 01 01 " //packetCount
151                                             + "0F 01 01 01 01 01 01 01 " //byteCount
152                                             + "00 00 00 08 " //flowCount
153                                             + "00 00 00 00" //pad
154                                             );
155
156         MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
157
158         BufferHelper.checkHeaderV13(builtByFactory);
159         Assert.assertEquals("Wrong type", 0x02, builtByFactory.getType().getIntValue());
160         Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().getOFPMPFREQMORE());
161         MultipartReplyAggregateCase messageCase = (MultipartReplyAggregateCase) builtByFactory.getMultipartReplyBody();
162         MultipartReplyAggregate message = messageCase.getMultipartReplyAggregate();
163         Assert.assertEquals("Wrong packetCount", Uint64.valueOf("FF01010101010101", 16), message.getPacketCount());
164         Assert.assertEquals("Wrong byteCount", Uint64.valueOf("0F01010101010101", 16), message.getByteCount());
165         Assert.assertEquals("Wrong flowCount", 8, message.getFlowCount().intValue());
166     }
167
168     /**
169      * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
170      */
171     @Test
172     public void testMultipartReplyTableBody() {
173         ByteBuf bb = BufferHelper.buildBuffer("00 03 00 01 00 00 00 00 "
174                                             + "08 " //tableId
175                                             + "00 00 00 " //pad
176                                             + "00 00 00 10 " //activeCount
177                                             + "FF 01 01 01 01 01 01 01 " //lookupCount
178                                             + "AF 01 01 01 01 01 01 01"//matchedCount
179                                             );
180
181         MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
182
183         BufferHelper.checkHeaderV13(builtByFactory);
184         Assert.assertEquals("Wrong type", 0x03, builtByFactory.getType().getIntValue());
185         Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().getOFPMPFREQMORE());
186
187         MultipartReplyTableCase messageCase = (MultipartReplyTableCase) builtByFactory.getMultipartReplyBody();
188         MultipartReplyTable message = messageCase.getMultipartReplyTable();
189         Assert.assertEquals("Wrong tableId", 8, message.getTableStats().get(0).getTableId().intValue());
190         Assert.assertEquals("Wrong activeCount", 16, message.getTableStats().get(0).getActiveCount().longValue());
191         Assert.assertEquals("Wrong lookupCount", Uint64.valueOf("FF01010101010101", 16),
192                 message.getTableStats().get(0).getLookupCount());
193         Assert.assertEquals("Wrong matchedCount", Uint64.valueOf("AF01010101010101", 16),
194                 message.getTableStats().get(0).getMatchedCount());
195     }
196
197     /**
198      * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
199      */
200     @Test
201     public void testMultipartReplyPortStatsBody() {
202         ByteBuf bb = BufferHelper.buildBuffer("00 04 00 01 00 00 00 00 "
203                                             + "00 00 00 FF " //portNo
204                                             + "00 00 00 00 " //pad
205                                             + "FF 01 01 01 01 01 01 01 " //rxPackets
206                                             + "FF 02 02 02 02 02 02 02 " //txPackets
207                                             + "FF 02 03 02 03 02 03 02 " //rxBytes
208                                             + "FF 02 03 02 03 02 03 02 " //txBytes
209                                             + "FF 02 03 02 03 02 03 02 " //rxDropped
210                                             + "FF 02 03 02 03 02 03 02 " //txDropped
211                                             + "FF 02 03 02 03 02 03 02 " //rxErrors
212                                             + "FF 02 03 02 03 02 03 02 " //txErrors
213                                             + "FF 02 03 02 03 02 03 02 " //rxFrameErr
214                                             + "FF 02 03 02 03 02 03 02 " //rxOverErr
215                                             + "FF 02 03 02 03 02 03 02 " //rxCrcErr
216                                             + "FF 02 03 02 03 02 03 02 " //collisions
217                                             + "00 00 00 02 " //durationSec
218                                             + "00 00 00 04"//durationNsec
219                                             );
220
221         MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
222
223         BufferHelper.checkHeaderV13(builtByFactory);
224         Assert.assertEquals("Wrong type", 0x04, builtByFactory.getType().getIntValue());
225         Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().getOFPMPFREQMORE());
226         MultipartReplyPortStatsCase messageCase = (MultipartReplyPortStatsCase) builtByFactory.getMultipartReplyBody();
227         MultipartReplyPortStats message = messageCase.getMultipartReplyPortStats();
228         Assert.assertEquals("Wrong portNo", 255, message.getPortStats().get(0).getPortNo().intValue());
229         Assert.assertEquals("Wrong rxPackets", Uint64.valueOf("FF01010101010101", 16),
230                 message.getPortStats().get(0).getRxPackets());
231         Assert.assertEquals("Wrong txPackets", Uint64.valueOf("FF02020202020202", 16),
232                 message.getPortStats().get(0).getTxPackets());
233         Assert.assertEquals("Wrong rxBytes", Uint64.valueOf("FF02030203020302", 16),
234                 message.getPortStats().get(0).getRxBytes());
235         Assert.assertEquals("Wrong txBytes", Uint64.valueOf("FF02030203020302", 16),
236                 message.getPortStats().get(0).getTxBytes());
237         Assert.assertEquals("Wrong rxDropped", Uint64.valueOf("FF02030203020302", 16),
238                 message.getPortStats().get(0).getRxDropped());
239         Assert.assertEquals("Wrong txDropped", Uint64.valueOf("FF02030203020302", 16),
240                 message.getPortStats().get(0).getTxDropped());
241         Assert.assertEquals("Wrong rxErrors", Uint64.valueOf("FF02030203020302", 16),
242                 message.getPortStats().get(0).getRxErrors());
243         Assert.assertEquals("Wrong txErrors", Uint64.valueOf("FF02030203020302", 16),
244                 message.getPortStats().get(0).getTxErrors());
245         Assert.assertEquals("Wrong rxFrameErr", Uint64.valueOf("FF02030203020302", 16),
246                 message.getPortStats().get(0).getRxFrameErr());
247         Assert.assertEquals("Wrong rxOverErr", Uint64.valueOf("FF02030203020302", 16),
248                 message.getPortStats().get(0).getRxOverErr());
249         Assert.assertEquals("Wrong rxCrcErr", Uint64.valueOf("FF02030203020302", 16),
250                 message.getPortStats().get(0).getRxCrcErr());
251         Assert.assertEquals("Wrong collisions", Uint64.valueOf("FF02030203020302", 16),
252                 message.getPortStats().get(0).getCollisions());
253         Assert.assertEquals("Wrong durationSec", 2, message.getPortStats().get(0).getDurationSec().intValue());
254         Assert.assertEquals("Wrong durationNsec", 4, message.getPortStats().get(0).getDurationNsec().intValue());
255     }
256
257     /**
258      * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
259      */
260     @Test
261     public void testMultipartReplyQueueBody() {
262         ByteBuf bb = BufferHelper.buildBuffer("00 05 00 01 00 00 00 00 "
263                                             + "00 00 00 FF " //portNo
264                                             + "00 00 00 10 " //queueId
265                                             + "FF 02 03 02 03 02 03 02 " //txBytes
266                                             + "FF 02 02 02 02 02 02 02 " //txPackets
267                                             + "FF 02 03 02 03 02 03 02 " //txErrors
268                                             + "00 00 00 02 " //durationSec
269                                             + "00 00 00 04"//durationNsec
270                                             );
271
272         MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
273
274         BufferHelper.checkHeaderV13(builtByFactory);
275         Assert.assertEquals("Wrong type", 0x05, builtByFactory.getType().getIntValue());
276         Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().getOFPMPFREQMORE());
277         MultipartReplyQueueCase messageCase = (MultipartReplyQueueCase) builtByFactory.getMultipartReplyBody();
278         MultipartReplyQueue message = messageCase.getMultipartReplyQueue();
279         Assert.assertEquals("Wrong portNo", 255, message.getQueueStats().get(0).getPortNo().intValue());
280         Assert.assertEquals("Wrong queueId", 16, message.getQueueStats().get(0).getQueueId().intValue());
281         Assert.assertEquals("Wrong txBytes", Uint64.valueOf("FF02030203020302", 16),
282                 message.getQueueStats().get(0).getTxBytes());
283         Assert.assertEquals("Wrong txPackets", Uint64.valueOf("FF02020202020202", 16),
284                 message.getQueueStats().get(0).getTxPackets());
285         Assert.assertEquals("Wrong txErrors", Uint64.valueOf("FF02030203020302", 16),
286                 message.getQueueStats().get(0).getTxErrors());
287         Assert.assertEquals("Wrong durationSec", 2, message.getQueueStats().get(0).getDurationSec().intValue());
288         Assert.assertEquals("Wrong durationNsec", 4, message.getQueueStats().get(0).getDurationNsec().intValue());
289     }
290
291     /**
292      * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
293      */
294     @Test
295     public void testMultipartReplyGroupBody() {
296         ByteBuf bb = BufferHelper.buildBuffer("00 06 00 01 00 00 00 00 "
297                                             + "00 48 " //length
298                                             + "00 00 " //pad1
299                                             + "00 00 00 10 " //groupId
300                                             + "00 00 00 12 " //refCount
301                                             + "00 00 00 00 " //pad2
302                                             + "FF 01 01 01 01 01 01 01 " //packetCount
303                                             + "FF 01 01 01 01 01 01 01 " //byteCount
304                                             + "00 00 00 08 " //durationSec
305                                             + "00 00 00 09 " //durationNsec
306                                             + "FF 01 01 01 01 01 01 01 " //packetCountBucket
307                                             + "FF 01 01 01 01 01 01 01 " //byteCountBucket
308                                             + "FF 02 02 02 02 02 02 02 " //packetCountBucket_2
309                                             + "FF 02 02 02 02 02 02 02 " //byteCountBucket_2
310                                             + "00 48 " //length_2
311                                             + "00 00 " //pad1.2
312                                             + "00 00 00 10 " //groupId_2
313                                             + "00 00 00 12 " //refCount_2
314                                             + "00 00 00 00 " //pad2.2
315                                             + "FF 01 01 01 01 01 01 01 " //packetCount_2
316                                             + "FF 01 01 01 01 01 01 01 " //byteCount_2
317                                             + "00 00 00 08 " //durationSec_2
318                                             + "00 00 00 09 " //durationNsec_2
319                                             + "FF 01 01 01 01 01 01 01 " //packetCountBucket_1.2
320                                             + "FF 01 01 01 01 01 01 01 " //byteCountBucket_1.2
321                                             + "FF 02 02 02 02 02 02 02 " //packetCountBucket_2.2
322                                             + "FF 02 02 02 02 02 02 02"//byteCountBucket_2.2
323                                             );
324
325         MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
326
327         BufferHelper.checkHeaderV13(builtByFactory);
328         Assert.assertEquals("Wrong type", 0x06, builtByFactory.getType().getIntValue());
329         Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().getOFPMPFREQMORE());
330         MultipartReplyGroupCase messageCase = (MultipartReplyGroupCase) builtByFactory.getMultipartReplyBody();
331         MultipartReplyGroup message = messageCase.getMultipartReplyGroup();
332         Assert.assertEquals("Wrong groupId", 16, message.getGroupStats().get(0).getGroupId().getValue().intValue());
333         Assert.assertEquals("Wrong refCount", 18, message.getGroupStats().get(0).getRefCount().intValue());
334         Assert.assertEquals("Wrong packetCount", Uint64.valueOf("FF01010101010101", 16),
335                 message.getGroupStats().get(0).getPacketCount());
336         Assert.assertEquals("Wrong byteCount", Uint64.valueOf("FF01010101010101", 16),
337                 message.getGroupStats().get(0).getByteCount());
338         Assert.assertEquals("Wrong durationSec", 8, message.getGroupStats().get(0).getDurationSec().intValue());
339         Assert.assertEquals("Wrong durationNsec", 9, message.getGroupStats().get(0).getDurationNsec().intValue());
340         Assert.assertEquals("Wrong packetCountBucket", Uint64.valueOf("FF01010101010101", 16),
341                 message.getGroupStats().get(0).getBucketStats().get(0).getPacketCount());
342         Assert.assertEquals("Wrong byteCountBucket", Uint64.valueOf("FF01010101010101", 16),
343                 message.getGroupStats().get(0).getBucketStats().get(0).getByteCount());
344         Assert.assertEquals("Wrong packetCountBucket_2", Uint64.valueOf("FF02020202020202", 16),
345                 message.getGroupStats().get(0).getBucketStats().get(1).getPacketCount());
346         Assert.assertEquals("Wrong byteCountBucket_2", Uint64.valueOf("FF02020202020202", 16),
347                 message.getGroupStats().get(0).getBucketStats().get(1).getByteCount());
348
349         Assert.assertEquals("Wrong groupId_2", 16, message.getGroupStats().get(1).getGroupId().getValue().intValue());
350         Assert.assertEquals("Wrong refCount_2", 18, message.getGroupStats().get(1).getRefCount().intValue());
351         Assert.assertEquals("Wrong packetCount_2", Uint64.valueOf("FF01010101010101", 16),
352                 message.getGroupStats().get(1).getPacketCount());
353         Assert.assertEquals("Wrong byteCount_2", Uint64.valueOf("FF01010101010101", 16),
354                 message.getGroupStats().get(1).getByteCount());
355         Assert.assertEquals("Wrong durationSec_2", 8, message.getGroupStats().get(1).getDurationSec().intValue());
356         Assert.assertEquals("Wrong durationNsec_2", 9, message.getGroupStats().get(1).getDurationNsec().intValue());
357         Assert.assertEquals("Wrong packetCountBucket_1.2", Uint64.valueOf("FF01010101010101", 16),
358                 message.getGroupStats().get(1).getBucketStats().get(0).getPacketCount());
359         Assert.assertEquals("Wrong byteCountBucket_1.2", Uint64.valueOf("FF01010101010101", 16),
360                 message.getGroupStats().get(1).getBucketStats().get(0).getByteCount());
361         Assert.assertEquals("Wrong packetCountBucket_2.2", Uint64.valueOf("FF02020202020202", 16),
362                 message.getGroupStats().get(1).getBucketStats().get(1).getPacketCount());
363         Assert.assertEquals("Wrong byteCountBucket_2.2", Uint64.valueOf("FF02020202020202", 16),
364                 message.getGroupStats().get(1).getBucketStats().get(1).getByteCount());
365     }
366
367     /**
368      * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
369      */
370     @Test
371     public void testMultipartReplyMeterBody() {
372         ByteBuf bb = BufferHelper.buildBuffer("00 09 00 01 00 00 00 00 "
373                                             + "00 00 00 09 " //meterId
374                                             + "00 58 " //len
375                                             + "00 00 00 00 00 00 " //pad
376                                             + "00 00 00 07 " //flowCount
377                                             + "FF 01 01 01 01 01 01 01 " //packetInCount
378                                             + "FF 01 01 01 01 01 01 01 " //byteInCount
379                                             + "00 00 00 05 " //durationSec
380                                             + "00 00 00 05 " //durationNsec
381                                             + "FF 01 01 01 01 01 01 01 " //packetBandCount_01
382                                             + "FF 01 01 01 01 01 01 01 " //byteBandCount_01
383                                             + "FF 02 02 02 02 02 02 02 " //packetBandCount_02
384                                             + "FF 02 02 02 02 02 02 02 " //byteBandCount_02
385                                             + "FF 03 03 03 03 03 03 03 " //packetBandCount_03
386                                             + "FF 03 03 03 03 03 03 03" //byteBandCount_03
387                                             );
388
389         MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
390
391         BufferHelper.checkHeaderV13(builtByFactory);
392         Assert.assertEquals("Wrong type", 9, builtByFactory.getType().getIntValue());
393         Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().getOFPMPFREQMORE());
394         MultipartReplyMeterCase messageCase = (MultipartReplyMeterCase) builtByFactory.getMultipartReplyBody();
395         MultipartReplyMeter message = messageCase.getMultipartReplyMeter();
396         Assert.assertEquals("Wrong meterId", 9,
397                              message.getMeterStats().get(0).getMeterId().getValue().intValue());
398         Assert.assertEquals("Wrong flowCount", 7,
399                             message.getMeterStats().get(0).getFlowCount().intValue());
400         Assert.assertEquals("Wrong packetInCount", Uint64.valueOf("FF01010101010101", 16),
401                 message.getMeterStats().get(0).getPacketInCount());
402         Assert.assertEquals("Wrong byteInCount", Uint64.valueOf("FF01010101010101", 16),
403                 message.getMeterStats().get(0).getByteInCount());
404         Assert.assertEquals("Wrong durationSec", 5,
405                 message.getMeterStats().get(0).getDurationSec().intValue());
406         Assert.assertEquals("Wrong durationNsec", 5,
407                 message.getMeterStats().get(0).getDurationNsec().intValue());
408         Assert.assertEquals("Wrong packetBandCount_01", Uint64.valueOf("FF01010101010101", 16),
409                 message.getMeterStats().get(0).getMeterBandStats().get(0).getPacketBandCount());
410         Assert.assertEquals("Wrong byteBandCount_01", Uint64.valueOf("FF01010101010101", 16),
411                 message.getMeterStats().get(0).getMeterBandStats().get(0).getByteBandCount());
412         Assert.assertEquals("Wrong packetBandCount_02", Uint64.valueOf("FF02020202020202", 16),
413                 message.getMeterStats().get(0).getMeterBandStats().get(1).getPacketBandCount());
414         Assert.assertEquals("Wrong byteBandCount_02", Uint64.valueOf("FF02020202020202", 16),
415                 message.getMeterStats().get(0).getMeterBandStats().get(1).getByteBandCount());
416         Assert.assertEquals("Wrong packetBandCount_03", Uint64.valueOf("FF03030303030303", 16),
417                 message.getMeterStats().get(0).getMeterBandStats().get(2).getPacketBandCount());
418         Assert.assertEquals("Wrong byteBandCount_03", Uint64.valueOf("FF03030303030303", 16),
419                 message.getMeterStats().get(0).getMeterBandStats().get(2).getByteBandCount());
420     }
421
422     /**
423      * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
424      */
425     @Test
426     public void testMultipartReplyMeterBodyMulti() {
427         ByteBuf bb = BufferHelper.buildBuffer("00 09 00 01 00 00 00 00 "
428                                             + "00 00 00 09 " //meterId_0
429                                             + "00 58 " //len_0
430                                             + "00 00 00 00 00 00 " //pad_0
431                                             + "00 00 00 07 " //flowCount_0
432                                             + "FF 01 01 01 01 01 01 01 " //packetInCount_0
433                                             + "FF 01 01 01 01 01 01 01 " //byteInCount_0
434                                             + "00 00 00 05 " //durationSec_0
435                                             + "00 00 00 05 " //durationNsec_0
436                                             + "FF 01 01 01 01 01 01 01 " //packetBandCount_01
437                                             + "FF 01 01 01 01 01 01 01 " //byteBandCount_01
438                                             + "FF 02 02 02 02 02 02 02 " //packetBandCount_02
439                                             + "FF 02 02 02 02 02 02 02 " //byteBandCount_02
440                                             + "FF 03 03 03 03 03 03 03 " //packetBandCount_03
441                                             + "FF 03 03 03 03 03 03 03 " //byteBandCount_03
442                                             + "00 00 00 08 " //meterId_1
443                                             + "00 58 " //len_1
444                                             + "00 00 00 00 00 00 " //pad_1
445                                             + "00 00 00 07 " //flowCount_1
446                                             + "FF 01 01 01 01 01 01 01 " //packetInCount_1
447                                             + "FF 01 01 01 01 01 01 01 " //byteInCount_1
448                                             + "00 00 00 05 " //durationSec_1
449                                             + "00 00 00 05 " //durationNsec_1
450                                             + "FF 01 01 01 01 01 01 01 " //packetBandCount_11
451                                             + "FF 01 01 01 01 01 01 01 " //byteBandCount_11
452                                             + "FF 02 02 02 02 02 02 02 " //packetBandCount_12
453                                             + "FF 02 02 02 02 02 02 02 " //byteBandCount_12
454                                             + "FF 03 03 03 03 03 03 03 " //packetBandCount_13
455                                             + "FF 03 03 03 03 03 03 03"//byteBandCount_13
456                                            );
457
458         MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
459
460         BufferHelper.checkHeaderV13(builtByFactory);
461         Assert.assertEquals("Wrong type", 9, builtByFactory.getType().getIntValue());
462         Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().getOFPMPFREQMORE());
463         MultipartReplyMeterCase messageCase = (MultipartReplyMeterCase) builtByFactory.getMultipartReplyBody();
464         MultipartReplyMeter message = messageCase.getMultipartReplyMeter();
465         Assert.assertEquals("Wrong meterId", 9,
466                              message.getMeterStats().get(0).getMeterId().getValue().intValue());
467         Assert.assertEquals("Wrong flowCount", 7,
468                             message.getMeterStats().get(0).getFlowCount().intValue());
469         Assert.assertEquals("Wrong packetInCount", Uint64.valueOf("FF01010101010101", 16),
470                 message.getMeterStats().get(0).getPacketInCount());
471         Assert.assertEquals("Wrong byteInCount", Uint64.valueOf("FF01010101010101", 16),
472                 message.getMeterStats().get(0).getByteInCount());
473         Assert.assertEquals("Wrong durationSec", 5,
474                 message.getMeterStats().get(0).getDurationSec().intValue());
475         Assert.assertEquals("Wrong durationNsec", 5,
476                 message.getMeterStats().get(0).getDurationNsec().intValue());
477         Assert.assertEquals("Wrong packetBandCount_01", Uint64.valueOf("FF01010101010101", 16),
478                 message.getMeterStats().get(0).getMeterBandStats().get(0).getPacketBandCount());
479         Assert.assertEquals("Wrong byteBandCount_01", Uint64.valueOf("FF01010101010101", 16),
480                 message.getMeterStats().get(0).getMeterBandStats().get(0).getByteBandCount());
481         Assert.assertEquals("Wrong packetBandCount_02", Uint64.valueOf("FF02020202020202", 16),
482                 message.getMeterStats().get(0).getMeterBandStats().get(1).getPacketBandCount());
483         Assert.assertEquals("Wrong byteBandCount_02", Uint64.valueOf("FF02020202020202", 16),
484                 message.getMeterStats().get(0).getMeterBandStats().get(1).getByteBandCount());
485         Assert.assertEquals("Wrong packetBandCount_03", Uint64.valueOf("FF03030303030303", 16),
486                 message.getMeterStats().get(0).getMeterBandStats().get(2).getPacketBandCount());
487         Assert.assertEquals("Wrong byteBandCount_03", Uint64.valueOf("FF03030303030303", 16),
488                 message.getMeterStats().get(0).getMeterBandStats().get(2).getByteBandCount());
489
490         Assert.assertEquals("Wrong meterId", 8,
491                 message.getMeterStats().get(1).getMeterId().getValue().intValue());
492         Assert.assertEquals("Wrong flowCount", 7,
493                 message.getMeterStats().get(1).getFlowCount().intValue());
494         Assert.assertEquals("Wrong packetInCount", Uint64.valueOf("FF01010101010101", 16),
495                 message.getMeterStats().get(1).getPacketInCount());
496         Assert.assertEquals("Wrong byteInCount", Uint64.valueOf("FF01010101010101", 16),
497                 message.getMeterStats().get(1).getByteInCount());
498         Assert.assertEquals("Wrong durationSec", 5,
499                 message.getMeterStats().get(1).getDurationSec().intValue());
500         Assert.assertEquals("Wrong durationNsec", 5,
501                 message.getMeterStats().get(1).getDurationNsec().intValue());
502         Assert.assertEquals("Wrong packetBandCount_01", Uint64.valueOf("FF01010101010101", 16),
503                 message.getMeterStats().get(1).getMeterBandStats().get(0).getPacketBandCount());
504         Assert.assertEquals("Wrong byteBandCount_01", Uint64.valueOf("FF01010101010101", 16),
505                 message.getMeterStats().get(1).getMeterBandStats().get(0).getByteBandCount());
506         Assert.assertEquals("Wrong packetBandCount_02", Uint64.valueOf("FF02020202020202", 16),
507                 message.getMeterStats().get(1).getMeterBandStats().get(1).getPacketBandCount());
508         Assert.assertEquals("Wrong byteBandCount_02", Uint64.valueOf("FF02020202020202", 16),
509                 message.getMeterStats().get(1).getMeterBandStats().get(1).getByteBandCount());
510         Assert.assertEquals("Wrong packetBandCount_03", Uint64.valueOf("FF03030303030303", 16),
511                 message.getMeterStats().get(1).getMeterBandStats().get(2).getPacketBandCount());
512         Assert.assertEquals("Wrong byteBandCount_03", Uint64.valueOf("FF03030303030303", 16),
513                 message.getMeterStats().get(1).getMeterBandStats().get(2).getByteBandCount());
514     }
515
516     /**
517      * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
518      */
519     @Test
520     public void testMultipartReplyMeterConfigBody() {
521         ByteBuf bb = BufferHelper.buildBuffer("00 0A 00 01 00 00 00 00 "
522                                             + "00 28 " //len
523                                             + "00 0A " //flags
524                                             + "00 00 00 09 " //meterId
525                                             + "00 01 " //meterBandDrop.type
526                                             + "00 10 " //meterBandDrop.len
527                                             + "00 00 00 11 " //meterBandDrop.rate
528                                             + "00 00 00 20 " //meterBandDrop.burstSize
529                                             + "00 00 00 00 " //meterBandDrop.pad
530                                             + "00 02 " //meterBandDscp.type
531                                             + "00 10 " //meterBandDscp.len
532                                             + "00 00 00 11 " //meterBandDscp.rate
533                                             + "00 00 00 20 " //meterBandDscp.burstSize
534                                             + "04 " //meterBandDscp.precLevel
535                                             + "00 00 00");//meterBandDscp.pad
536
537         MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
538
539         BufferHelper.checkHeaderV13(builtByFactory);
540         Assert.assertEquals("Wrong type", 10, builtByFactory.getType().getIntValue());
541         Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().getOFPMPFREQMORE());
542         MultipartReplyMeterConfigCase messageCase =
543                 (MultipartReplyMeterConfigCase) builtByFactory.getMultipartReplyBody();
544         MultipartReplyMeterConfig message = messageCase.getMultipartReplyMeterConfig();
545         Assert.assertEquals("Wrong flags", new MeterFlags(false, false, true, true),
546                              message.getMeterConfig().get(0).getFlags());
547         Assert.assertEquals("Wrong meterId", 9,
548                              message.getMeterConfig().get(0).getMeterId().getValue().intValue());
549
550         MeterBandDropCase dropCase =
551                 (MeterBandDropCase) message.getMeterConfig().get(0).getBands().get(0).getMeterBand();
552         MeterBandDrop meterBandDrop = dropCase.getMeterBandDrop();
553         Assert.assertEquals("Wrong meterBandDrop.type", 1, meterBandDrop.getType().getIntValue());
554         Assert.assertEquals("Wrong meterBandDrop.rate", 17, meterBandDrop.getRate().intValue());
555         Assert.assertEquals("Wrong meterBandDrop.burstSize", 32, meterBandDrop.getBurstSize().intValue());
556
557         MeterBandDscpRemarkCase dscpCase =
558                 (MeterBandDscpRemarkCase) message.getMeterConfig().get(0).getBands().get(1).getMeterBand();
559         MeterBandDscpRemark meterBandDscp = dscpCase.getMeterBandDscpRemark();
560         Assert.assertEquals("Wrong meterBandDscp.type", 2, meterBandDscp.getType().getIntValue());
561         Assert.assertEquals("Wrong meterBandDscp.rate", 17, meterBandDscp.getRate().intValue());
562         Assert.assertEquals("Wrong meterBandDscp.burstSize", 32, meterBandDscp.getBurstSize().intValue());
563         Assert.assertEquals("Wrong meterBandDscp.precLevel", 4, meterBandDscp.getPrecLevel().intValue());
564     }
565
566     /**
567      * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
568      */
569     @Test
570     public void testMultipartReplyMeterConfigBodyMulti() {
571         ByteBuf bb = BufferHelper.buildBuffer("00 0A 00 01 00 00 00 00 "
572                                             + "00 28 " //len
573                                             + "00 06 " //flags
574                                             + "00 00 00 09 " //meterId
575                                             + "00 01 " //meterBandDrop.type
576                                             + "00 10 " //meterBandDrop.len
577                                             + "00 00 00 11 " //meterBandDrop.rate
578                                             + "00 00 00 20 " //meterBandDrop.burstSize
579                                             + "00 00 00 00 " //meterBandDrop.pad
580                                             + "00 02 " //meterBandDscp.type
581                                             + "00 10 " //meterBandDscp.len
582                                             + "00 00 00 11 " //meterBandDscp.rate
583                                             + "00 00 00 20 " //meterBandDscp.burstSize
584                                             + "04 " //meterBandDscp.precLevel
585                                             + "00 00 00 " //meterBandDscp.pad
586                                             + "00 18 " //len01
587                                             + "00 03 " //flags01
588                                             + "00 00 00 07 " //meterId01
589                                             + "00 02 " //meterBandDscp01.type
590                                             + "00 10 " //meterBandDscp01.len
591                                             + "00 00 00 11 " //meterBandDscp01.rate
592                                             + "00 00 00 20 " //meterBandDscp01.burstSize
593                                             + "04 " //meterBandDscp01.precLevel
594                                             + "00 00 00"//meterBandDscp01.pad
595                                             );
596
597         MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
598
599         BufferHelper.checkHeaderV13(builtByFactory);
600         Assert.assertEquals("Wrong type", 10, builtByFactory.getType().getIntValue());
601         Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().getOFPMPFREQMORE());
602         MultipartReplyMeterConfigCase messageCase =
603                 (MultipartReplyMeterConfigCase) builtByFactory.getMultipartReplyBody();
604         MultipartReplyMeterConfig message = messageCase.getMultipartReplyMeterConfig();
605         Assert.assertEquals("Wrong flags", new MeterFlags(true, false, true, false),
606                              message.getMeterConfig().get(0).getFlags());
607         Assert.assertEquals("Wrong meterId", 9,
608                              message.getMeterConfig().get(0).getMeterId().getValue().intValue());
609
610         MeterBandDropCase dropCase =
611                 (MeterBandDropCase) message.getMeterConfig().get(0).getBands().get(0).getMeterBand();
612         MeterBandDrop meterBandDrop = dropCase.getMeterBandDrop();
613         Assert.assertEquals("Wrong meterBandDrop.type", 1, meterBandDrop.getType().getIntValue());
614         Assert.assertEquals("Wrong meterBandDrop.rate", 17, meterBandDrop.getRate().intValue());
615         Assert.assertEquals("Wrong meterBandDrop.burstSize", 32, meterBandDrop.getBurstSize().intValue());
616
617         MeterBandDscpRemarkCase dscpCase =
618                 (MeterBandDscpRemarkCase) message.getMeterConfig().get(0).getBands().get(1).getMeterBand();
619         MeterBandDscpRemark meterBandDscp = dscpCase.getMeterBandDscpRemark();
620         Assert.assertEquals("Wrong meterBandDscp.type", 2, meterBandDscp.getType().getIntValue());
621         Assert.assertEquals("Wrong meterBandDscp.rate", 17, meterBandDscp.getRate().intValue());
622         Assert.assertEquals("Wrong meterBandDscp.burstSize", 32, meterBandDscp.getBurstSize().intValue());
623         Assert.assertEquals("Wrong meterBandDscp.precLevel", 4, meterBandDscp.getPrecLevel().intValue());
624
625         LOG.info(message.getMeterConfig().get(0).getFlags().toString());
626         Assert.assertEquals("Wrong flags01", new MeterFlags(false, true, true, false),
627                              message.getMeterConfig().get(1).getFlags());
628         Assert.assertEquals("Wrong meterId01", 7,
629                              message.getMeterConfig().get(1).getMeterId().getValue().intValue());
630
631         MeterBandDscpRemarkCase dscpCase01 =
632                 (MeterBandDscpRemarkCase) message.getMeterConfig().get(1).getBands().get(0).getMeterBand();
633         MeterBandDscpRemark meterBandDscp01 = dscpCase01.getMeterBandDscpRemark();
634         Assert.assertEquals("Wrong meterBandDscp01.type", 2, meterBandDscp01.getType().getIntValue());
635         Assert.assertEquals("Wrong meterBandDscp01.rate", 17, meterBandDscp01.getRate().intValue());
636         Assert.assertEquals("Wrong meterBandDscp01.burstSize", 32, meterBandDscp01.getBurstSize().intValue());
637         Assert.assertEquals("Wrong meterBandDscp01.precLevel", 4, meterBandDscp01.getPrecLevel().intValue());
638
639     }
640
641     /**
642      * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
643      * Test covers bodies of actions Output, Copy TTL Out, Copy TTL In.
644      */
645     @Test
646     public void testMultipartReplyGroupDescBody01() {
647         ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "
648                                             + "00 38 " //len
649                                             + "01 " //type
650                                             + "00 " //pad
651                                             + "00 00 00 08 " //groupId
652                                             + "00 30 " //bucketLen
653                                             + "00 06 " //bucketWeight
654                                             + "00 00 00 05 " //bucketWatchPort
655                                             + "00 00 00 04 " //bucketWatchGroup
656                                             + "00 00 00 00 " //bucketPad
657                                             + "00 00 " //outputType
658                                             + "00 10 " //outputLen
659                                             + "00 00 10 FF " //outputPort
660                                             + "FF FF " //outputMaxLen
661                                             + "00 00 00 00 00 00 " //outputPad
662                                             + "00 0B " //copyTTLOutType
663                                             + "00 08 " //copyTTLOutLen
664                                             + "00 00 00 00 " //copyTTLOutPad
665                                             + "00 0C " //copyTTLIntType
666                                             + "00 08 " //copyTTLIntLen
667                                             + "00 00 00 00"//copyTTLInPad
668                                             );
669         MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
670
671         BufferHelper.checkHeaderV13(builtByFactory);
672         Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
673         Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().getOFPMPFREQMORE());
674         MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody();
675         MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc();
676         Assert.assertEquals("Wrong type", 1,
677                              message.getGroupDesc().get(0).getType().getIntValue());
678         Assert.assertEquals("Wrong groupId", 8,
679                              message.getGroupDesc().get(0).getGroupId().getValue().intValue());
680         Assert.assertEquals("Wrong bucketWeight", 6,
681                 message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());
682         Assert.assertEquals("Wrong bucketWatchPort", 5,
683                 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().getValue().intValue());
684         Assert.assertEquals("Wrong bucketWatchGroup", 4,
685                 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());
686
687         Assert.assertTrue("Wrong outputType",message.getGroupDesc().get(0).getBucketsList().get(0)
688                 .getAction().get(0).getActionChoice() instanceof OutputActionCase);
689
690         Assert.assertEquals("Wrong outputPort", 4351, ((OutputActionCase) message.getGroupDesc().get(0)
691                 .getBucketsList().get(0).getAction().get(0).getActionChoice())
692                 .getOutputAction().getPort().getValue().intValue());
693
694         Assert.assertEquals("Wrong outputMaxLen", 65535, ((OutputActionCase) message.getGroupDesc().get(0)
695                 .getBucketsList().get(0).getAction().get(0).getActionChoice())
696                 .getOutputAction().getMaxLength().intValue());
697
698         Assert.assertTrue("Wrong copyTtlOutType", message.getGroupDesc().get(0).getBucketsList()
699                 .get(0).getAction().get(1).getActionChoice() instanceof CopyTtlOutCase);
700
701         Assert.assertTrue("Wrong copyTtlInType", message.getGroupDesc().get(0).getBucketsList()
702                 .get(0).getAction().get(2).getActionChoice() instanceof CopyTtlInCase);
703     }
704
705     /**
706      * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
707      * Test covers bodies of actions Set MPLS TTL , Dec MPLS TTL, Push VLAN. Push MPLS, Push PBB.
708      */
709     @Test
710     public void testMultipartReplyGroupDescBody02() {
711         ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "
712                                             + "00 40 " //len
713                                             + "01 " //type
714                                             + "00 " //pad
715                                             + "00 00 00 08 " //groupId
716                                             + "00 38 " //bucketLen
717                                             + "00 06 " //bucketWeight
718                                             + "00 00 00 05 " //bucketWatchPort
719                                             + "00 00 00 04 " //bucketWatchGroup
720                                             + "00 00 00 00 " //bucketPad
721                                             + "00 0F " //setMplsTtlType
722                                             + "00 08 " //setMplsTtlLen
723                                             + "09 " //setMplsTtlMPLS_TTL
724                                             + "00 00 00 " //setMplsTtlPad
725                                             + "00 10 " //decMplsTtlType
726                                             + "00 08 " //decMplsTtlLen
727                                             + "00 00 00 00 " //decMplsTtlPad
728                                             + "00 11 " //pushVlanType
729                                             + "00 08 " //pushVlanLen
730                                             + "00 20 " //pushVlanEthertype
731                                             + "00 00 " //pushVlanPad
732                                             + "00 13 " //pushMplsType
733                                             + "00 08 " //pushMplsLen
734                                             + "00 FF " //pushMplsEthertype
735                                             + "00 00 " //pushMplsPad
736                                             + "00 1A " //pushPbbType
737                                             + "00 08 " //pushPbbLen
738                                             + "0F FF " //pushPbbEthertype
739                                             + "00 00"//pushPbbPad
740                                             );
741
742         MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
743
744         BufferHelper.checkHeaderV13(builtByFactory);
745         Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
746         Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().getOFPMPFREQMORE());
747         MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody();
748         MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc();
749         Assert.assertEquals("Wrong type", 1,
750                              message.getGroupDesc().get(0).getType().getIntValue());
751         Assert.assertEquals("Wrong groupId", 8,
752                              message.getGroupDesc().get(0).getGroupId().getValue().intValue());
753         Assert.assertEquals("Wrong bucketWeight", 6,
754                 message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());
755         Assert.assertEquals("Wrong bucketWatchPort", 5,
756                 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().getValue().intValue());
757         Assert.assertEquals("Wrong bucketWatchGroup", 4,
758                 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());
759         Assert.assertTrue("Wrong setMplsTtlType", message.getGroupDesc().get(0).getBucketsList().get(0)
760                 .getAction().get(0).getActionChoice() instanceof SetMplsTtlCase);
761         Assert.assertEquals("Wrong setMplsTtlMPLS_TTL", 9, ((SetMplsTtlCase) message.getGroupDesc().get(0)
762                 .getBucketsList().get(0).getAction().get(0).getActionChoice()).getSetMplsTtlAction()
763                 .getMplsTtl().intValue());
764         Assert.assertTrue("Wrong decMplsTtlType", message.getGroupDesc().get(0).getBucketsList().get(0)
765                 .getAction().get(1).getActionChoice() instanceof DecMplsTtlCase);
766         Assert.assertTrue("Wrong pushVlanType", message.getGroupDesc().get(0).getBucketsList().get(0)
767                 .getAction().get(2).getActionChoice() instanceof PushVlanCase);
768         Assert.assertEquals("Wrong pushVlanEthertype", 32,((PushVlanCase) message.getGroupDesc().get(0)
769                 .getBucketsList().get(0).getAction().get(2).getActionChoice())
770                 .getPushVlanAction().getEthertype().getValue().intValue());
771         Assert.assertTrue("Wrong pushMplsType", message.getGroupDesc().get(0).getBucketsList().get(0)
772                 .getAction().get(3).getActionChoice() instanceof PushMplsCase);
773         Assert.assertEquals("Wrong pushMplsEthertype", 255, ((PushMplsCase) message.getGroupDesc().get(0)
774                 .getBucketsList().get(0).getAction().get(3).getActionChoice())
775                 .getPushMplsAction().getEthertype().getValue().intValue());
776         Assert.assertTrue("Wrong pushPbbType", message.getGroupDesc().get(0).getBucketsList().get(0)
777                 .getAction().get(4).getActionChoice() instanceof PushPbbCase);
778         Assert.assertEquals("Wrong pushPbbEthertype", 4095, ((PushPbbCase) message.getGroupDesc().get(0)
779                 .getBucketsList().get(0).getAction().get(4).getActionChoice())
780                 .getPushPbbAction().getEthertype().getValue().intValue());
781     }
782
783     /**
784      * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
785      * Test covers bodies of actions Pop VLAN, Pop PBB, Pop MPLS, Group, Dec NW TTL.
786      */
787     @Test
788     public void testMultipartReplyGroupDescBody03() {
789         ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "
790                                             + "00 48 " //len
791                                             + "01 " //type
792                                             + "00 " //pad
793                                             + "00 00 00 08 " //groupId
794                                             + "00 40 " //bucketLen
795                                             + "00 06 " //bucketWeight
796                                             + "00 00 00 05 " //bucketWatchPort
797                                             + "00 00 00 04 " //bucketWatchGroup
798                                             + "00 00 00 00 " //bucketPad
799                                             + "00 12 " //popVlanType
800                                             + "00 08 " //popVlanLen
801                                             + "00 00 00 00 " //popVlanPad
802                                             + "00 1B " //popPbbType
803                                             + "00 08 " //popPbbLen
804                                             + "00 00 00 00 " //popPbbPad
805                                             + "00 14 " //popMplsType
806                                             + "00 08 " //popMplsLen
807                                             + "00 CF " //popMplsEthertype
808                                             + "00 00 " //popMplsPad
809                                             + "00 15 " //setQueueType
810                                             + "00 08 " //setQueueLen
811                                             + "00 CF 00 00 " //setQueueQueueId
812                                             + "00 16 " //groupType
813                                             + "00 08 " //groupLen
814                                             + "00 CF 00 00 " //groupGroupId
815                                             + "00 18 " //decNwTtlType
816                                             + "00 08 " //decNwTtlLen
817                                             + "00 00 00 00"//decNwTtlPad
818                                             );
819
820         MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
821
822         BufferHelper.checkHeaderV13(builtByFactory);
823         Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
824         Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().getOFPMPFREQMORE());
825         MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody();
826         MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc();
827         Assert.assertEquals("Wrong type", 1, message.getGroupDesc().get(0).getType().getIntValue());
828         Assert.assertEquals("Wrong groupId", 8, message.getGroupDesc().get(0).getGroupId().getValue().intValue());
829         Assert.assertEquals("Wrong bucketWeight", 6,
830                 message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());
831         Assert.assertEquals("Wrong bucketWatchPort", 5,
832                 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().getValue().intValue());
833         Assert.assertEquals("Wrong bucketWatchGroup", 4,
834                 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());
835         Assert.assertTrue("Wrong popVlanType", message.getGroupDesc().get(0).getBucketsList().get(0)
836                 .getAction().get(0).getActionChoice() instanceof PopVlanCase);
837         Assert.assertTrue("Wrong popPbbType", message.getGroupDesc().get(0).getBucketsList().get(0)
838                 .getAction().get(1).getActionChoice() instanceof PopPbbCase);
839         Assert.assertTrue("Wrong popMplsType", message.getGroupDesc().get(0).getBucketsList().get(0)
840                 .getAction().get(2).getActionChoice() instanceof PopMplsCase);
841         Assert.assertEquals("Wrong popMplsEthertype", 207, ((PopMplsCase) message.getGroupDesc().get(0)
842                 .getBucketsList().get(0).getAction().get(2).getActionChoice())
843                 .getPopMplsAction().getEthertype().getValue().intValue());
844         Assert.assertTrue("Wrong setQueueType", message.getGroupDesc().get(0).getBucketsList().get(0)
845                 .getAction().get(3).getActionChoice() instanceof SetQueueCase);
846         Assert.assertEquals("Wrong setQueueQueueId", 13565952, ((SetQueueCase) message.getGroupDesc().get(0)
847                 .getBucketsList().get(0).getAction().get(3).getActionChoice())
848                 .getSetQueueAction().getQueueId().intValue());
849         Assert.assertTrue("Wrong groupType", message.getGroupDesc().get(0).getBucketsList().get(0)
850                 .getAction().get(4).getActionChoice() instanceof GroupCase);
851         Assert.assertEquals("Wrong groupGroupId", 13565952, ((GroupCase) message.getGroupDesc().get(0)
852                 .getBucketsList().get(0).getAction().get(4).getActionChoice())
853                 .getGroupAction().getGroupId().intValue());
854         Assert.assertTrue("Wrong decNwTtlType", message.getGroupDesc().get(0).getBucketsList().get(0)
855                 .getAction().get(5).getActionChoice() instanceof DecNwTtlCase);
856     }
857
858     /**
859      * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
860      * Test covers bodies of actions NW TTL, Experimenter.
861      */
862     @Test
863     public void testMultipartReplyGroupDescBody04() {
864         ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 "
865                                             + "00 30 " //len
866                                             + "01 " //type
867                                             + "00 " //pad
868                                             + "00 00 00 08 " //groupId
869                                             + "00 28 " //bucketLen
870                                             + "00 06 " //bucketWeight
871                                             + "00 00 00 05 " //bucketWatchPort
872                                             + "00 00 00 04 " //bucketWatchGroup
873                                             + "00 00 00 00 " //bucketPad
874                                             + "00 17 " //nwTTlType
875                                             + "00 08 " //nwTTlLen
876                                             + "0E " //nwTTlnwTTL
877                                             + "00 00 00 " //nwTTlPad
878                                             + "00 19 " //setFieldType
879                                             + "00 10 " //setFieldLen
880                                             + "80 00 " //setFieldOXMClass
881                                             + "00 " //setFieldOXMField
882                                             + "04 " //setFieldOXMLength
883                                             + "00 00 00 FF " //setFieldPort
884                                             + "00 00 00 00");
885
886         MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
887
888         BufferHelper.checkHeaderV13(builtByFactory);
889         Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
890         Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().getOFPMPFREQMORE());
891         MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody();
892         MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc();
893         Assert.assertEquals("Wrong type", 1,
894                              message.getGroupDesc().get(0).getType().getIntValue());
895         Assert.assertEquals("Wrong groupId", 8,
896                              message.getGroupDesc().get(0).getGroupId().getValue().intValue());
897         Assert.assertEquals("Wrong bucketWeight", 6,
898                 message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());
899         Assert.assertEquals("Wrong bucketWatchPort", 5,
900                 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().getValue().intValue());
901         Assert.assertEquals("Wrong bucketWatchGroup", 4,
902                 message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());
903
904         Assert.assertTrue("Wrong nwTTlType", message.getGroupDesc().get(0).getBucketsList().get(0)
905                 .getAction().get(0).getActionChoice() instanceof SetNwTtlCase);
906
907         Assert.assertEquals("Wrong nwTTlnwTTL", 14, ((SetNwTtlCase) message.getGroupDesc().get(0)
908                 .getBucketsList().get(0).getAction().get(0).getActionChoice())
909                 .getSetNwTtlAction().getNwTtl().intValue());
910
911         Assert.assertTrue("Wrong setFieldType", message.getGroupDesc().get(0).getBucketsList().get(0)
912                 .getAction().get(1).getActionChoice() instanceof SetFieldCase);
913
914         Assert.assertEquals("Wrong setFieldOXMClass", OpenflowBasicClass.class,
915                 ((SetFieldCase) message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1)
916                 .getActionChoice()).getSetFieldAction().getMatchEntry().get(0).getOxmClass());
917
918         Assert.assertEquals("Wrong setFieldOXMField", InPort.class,
919                 ((SetFieldCase) message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1)
920                         .getActionChoice()).getSetFieldAction().getMatchEntry().get(0).getOxmMatchField());
921
922         MatchEntry entry = ((SetFieldCase) message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1)
923                 .getActionChoice()).getSetFieldAction().getMatchEntry().get(0);
924         Assert.assertEquals("Wrong setFieldOXMValue", 255, ((InPortCase) entry.getMatchEntryValue())
925                 .getInPort().getPortNumber().getValue().intValue());
926     }
927 }