-/*\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.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState;\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.MultipartReplyPortDescCase;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDesc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.Ports;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class MultipartReplyPortDescTest {\r
-\r
- private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory();\r
-\r
- /**\r
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
- */\r
- @Test\r
- public void testEmptyMultipartReplyPortDesc() {\r
- ByteBuf bb = BufferHelper.buildBuffer("00 0D 00 00 00 00 00 00");\r
- MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);\r
-\r
- BufferHelper.checkHeaderV13(builtByFactory);\r
- Assert.assertEquals("Wrong type", 13, builtByFactory.getType().getIntValue());\r
- Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE());\r
- MultipartReplyPortDescCase messageCase = (MultipartReplyPortDescCase) builtByFactory.getMultipartReplyBody();\r
- MultipartReplyPortDesc message = messageCase.getMultipartReplyPortDesc();\r
- Assert.assertEquals("Wrong table features size", 0, message.getPorts().size());\r
- }\r
-\r
- /**\r
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
- */\r
- @Test\r
- public void testMultipartReplyPortDesc() {\r
- ByteBuf bb = BufferHelper.buildBuffer("00 0D 00 00 00 00 00 00 " +\r
- // first port desc\r
- "00 01 02 03 00 00 00 00 " + // portNo, padding\r
- "08 00 27 00 B0 EB 00 00 " + // mac address, padding\r
- "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 " + // name\r
- "00 00 00 65 " + //port config\r
- "00 00 00 07 " + //port state\r
- "00 00 00 81 " + //current features\r
- "00 00 FF FF " + //advertised features\r
- "00 00 C1 89 " + //supported features\r
- "00 00 C5 8D " + //peer features\r
- "00 00 00 81 " + //curr speed\r
- "00 00 00 80 " + //max speed\r
- // second port desc\r
- "00 00 00 01 00 00 00 00 " + // portNo, padding\r
- "08 00 27 00 B0 EB 00 00 " + // mac address, padding\r
- "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 " + // name\r
- "00 00 00 00 " + //port config\r
- "00 00 00 00 " + //port state\r
- "00 00 00 00 " + //current features\r
- "00 00 00 00 " + //advertised features\r
- "00 00 00 00 " + //supported features\r
- "00 00 00 00 " + //peer features\r
- "00 00 00 05 " + //curr speed\r
- "00 00 00 06" //max speed\r
- );\r
- MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);\r
-\r
- BufferHelper.checkHeaderV13(builtByFactory);\r
- Assert.assertEquals("Wrong type", 13, builtByFactory.getType().getIntValue());\r
- Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE());\r
- MultipartReplyPortDescCase messageCase = (MultipartReplyPortDescCase) builtByFactory.getMultipartReplyBody();\r
- MultipartReplyPortDesc message = messageCase.getMultipartReplyPortDesc();\r
- Assert.assertEquals("Wrong port desc size", 2, message.getPorts().size());\r
- Ports port = message.getPorts().get(0);\r
- Assert.assertEquals("Wrong portNo", 66051L, port.getPortNo().longValue());\r
- Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:B0:EB"), port.getHwAddr());\r
- Assert.assertEquals("Wrong portName", "Opendaylight", port.getName());\r
- Assert.assertEquals("Wrong portConfig", new PortConfig(true, true, true, true), port.getConfig());\r
- Assert.assertEquals("Wrong portState", new PortState(true, true, true), port.getState());\r
- Assert.assertEquals("Wrong currentFeatures", new PortFeatures(false, false, false, false, false, true,\r
- false, false, false, true, false, false, false, false, false, false), port.getCurrentFeatures());\r
- Assert.assertEquals("Wrong advertisedFeatures", new PortFeatures(true, true, true, true, true, true,\r
- true, true, true, true, true, true, true, true, true, true), port.getAdvertisedFeatures());\r
- Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(true, true, false, false, false, true,\r
- false, false, false, true, false, false, false, false, true, true), port.getSupportedFeatures());\r
- Assert.assertEquals("Wrong peerFeatures", new PortFeatures(true, true, true, false, false, true, false,\r
- false, false, true, false, false, false, true, true, true), port.getPeerFeatures());\r
- Assert.assertEquals("Wrong currSpeed", 129L, port.getCurrSpeed().longValue());\r
- Assert.assertEquals("Wrong maxSpeed", 128L, port.getMaxSpeed().longValue());\r
- port = message.getPorts().get(1);\r
- Assert.assertEquals("Wrong portNo", 1L, port.getPortNo().longValue());\r
- Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:B0:EB"), port.getHwAddr());\r
- Assert.assertEquals("Wrong portName", "Opendaylight", port.getName());\r
- Assert.assertEquals("Wrong portConfig", new PortConfig(false, false, false, false), port.getConfig());\r
- Assert.assertEquals("Wrong portState", new PortState(false, false, false), port.getState());\r
- Assert.assertEquals("Wrong currentFeatures", new PortFeatures(false, false, false, false, false, false, false,\r
- false, false, false, false, false, false, false, false, false), port.getCurrentFeatures());\r
- Assert.assertEquals("Wrong advertisedFeatures", new PortFeatures(false, false, false, false, false, false, false,\r
- false, false, false, false, false, false, false, false, false), port.getAdvertisedFeatures());\r
- Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(false, false, false, false, false, false, false,\r
- false, false, false, false, false, false, false, false, false), port.getSupportedFeatures());\r
- Assert.assertEquals("Wrong peerFeatures", new PortFeatures(false, false, false, false, false, false, false,\r
- false, false, false, false, false, false, false, false, false), port.getPeerFeatures());\r
- Assert.assertEquals("Wrong currSpeed", 5L, port.getCurrSpeed().longValue());\r
- Assert.assertEquals("Wrong maxSpeed", 6L, port.getMaxSpeed().longValue());\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 org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+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.PortFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState;
+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.MultipartReplyPortDescCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDesc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.Ports;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class MultipartReplyPortDescTest {
+
+ private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory();
+
+ /**
+ * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+ */
+ @Test
+ public void testEmptyMultipartReplyPortDesc() {
+ ByteBuf bb = BufferHelper.buildBuffer("00 0D 00 00 00 00 00 00");
+ MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
+
+ BufferHelper.checkHeaderV13(builtByFactory);
+ Assert.assertEquals("Wrong type", 13, builtByFactory.getType().getIntValue());
+ Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE());
+ MultipartReplyPortDescCase messageCase = (MultipartReplyPortDescCase) builtByFactory.getMultipartReplyBody();
+ MultipartReplyPortDesc message = messageCase.getMultipartReplyPortDesc();
+ Assert.assertEquals("Wrong table features size", 0, message.getPorts().size());
+ }
+
+ /**
+ * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+ */
+ @Test
+ public void testMultipartReplyPortDesc() {
+ ByteBuf bb = BufferHelper.buildBuffer("00 0D 00 00 00 00 00 00 " +
+ // first port desc
+ "00 01 02 03 00 00 00 00 " + // portNo, padding
+ "08 00 27 00 B0 EB 00 00 " + // mac address, padding
+ "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 " + // name
+ "00 00 00 65 " + //port config
+ "00 00 00 07 " + //port state
+ "00 00 00 81 " + //current features
+ "00 00 FF FF " + //advertised features
+ "00 00 C1 89 " + //supported features
+ "00 00 C5 8D " + //peer features
+ "00 00 00 81 " + //curr speed
+ "00 00 00 80 " + //max speed
+ // second port desc
+ "00 00 00 01 00 00 00 00 " + // portNo, padding
+ "08 00 27 00 B0 EB 00 00 " + // mac address, padding
+ "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 " + // name
+ "00 00 00 00 " + //port config
+ "00 00 00 00 " + //port state
+ "00 00 00 00 " + //current features
+ "00 00 00 00 " + //advertised features
+ "00 00 00 00 " + //supported features
+ "00 00 00 00 " + //peer features
+ "00 00 00 05 " + //curr speed
+ "00 00 00 06" //max speed
+ );
+ MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
+
+ BufferHelper.checkHeaderV13(builtByFactory);
+ Assert.assertEquals("Wrong type", 13, builtByFactory.getType().getIntValue());
+ Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE());
+ MultipartReplyPortDescCase messageCase = (MultipartReplyPortDescCase) builtByFactory.getMultipartReplyBody();
+ MultipartReplyPortDesc message = messageCase.getMultipartReplyPortDesc();
+ Assert.assertEquals("Wrong port desc size", 2, message.getPorts().size());
+ Ports port = message.getPorts().get(0);
+ Assert.assertEquals("Wrong portNo", 66051L, port.getPortNo().longValue());
+ Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:B0:EB"), port.getHwAddr());
+ Assert.assertEquals("Wrong portName", "Opendaylight", port.getName());
+ Assert.assertEquals("Wrong portConfig", new PortConfig(true, true, true, true), port.getConfig());
+ Assert.assertEquals("Wrong portState", new PortState(true, true, true), port.getState());
+ Assert.assertEquals("Wrong currentFeatures", new PortFeatures(false, false, false, false, false, true,
+ false, false, false, true, false, false, false, false, false, false), port.getCurrentFeatures());
+ Assert.assertEquals("Wrong advertisedFeatures", new PortFeatures(true, true, true, true, true, true,
+ true, true, true, true, true, true, true, true, true, true), port.getAdvertisedFeatures());
+ Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(true, true, false, false, false, true,
+ false, false, false, true, false, false, false, false, true, true), port.getSupportedFeatures());
+ Assert.assertEquals("Wrong peerFeatures", new PortFeatures(true, true, true, false, false, true, false,
+ false, false, true, false, false, false, true, true, true), port.getPeerFeatures());
+ Assert.assertEquals("Wrong currSpeed", 129L, port.getCurrSpeed().longValue());
+ Assert.assertEquals("Wrong maxSpeed", 128L, port.getMaxSpeed().longValue());
+ port = message.getPorts().get(1);
+ Assert.assertEquals("Wrong portNo", 1L, port.getPortNo().longValue());
+ Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:B0:EB"), port.getHwAddr());
+ Assert.assertEquals("Wrong portName", "Opendaylight", port.getName());
+ Assert.assertEquals("Wrong portConfig", new PortConfig(false, false, false, false), port.getConfig());
+ Assert.assertEquals("Wrong portState", new PortState(false, false, false), port.getState());
+ Assert.assertEquals("Wrong currentFeatures", new PortFeatures(false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false, false), port.getCurrentFeatures());
+ Assert.assertEquals("Wrong advertisedFeatures", new PortFeatures(false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false, false), port.getAdvertisedFeatures());
+ Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false, false), port.getSupportedFeatures());
+ Assert.assertEquals("Wrong peerFeatures", new PortFeatures(false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false, false), port.getPeerFeatures());
+ Assert.assertEquals("Wrong currSpeed", 5L, port.getCurrSpeed().longValue());
+ Assert.assertEquals("Wrong maxSpeed", 6L, port.getMaxSpeed().longValue());
+ }
}
\ No newline at end of file