X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fsal%2Fapi%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Faction%2FActionTest.java;h=14f0d83ff670d7343b1b67e59796cdec44223cf9;hp=954e07b16a80b31fb8345c1daffe54c6ed4ef055;hb=e38e37d94000a573ccfec627f490d1847ae6304d;hpb=b7a34b47e39a9fe25617c9e536817858e58b2558 diff --git a/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/action/ActionTest.java b/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/action/ActionTest.java index 954e07b16a..14f0d83ff6 100644 --- a/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/action/ActionTest.java +++ b/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/action/ActionTest.java @@ -1,12 +1,10 @@ - /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013-2014 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.sal.action; import org.opendaylight.controller.sal.core.ConstructionException; @@ -17,26 +15,16 @@ import java.util.List; import org.junit.Test; import org.junit.Assert; -import org.opendaylight.controller.sal.action.Action; -import org.opendaylight.controller.sal.action.Controller; -import org.opendaylight.controller.sal.action.Output; -import org.opendaylight.controller.sal.action.PopVlan; -import org.opendaylight.controller.sal.action.PushVlan; -import org.opendaylight.controller.sal.action.SetDlSrc; -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.core.Node; import org.opendaylight.controller.sal.core.NodeConnector; import org.opendaylight.controller.sal.utils.EtherTypes; import org.opendaylight.controller.sal.utils.NodeConnectorCreator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ActionTest { + protected static final Logger logger = LoggerFactory + .getLogger(ActionTest.class); @Test public void tesActionCreationValidation() { Action action = new PopVlan(); @@ -99,6 +87,24 @@ public class ActionTest { action = new PushVlan(EtherTypes.QINQ, 0x4, -1, 2000); Assert.assertFalse(action.isValid()); + + // OF 1.3 PUSH_VLAN test. + for (EtherTypes tag: EtherTypes.values()) { + int t = tag.intValue(); + boolean valid = + (tag == EtherTypes.VLANTAGGED || tag == EtherTypes.QINQ); + PushVlan pv = new PushVlan(tag); + Assert.assertEquals(valid, pv.isValid()); + if (valid) { + Assert.assertEquals(t, pv.getTag()); + } + + pv = new PushVlan(t); + Assert.assertEquals(valid, pv.isValid()); + if (valid) { + Assert.assertEquals(t, pv.getTag()); + } + } } @Test @@ -140,7 +146,7 @@ public class ActionTest { try { ip = InetAddress.getByName("171.71.9.52"); } catch (UnknownHostException e) { - e.printStackTrace(); + logger.error("",e); } action = new SetNwSrc(ip); @@ -152,7 +158,7 @@ public class ActionTest { try { ip = InetAddress.getByName("2001:420:281:1003:f2de:f1ff:fe71:728d"); } catch (UnknownHostException e) { - e.printStackTrace(); + logger.error("", e); } action = new SetNwSrc(ip); Assert.assertTrue(action.isValid()); @@ -168,7 +174,7 @@ public class ActionTest { action = new SetNwTos(0x40); Assert.assertFalse(action.isValid()); - + action = new SetNwTos(0xff1); Assert.assertFalse(action.isValid()); @@ -186,8 +192,11 @@ public class ActionTest { action = new SetTpDst(65535); Assert.assertTrue(action.isValid()); + action = new SetTpSrc(0); + Assert.assertTrue(action.isValid()); + action = new SetTpDst(0); - Assert.assertFalse(action.isValid()); + Assert.assertTrue(action.isValid()); action = new SetTpSrc(-1); Assert.assertFalse(action.isValid()); @@ -202,6 +211,29 @@ public class ActionTest { Assert.assertFalse(action.isValid()); } + @Test + public void testNextHopActionCreation() { + SetNextHop action = null; + + InetAddress ip = null; + try { + ip = InetAddress.getByName("171.71.9.52"); + } catch (UnknownHostException e) { + logger.error("", e); + } + + action = new SetNextHop(ip); + Assert.assertTrue(action.getAddress().equals(ip)); + + try { + ip = InetAddress.getByName("2001:420:281:1003:f2de:f1ff:fe71:728d"); + } catch (UnknownHostException e) { + logger.error("", e); + } + action = new SetNextHop(ip); + Assert.assertTrue(action.getAddress().equals(ip)); + } + @Test public void testActionList() { List actions = new ArrayList(); @@ -222,7 +254,7 @@ public class ActionTest { try { ip = InetAddress.getByName("1.1.1.1"); } catch (UnknownHostException e) { - e.printStackTrace(); + logger.error("",e); } actions.add(new SetDlSrc(mac));