blob: a9a3dbf8d012e47bb2f0d3d150e1b22b28db73be [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;
Sho SHIMIZU7226e012014-08-14 14:21:30 -070013import net.onrc.onos.core.util.PortNumber;
14import net.onrc.onos.core.util.SwitchPort;
15
Pavlin Radoslavovb05aac92014-08-26 18:26:10 -070016import org.apache.commons.lang3.tuple.Pair;
17
Sho SHIMIZU7226e012014-08-14 14:21:30 -070018import java.util.Arrays;
19import java.util.HashSet;
20import java.util.Set;
21
22/**
23 * Suites of test of {@link SingleSrcTreeFlowIntent}.
24 */
25public class SingleSrcTreeFlowIntentTest extends IntentTest {
26
27 private final IntentId intentId1 = new IntentId(1L);
28 private final IntentId intentId2 = new IntentId(2L);
Toshio Koide515ba842014-08-20 11:53:37 -070029 private final FlowId flowId1 = new FlowId(1L);
30 private final FlowId flowId2 = new FlowId(2L);
Sho SHIMIZU7226e012014-08-14 14:21:30 -070031 private final Dpid dpid1 = new Dpid(1);
32 private final Dpid dpid2 = new Dpid(2);
33 private final Dpid dpid3 = new Dpid(3);
34 private final PortNumber port1 = PortNumber.uint32(1);
35 private final PortNumber port2 = PortNumber.uint32(2);
36 private final PortNumber port3 = PortNumber.uint32(3);
37 private final OutputAction action1 = new OutputAction(port1);
38 private final OutputAction action2 = new OutputAction(port2);
39 private final OutputAction action3 = new OutputAction(port3);
40 private final PacketMatch match = new PacketMatchBuilder().build();
41
42 @Override
43 protected SingleSrcTreeFlowIntent createOne() {
44 Set<Pair<Dpid, OutputAction>> actions = new HashSet<>(Arrays.asList(
Pavlin Radoslavovb05aac92014-08-26 18:26:10 -070045 Pair.of(dpid2, action2),
46 Pair.of(dpid3, action3)
Sho SHIMIZU7226e012014-08-14 14:21:30 -070047 ));
48 SingleSrcTreeFlow tree = new SingleSrcTreeFlow(flowId1, match,
49 new SwitchPort(dpid1, port3), createTree(), actions
50 );
51 return new SingleSrcTreeFlowIntent(intentId1, tree);
52 }
53
54 @Override
55 protected SingleSrcTreeFlowIntent createAnother() {
56 Set<Pair<Dpid, OutputAction>> actions = new HashSet<>(Arrays.asList(
Pavlin Radoslavovb05aac92014-08-26 18:26:10 -070057 Pair.of(dpid1, action1),
58 Pair.of(dpid3, action3)
Sho SHIMIZU7226e012014-08-14 14:21:30 -070059 ));
60 SingleSrcTreeFlow tree = new SingleSrcTreeFlow(flowId2, match,
61 new SwitchPort(dpid2, port3), createTree(), actions
62 );
63 return new SingleSrcTreeFlowIntent(intentId2, tree);
64 }
65
66 private Tree createTree() {
67 Tree tree = new Tree();
68 tree.add(new FlowLink(dpid1, port1, dpid2, port2));
69 tree.add(new FlowLink(dpid1, port2, dpid3, port3));
70
71 return tree;
72 }
73}