use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.Queue in project openflowplugin by opendaylight.
the class OF10QueueGetConfigReplyMessageFactoryTest method test.
/**
* Testing of {@link OF10QueueGetConfigReplyMessageFactory} for correct
* translation into POJO.
*/
@Test
public void test() {
ByteBuf bb = BufferHelper.buildBuffer("00 01 00 00 00 00 00 00 " + "00 00 00 08 00 10 00 00 00 00 00 08 00 00 00 00 " + "00 00 00 02 00 28 00 00 00 01 00 10 00 00 00 00 00 20 00 00 00 00 00 00 " + "00 01 00 10 00 00 00 00 00 30 00 00 00 00 00 00");
GetQueueConfigOutput builtByFactory = BufferHelper.deserialize(queueFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong port", 1, builtByFactory.getPort().getValue().intValue());
Assert.assertEquals("Wrong queues size", 2, builtByFactory.getQueues().size());
Queues queue1 = builtByFactory.getQueues().get(0);
Queues queue2 = builtByFactory.getQueues().get(1);
Assert.assertEquals("Wrong queueId", 8, queue1.getQueueId().getValue().intValue());
Assert.assertEquals("Wrong queue - # properties", 1, queue1.getQueueProperty().size());
Assert.assertEquals("Wrong queue - wrong property", QueueProperties.OFPQTNONE, queue1.getQueueProperty().get(0).getProperty());
Assert.assertEquals("Wrong queueId", 2, queue2.getQueueId().getValue().intValue());
Assert.assertEquals("Wrong queue - # properties", 2, queue2.getQueueProperty().size());
Assert.assertEquals("Wrong queue - wrong property", QueueProperties.OFPQTMINRATE, queue2.getQueueProperty().get(0).getProperty());
Assert.assertEquals("Wrong queue - wrong property", QueueProperties.OFPQTMINRATE, queue2.getQueueProperty().get(1).getProperty());
RateQueueProperty rate1 = queue2.getQueueProperty().get(0).getAugmentation(RateQueueProperty.class);
RateQueueProperty rate2 = queue2.getQueueProperty().get(1).getAugmentation(RateQueueProperty.class);
Assert.assertEquals("Wrong queue - wrong property rate", 32, rate1.getRate().intValue());
Assert.assertEquals("Wrong queue - wrong property rate", 48, rate2.getRate().intValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.Queue in project openflowplugin by opendaylight.
the class OF10QueueGetConfigReplyMessageFactoryTest method testSerialize.
@Test
public void testSerialize() throws Exception {
GetQueueConfigOutputBuilder builder = new GetQueueConfigOutputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
builder.setPort(new PortNumber(1L));
builder.setQueues(createQueues());
GetQueueConfigOutput message = builder.build();
ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
factory.serialize(message, serializedBuffer);
BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 40);
Assert.assertEquals("Wrong port", message.getPort().getValue().longValue(), serializedBuffer.readShort());
serializedBuffer.skipBytes(6);
Assert.assertEquals("Wrong queue Id", message.getQueues().get(0).getQueueId().getValue().longValue(), serializedBuffer.readInt());
Assert.assertEquals("Wrong length", 24, serializedBuffer.readShort());
serializedBuffer.skipBytes(2);
List<QueueProperty> properties = message.getQueues().get(0).getQueueProperty();
Assert.assertEquals("Wrong property", properties.get(0).getProperty().getIntValue(), serializedBuffer.readShort());
Assert.assertEquals("Wrong property length", 16, serializedBuffer.readShort());
serializedBuffer.skipBytes(4);
RateQueueProperty rateQueueProperty = properties.get(0).getAugmentation(RateQueueProperty.class);
Assert.assertEquals("Wrong rate", rateQueueProperty.getRate().intValue(), serializedBuffer.readShort());
serializedBuffer.skipBytes(6);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.Queue in project openflowplugin by opendaylight.
the class OF10StatsRequestInputFactoryTest method testQueue.
/**
* Testing OF10StatsRequestInputFactory (Queue) for correct serialization.
*/
@Test
public void testQueue() throws Exception {
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
builder.setType(MultipartType.OFPMPQUEUE);
builder.setFlags(new MultipartRequestFlags(false));
MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
MultipartRequestQueueBuilder queueBuilder = new MultipartRequestQueueBuilder();
queueBuilder.setPortNo(15L);
queueBuilder.setQueueId(16L);
caseBuilder.setMultipartRequestQueue(queueBuilder.build());
builder.setMultipartRequestBody(caseBuilder.build());
MultipartRequestInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
multipartFactory.serialize(message, out);
BufferHelper.checkHeaderV10(out, (byte) 16, 20);
Assert.assertEquals("Wrong type", 5, out.readUnsignedShort());
Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
Assert.assertEquals("Wrong port-no", 15, out.readUnsignedShort());
out.skipBytes(2);
Assert.assertEquals("Wrong queue-id", 16, out.readUnsignedInt());
Assert.assertTrue("Unread data", out.readableBytes() == 0);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.Queue in project openflowplugin by opendaylight.
the class OF10ActionsDeserializerTest method test.
/**
* Testing correct deserialization of actions (OF v1.0).
*/
@Test
public void test() {
ByteBuf message = BufferHelper.buildBuffer("00 00 00 08 00 10 20 00 " + "00 01 00 08 10 10 00 00 " + "00 02 00 08 25 00 00 00 " + "00 03 00 08 00 00 00 00 " + "00 04 00 10 01 02 03 04 05 06 00 00 00 00 00 00 " + "00 05 00 10 02 03 04 05 06 07 00 00 00 00 00 00 " + "00 06 00 08 0A 00 00 01 " + "00 07 00 08 0B 00 00 02 " + "00 08 00 08 01 00 00 00 " + "00 09 00 08 00 02 00 00 " + "00 0A 00 08 00 03 00 00 " + "00 0B 00 10 00 04 00 00 00 00 00 00 00 00 00 30");
// skip XID
message.skipBytes(4);
CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF10_VERSION_ID);
List<Action> actions = ListDeserializer.deserializeList(EncodeConstants.OF10_VERSION_ID, message.readableBytes(), message, keyMaker, registry);
Assert.assertEquals("Wrong number of actions", 12, actions.size());
Action action1 = actions.get(0);
Assert.assertTrue("Wrong action type", action1.getActionChoice() instanceof OutputActionCase);
Assert.assertEquals("Wrong port", 16, ((OutputActionCase) action1.getActionChoice()).getOutputAction().getPort().getValue().intValue());
Assert.assertEquals("Wrong max-length", 8192, ((OutputActionCase) action1.getActionChoice()).getOutputAction().getMaxLength().intValue());
Action action2 = actions.get(1);
Assert.assertTrue("Wrong action type", action2.getActionChoice() instanceof SetVlanVidCase);
Assert.assertEquals("Wrong vlan-vid", 4112, ((SetVlanVidCase) action2.getActionChoice()).getSetVlanVidAction().getVlanVid().intValue());
Action action3 = actions.get(2);
Assert.assertTrue("Wrong action type", action3.getActionChoice() instanceof SetVlanPcpCase);
Assert.assertEquals("Wrong vlan-pcp", 37, ((SetVlanPcpCase) action3.getActionChoice()).getSetVlanPcpAction().getVlanPcp().intValue());
Action action4 = actions.get(3);
Assert.assertTrue("Wrong action type", action4.getActionChoice() instanceof StripVlanCase);
Action action5 = actions.get(4);
Assert.assertTrue("Wrong action type", action5.getActionChoice() instanceof SetDlSrcCase);
Assert.assertEquals("Wrong dl-src", "01:02:03:04:05:06", ((SetDlSrcCase) action5.getActionChoice()).getSetDlSrcAction().getDlSrcAddress().getValue());
Action action6 = actions.get(5);
Assert.assertTrue("Wrong action type", action6.getActionChoice() instanceof SetDlDstCase);
Assert.assertEquals("Wrong dl-dst", "02:03:04:05:06:07", ((SetDlDstCase) action6.getActionChoice()).getSetDlDstAction().getDlDstAddress().getValue());
Action action7 = actions.get(6);
Assert.assertTrue("Wrong action type", action7.getActionChoice() instanceof SetNwSrcCase);
Assert.assertEquals("Wrong nw-src", new Ipv4Address("10.0.0.1"), ((SetNwSrcCase) action7.getActionChoice()).getSetNwSrcAction().getIpAddress());
Action action8 = actions.get(7);
Assert.assertTrue("Wrong action type", action8.getActionChoice() instanceof SetNwDstCase);
Assert.assertEquals("Wrong nw-dst", new Ipv4Address("11.0.0.2"), ((SetNwDstCase) action8.getActionChoice()).getSetNwDstAction().getIpAddress());
Action action9 = actions.get(8);
Assert.assertTrue("Wrong action type", action9.getActionChoice() instanceof SetNwTosCase);
Assert.assertEquals("Wrong nw-tos", 1, ((SetNwTosCase) action9.getActionChoice()).getSetNwTosAction().getNwTos().intValue());
Action action10 = actions.get(9);
Assert.assertTrue("Wrong action type", action10.getActionChoice() instanceof SetTpSrcCase);
Assert.assertEquals("Wrong port", 2, ((SetTpSrcCase) action10.getActionChoice()).getSetTpSrcAction().getPort().getValue().intValue());
Action action11 = actions.get(10);
Assert.assertTrue("Wrong action type", action11.getActionChoice() instanceof SetTpDstCase);
Assert.assertEquals("Wrong port", 3, ((SetTpDstCase) action11.getActionChoice()).getSetTpDstAction().getPort().getValue().intValue());
Action action12 = actions.get(11);
Assert.assertTrue("Wrong action type", action12.getActionChoice() instanceof EnqueueCase);
Assert.assertEquals("Wrong port", 4, ((EnqueueCase) action12.getActionChoice()).getEnqueueAction().getPort().getValue().intValue());
Assert.assertEquals("Wrong queue-id", 48, ((EnqueueCase) action12.getActionChoice()).getEnqueueAction().getQueueId().getValue().intValue());
}
Aggregations