X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fcompatibility%2Fsal-compatibility%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fcompatibility%2Ftest%2FTestToSalConversionsUtils.java;h=0157bc0c6415835b8ed52a7add015d707d57a6d8;hp=71f2e9480543feae77bb92275595c29d2119f1c6;hb=5135f2d97f0886632f3ad3b7160a3be54909810f;hpb=31b7a44c89d1057489338492fcf62a64147bea24 diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/TestToSalConversionsUtils.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/TestToSalConversionsUtils.java index 71f2e94805..0157bc0c64 100644 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/TestToSalConversionsUtils.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/TestToSalConversionsUtils.java @@ -22,6 +22,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import junit.framework.Assert; + import org.junit.Test; import org.opendaylight.controller.sal.action.Flood; import org.opendaylight.controller.sal.action.FloodAll; @@ -47,6 +49,7 @@ import org.opendaylight.controller.sal.compatibility.ToSalConversionsUtils; import org.opendaylight.controller.sal.core.ConstructionException; import org.opendaylight.controller.sal.core.Node; import org.opendaylight.controller.sal.core.Node.NodeIDType; +import org.opendaylight.controller.sal.core.NodeConnector; import org.opendaylight.controller.sal.flowprogrammer.Flow; import org.opendaylight.controller.sal.match.MatchType; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; @@ -155,9 +158,9 @@ public class TestToSalConversionsUtils { public void testToSalConversion() throws ConstructionException { FlowAddedBuilder odNodeFlowBuilder = new FlowAddedBuilder(); odNodeFlowBuilder = prepareOdFlowCommon(); - + Node node = new Node(NodeIDType.OPENFLOW,(long)1); - + Flow salFlow = ToSalConversionsUtils.toFlow(prepareOdFlow(odNodeFlowBuilder, MtchType.other), node); checkSalMatch(salFlow.getMatch(), MtchType.other); @@ -182,10 +185,21 @@ public class TestToSalConversionsUtils { checkSalFlow(salFlow); } + /** + * test of {@link ToSalConversionsUtils#fromNodeConnectorRef(Uri, Node)} + * @throws ConstructionException + */ + @Test + public void testFromNodeConnectorRef() throws ConstructionException { + Node node = new Node(NodeIDType.OPENFLOW, 42L); + NodeConnector nodeConnector = ToSalConversionsUtils.fromNodeConnectorRef(new Uri("1"), node); + Assert.assertEquals("OF|1@OF|00:00:00:00:00:00:00:2a", nodeConnector.toString()); + } + private void checkSalMatch(org.opendaylight.controller.sal.match.Match match, MtchType mt) { switch (mt) { case other: - /*assertNotNull("DL_DST isn't equal.", "3C:A9:F4:00:E0:C8", + /*assertNotNull("DL_DST isn't equal.", "3C:A9:F4:00:E0:C8", new String((byte[]) match.getField(MatchType.DL_DST).getValue())); assertEquals("DL_SRC isn't equal.", "24:77:03:7C:C5:F1", new String((byte[]) match.getField(MatchType.DL_SRC).getValue())); @@ -312,7 +326,7 @@ public class TestToSalConversionsUtils { //assertEquals("Wrong value for action SetDlSrc for MAC address.", "24:77:03:7C:C5:F1", new String( // ((SetDlSrc) action).getDlAddress())); } else if (action instanceof SetDlType) { - assertEquals("Wrong value for action SetDlType for.", 513l, ((SetDlType) action).getDlType()); + assertEquals("Wrong value for action SetDlType for.", 513L, ((SetDlType) action).getDlType()); } else if (action instanceof SetNextHop) { InetAddress inetAddress = ((SetNextHop) action).getAddress(); checkIpAddresses(inetAddress, "192.168.100.100", "2001:db8:85a3::8a2e:370:7334"); @@ -431,14 +445,14 @@ public class TestToSalConversionsUtils { odActions.add(new ActionBuilder().setAction(setVlanPcpActionBuilder.build()).build()); odActions.add(new ActionBuilder().setAction(swPathActionBuilder.build()).build()); - + ApplyActionsCase innerInst = new ApplyActionsCaseBuilder().setApplyActions(new ApplyActionsBuilder().setAction(odActions).build()).build(); Instruction applyActions = new InstructionBuilder().setInstruction(innerInst).build(); List instructions = Collections.singletonList(applyActions ); InstructionsBuilder instBuilder = new InstructionsBuilder(); - + instBuilder.setInstruction(instructions); - + return instBuilder.build(); } @@ -492,7 +506,7 @@ public class TestToSalConversionsUtils { private void prepareActionSetNwDst(List odActions) { // test case for IPv4 - + SetNwDstActionBuilder setNwDstActionBuilderIpv4 = new SetNwDstActionBuilder(); setNwDstActionBuilderIpv4.setAddress(prapareIpv4Address("192.168.100.101")); odActions.add(new ActionBuilder().setAction(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilderIpv4.build()).build()).build()); @@ -529,7 +543,7 @@ public class TestToSalConversionsUtils { private void prepareActionSetDlType(SetDlTypeActionCaseBuilder wrapper) { SetDlTypeActionBuilder setDlTypeActionBuilder = new SetDlTypeActionBuilder(); - setDlTypeActionBuilder.setDlType(new EtherType(513l)); + setDlTypeActionBuilder.setDlType(new EtherType(513L)); wrapper.setSetDlTypeAction(setDlTypeActionBuilder.build()); } @@ -674,7 +688,7 @@ public class TestToSalConversionsUtils { private EthernetType prepEthType() { EthernetTypeBuilder ethTypeBuild = new EthernetTypeBuilder(); - ethTypeBuild.setType(new EtherType(0xffffl)); + ethTypeBuild.setType(new EtherType(0xffffL)); return ethTypeBuild.build(); }