* @param message message that will be transformed into ByteBuf\r
*/\r
public abstract void messageToBuffer(short version, ByteBuf out, E message);\r
+ \r
+ /**\r
+ * Compute length of received message\r
+ * @return computed length\r
+ */\r
+ public abstract int computeLength();\r
+ \r
+ /**\r
+ * \r
+ * @return message code type\r
+ */\r
+ public byte getMessageType();\r
}\r
\r
import io.netty.buffer.ByteBuf;\r
\r
-import org.opendaylight.openflowjava.protocol.impl.core.OFFrameDecoder;\r
import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;\r
\r
/**\r
/** Code type of BarrierRequest message */\r
public static final byte MESSAGE_TYPE = 20;\r
private static BarrierInputMessageFactory instance;\r
+ private static final int MESSAGE_LENGTH = 8;\r
\r
private BarrierInputMessageFactory() {\r
// do nothing, just singleton\r
\r
@Override\r
public void messageToBuffer(short version, ByteBuf out, BarrierInput message) {\r
- out.writeByte(message.getVersion());\r
- out.writeByte(MESSAGE_TYPE);\r
- out.writeShort(OFFrameDecoder.LENGTH_OF_HEADER);\r
- out.writeInt(message.getXid().intValue());\r
+ ByteBufUtils.writeOFHeader(instance, message, out);\r
}\r
\r
+ @Override\r
+ public int computeLength() {\r
+ return MESSAGE_LENGTH;\r
+ }\r
+\r
+ @Override\r
+ public byte getMessageType() {\r
+ return MESSAGE_TYPE;\r
+ }\r
}\r
\r
import io.netty.buffer.ByteBuf;\r
\r
-import org.opendaylight.openflowjava.protocol.impl.core.OFFrameDecoder;\r
import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput;\r
\r
/**\r
/** Code type of EchoRequest message */\r
public static final byte MESSAGE_TYPE = 2;\r
private static EchoInputMessageFactory instance;\r
+ private static final int MESSAGE_LENGTH = 8;\r
\r
private EchoInputMessageFactory() {\r
// do nothing, just singleton\r
\r
@Override\r
public void messageToBuffer(short version, ByteBuf out, EchoInput message) {\r
- out.writeByte(message.getVersion());\r
- out.writeByte(MESSAGE_TYPE);\r
- out.writeShort(OFFrameDecoder.LENGTH_OF_HEADER);\r
- out.writeInt(message.getXid().intValue());\r
+ ByteBufUtils.writeOFHeader(instance, message, out);\r
+ }\r
+\r
+ @Override\r
+ public int computeLength() {\r
+ return MESSAGE_LENGTH;\r
+ }\r
+\r
+ @Override\r
+ public byte getMessageType() {\r
+ return MESSAGE_TYPE;\r
}\r
\r
}\r
\r
import io.netty.buffer.ByteBuf;\r
\r
-import org.opendaylight.openflowjava.protocol.impl.core.OFFrameDecoder;\r
import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput;\r
\r
/**\r
\r
/** Code type of EchoReply message */\r
public static final byte MESSAGE_TYPE = 3;\r
+ private static final int MESSAGE_LENGTH = 8;\r
private static EchoReplyInputMessageFactory instance;\r
\r
private EchoReplyInputMessageFactory() {\r
@Override\r
public void messageToBuffer(short version, ByteBuf out,\r
EchoReplyInput message) {\r
- out.writeByte(message.getVersion());\r
- out.writeByte(MESSAGE_TYPE);\r
- out.writeShort(OFFrameDecoder.LENGTH_OF_HEADER);\r
- out.writeInt(message.getXid().intValue());\r
+ ByteBufUtils.writeOFHeader(instance, message, out);\r
+ }\r
+\r
+ @Override\r
+ public int computeLength() {\r
+ return MESSAGE_LENGTH;\r
+ }\r
+\r
+ @Override\r
+ public byte getMessageType() {\r
+ return MESSAGE_TYPE;\r
}\r
}\r
\r
import io.netty.buffer.ByteBuf;\r
\r
-import org.opendaylight.openflowjava.protocol.impl.core.OFFrameDecoder;\r
import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput;\r
\r
/**\r
\r
/** Code type of Experimenter message */\r
public static final byte MESSAGE_TYPE = 4;\r
+ private static final int MESSAGE_LENGTH = 16;\r
private static ExperimenterInputMessageFactory instance;\r
\r
private ExperimenterInputMessageFactory() {\r
@Override\r
public void messageToBuffer(short version, ByteBuf out,\r
ExperimenterInput message) {\r
- out.writeByte(message.getVersion());\r
- out.writeByte(MESSAGE_TYPE);\r
- out.writeShort(OFFrameDecoder.LENGTH_OF_HEADER + (Integer.SIZE/Byte.SIZE)*2);\r
- out.writeInt(message.getXid().intValue());\r
+ \r
+ ByteBufUtils.writeOFHeader(instance, message, out);\r
out.writeInt(message.getExperimenter().intValue());\r
out.writeInt(message.getExpType().intValue());\r
}\r
\r
+ @Override\r
+ public int computeLength() {\r
+ return MESSAGE_LENGTH;\r
+ }\r
+\r
+ @Override\r
+ public byte getMessageType() {\r
+ return MESSAGE_TYPE;\r
+ }\r
+\r
}\r
\r
import io.netty.buffer.ByteBuf;\r
\r
-import org.opendaylight.openflowjava.protocol.impl.core.OFFrameDecoder;\r
import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput;\r
\r
/**\r
\r
/** Code type of GetConfigRequest message */\r
public static final byte MESSAGE_TYPE = 7;\r
+ private static final int MESSAGE_LENGTH = 8;\r
private static GetConfigInputMessageFactory instance;\r
\r
private GetConfigInputMessageFactory() {\r
@Override\r
public void messageToBuffer(short version, ByteBuf out,\r
GetConfigInput message) {\r
- out.writeByte(message.getVersion());\r
- out.writeByte(MESSAGE_TYPE);\r
- out.writeShort(OFFrameDecoder.LENGTH_OF_HEADER);\r
- out.writeInt(message.getXid().intValue());\r
- \r
+ ByteBufUtils.writeOFHeader(instance, message, out);\r
+ }\r
+\r
+ @Override\r
+ public int computeLength() {\r
+ return MESSAGE_LENGTH;\r
+ }\r
+\r
+ @Override\r
+ public byte getMessageType() {\r
+ return MESSAGE_TYPE;\r
}\r
\r
}\r
\r
import io.netty.buffer.ByteBuf;\r
\r
-import org.opendaylight.openflowjava.protocol.impl.core.OFFrameDecoder;\r
import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput;\r
\r
/**\r
\r
/** Code type of FeaturesRequest message */\r
public static final byte MESSAGE_TYPE = 5;\r
+ private static final int MESSAGE_LENGTH = 8;\r
private static GetFeaturesInputMessageFactory instance;\r
\r
private GetFeaturesInputMessageFactory() {\r
@Override\r
public void messageToBuffer(short version, ByteBuf out,\r
GetFeaturesInput message) {\r
- out.writeByte(message.getVersion());\r
- out.writeByte(MESSAGE_TYPE);\r
- out.writeShort(OFFrameDecoder.LENGTH_OF_HEADER);\r
- out.writeInt(message.getXid().intValue());\r
+ ByteBufUtils.writeOFHeader(instance, message, out);\r
+ }\r
+\r
+ @Override\r
+ public int computeLength() {\r
+ return MESSAGE_LENGTH;\r
+ }\r
+\r
+ @Override\r
+ public byte getMessageType() {\r
+ return MESSAGE_TYPE;\r
}\r
\r
}\r
--- /dev/null
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput;
+
+/**
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public class GetQueueConfigInputMessageFactory implements OFSerializer<GetQueueConfigInput> {
+
+ private static final byte MESSAGE_TYPE = 22;
+ private static final byte PADDING_IN_GET_QUEUE_CONFIG_MESSAGE = 4;
+ private static final int MESSAGE_LENGTH = 16;
+
+ private static GetQueueConfigInputMessageFactory instance;
+
+
+ private GetQueueConfigInputMessageFactory() {
+ // singleton
+ }
+
+
+ /**
+ * @return singleton factory
+ */
+ public static GetQueueConfigInputMessageFactory getInstance(){
+
+ if(instance == null){
+ instance = new GetQueueConfigInputMessageFactory();
+ }
+
+ return instance;
+ }
+
+ @Override
+ public void messageToBuffer(short version, ByteBuf out, GetQueueConfigInput message){
+ ByteBufUtils.writeOFHeader(instance, message, out);
+ out.writeInt(message.getPort().getValue().intValue());
+ ByteBufUtils.padBuffer(PADDING_IN_GET_QUEUE_CONFIG_MESSAGE, out);
+ }
+
+ @Override
+ public int computeLength(){
+ return MESSAGE_LENGTH;
+ }
+
+ @Override
+ public byte getMessageType() {
+ return MESSAGE_TYPE;
+ }
+}
\r
import io.netty.buffer.ByteBuf;\r
\r
-import org.opendaylight.openflowjava.protocol.impl.core.OFFrameDecoder;\r
import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput;\r
\r
/**\r
\r
/** Code type of Hello message */\r
public static final byte MESSAGE_TYPE = 0;\r
+ private static final int MESSAGE_LENGTH = 8;\r
private static HelloInputMessageFactory instance;\r
\r
private HelloInputMessageFactory() {\r
\r
@Override\r
public void messageToBuffer(short version, ByteBuf out, HelloInput message) {\r
- out.writeByte(message.getVersion());\r
- out.writeByte(MESSAGE_TYPE);\r
- out.writeShort(OFFrameDecoder.LENGTH_OF_HEADER);\r
- out.writeInt(message.getXid().intValue());\r
+ ByteBufUtils.writeOFHeader(instance, message, out);\r
// TODO - fill list of elements into ByteBuf, check length too\r
}\r
+\r
+ @Override\r
+ public int computeLength() {\r
+ return MESSAGE_LENGTH;\r
+ }\r
+\r
+ @Override\r
+ public byte getMessageType() {\r
+ return MESSAGE_TYPE;\r
+ }\r
\r
}\r
\r
import io.netty.buffer.ByteBuf;\r
\r
-import org.opendaylight.openflowjava.protocol.impl.core.OFFrameDecoder;\r
import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;\r
\r
/** Code type of PacketOut message */\r
public static final byte MESSAGE_TYPE = 13;\r
+ private static final int MESSAGE_LENGTH = 8;\r
private static final byte PADDING_IN_PACKET_OUT_MESSAGE = 6;\r
private static PacketOutInputMessageFactory instance;\r
\r
@Override\r
public void messageToBuffer(short version, ByteBuf out,\r
PacketOutInput message) {\r
- out.writeByte(message.getVersion());\r
- out.writeByte(MESSAGE_TYPE);\r
- out.writeShort(OFFrameDecoder.LENGTH_OF_HEADER);\r
- out.writeInt(message.getXid().intValue());\r
+ ByteBufUtils.writeOFHeader(instance, message, out);\r
out.writeInt(message.getBufferId().intValue());\r
out.writeInt(message.getInPort().getValue().intValue());\r
// TODO - finish implementation after Action serialization is done\r
\r
}\r
\r
+ @Override\r
+ public int computeLength() {\r
+ return MESSAGE_LENGTH;\r
+ }\r
+\r
+ @Override\r
+ public byte getMessageType() {\r
+ return MESSAGE_TYPE;\r
+ }\r
+\r
}\r
\r
import io.netty.buffer.ByteBuf;\r
\r
-import org.opendaylight.openflowjava.protocol.impl.core.OFFrameDecoder;\r
import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput;\r
\r
/** Code type of RoleRequest message */\r
public static final byte MESSAGE_TYPE = 24;\r
+ private static final int MESSAGE_LENGTH = 8;\r
private static final byte PADDING_IN_ROLE_REQUEST_MESSAGE = 4;\r
private static RoleRequestInputMessageFactory instance;\r
\r
@Override\r
public void messageToBuffer(short version, ByteBuf out,\r
RoleRequestInput message) {\r
- out.writeByte(message.getVersion());\r
- out.writeByte(MESSAGE_TYPE);\r
- out.writeShort(OFFrameDecoder.LENGTH_OF_HEADER);\r
- out.writeInt(message.getXid().intValue());\r
+ ByteBufUtils.writeOFHeader(instance, message, out);\r
out.writeInt(message.getRole().getIntValue());\r
ByteBufUtils.padBuffer(PADDING_IN_ROLE_REQUEST_MESSAGE, out);\r
out.writeLong(message.getGenerationId().longValue());\r
}\r
\r
+ @Override\r
+ public int computeLength() {\r
+ return MESSAGE_LENGTH;\r
+ }\r
+\r
+ @Override\r
+ public byte getMessageType() {\r
+ return MESSAGE_TYPE;\r
+ }\r
+\r
}\r
\r
import io.netty.buffer.ByteBuf;\r
\r
-import org.opendaylight.openflowjava.protocol.impl.core.OFFrameDecoder;\r
import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput;\r
\r
/**\r
\r
/** Code type of SetConfig message */\r
public static final byte MESSAGE_TYPE = 9;\r
+ private static final int MESSAGE_LENGTH = 8;\r
private static SetConfigMessageFactory instance;\r
\r
private SetConfigMessageFactory() {\r
@Override\r
public void messageToBuffer(short version, ByteBuf out,\r
SetConfigInput message) {\r
- out.writeByte(message.getVersion());\r
- out.writeByte(MESSAGE_TYPE);\r
- out.writeShort(OFFrameDecoder.LENGTH_OF_HEADER);\r
- out.writeInt(message.getXid().intValue());\r
+ ByteBufUtils.writeOFHeader(instance, message, out);\r
// TODO - finish implementation after enums provide needed funcionality\r
out.writeShort(message.getFlags().getIntValue());\r
out.writeShort(message.getMissSendLen());\r
}\r
\r
+ @Override\r
+ public int computeLength() {\r
+ return MESSAGE_LENGTH;\r
+ }\r
+\r
+ @Override\r
+ public byte getMessageType() {\r
+ return MESSAGE_TYPE;\r
+ }\r
+\r
}\r
--- /dev/null
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput;
+
+/**
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public class TableModInputMessageFactory implements OFSerializer<TableModInput> {
+
+ private static final byte MESSAGE_TYPE = 17;
+ private static final byte PADDING_IN_TABLE_MOD_MESSAGE = 3;
+ private static final int MESSAGE_LENGTH = 16;
+ private static TableModInputMessageFactory instance;
+
+ private TableModInputMessageFactory() {
+ // just singleton
+ }
+
+ /**
+ * @return singleton factory
+ */
+ public static TableModInputMessageFactory getInstance() {
+ if(instance == null){
+ instance = new TableModInputMessageFactory();
+ }
+ return instance;
+ }
+
+ @Override
+ public void messageToBuffer(short version, ByteBuf out, TableModInput message) {
+
+ ByteBufUtils.writeOFHeader(instance, message, out);
+ out.writeByte(message.getTableId().getValue().byteValue());
+ ByteBufUtils.padBuffer(PADDING_IN_TABLE_MOD_MESSAGE, out);
+ out.writeInt(createConfigBitmask(message.getConfig()));
+ }
+
+ @Override
+ public int computeLength() {
+ return MESSAGE_LENGTH;
+ }
+
+ @Override
+ public byte getMessageType() {
+ return MESSAGE_TYPE;
+ }
+
+ /**
+ * @param config
+ * @return port config bitmask
+ */
+ private static int createConfigBitmask(PortConfig config) {
+ int configBitmask = 0;
+ Map<Integer, Boolean> portConfigMap = new HashMap<>();
+ portConfigMap.put(0, config.isPortDown());
+ portConfigMap.put(2, config.isNoRecv());
+ portConfigMap.put(5, config.isNoFwd());
+ portConfigMap.put(6, config.isNoPacketIn());
+
+ configBitmask = ByteBufUtils.fillBitMaskFromMap(portConfigMap);
+ return configBitmask;
+ }
+}
import io.netty.buffer.ByteBuf;\r
import io.netty.buffer.UnpooledByteBufAllocator;\r
\r
+import java.util.Map;\r
+import java.util.Map.Entry;\r
+\r
+import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;\r
+\r
/** Class for common operations on ByteBuf\r
*\r
* @author michal.polkorab\r
out.writeByte(0);\r
}\r
}\r
+ \r
+ /**\r
+ * Create standard OF header\r
+ * @param factory serialization factory \r
+ * @param message POJO\r
+ * @param out writing buffer\r
+ */\r
+ public static void writeOFHeader(OFSerializer<?> factory, OfHeader message, ByteBuf out) { \r
+ out.writeByte(message.getVersion());\r
+ out.writeByte(factory.getMessageType());\r
+ out.writeShort(factory.computeLength());\r
+ out.writeInt(message.getXid().intValue());\r
+\r
+ }\r
+\r
+ /**\r
+ * Fills the bitmask from boolean map where key is bit position\r
+ * @param booleanMap bit to boolean mapping\r
+ * @return bit mask\r
+ */\r
+ public static int fillBitMaskFromMap(Map<Integer, Boolean> booleanMap) {\r
+ int bitmask = 0;\r
+ \r
+ for (Entry<Integer, Boolean> iterator : booleanMap.entrySet()) {\r
+ if (iterator.getValue() != null && iterator.getValue().booleanValue()) {\r
+ bitmask |= 1 << iterator.getKey();\r
+ }\r
+ }\r
+ return bitmask;\r
+ }\r
}\r
--- /dev/null
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Comparator;\r
+import java.util.List;\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.util.BufferHelper;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperty;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.packet.queue.Properties;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.packet.queue.PropertiesBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.QueuesBuilder;\r
+\r
+import com.google.common.collect.ComparisonChain;\r
+\r
+/**\r
+ * @author timotej.kubas\r
+ * @author michal.polkorab\r
+ */\r
+public class QueueGetConfigReplyMessageFactoryTest {\r
+\r
+ @Test\r
+ public void test(){\r
+ ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 02 00 00 00 00 00 00");\r
+ GetQueueConfigOutput builtByFactory = BufferHelper.decodeV13(QueueGetConfigReplyMessageFactory.getInstance(), bb);\r
+ BufferHelper.checkHeaderV13(builtByFactory);\r
+ Assert.assertTrue("Wrong port",66051L == builtByFactory.getPort().getValue());\r
+ Assert.assertTrue("Wrong queues", true == compareLists(builtByFactory.getQueues(), createQueuesList()));\r
+ }\r
+ \r
+ public List<Queues> createQueuesList(){\r
+ final byte PADDING_IN_PACKET_QUEUE_HEADER = 6;\r
+ List<Queues> queuesList = new ArrayList<Queues>();\r
+ QueuesBuilder qb = new QueuesBuilder();\r
+ qb.setQueueId(new QueueId((long) 1));\r
+ qb.setPort(new PortNumber((long) 1));\r
+ qb.setProperties(createPropertiesList());\r
+ queuesList.add(qb.build());\r
+ \r
+ return queuesList;\r
+ }\r
+ \r
+ public List<Properties> createPropertiesList(){\r
+ final byte PADDING_IN_QUEUE_PROPERTY_HEADER = 4;\r
+ List<Properties> propertiesList = new ArrayList<Properties>();\r
+ PropertiesBuilder pb = new PropertiesBuilder();\r
+ pb.setProperty(QueueProperty.values()[2]);\r
+ propertiesList.add(pb.build());\r
+ \r
+ return propertiesList;\r
+ }\r
+ \r
+ public boolean compareLists(List<Queues> originalList, List<Queues> testList){\r
+ boolean decision = false;\r
+ int originalListLength = originalList.size();\r
+ int testListLength = testList.size();\r
+ \r
+ for(int i=0; i<originalListLength; i++){\r
+ if(originalList.get(i).getPort().equals(testList.get(i).getPort())) {\r
+ decision = true;\r
+ } else {\r
+ decision = false;\r
+ break;\r
+ }\r
+ if(originalList.get(i).getQueueId().equals(testList.get(i).getQueueId())) {\r
+ decision = true;\r
+ } else {\r
+ decision = false;\r
+ break;\r
+ }\r
+ if(originalList.get(i).getProperties().get(0).getProperty().equals(\r
+ testList.get(i).getProperties().get(0).getProperty())) {\r
+ decision = true;\r
+ } else {\r
+ decision = false;\r
+ break;\r
+ }\r
+ }\r
+ return decision;\r
+ }\r
+}\r
--- /dev/null
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import static org.junit.Assert.*;
+import junit.framework.Assert;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInputBuilder;
+
+/**
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public class GetQueueConfigInputMessageFactoryTest {
+
+ private static final byte GET_QUEUE_CONFIG_INPUT_MESSAGE_CODE_TYPE = 22;
+ private static final byte PADDING_IN_QUEUE_CONFIG_INPUT_MESSAGE = 4;
+
+ @Test
+ public void testWithElements() throws Exception {
+ GetQueueConfigInputBuilder builder = new GetQueueConfigInputBuilder();
+ BufferHelper.setupHeader(builder);
+ builder.setPort(new PortNumber(0x00010203L));
+ GetQueueConfigInput message = builder.build();
+
+ ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+ GetQueueConfigInputMessageFactory factory = GetQueueConfigInputMessageFactory.getInstance();
+ factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
+
+ BufferHelper.checkHeaderV13(out, GET_QUEUE_CONFIG_INPUT_MESSAGE_CODE_TYPE, 16);
+ Assert.assertEquals("Wrong port", 0x00010203, out.readUnsignedInt());
+ out.skipBytes(PADDING_IN_QUEUE_CONFIG_INPUT_MESSAGE);
+ }
+
+}
--- /dev/null
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import junit.framework.Assert;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInputBuilder;
+
+/**
+ * @author timotej.kubas
+ * @author michal.polkorab
+ */
+public class TableModInputMessageFactoryTest {
+
+ private static final byte MESSAGE_TYPE = 17;
+ private static final byte PADDING_IN_TABLE_MOD_MESSAGE = 3;
+
+ @Test
+ public void testTableModInput() throws Exception {
+ TableModInputBuilder builder = new TableModInputBuilder();
+ BufferHelper.setupHeader(builder);
+ builder.setTableId(new TableId(9L));
+ builder.setConfig(new PortConfig(true, false, true, false));
+ TableModInput message = builder.build();
+
+ ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+ TableModInputMessageFactory factory = TableModInputMessageFactory.getInstance();
+ factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
+
+ BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, 16);
+ Assert.assertEquals("Wrong TableID", 0x09, out.readByte());
+ out.skipBytes(PADDING_IN_TABLE_MOD_MESSAGE);
+ Assert.assertEquals("Wrong PortConfig", 33, out.readInt());
+ }
+}