2 * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.
\r
4 * This program and the accompanying materials are made available under the
\r
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
\r
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
\r
9 package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart;
\r
11 import io.netty.buffer.ByteBuf;
\r
13 import org.junit.Assert;
\r
14 import org.junit.Test;
\r
15 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory;
\r
16 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
\r
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType;
\r
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities;
\r
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes;
\r
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
\r
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCase;
\r
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeatures;
\r
25 * @author michal.polkorab
\r
28 public class MultipartReplyGroupFeaturesTest {
\r
30 private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory();
\r
33 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
\r
36 public void testMultipartReplyGroupFeatures() {
\r
37 ByteBuf bb = BufferHelper.buildBuffer("00 08 00 01 00 00 00 00 "+
\r
38 "00 00 00 0F "+// types
\r
39 "00 00 00 0F "+// capabilities
\r
40 "00 00 00 01 "+// max groups
\r
41 "00 00 00 02 "+// max groups
\r
42 "00 00 00 03 "+// max groups
\r
43 "00 00 00 04 "+// max groups
\r
44 "0F FF 98 01 "+// actions bitmap (all actions included)
\r
45 "00 00 00 00 "+// actions bitmap (no actions included)
\r
46 "00 00 00 00 "+// actions bitmap (no actions included)
\r
47 "00 00 00 00"// actions bitmap (no actions included)
\r
49 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
\r
51 BufferHelper.checkHeaderV13(builtByFactory);
\r
52 Assert.assertEquals("Wrong type", 8, builtByFactory.getType().getIntValue());
\r
53 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
\r
54 MultipartReplyGroupFeaturesCase messageCase =
\r
55 (MultipartReplyGroupFeaturesCase) builtByFactory.getMultipartReplyBody();
\r
56 MultipartReplyGroupFeatures message = messageCase.getMultipartReplyGroupFeatures();
\r
57 Assert.assertEquals("Wrong group types", new GroupTypes(true, true, true, true), message.getTypes());
\r
58 Assert.assertEquals("Wrong capabilities", new GroupCapabilities(true, true, true, true),
\r
59 message.getCapabilities());
\r
60 Assert.assertEquals("Wrong max groups", 1, message.getMaxGroups().get(0).intValue());
\r
61 Assert.assertEquals("Wrong max groups", 2, message.getMaxGroups().get(1).intValue());
\r
62 Assert.assertEquals("Wrong max groups", 3, message.getMaxGroups().get(2).intValue());
\r
63 Assert.assertEquals("Wrong max groups", 4, message.getMaxGroups().get(3).intValue());
\r
64 Assert.assertEquals("Wrong actions bitmap", new ActionType(true, true, true, true, false, true, true, true, true,
\r
65 true, true, true, true, true, true, true, true), message.getActionsBitmap().get(0));
\r
66 Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false, false,
\r
67 false, false, false, false, false, false, false, false, false), message.getActionsBitmap().get(1));
\r
68 Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false, false,
\r
69 false, false, false, false, false, false, false, false, false), message.getActionsBitmap().get(2));
\r
70 Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false, false,
\r
71 false, false, false, false, false, false, false, false, false), message.getActionsBitmap().get(3));
\r
75 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
\r
76 * (with different group types and capabilities)
\r
79 public void testMultipartReplyGroupFeatures2() {
\r
80 ByteBuf bb = BufferHelper.buildBuffer("00 08 00 01 00 00 00 00 "+
\r
81 "00 00 00 00 "+// types
\r
82 "00 00 00 00 "+// capabilities
\r
83 "00 00 00 01 "+// max groups
\r
84 "00 00 00 02 "+// max groups
\r
85 "00 00 00 03 "+// max groups
\r
86 "00 00 00 04 "+// max groups
\r
87 "00 00 00 00 "+// actions bitmap (all actions included)
\r
88 "00 00 00 00 "+// actions bitmap (no actions included)
\r
89 "00 00 00 00 "+// actions bitmap (no actions included)
\r
90 "00 00 00 00"// actions bitmap (no actions included)
\r
92 MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
\r
94 BufferHelper.checkHeaderV13(builtByFactory);
\r
95 Assert.assertEquals("Wrong type", 8, builtByFactory.getType().getIntValue());
\r
96 Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
\r
97 MultipartReplyGroupFeaturesCase messageCase =
\r
98 (MultipartReplyGroupFeaturesCase) builtByFactory.getMultipartReplyBody();
\r
99 MultipartReplyGroupFeatures message = messageCase.getMultipartReplyGroupFeatures();
\r
100 Assert.assertEquals("Wrong group types", new GroupTypes(false, false, false, false), message.getTypes());
\r
101 Assert.assertEquals("Wrong capabilities", new GroupCapabilities(false, false, false, false),
\r
102 message.getCapabilities());
\r