blob: cfd9391ab1ba7cd69913dbded7c1b4d857414f76 [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.SingleSrcTreeFlow;
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.OutputAction;
10import net.onrc.onos.core.matchaction.match.PacketMatch;
11import net.onrc.onos.core.matchaction.match.PacketMatchBuilder;
12import net.onrc.onos.core.util.Dpid;
13import net.onrc.onos.core.util.Pair;
14import net.onrc.onos.core.util.PortNumber;
15import net.onrc.onos.core.util.SwitchPort;
16
17import java.util.Arrays;
18import java.util.HashSet;
19import java.util.Set;
20
21/**
22 * Suites of test of {@link SingleSrcTreeFlowIntent}.
23 */
24public class SingleSrcTreeFlowIntentTest extends IntentTest {
25
26 private final IntentId intentId1 = new IntentId(1L);
27 private final IntentId intentId2 = new IntentId(2L);
Toshio Koide515ba842014-08-20 11:53:37 -070028 private final FlowId flowId1 = new FlowId(1L);
29 private final FlowId flowId2 = new FlowId(2L);
Sho SHIMIZU7226e012014-08-14 14:21:30 -070030 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}