Sho SHIMIZU | 7226e01 | 2014-08-14 14:21:30 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.newintent; |
| 2 | |
| 3 | import net.onrc.onos.api.flowmanager.FlowId; |
| 4 | import net.onrc.onos.api.flowmanager.FlowLink; |
| 5 | import net.onrc.onos.api.flowmanager.SingleSrcTreeFlow; |
| 6 | import net.onrc.onos.api.flowmanager.Tree; |
| 7 | import net.onrc.onos.api.newintent.IntentId; |
| 8 | import net.onrc.onos.api.newintent.IntentTest; |
| 9 | import net.onrc.onos.core.matchaction.action.OutputAction; |
| 10 | import net.onrc.onos.core.matchaction.match.PacketMatch; |
| 11 | import net.onrc.onos.core.matchaction.match.PacketMatchBuilder; |
| 12 | import net.onrc.onos.core.util.Dpid; |
| 13 | import net.onrc.onos.core.util.Pair; |
| 14 | import net.onrc.onos.core.util.PortNumber; |
| 15 | import net.onrc.onos.core.util.SwitchPort; |
| 16 | |
| 17 | import java.util.Arrays; |
| 18 | import java.util.HashSet; |
| 19 | import java.util.Set; |
| 20 | |
| 21 | /** |
| 22 | * Suites of test of {@link SingleSrcTreeFlowIntent}. |
| 23 | */ |
| 24 | public class SingleSrcTreeFlowIntentTest extends IntentTest { |
| 25 | |
| 26 | private final IntentId intentId1 = new IntentId(1L); |
| 27 | private final IntentId intentId2 = new IntentId(2L); |
Toshio Koide | 515ba84 | 2014-08-20 11:53:37 -0700 | [diff] [blame] | 28 | private final FlowId flowId1 = new FlowId(1L); |
| 29 | private final FlowId flowId2 = new FlowId(2L); |
Sho SHIMIZU | 7226e01 | 2014-08-14 14:21:30 -0700 | [diff] [blame] | 30 | private final Dpid dpid1 = new Dpid(1); |
| 31 | private final Dpid dpid2 = new Dpid(2); |
| 32 | private final Dpid dpid3 = new Dpid(3); |
| 33 | private final PortNumber port1 = PortNumber.uint32(1); |
| 34 | private final PortNumber port2 = PortNumber.uint32(2); |
| 35 | private final PortNumber port3 = PortNumber.uint32(3); |
| 36 | private final OutputAction action1 = new OutputAction(port1); |
| 37 | private final OutputAction action2 = new OutputAction(port2); |
| 38 | private final OutputAction action3 = new OutputAction(port3); |
| 39 | private final PacketMatch match = new PacketMatchBuilder().build(); |
| 40 | |
| 41 | @Override |
| 42 | protected SingleSrcTreeFlowIntent createOne() { |
| 43 | Set<Pair<Dpid, OutputAction>> actions = new HashSet<>(Arrays.asList( |
| 44 | new Pair<>(dpid2, action2), |
| 45 | new Pair<>(dpid3, action3) |
| 46 | )); |
| 47 | SingleSrcTreeFlow tree = new SingleSrcTreeFlow(flowId1, match, |
| 48 | new SwitchPort(dpid1, port3), createTree(), actions |
| 49 | ); |
| 50 | return new SingleSrcTreeFlowIntent(intentId1, tree); |
| 51 | } |
| 52 | |
| 53 | @Override |
| 54 | protected SingleSrcTreeFlowIntent createAnother() { |
| 55 | Set<Pair<Dpid, OutputAction>> actions = new HashSet<>(Arrays.asList( |
| 56 | new Pair<>(dpid1, action1), |
| 57 | new Pair<>(dpid3, action3) |
| 58 | )); |
| 59 | SingleSrcTreeFlow tree = new SingleSrcTreeFlow(flowId2, match, |
| 60 | new SwitchPort(dpid2, port3), createTree(), actions |
| 61 | ); |
| 62 | return new SingleSrcTreeFlowIntent(intentId2, tree); |
| 63 | } |
| 64 | |
| 65 | private Tree createTree() { |
| 66 | Tree tree = new Tree(); |
| 67 | tree.add(new FlowLink(dpid1, port1, dpid2, port2)); |
| 68 | tree.add(new FlowLink(dpid1, port2, dpid3, port3)); |
| 69 | |
| 70 | return tree; |
| 71 | } |
| 72 | } |