use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage in project openflowplugin by opendaylight.
the class OF10StatsReplyMessageFactoryTest method testFlow.
/**
* Testing OF10StatsReplyMessageFactory (Flow) for correct deserialization.
*/
@Test
public void testFlow() {
ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 68 01 00 " + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 " + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 " + "00 00 00 02 00 00 00 03 00 04 00 05 00 06 00 00 00 00 00 00 " + "FF 01 02 03 04 05 06 07 FF 01 02 03 04 05 06 07 FF 00 00 00 00 00 00 20 " + "00 00 00 08 00 01 00 02 00 01 00 08 00 03 00 00");
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE().booleanValue());
MultipartReplyFlowCase messageCase = (MultipartReplyFlowCase) builtByFactory.getMultipartReplyBody();
MultipartReplyFlow message = messageCase.getMultipartReplyFlow();
Assert.assertEquals("Wrong tableId", 1, message.getFlowStats().get(0).getTableId().intValue());
Assert.assertEquals("Wrong durationSec", 2, message.getFlowStats().get(0).getDurationSec().intValue());
Assert.assertEquals("Wrong durationNsec", 3, message.getFlowStats().get(0).getDurationNsec().intValue());
Assert.assertEquals("Wrong priority", 4, message.getFlowStats().get(0).getPriority().intValue());
Assert.assertEquals("Wrong idleTimeOut", 5, message.getFlowStats().get(0).getIdleTimeout().intValue());
Assert.assertEquals("Wrong hardTimeOut", 6, message.getFlowStats().get(0).getHardTimeout().intValue());
Assert.assertEquals("Wrong cookie", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }), message.getFlowStats().get(0).getCookie());
Assert.assertEquals("Wrong packetCount", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }), message.getFlowStats().get(0).getPacketCount());
Assert.assertEquals("Wrong byteCount", new BigInteger(1, new byte[] { (byte) 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20 }), message.getFlowStats().get(0).getByteCount());
Action action1 = message.getFlowStats().get(0).getAction().get(0);
Assert.assertTrue("Wrong action type", action1.getActionChoice() instanceof OutputActionCase);
Assert.assertEquals("Wrong action port", 1, ((OutputActionCase) action1.getActionChoice()).getOutputAction().getPort().getValue().intValue());
Assert.assertEquals("Wrong action port", 2, ((OutputActionCase) action1.getActionChoice()).getOutputAction().getMaxLength().intValue());
Action action2 = message.getFlowStats().get(0).getAction().get(1);
Assert.assertTrue("Wrong action type", action2.getActionChoice() instanceof SetVlanVidCase);
Assert.assertEquals("Wrong action port", 3, ((SetVlanVidCase) action2.getActionChoice()).getSetVlanVidAction().getVlanVid().intValue());
Assert.assertTrue("Unread data", bb.readableBytes() == 0);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage in project openflowplugin by opendaylight.
the class OF10StatsReplyMessageFactoryTest method testAggregate.
/**
* Testing OF10StatsReplyMessageFactory (Aggregate) for correct deserialization.
*/
@Test
public void testAggregate() {
ByteBuf bb = BufferHelper.buildBuffer("00 02 00 01 " + "FF 01 02 03 04 05 06 07 FF 00 00 00 00 00 00 20 00 00 00 30 00 00 00 00");
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong type", 0x02, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE().booleanValue());
MultipartReplyAggregateCase messageCase = (MultipartReplyAggregateCase) builtByFactory.getMultipartReplyBody();
MultipartReplyAggregate message = messageCase.getMultipartReplyAggregate();
Assert.assertEquals("Wrong packet-count", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }), message.getPacketCount());
Assert.assertEquals("Wrong byte-count", new BigInteger(1, new byte[] { (byte) 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20 }), message.getByteCount());
Assert.assertEquals("Wrong flow-count", 48, message.getFlowCount().intValue());
Assert.assertTrue("Unread data", bb.readableBytes() == 0);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage in project openflowplugin by opendaylight.
the class OF10StatsReplyMessageFactoryTest method testPort.
/**
* Testing OF10StatsReplyMessageFactory (Port) for correct deserialization.
*/
@Test
public void testPort() {
ByteBuf bb = BufferHelper.buildBuffer("00 04 00 01 " + "00 FF 00 00 00 00 00 00 " + "FF 01 01 01 01 01 01 01 FF 02 02 02 02 02 02 02 " + "FF 02 03 02 03 02 03 02 FF 02 03 02 03 02 03 02 " + "FF 02 03 02 03 02 03 02 FF 02 03 02 03 02 03 02 " + "FF 02 03 02 03 02 03 02 FF 02 03 02 03 02 03 02 " + "FF 02 03 02 03 02 03 02 FF 02 03 02 03 02 03 02 FF 02 03 02 03 02 03 02 " + "FF 02 03 02 03 02 03 02");
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong type", 0x04, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyPortStatsCase messageCase = (MultipartReplyPortStatsCase) builtByFactory.getMultipartReplyBody();
MultipartReplyPortStats message = messageCase.getMultipartReplyPortStats();
Assert.assertEquals("Wrong portNo", 255, message.getPortStats().get(0).getPortNo().intValue());
Assert.assertEquals("Wrong rxPackets", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getPortStats().get(0).getRxPackets());
Assert.assertEquals("Wrong txPackets", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 }), message.getPortStats().get(0).getTxPackets());
Assert.assertEquals("Wrong rxBytes", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02 }), message.getPortStats().get(0).getRxBytes());
Assert.assertEquals("Wrong txBytes", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02 }), message.getPortStats().get(0).getTxBytes());
Assert.assertEquals("Wrong rxDropped", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02 }), message.getPortStats().get(0).getRxDropped());
Assert.assertEquals("Wrong txDropped", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02 }), message.getPortStats().get(0).getTxDropped());
Assert.assertEquals("Wrong rxErrors", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02 }), message.getPortStats().get(0).getRxErrors());
Assert.assertEquals("Wrong txErrors", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02 }), message.getPortStats().get(0).getTxErrors());
Assert.assertEquals("Wrong rxFrameErr", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02 }), message.getPortStats().get(0).getRxFrameErr());
Assert.assertEquals("Wrong rxOverErr", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02 }), message.getPortStats().get(0).getRxOverErr());
Assert.assertEquals("Wrong rxCrcErr", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02 }), message.getPortStats().get(0).getRxCrcErr());
Assert.assertEquals("Wrong collisions", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02 }), message.getPortStats().get(0).getCollisions());
Assert.assertTrue("Unread data", bb.readableBytes() == 0);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage in project openflowplugin by opendaylight.
the class OF10StatsReplyMessageFactoryTest method testQueue.
/**
* Testing OF10StatsReplyMessageFactory (Queue) for correct deserialization.
*/
@Test
public void testQueue() {
ByteBuf bb = BufferHelper.buildBuffer("00 05 00 00 " + "00 FF 00 00 00 00 00 10 " + "FF 02 03 02 03 02 03 02 " + "FF 02 02 02 02 02 02 02 " + "FF 02 03 02 03 02 03 02");
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong type", 0x05, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyQueueCase messageCase = (MultipartReplyQueueCase) builtByFactory.getMultipartReplyBody();
MultipartReplyQueue message = messageCase.getMultipartReplyQueue();
Assert.assertEquals("Wrong portNo", 255, message.getQueueStats().get(0).getPortNo().intValue());
Assert.assertEquals("Wrong queueId", 16, message.getQueueStats().get(0).getQueueId().intValue());
Assert.assertEquals("Wrong txBytes", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02 }), message.getQueueStats().get(0).getTxBytes());
Assert.assertEquals("Wrong txPackets", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 }), message.getQueueStats().get(0).getTxPackets());
Assert.assertEquals("Wrong txErrors", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02 }), message.getQueueStats().get(0).getTxErrors());
Assert.assertTrue("Unread data", bb.readableBytes() == 0);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage in project openflowplugin by opendaylight.
the class MultipartReplyFlowTest method testEmptyMultipartReplyFlowBody.
/**
* 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());
}
Aggregations