private static ActionType createActionBitmap(long input) {
final Boolean OFPAT_OUTPUT = ((input) & (1<<0)) != 0;
- final Boolean OFPAT_COPY_TTL_OUT = ((input) & (1<<1)) != 0;
- final Boolean OFPAT_COPY_TTL_IN = ((input) & (1<<2)) != 0;
- final Boolean OFPAT_SET_MPLS_TTL = ((input) & (1<<3)) != 0;
- final Boolean OFPAT_DEC_MPLS_TTL = ((input) & (1<<4)) != 0;
- final Boolean OFPAT_PUSH_VLAN = ((input) & (1<<5)) != 0;
- final Boolean OFPAT_POP_VLAN = ((input) & (1<<6)) != 0;
- final Boolean OFPAT_PUSH_MPLS = ((input) & (1<<7)) != 0;
- final Boolean OFPAT_POP_MPLS = ((input) & (1<<8)) != 0;
- final Boolean OFPAT_SET_QUEUE = ((input) & (1<<9)) != 0;
- final Boolean OFPAT_GROUP = ((input) & (1<<10)) != 0;
- final Boolean OFPAT_SET_NW_TTL = ((input) & (1<<11)) != 0;
- final Boolean OFPAT_DEC_NW_TTL = ((input) & (1<<12)) != 0;
- final Boolean OFPAT_SET_FIELD = ((input) & (1<<13)) != 0;
- final Boolean OFPAT_PUSH_PBB = ((input) & (1<<14)) != 0;
- final Boolean OFPAT_POP_PBB = ((input) & (1<<15)) != 0;
- final Boolean OFPAT_EXPERIMENTER = ((input) & (1<<16)) != 0;
+ final Boolean OFPAT_COPY_TTL_OUT = ((input) & (1<<11)) != 0;
+ final Boolean OFPAT_COPY_TTL_IN = ((input) & (1<<12)) != 0;
+ final Boolean OFPAT_SET_MPLS_TTL = ((input) & (1<<15)) != 0;
+ final Boolean OFPAT_DEC_MPLS_TTL = ((input) & (1<<16)) != 0;
+ final Boolean OFPAT_PUSH_VLAN = ((input) & (1<<17)) != 0;
+ final Boolean OFPAT_POP_VLAN = ((input) & (1<<18)) != 0;
+ final Boolean OFPAT_PUSH_MPLS = ((input) & (1<<19)) != 0;
+ final Boolean OFPAT_POP_MPLS = ((input) & (1<<20)) != 0;
+ final Boolean OFPAT_SET_QUEUE = ((input) & (1<<21)) != 0;
+ final Boolean OFPAT_GROUP = ((input) & (1<<22)) != 0;
+ final Boolean OFPAT_SET_NW_TTL = ((input) & (1<<23)) != 0;
+ final Boolean OFPAT_DEC_NW_TTL = ((input) & (1<<24)) != 0;
+ final Boolean OFPAT_SET_FIELD = ((input) & (1<<25)) != 0;
+ final Boolean OFPAT_PUSH_PBB = ((input) & (1<<26)) != 0;
+ final Boolean OFPAT_POP_PBB = ((input) & (1<<27)) != 0;
+ final Boolean OFPAT_EXPERIMENTER = false;
return new ActionType(OFPAT_COPY_TTL_IN, OFPAT_COPY_TTL_OUT, OFPAT_DEC_MPLS_TTL,
OFPAT_DEC_NW_TTL, OFPAT_EXPERIMENTER, OFPAT_GROUP, OFPAT_OUTPUT, OFPAT_POP_MPLS,
OFPAT_POP_PBB, OFPAT_POP_VLAN, OFPAT_PUSH_MPLS, OFPAT_PUSH_PBB, OFPAT_PUSH_VLAN,
--- /dev/null
+/*\r
+ * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCase;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeatures;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class MultipartReplyGroupFeaturesTest {\r
+\r
+ private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory();\r
+\r
+ /**\r
+ * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
+ */\r
+ @Test\r
+ public void testMultipartReplyGroupFeatures() {\r
+ ByteBuf bb = BufferHelper.buildBuffer("00 08 00 01 00 00 00 00 "+\r
+ "00 00 00 0F "+// types\r
+ "00 00 00 0F "+// capabilities\r
+ "00 00 00 01 "+// max groups\r
+ "00 00 00 02 "+// max groups\r
+ "00 00 00 03 "+// max groups\r
+ "00 00 00 04 "+// max groups\r
+ "0F FF 98 01 "+// actions bitmap (all actions included)\r
+ "00 00 00 00 "+// actions bitmap (no actions included)\r
+ "00 00 00 00 "+// actions bitmap (no actions included)\r
+ "00 00 00 00"// actions bitmap (no actions included)\r
+ );\r
+ MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);\r
+\r
+ BufferHelper.checkHeaderV13(builtByFactory);\r
+ Assert.assertEquals("Wrong type", 8, builtByFactory.getType().getIntValue());\r
+ Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
+ MultipartReplyGroupFeaturesCase messageCase =\r
+ (MultipartReplyGroupFeaturesCase) builtByFactory.getMultipartReplyBody();\r
+ MultipartReplyGroupFeatures message = messageCase.getMultipartReplyGroupFeatures();\r
+ Assert.assertEquals("Wrong group types", new GroupTypes(true, true, true, true), message.getTypes());\r
+ Assert.assertEquals("Wrong capabilities", new GroupCapabilities(true, true, true, true),\r
+ message.getCapabilities());\r
+ Assert.assertEquals("Wrong max groups", 1, message.getMaxGroups().get(0).intValue());\r
+ Assert.assertEquals("Wrong max groups", 2, message.getMaxGroups().get(1).intValue());\r
+ Assert.assertEquals("Wrong max groups", 3, message.getMaxGroups().get(2).intValue());\r
+ Assert.assertEquals("Wrong max groups", 4, message.getMaxGroups().get(3).intValue());\r
+ Assert.assertEquals("Wrong actions bitmap", new ActionType(true, true, true, true, false, true, true, true, true,\r
+ true, true, true, true, true, true, true, true), message.getActionsBitmap().get(0));\r
+ Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false, false,\r
+ false, false, false, false, false, false, false, false, false), message.getActionsBitmap().get(1));\r
+ Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false, false,\r
+ false, false, false, false, false, false, false, false, false), message.getActionsBitmap().get(2));\r
+ Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false, false,\r
+ false, false, false, false, false, false, false, false, false), message.getActionsBitmap().get(3));\r
+ }\r
+\r
+ /**\r
+ * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
+ * (with different group types and capabilities)\r
+ */\r
+ @Test\r
+ public void testMultipartReplyGroupFeatures2() {\r
+ ByteBuf bb = BufferHelper.buildBuffer("00 08 00 01 00 00 00 00 "+\r
+ "00 00 00 00 "+// types\r
+ "00 00 00 00 "+// capabilities\r
+ "00 00 00 01 "+// max groups\r
+ "00 00 00 02 "+// max groups\r
+ "00 00 00 03 "+// max groups\r
+ "00 00 00 04 "+// max groups\r
+ "00 00 00 00 "+// actions bitmap (all actions included)\r
+ "00 00 00 00 "+// actions bitmap (no actions included)\r
+ "00 00 00 00 "+// actions bitmap (no actions included)\r
+ "00 00 00 00"// actions bitmap (no actions included)\r
+ );\r
+ MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);\r
+\r
+ BufferHelper.checkHeaderV13(builtByFactory);\r
+ Assert.assertEquals("Wrong type", 8, builtByFactory.getType().getIntValue());\r
+ Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
+ MultipartReplyGroupFeaturesCase messageCase =\r
+ (MultipartReplyGroupFeaturesCase) builtByFactory.getMultipartReplyBody();\r
+ MultipartReplyGroupFeatures message = messageCase.getMultipartReplyGroupFeatures();\r
+ Assert.assertEquals("Wrong group types", new GroupTypes(false, false, false, false), message.getTypes());\r
+ Assert.assertEquals("Wrong capabilities", new GroupCapabilities(false, false, false, false),\r
+ message.getCapabilities());\r
+ }\r
+}
\ No newline at end of file