-/*\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 java.math.BigInteger;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
-import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;\r
-import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
-import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
-import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;\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.FlowModFlags;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType;\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.MultipartReplyFlowCase;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class MultipartReplyFlowTest {\r
-\r
- private OFDeserializer<MultipartReplyMessage> factory;\r
-\r
- /**\r
- * Initializes deserializer registry and lookups correct deserializer\r
- */\r
- @Before\r
- public void startUp() {\r
- DeserializerRegistry registry = new DeserializerRegistryImpl();\r
- registry.init();\r
- factory = registry.getDeserializer(\r
- new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 19, MultipartReplyMessage.class));\r
- }\r
-\r
- /**\r
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
- */\r
- @Test\r
- public void testEmptyMultipartReplyFlowBody(){\r
- ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 00 00 00");\r
- MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);\r
-\r
- BufferHelper.checkHeaderV13(builtByFactory);\r
- Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue());\r
- Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
- MultipartReplyFlowCase messageCase = (MultipartReplyFlowCase) builtByFactory.getMultipartReplyBody();\r
- MultipartReplyFlow message = messageCase.getMultipartReplyFlow();\r
- Assert.assertEquals("Wrong flow stats size", 0, message.getFlowStats().size());\r
- }\r
-\r
- /**\r
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
- */\r
- @Test\r
- public void testMultipartReplyFlowBody(){\r
- ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 00 00 00 "+\r
- // first flow stat\r
- "00 48 08 00 "+ // length, tableId, padding\r
- "00 00 00 09 "+//durationSec\r
- "00 00 00 07 "+//durationNsec\r
- "00 0C 00 0E 00 0F 00 1F "+//priority, idleTimeout, hardTimeout, flags\r
- "00 00 00 00 "+//pad_02\r
- "FF 01 01 01 01 01 01 01 "+//cookie\r
- "EF 01 01 01 01 01 01 01 "+//packetCount\r
- "7F 01 01 01 01 01 01 01 "+//byteCount\r
- "00 01 00 04 00 00 00 00 "+//empty match\r
- "00 01 00 08 06 00 00 00 "+\r
- "00 01 00 08 06 00 00 00 "+\r
- // second flow stat\r
- "00 48 08 00 "+ // length, tableId, padding\r
- "00 00 00 09 "+//durationSec\r
- "00 00 00 07 "+//durationNsec\r
- "00 0C 00 0E 00 0F 00 00 "+//priority, idleTimeout, hardTimeout, flags\r
- "00 00 00 00 "+//pad_02\r
- "FF 01 01 01 01 01 01 01 "+//cookie\r
- "EF 01 01 01 01 01 01 01 "+//packetCount\r
- "7F 01 01 01 01 01 01 01 "+//byteCount\r
- "00 01 00 04 00 00 00 00 "+//empty match\r
- "00 01 00 08 06 00 00 00 "+\r
- "00 01 00 08 06 00 00 00");\r
- MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);\r
-\r
- BufferHelper.checkHeaderV13(builtByFactory);\r
- Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue());\r
- Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
- MultipartReplyFlowCase messageCase = (MultipartReplyFlowCase) builtByFactory.getMultipartReplyBody();\r
- MultipartReplyFlow message = messageCase.getMultipartReplyFlow();\r
- Assert.assertEquals("Wrong flow stats size", 2, message.getFlowStats().size());\r
- FlowStats flowStats1 = message.getFlowStats().get(0);\r
- Assert.assertEquals("Wrong tableId", 8, flowStats1.getTableId().intValue());\r
- Assert.assertEquals("Wrong durationSec", 9, flowStats1.getDurationSec().intValue());\r
- Assert.assertEquals("Wrong durationNsec", 7, flowStats1.getDurationNsec().intValue());\r
- Assert.assertEquals("Wrong priority", 12, flowStats1.getPriority().intValue());\r
- Assert.assertEquals("Wrong idleTimeOut", 14, flowStats1.getIdleTimeout().intValue());\r
- Assert.assertEquals("Wrong hardTimeOut", 15, flowStats1.getHardTimeout().intValue());\r
- Assert.assertEquals("Wrong flags", new FlowModFlags(true, true, true, true, true), flowStats1.getFlags());\r
- Assert.assertEquals("Wrong cookie", new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01,\r
- 0x01, 0x01, 0x01}), flowStats1.getCookie());\r
- Assert.assertEquals("Wrong packetCount", new BigInteger(1, new byte[]{(byte) 0xEF, 0x01, 0x01, 0x01,\r
- 0x01, 0x01, 0x01, 0x01}), flowStats1.getPacketCount());\r
- Assert.assertEquals("Wrong byteCount", new BigInteger(1, new byte[]{(byte) 0x7F, 0x01, 0x01, 0x01,\r
- 0x01, 0x01, 0x01, 0x01}), flowStats1.getByteCount());\r
- Assert.assertEquals("Wrong match type", OxmMatchType.class, flowStats1.getMatch().getType());\r
- flowStats1 = message.getFlowStats().get(1);\r
- Assert.assertEquals("Wrong tableId", 8, flowStats1.getTableId().intValue());\r
- Assert.assertEquals("Wrong durationSec", 9, flowStats1.getDurationSec().intValue());\r
- Assert.assertEquals("Wrong durationNsec", 7, flowStats1.getDurationNsec().intValue());\r
- Assert.assertEquals("Wrong priority", 12, flowStats1.getPriority().intValue());\r
- Assert.assertEquals("Wrong idleTimeOut", 14, flowStats1.getIdleTimeout().intValue());\r
- Assert.assertEquals("Wrong hardTimeOut", 15, flowStats1.getHardTimeout().intValue());\r
- Assert.assertEquals("Wrong flags", new FlowModFlags(false, false, false, false, false), flowStats1.getFlags());\r
- Assert.assertEquals("Wrong cookie", new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01,\r
- 0x01, 0x01, 0x01}), flowStats1.getCookie());\r
- Assert.assertEquals("Wrong packetCount", new BigInteger(1, new byte[]{(byte) 0xEF, 0x01, 0x01, 0x01,\r
- 0x01, 0x01, 0x01, 0x01}), flowStats1.getPacketCount());\r
- Assert.assertEquals("Wrong byteCount", new BigInteger(1, new byte[]{(byte) 0x7F, 0x01, 0x01, 0x01,\r
- 0x01, 0x01, 0x01, 0x01}), flowStats1.getByteCount());\r
- Assert.assertEquals("Wrong match type", OxmMatchType.class, flowStats1.getMatch().getType());\r
- }\r
+/*
+ * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart;
+
+import io.netty.buffer.ByteBuf;
+
+import java.math.BigInteger;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmMatchType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class MultipartReplyFlowTest {
+
+ private OFDeserializer<MultipartReplyMessage> factory;
+
+ /**
+ * Initializes deserializer registry and lookups correct deserializer
+ */
+ @Before
+ public void startUp() {
+ DeserializerRegistry registry = new DeserializerRegistryImpl();
+ registry.init();
+ factory = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 19, MultipartReplyMessage.class));
+ }
+
+ /**
+ * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+ */
+ @Test
+ public void testEmptyMultipartReplyFlowBody(){
+ ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 00 00 00");
+ MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
+
+ BufferHelper.checkHeaderV13(builtByFactory);
+ Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue());
+ Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
+ MultipartReplyFlowCase messageCase = (MultipartReplyFlowCase) builtByFactory.getMultipartReplyBody();
+ MultipartReplyFlow message = messageCase.getMultipartReplyFlow();
+ Assert.assertEquals("Wrong flow stats size", 0, message.getFlowStats().size());
+ }
+
+ /**
+ * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+ */
+ @Test
+ public void testMultipartReplyFlowBody(){
+ ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 00 00 00 "+
+ // first flow stat
+ "00 48 08 00 "+ // length, tableId, padding
+ "00 00 00 09 "+//durationSec
+ "00 00 00 07 "+//durationNsec
+ "00 0C 00 0E 00 0F 00 1F "+//priority, idleTimeout, hardTimeout, flags
+ "00 00 00 00 "+//pad_02
+ "FF 01 01 01 01 01 01 01 "+//cookie
+ "EF 01 01 01 01 01 01 01 "+//packetCount
+ "7F 01 01 01 01 01 01 01 "+//byteCount
+ "00 01 00 04 00 00 00 00 "+//empty match
+ "00 01 00 08 06 00 00 00 "+
+ "00 01 00 08 06 00 00 00 "+
+ // second flow stat
+ "00 48 08 00 "+ // length, tableId, padding
+ "00 00 00 09 "+//durationSec
+ "00 00 00 07 "+//durationNsec
+ "00 0C 00 0E 00 0F 00 00 "+//priority, idleTimeout, hardTimeout, flags
+ "00 00 00 00 "+//pad_02
+ "FF 01 01 01 01 01 01 01 "+//cookie
+ "EF 01 01 01 01 01 01 01 "+//packetCount
+ "7F 01 01 01 01 01 01 01 "+//byteCount
+ "00 01 00 04 00 00 00 00 "+//empty match
+ "00 01 00 08 06 00 00 00 "+
+ "00 01 00 08 06 00 00 00");
+ MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
+
+ BufferHelper.checkHeaderV13(builtByFactory);
+ Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue());
+ Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
+ MultipartReplyFlowCase messageCase = (MultipartReplyFlowCase) builtByFactory.getMultipartReplyBody();
+ MultipartReplyFlow message = messageCase.getMultipartReplyFlow();
+ Assert.assertEquals("Wrong flow stats size", 2, message.getFlowStats().size());
+ FlowStats flowStats1 = message.getFlowStats().get(0);
+ Assert.assertEquals("Wrong tableId", 8, flowStats1.getTableId().intValue());
+ Assert.assertEquals("Wrong durationSec", 9, flowStats1.getDurationSec().intValue());
+ Assert.assertEquals("Wrong durationNsec", 7, flowStats1.getDurationNsec().intValue());
+ Assert.assertEquals("Wrong priority", 12, flowStats1.getPriority().intValue());
+ Assert.assertEquals("Wrong idleTimeOut", 14, flowStats1.getIdleTimeout().intValue());
+ Assert.assertEquals("Wrong hardTimeOut", 15, flowStats1.getHardTimeout().intValue());
+ Assert.assertEquals("Wrong flags", new FlowModFlags(true, true, true, true, true), flowStats1.getFlags());
+ Assert.assertEquals("Wrong cookie", new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01}), flowStats1.getCookie());
+ Assert.assertEquals("Wrong packetCount", new BigInteger(1, new byte[]{(byte) 0xEF, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01}), flowStats1.getPacketCount());
+ Assert.assertEquals("Wrong byteCount", new BigInteger(1, new byte[]{(byte) 0x7F, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01}), flowStats1.getByteCount());
+ Assert.assertEquals("Wrong match type", OxmMatchType.class, flowStats1.getMatch().getType());
+ flowStats1 = message.getFlowStats().get(1);
+ Assert.assertEquals("Wrong tableId", 8, flowStats1.getTableId().intValue());
+ Assert.assertEquals("Wrong durationSec", 9, flowStats1.getDurationSec().intValue());
+ Assert.assertEquals("Wrong durationNsec", 7, flowStats1.getDurationNsec().intValue());
+ Assert.assertEquals("Wrong priority", 12, flowStats1.getPriority().intValue());
+ Assert.assertEquals("Wrong idleTimeOut", 14, flowStats1.getIdleTimeout().intValue());
+ Assert.assertEquals("Wrong hardTimeOut", 15, flowStats1.getHardTimeout().intValue());
+ Assert.assertEquals("Wrong flags", new FlowModFlags(false, false, false, false, false), flowStats1.getFlags());
+ Assert.assertEquals("Wrong cookie", new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01}), flowStats1.getCookie());
+ Assert.assertEquals("Wrong packetCount", new BigInteger(1, new byte[]{(byte) 0xEF, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01}), flowStats1.getPacketCount());
+ Assert.assertEquals("Wrong byteCount", new BigInteger(1, new byte[]{(byte) 0x7F, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01}), flowStats1.getByteCount());
+ Assert.assertEquals("Wrong match type", OxmMatchType.class, flowStats1.getMatch().getType());
+ }
}
\ No newline at end of file