X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-compability%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fcompability%2FTestFromSalConversionsUtils.java;h=e6d05553ef7e7fb1e748878cb8448bc284240fbb;hp=aa3950db45f318eec5a88767bcbf66f9e9ca4233;hb=4f623c74a703a31e787387b536981dcb344ca4f9;hpb=8cf4238d55b80059f7835c6cd377198b79d34b75 diff --git a/opendaylight/md-sal/sal-compability/src/test/java/org/opendaylight/controller/sal/compability/TestFromSalConversionsUtils.java b/opendaylight/md-sal/sal-compability/src/test/java/org/opendaylight/controller/sal/compability/TestFromSalConversionsUtils.java index aa3950db45..e6d05553ef 100644 --- a/opendaylight/md-sal/sal-compability/src/test/java/org/opendaylight/controller/sal/compability/TestFromSalConversionsUtils.java +++ b/opendaylight/md-sal/sal-compability/src/test/java/org/opendaylight/controller/sal/compability/TestFromSalConversionsUtils.java @@ -12,22 +12,59 @@ import java.util.ArrayList; import java.util.List; import org.junit.Test; -import org.opendaylight.controller.sal.action.*; +import org.opendaylight.controller.sal.action.Action; +import org.opendaylight.controller.sal.action.Flood; +import org.opendaylight.controller.sal.action.FloodAll; +import org.opendaylight.controller.sal.action.HwPath; +import org.opendaylight.controller.sal.action.Loopback; +import org.opendaylight.controller.sal.action.PopVlan; +import org.opendaylight.controller.sal.action.PushVlan; +import org.opendaylight.controller.sal.action.SetDlDst; +import org.opendaylight.controller.sal.action.SetDlSrc; +import org.opendaylight.controller.sal.action.SetDlType; +import org.opendaylight.controller.sal.action.SetNextHop; +import org.opendaylight.controller.sal.action.SetNwDst; +import org.opendaylight.controller.sal.action.SetNwSrc; +import org.opendaylight.controller.sal.action.SetNwTos; +import org.opendaylight.controller.sal.action.SetTpDst; +import org.opendaylight.controller.sal.action.SetTpSrc; +import org.opendaylight.controller.sal.action.SetVlanCfi; +import org.opendaylight.controller.sal.action.SetVlanId; +import org.opendaylight.controller.sal.action.SetVlanPcp; +import org.opendaylight.controller.sal.action.SwPath; import org.opendaylight.controller.sal.flowprogrammer.Flow; import org.opendaylight.controller.sal.match.Match; import org.opendaylight.controller.sal.match.MatchType; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeFlow; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.*; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.address.Address; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.address.address.Ipv4; -import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.Layer3Match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.Layer4Match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.layer._3.match.ArpMatch; -import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.layer._3.match.Ipv4Match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.layer._3.match.Ipv6Match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.layer._4.match.SctpMatch; -import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.layer._4.match.TcpMatch; -import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev130819.match.layer._4.match.UdpMatch; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.FloodAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.FloodAllAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.HwPathAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.LoopbackAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.PopVlanAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.PushVlanAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetDlDstAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetDlSrcAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetDlTypeAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetNextHopAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetNwDstAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetNwSrcAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetNwTosAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetTpDstAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetTpSrcAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetVlanCfiAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetVlanIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetVlanPcpAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SwPathAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.address.Address; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.address.address.Ipv4; +import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match; +import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer4Match; +import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch; +import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match; +import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match; +import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatch; +import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch; +import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch; import com.google.common.net.InetAddresses; @@ -40,33 +77,33 @@ public class TestFromSalConversionsUtils { public void testFromSalConversion() { Flow salFlow = prepareSalFlowCommon(); - NodeFlow odNodeFlow = FromSalConversionsUtils.flowFrom(salFlow); + NodeFlow odNodeFlow = MDFlowMapping.flowAdded(salFlow); checkOdFlow(odNodeFlow); - odNodeFlow = FromSalConversionsUtils.flowFrom(prepareSalMatch(salFlow, MtchType.other)); + odNodeFlow = MDFlowMapping.flowAdded(prepareSalMatch(salFlow, MtchType.other)); checkOdMatch(odNodeFlow.getMatch(), MtchType.other); - odNodeFlow = FromSalConversionsUtils.flowFrom(prepareSalMatch(salFlow, MtchType.arp)); + odNodeFlow = MDFlowMapping.flowAdded(prepareSalMatch(salFlow, MtchType.arp)); checkOdMatch(odNodeFlow.getMatch(), MtchType.arp); - odNodeFlow = FromSalConversionsUtils.flowFrom(prepareSalMatch(salFlow, MtchType.ipv4)); + odNodeFlow = MDFlowMapping.flowAdded(prepareSalMatch(salFlow, MtchType.ipv4)); checkOdMatch(odNodeFlow.getMatch(), MtchType.ipv4); - odNodeFlow = FromSalConversionsUtils.flowFrom(prepareSalMatch(salFlow, MtchType.ipv6)); + odNodeFlow = MDFlowMapping.flowAdded(prepareSalMatch(salFlow, MtchType.ipv6)); checkOdMatch(odNodeFlow.getMatch(), MtchType.ipv6); - odNodeFlow = FromSalConversionsUtils.flowFrom(prepareSalMatch(salFlow, MtchType.sctp)); + odNodeFlow = MDFlowMapping.flowAdded(prepareSalMatch(salFlow, MtchType.sctp)); checkOdMatch(odNodeFlow.getMatch(), MtchType.sctp); - odNodeFlow = FromSalConversionsUtils.flowFrom(prepareSalMatch(salFlow, MtchType.tcp)); + odNodeFlow = MDFlowMapping.flowAdded(prepareSalMatch(salFlow, MtchType.tcp)); checkOdMatch(odNodeFlow.getMatch(), MtchType.tcp); - odNodeFlow = FromSalConversionsUtils.flowFrom(prepareSalMatch(salFlow, MtchType.udp)); + odNodeFlow = MDFlowMapping.flowAdded(prepareSalMatch(salFlow, MtchType.udp)); checkOdMatch(odNodeFlow.getMatch(), MtchType.udp); } - private void checkOdMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.flow.Match match, + private void checkOdMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match match, MtchType mt) { switch (mt) { case arp: @@ -79,7 +116,7 @@ public class TestFromSalConversionsUtils { .getArpSourceTransportAddress().getValue()); assertEquals("Destination IP address is wrong.", "192.168.100.101", ((ArpMatch) layer3Match) .getArpTargetTransportAddress().getValue()); - assertEquals("Source MAC address is wrong.", "aa:bb:cc:dd:ee:ff", ((ArpMatch) layer3Match) + assertEquals("Source MAC address is wrong.", "ff:ee:dd:cc:bb:aa", ((ArpMatch) layer3Match) .getArpSourceHardwareAddress().getAddress().getValue()); assertEquals("Destination MAC address is wrong.", "ff:ee:dd:cc:bb:aa", ((ArpMatch) layer3Match) .getArpTargetHardwareAddress().getAddress().getValue()); @@ -114,9 +151,9 @@ public class TestFromSalConversionsUtils { assertNotNull("Ipv6 wasn't found", ipv6Found); break; case other: - assertEquals("Source MAC address is wrong.", "24:77:03:7C:C5:F1", match.getEthernetMatch() + assertEquals("Source MAC address is wrong.", "ff:ee:dd:cc:bb:aa", match.getEthernetMatch() .getEthernetSource().getAddress().getValue()); - assertEquals("Destinatio MAC address is wrong.", "3C:A9:F4:00:E0:C8", match.getEthernetMatch() + assertEquals("Destinatio MAC address is wrong.", "ff:ee:dd:cc:bb:aa", match.getEthernetMatch() .getEthernetDestination().getAddress().getValue()); assertEquals("Vlan ID is wrong.", (Integer) 0xfff, match.getVlanMatch().getVlanId().getVlanId().getValue()); assertEquals("Vlan ID priority is wrong.", (short) 0x7, (short) match.getVlanMatch().getVlanPcp() @@ -172,11 +209,11 @@ public class TestFromSalConversionsUtils { assertEquals("Iddle timeout is incorrect.", 32766, odNodeFlow.getIdleTimeout().shortValue()); assertEquals("Priority is incorrect.", 32767, odNodeFlow.getPriority().shortValue()); - checkOdActions(odNodeFlow.getAction()); + checkOdActions(ToSalConversionsUtils.getAction(odNodeFlow)); } private void checkOdActions( - List actions) { + List actions) { checkOdAction(actions, FloodAction.class, false); checkOdAction(actions, FloodAllAction.class, false); checkOdAction(actions, HwPathAction.class, false); @@ -199,11 +236,11 @@ public class TestFromSalConversionsUtils { } private void checkOdAction( - List actions, Class cl, + List actions, Class cl, boolean b) { int numOfFoundActions = 0; - for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.flow.Action action : actions) { - org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.Action innerAction = action + for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.list.Action action : actions) { + org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.Action innerAction = action .getAction(); if (cl.isInstance(innerAction)) { numOfFoundActions++; @@ -217,11 +254,11 @@ public class TestFromSalConversionsUtils { assertEquals("Wrong value of vlad ID in PushVlanAction.", (Integer) 4095, ((PushVlanAction) innerAction).getVlanId().getValue()); } else if (innerAction instanceof SetDlDstAction) { - assertEquals("Wrong MAC destination address in SetDlDstAction.", "3C:A9:F4:00:E0:C8", new String( - ((SetDlDstAction) innerAction).getAddress().getValue())); + assertEquals("Wrong MAC destination address in SetDlDstAction.", "ff:ee:dd:cc:bb:aa", + ((SetDlDstAction) innerAction).getAddress().getValue()); } else if (innerAction instanceof SetDlSrcAction) { - assertEquals("Wrong MAC source address in SetDlDstAction.", "24:77:03:7C:C5:F1", new String( - ((SetDlSrcAction) innerAction).getAddress().getValue())); + assertEquals("Wrong MAC source address in SetDlDstAction.", "ff:ee:dd:cc:bb:aa", + ((SetDlSrcAction) innerAction).getAddress().getValue()); } else if (innerAction instanceof SetDlTypeAction) { assertEquals("Wrong data link type in SetDlTypeAction.", (long) 513, (long) ((SetDlTypeAction) innerAction).getDlType().getValue()); @@ -295,8 +332,8 @@ public class TestFromSalConversionsUtils { salMatch.setField(MatchType.DL_TYPE, ETHERNET_ARP); salMatch.setField(MatchType.NW_SRC, InetAddresses.forString("192.168.100.100")); salMatch.setField(MatchType.NW_DST, InetAddresses.forString("192.168.100.101")); - salMatch.setField(MatchType.DL_SRC, "aa:bb:cc:dd:ee:ff".getBytes()); - salMatch.setField(MatchType.DL_DST, "ff:ee:dd:cc:bb:aa".getBytes()); + salMatch.setField(MatchType.DL_SRC, new byte[]{(byte )0xff,(byte )0xee,(byte )0xdd,(byte )0xcc,(byte )0xbb,(byte )0xaa}); + salMatch.setField(MatchType.DL_DST, new byte[]{(byte )0xff,(byte )0xee,(byte )0xdd,(byte )0xcc,(byte )0xbb,(byte )0xaa}); break; case ipv4: salMatch.setField(MatchType.DL_TYPE, (short) 0xffff); @@ -309,8 +346,8 @@ public class TestFromSalConversionsUtils { salMatch.setField(MatchType.NW_DST, InetAddresses.forString("2001:0db8:85a3:0000:0000:8a2e:0370:7336")); break; case other: - salMatch.setField(MatchType.DL_SRC, "24:77:03:7C:C5:F1".getBytes()); - salMatch.setField(MatchType.DL_DST, "3C:A9:F4:00:E0:C8".getBytes()); + salMatch.setField(MatchType.DL_SRC, new byte[]{(byte )0xff,(byte )0xee,(byte )0xdd,(byte )0xcc,(byte )0xbb,(byte )0xaa}); + salMatch.setField(MatchType.DL_DST, new byte[]{(byte )0xff,(byte )0xee,(byte )0xdd,(byte )0xcc,(byte )0xbb,(byte )0xaa}); salMatch.setField(MatchType.DL_VLAN, (short) 0xfff); salMatch.setField(MatchType.DL_VLAN_PR, (byte) 0x7); salMatch.setField(MatchType.NW_TOS, (byte) 0x3f); @@ -348,8 +385,8 @@ public class TestFromSalConversionsUtils { // salActions.add(new Output //TODO: mapping is missing salActions.add(new PopVlan()); salActions.add(new PushVlan(0x8100, 7, 1, 4095)); - salActions.add(new SetDlDst("3C:A9:F4:00:E0:C8".getBytes())); - salActions.add(new SetDlSrc("24:77:03:7C:C5:F1".getBytes())); + salActions.add(new SetDlDst(new byte[]{(byte )0xff,(byte )0xee,(byte )0xdd,(byte )0xcc,(byte )0xbb,(byte )0xaa})); + salActions.add(new SetDlSrc(new byte[]{(byte )0xff,(byte )0xee,(byte )0xdd,(byte )0xcc,(byte )0xbb,(byte )0xaa})); salActions.add(new SetDlType(513)); salActions.add(new SetNextHop(InetAddresses.forString("192.168.100.100"))); salActions.add(new SetNwDst(InetAddresses.forString("192.168.100.101")));