blob: 2c4b969154da014c30aea841ec5cfbbaedf7acf1 [file] [log] [blame]
Sho SHIMIZU7226e012014-08-14 14:21:30 -07001package net.onrc.onos.core.newintent;
2
3import net.onrc.onos.api.flowmanager.FlowId;
4import net.onrc.onos.api.flowmanager.FlowLink;
5import net.onrc.onos.api.flowmanager.SingleDstTreeFlow;
6import net.onrc.onos.api.flowmanager.Tree;
7import net.onrc.onos.api.newintent.IntentId;
8import net.onrc.onos.api.newintent.IntentTest;
9import net.onrc.onos.core.matchaction.action.Action;
10import net.onrc.onos.core.matchaction.action.OutputAction;
11import net.onrc.onos.core.matchaction.match.PacketMatch;
12import net.onrc.onos.core.matchaction.match.PacketMatchBuilder;
13import net.onrc.onos.core.util.PortNumber;
14import net.onrc.onos.core.util.SwitchPort;
15
16import java.util.Arrays;
17
18/**
19 * Suites of test of {@link SingleDstTreeFlowIntent}.
20 */
21public class SingleDstTreeFlowIntentTest extends IntentTest {
22
23 private final IntentId intentId1 = new IntentId(1L);
24 private final IntentId intentId2 = new IntentId(2L);
Toshio Koide515ba842014-08-20 11:53:37 -070025 private final FlowId flowId1 = new FlowId(1L);
Sho SHIMIZU7226e012014-08-14 14:21:30 -070026 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 HIGUCHIa507baf2014-08-22 13:42:40 -070040 Arrays.asList((Action) new OutputAction(PortNumber.uint16(port3))));
Sho SHIMIZU7226e012014-08-14 14:21:30 -070041 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 HIGUCHIa507baf2014-08-22 13:42:40 -070050 Arrays.asList((Action) new OutputAction(PortNumber.uint16(port2))));
Sho SHIMIZU7226e012014-08-14 14:21:30 -070051 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}