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%2FOF10ActionsDeserializerTest.java;h=9da4762951b729247df149d59306c88f7ec03647;hb=6b0b81817d09cb4b42d6c65838dc07cce276e9b4;hp=d2db8e2f8f826bd260b44f8243c03e5f8ad859dd;hpb=7ec08418c1c54142deaa0d3a15726447f86c36a0;p=openflowjava.git diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java index d2db8e2f..9da47629 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java @@ -12,10 +12,12 @@ import io.netty.buffer.ByteBuf; import java.util.List; 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.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction; @@ -23,8 +25,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsList; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.actions.list.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; /** * @author michal.polkorab @@ -32,6 +33,17 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev1 */ public class OF10ActionsDeserializerTest { + private DeserializerRegistry registry; + + /** + * Initializes deserializer registry and lookups correct deserializer + */ + @Before + public void startUp() { + registry = new DeserializerRegistryImpl(); + registry.init(); + } + /** * Testing correct deserialization of actions (OF v1.0) */ @@ -48,78 +60,74 @@ public class OF10ActionsDeserializerTest { + "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 " - + "FF FF 00 08 00 00 12 34"); + + "00 0B 00 10 00 04 00 00 00 00 00 00 00 00 00 30"); message.skipBytes(4); // skip XID - List actions = OF10ActionsDeserializer.createActionsList(message); - Assert.assertEquals("Wrong number of actions", 13, actions.size()); - Action action1 = actions.get(0).getAction(); + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF10_VERSION_ID); + List 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.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + ".openflow.common.action.rev130731.Output", action1.getType().getName()); Assert.assertEquals("Wrong port", 16, action1.getAugmentation(PortAction.class).getPort().getValue().intValue()); Assert.assertEquals("Wrong max-length", 8192, action1.getAugmentation(MaxLengthAction.class).getMaxLength().intValue()); - Action action2 = actions.get(1).getAction(); + Action action2 = actions.get(1); Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + ".openflow.common.action.rev130731.SetVlanVid", action2.getType().getName()); Assert.assertEquals("Wrong vlan-vid", 4112, action2.getAugmentation(VlanVidAction.class).getVlanVid().intValue()); - Action action3 = actions.get(2).getAction(); + Action action3 = actions.get(2); Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + ".openflow.common.action.rev130731.SetVlanPcp", action3.getType().getName()); Assert.assertEquals("Wrong vlan-pcp", 37, action3.getAugmentation(VlanPcpAction.class).getVlanPcp().intValue()); - Action action4 = actions.get(3).getAction(); + Action action4 = actions.get(3); Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + ".openflow.common.action.rev130731.StripVlan", action4.getType().getName()); - Action action5 = actions.get(4).getAction(); + Action action5 = actions.get(4); Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + ".openflow.common.action.rev130731.SetDlSrc", action5.getType().getName()); Assert.assertArrayEquals("Wrong dl-src", ByteBufUtils.macAddressToBytes("01:02:03:04:05:06"), ByteBufUtils.macAddressToBytes(action5.getAugmentation(DlAddressAction.class).getDlAddress().getValue())); - Action action6 = actions.get(5).getAction(); + Action action6 = actions.get(5); Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + ".openflow.common.action.rev130731.SetDlDst", action6.getType().getName()); Assert.assertArrayEquals("Wrong dl-dst", ByteBufUtils.macAddressToBytes("02:03:04:05:06:07"), ByteBufUtils.macAddressToBytes(action6.getAugmentation(DlAddressAction.class).getDlAddress().getValue())); - Action action7 = actions.get(6).getAction(); + Action action7 = actions.get(6); Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + ".openflow.common.action.rev130731.SetNwSrc", action7.getType().getName()); Assert.assertEquals("Wrong nw-src", new Ipv4Address("10.0.0.1"), action7.getAugmentation(IpAddressAction.class).getIpAddress()); - Action action8 = actions.get(7).getAction(); + Action action8 = actions.get(7); Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + ".openflow.common.action.rev130731.SetNwDst", action8.getType().getName()); Assert.assertEquals("Wrong nw-dst", new Ipv4Address("11.0.0.2"), action8.getAugmentation(IpAddressAction.class).getIpAddress()); - Action action9 = actions.get(8).getAction(); + Action action9 = actions.get(8); Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + ".openflow.common.action.rev130731.SetNwTos", action9.getType().getName()); Assert.assertEquals("Wrong nw-tos", 1, action9.getAugmentation(NwTosAction.class).getNwTos().intValue()); - Action action10 = actions.get(9).getAction(); + Action action10 = actions.get(9); Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + ".openflow.common.action.rev130731.SetTpSrc", action10.getType().getName()); Assert.assertEquals("Wrong port", 2, action10.getAugmentation(PortAction.class) .getPort().getValue().intValue()); - Action action11 = actions.get(10).getAction(); + Action action11 = actions.get(10); Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + ".openflow.common.action.rev130731.SetTpDst", action11.getType().getName()); Assert.assertEquals("Wrong port", 3, action11.getAugmentation(PortAction.class) .getPort().getValue().intValue()); - Action action12 = actions.get(11).getAction(); + Action action12 = actions.get(11); Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + ".openflow.common.action.rev130731.Enqueue", action12.getType().getName()); Assert.assertEquals("Wrong port", 4, action12.getAugmentation(PortAction.class) .getPort().getValue().intValue()); Assert.assertEquals("Wrong queue-id", 48, action12.getAugmentation(QueueIdAction.class).getQueueId().intValue()); - Action action13 = actions.get(12).getAction(); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.Experimenter", action13.getType().getName()); - Assert.assertEquals("Wrong port", 4660, action13.getAugmentation(ExperimenterAction.class) - .getExperimenter().intValue()); } }