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