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.SingleDstTreeFlow; |
| 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.Action; |
| 10 | import net.onrc.onos.core.matchaction.action.OutputAction; |
| 11 | import net.onrc.onos.core.matchaction.match.PacketMatch; |
| 12 | import net.onrc.onos.core.matchaction.match.PacketMatchBuilder; |
| 13 | import net.onrc.onos.core.util.PortNumber; |
| 14 | import net.onrc.onos.core.util.SwitchPort; |
| 15 | |
| 16 | import java.util.Arrays; |
| 17 | |
| 18 | /** |
| 19 | * Suites of test of {@link SingleDstTreeFlowIntent}. |
| 20 | */ |
| 21 | public class SingleDstTreeFlowIntentTest extends IntentTest { |
| 22 | |
| 23 | private final IntentId intentId1 = new IntentId(1L); |
| 24 | private final IntentId intentId2 = new IntentId(2L); |
Toshio Koide | 515ba84 | 2014-08-20 11:53:37 -0700 | [diff] [blame] | 25 | private final FlowId flowId1 = new FlowId(1L); |
Sho SHIMIZU | 7226e01 | 2014-08-14 14:21:30 -0700 | [diff] [blame] | 26 | private final PacketMatch match = new PacketMatchBuilder().build(); |
| 27 | private final short port1 = (short) 1; |
| 28 | private final short port2 = (short) 2; |
| 29 | private final short port3 = (short) 3; |
| 30 | private final SwitchPort switchPort1 = new SwitchPort(1, port1); |
| 31 | private final SwitchPort switchPort2 = new SwitchPort(2, port2); |
| 32 | private final SwitchPort switchPort3 = new SwitchPort(3, port3); |
| 33 | |
| 34 | @Override |
| 35 | protected SingleDstTreeFlowIntent createOne() { |
| 36 | SingleDstTreeFlow treeFlow = new SingleDstTreeFlow(flowId1, |
| 37 | match, |
| 38 | Arrays.asList(switchPort1, switchPort2), |
| 39 | createTree(), |
Yuta HIGUCHI | a507baf | 2014-08-22 13:42:40 -0700 | [diff] [blame] | 40 | Arrays.asList((Action) new OutputAction(PortNumber.uint16(port3)))); |
Sho SHIMIZU | 7226e01 | 2014-08-14 14:21:30 -0700 | [diff] [blame] | 41 | return new SingleDstTreeFlowIntent(intentId1, treeFlow); |
| 42 | } |
| 43 | |
| 44 | @Override |
| 45 | protected SingleDstTreeFlowIntent createAnother() { |
| 46 | SingleDstTreeFlow treeFlow = new SingleDstTreeFlow(flowId1, |
| 47 | match, |
| 48 | Arrays.asList(switchPort1, switchPort3), |
| 49 | createTree(), |
Yuta HIGUCHI | a507baf | 2014-08-22 13:42:40 -0700 | [diff] [blame] | 50 | Arrays.asList((Action) new OutputAction(PortNumber.uint16(port2)))); |
Sho SHIMIZU | 7226e01 | 2014-08-14 14:21:30 -0700 | [diff] [blame] | 51 | return new SingleDstTreeFlowIntent(intentId2, treeFlow); |
| 52 | } |
| 53 | |
| 54 | private Tree createTree() { |
| 55 | Tree tree = new Tree(); |
| 56 | tree.add(new FlowLink(switchPort1, switchPort2)); |
| 57 | tree.add(new FlowLink(switchPort1, switchPort3)); |
| 58 | |
| 59 | return tree; |
| 60 | } |
| 61 | } |