X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflow-protocol-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowjava%2Fprotocol%2Fimpl%2Futil%2FActionsDeserializerTest.java;h=76fe9888a5ccfe9469eb046022553e5cc798b7d9;hb=272138f7081efbd9796a2a661c92c88727935235;hp=d7d29d842fcd675424f67d48fe445993b437af45;hpb=519a86d1ddcfb8f0fe264174e62e5424e1efba1f;p=openflowjava.git diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java index d7d29d84..76fe9888 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java @@ -18,17 +18,25 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegi import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.deserialization.action.AbstractActionDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecMplsTtlCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecNwTtlCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopMplsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopPbbCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushMplsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushPbbCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPhyPortCase; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -72,74 +80,68 @@ public class ActionsDeserializerTest { + "00 19 00 10 80 00 02 04 00 00 00 0B 00 00 00 00 " + "00 1A 00 08 00 0A 00 00 " + "00 1B 00 08 00 00 00 00"); - + message.skipBytes(4); // skip XID - LOGGER.info("bytes: " + message.readableBytes()); - + LOGGER.info("bytes: {}", message.readableBytes()); + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); List actions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, message.readableBytes(), message, keyMaker, registry); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.Output", actions.get(0).getType().getName()); + Assert.assertTrue("Wrong action type", actions.get(0).getActionChoice() instanceof OutputActionCase); Assert.assertEquals("Wrong action port", 1, - actions.get(0).getAugmentation(PortAction.class).getPort().getValue().intValue()); + ((OutputActionCase) actions.get(0).getActionChoice()).getOutputAction() + .getPort().getValue().intValue()); Assert.assertEquals("Wrong action max-length", 2, - actions.get(0).getAugmentation(MaxLengthAction.class).getMaxLength().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.CopyTtlOut", actions.get(1).getType().getName()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.CopyTtlIn", actions.get(2).getType().getName()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.SetMplsTtl", actions.get(3).getType().getName()); + ((OutputActionCase) actions.get(0).getActionChoice()).getOutputAction() + .getMaxLength().intValue()); + Assert.assertTrue("Wrong action type", actions.get(1).getActionChoice() instanceof CopyTtlOutCase); + Assert.assertTrue("Wrong action type", actions.get(2).getActionChoice() instanceof CopyTtlInCase); + Assert.assertTrue("Wrong action type", actions.get(3).getActionChoice() instanceof SetMplsTtlCase); Assert.assertEquals("Wrong action value", 3, - actions.get(3).getAugmentation(MplsTtlAction.class).getMplsTtl().shortValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.DecMplsTtl", actions.get(4).getType().getName()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.PushVlan", actions.get(5).getType().getName()); + ((SetMplsTtlCase) actions.get(3).getActionChoice()).getSetMplsTtlAction() + .getMplsTtl().shortValue()); + Assert.assertTrue("Wrong action type", actions.get(4).getActionChoice() instanceof DecMplsTtlCase); + Assert.assertTrue("Wrong action type", actions.get(5).getActionChoice() instanceof PushVlanCase); Assert.assertEquals("Wrong action value", 4, - actions.get(5).getAugmentation(EthertypeAction.class).getEthertype().getValue().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.PopVlan", actions.get(6).getType().getName()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.PushMpls", actions.get(7).getType().getName()); + ((PushVlanCase) actions.get(5).getActionChoice()).getPushVlanAction() + .getEthertype().getValue().intValue()); + Assert.assertTrue("Wrong action type", actions.get(6).getActionChoice() instanceof PopVlanCase); + Assert.assertTrue("Wrong action type", actions.get(7).getActionChoice() instanceof PushMplsCase); Assert.assertEquals("Wrong action value", 5, - actions.get(7).getAugmentation(EthertypeAction.class).getEthertype().getValue().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.PopMpls", actions.get(8).getType().getName()); + ((PushMplsCase) actions.get(7).getActionChoice()).getPushMplsAction() + .getEthertype().getValue().intValue()); + Assert.assertTrue("Wrong action type", actions.get(8).getActionChoice() instanceof PopMplsCase); Assert.assertEquals("Wrong action value", 6, - actions.get(8).getAugmentation(EthertypeAction.class).getEthertype().getValue().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.SetQueue", actions.get(9).getType().getName()); + ((PopMplsCase) actions.get(8).getActionChoice()).getPopMplsAction() + .getEthertype().getValue().intValue()); + Assert.assertTrue("Wrong action type", actions.get(9).getActionChoice() instanceof SetQueueCase); Assert.assertEquals("Wrong action value", 7, - actions.get(9).getAugmentation(QueueIdAction.class).getQueueId().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.Group", actions.get(10).getType().getName()); + ((SetQueueCase) actions.get(9).getActionChoice()).getSetQueueAction() + .getQueueId().intValue()); + Assert.assertTrue("Wrong action type", actions.get(10).getActionChoice() instanceof GroupCase); Assert.assertEquals("Wrong action value", 8, - actions.get(10).getAugmentation(GroupIdAction.class).getGroupId().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.SetNwTtl", actions.get(11).getType().getName()); + ((GroupCase) actions.get(10).getActionChoice()).getGroupAction().getGroupId().intValue()); + Assert.assertTrue("Wrong action type", actions.get(11).getActionChoice() instanceof SetNwTtlCase); Assert.assertEquals("Wrong action value", 9, - actions.get(11).getAugmentation(NwTtlAction.class).getNwTtl().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.DecNwTtl", actions.get(12).getType().getName()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.SetField", actions.get(13).getType().getName()); - List entries = actions.get(13).getAugmentation(OxmFieldsAction.class).getMatchEntries(); + ((SetNwTtlCase) actions.get(11).getActionChoice()).getSetNwTtlAction().getNwTtl().intValue()); + Assert.assertTrue("Wrong action type", actions.get(12).getActionChoice() instanceof DecNwTtlCase); + Assert.assertTrue("Wrong action type", actions.get(13).getActionChoice() instanceof SetFieldCase); + List entries = ((SetFieldCase) actions.get(13).getActionChoice()) + .getSetFieldAction().getMatchEntry(); Assert.assertEquals("Wrong number of fields", 1, entries.size()); Assert.assertEquals("Wrong match entry class", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow." - + "oxm.rev130731.OpenflowBasicClass", entries.get(0).getOxmClass().getName()); + + "oxm.rev150225.OpenflowBasicClass", entries.get(0).getOxmClass().getName()); Assert.assertEquals("Wrong match entry field", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow." - + "oxm.rev130731.InPhyPort", entries.get(0).getOxmMatchField().getName()); + + "oxm.rev150225.InPhyPort", entries.get(0).getOxmMatchField().getName()); Assert.assertEquals("Wrong match entry mask", false, entries.get(0).isHasMask()); - Assert.assertEquals("Wrong match entry value", 11, - entries.get(0).getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.PushPbb", actions.get(14).getType().getName()); + Assert.assertEquals("Wrong match entry value", 11, + ((InPhyPortCase) entries.get(0).getMatchEntryValue()).getInPhyPort().getPortNumber() + .getValue().intValue()); + Assert.assertTrue("Wrong action type", actions.get(14).getActionChoice() instanceof PushPbbCase); Assert.assertEquals("Wrong action value", 10, - actions.get(14).getAugmentation(EthertypeAction.class).getEthertype().getValue().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.PopPbb", actions.get(15).getType().getName()); + ((PushPbbCase) actions.get(14).getActionChoice()).getPushPbbAction() + .getEthertype().getValue().intValue()); + Assert.assertTrue("Wrong action type", actions.get(15).getActionChoice() instanceof PopPbbCase); Assert.assertTrue("Unread data in message", message.readableBytes() == 0); } @@ -155,12 +157,10 @@ public class ActionsDeserializerTest { List actions = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID, message.readableBytes(), message, keyMaker, registry); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.Output", actions.get(0).getType().getName()); - Assert.assertEquals("Wrong action port", null, actions.get(0).getAugmentation(PortAction.class)); - Assert.assertEquals("Wrong action max-length", null, actions.get(0).getAugmentation(MaxLengthAction.class)); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.SetField", actions.get(1).getType().getName()); - Assert.assertEquals("Wrong action oxm field", null, actions.get(1).getAugmentation(OxmFieldsAction.class)); + Assert.assertTrue("Wrong action type", actions.get(0).getActionChoice() instanceof OutputActionCase); + Assert.assertNull("Wrong action port", ((OutputActionCase) actions.get(0).getActionChoice()).getOutputAction()); + Assert.assertNull("Wrong action max-length", ((OutputActionCase) actions.get(0).getActionChoice()).getOutputAction()); + Assert.assertTrue("Wrong action type", actions.get(1).getActionChoice() instanceof SetFieldCase); + Assert.assertNull("Wrong action oxm field", ((SetFieldCase) actions.get(1).getActionChoice()).getSetFieldAction()); } }