blob: f031f6d8a26a73f44e917262d9677f44aaf59168 [file] [log] [blame]
Jonathan Hart23701d12014-04-03 10:45:48 -07001package net.onrc.onos.core.util;
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +09002
3import static org.junit.Assert.assertEquals;
Ray Milkey269ffb92014-04-03 14:43:30 -07004
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +09005import net.floodlightcontroller.util.MACAddress;
Jonathan Hart23701d12014-04-03 10:45:48 -07006import net.onrc.onos.core.util.FlowEntryAction.ActionEnqueue;
7import net.onrc.onos.core.util.FlowEntryAction.ActionOutput;
8import net.onrc.onos.core.util.FlowEntryAction.ActionSetEthernetAddr;
9import net.onrc.onos.core.util.FlowEntryAction.ActionSetIPv4Addr;
10import net.onrc.onos.core.util.FlowEntryAction.ActionSetIpToS;
11import net.onrc.onos.core.util.FlowEntryAction.ActionSetTcpUdpPort;
12import net.onrc.onos.core.util.FlowEntryAction.ActionSetVlanId;
13import net.onrc.onos.core.util.FlowEntryAction.ActionSetVlanPriority;
14import net.onrc.onos.core.util.FlowEntryAction.ActionStripVlan;
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +090015
16import org.junit.Test;
17
18public class FlowEntryActionTest {
19
Ray Milkey269ffb92014-04-03 14:43:30 -070020 @Test
21 public void testSetActionOutputActionOutput() {
22 FlowEntryAction act = new FlowEntryAction();
23 ActionOutput actout = new FlowEntryAction.ActionOutput(new Port((short) 42));
24 act.setActionOutput(actout);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +090025
Ray Milkey269ffb92014-04-03 14:43:30 -070026 assertEquals("action output", FlowEntryAction.ActionValues.ACTION_OUTPUT, act.actionType());
27 assertEquals("actionOutput port should be the same", actout.port(), act.actionOutput().port());
28 assertEquals("actionOutput maxlen should be the same", actout.maxLen(), act.actionOutput().maxLen());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +090029
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -070030 FlowEntryAction actCopy = new FlowEntryAction(act);
31 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +090032
Ray Milkey269ffb92014-04-03 14:43:30 -070033 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -070034 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -070035 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -070036 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -070037 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +090038
Ray Milkey269ffb92014-04-03 14:43:30 -070039 @Test
40 public void testSetActionOutputPort() {
41 FlowEntryAction act = new FlowEntryAction();
42 act.setActionOutput(new Port((short) 42));
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +090043
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -070044 FlowEntryAction actCopy = new FlowEntryAction(act);
45 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +090046
Ray Milkey269ffb92014-04-03 14:43:30 -070047 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -070048 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -070049 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -070050 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -070051 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +090052
Ray Milkey269ffb92014-04-03 14:43:30 -070053 @Test
54 public void testSetActionOutputToController() {
55 FlowEntryAction act = new FlowEntryAction();
56 act.setActionOutputToController((short) 0);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +090057
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -070058 FlowEntryAction actCopy = new FlowEntryAction();
59 actCopy.setActionOutput(new Port(Port.PortValues.PORT_CONTROLLER));
60
61 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +090062
Ray Milkey269ffb92014-04-03 14:43:30 -070063 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -070064 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -070065 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -070066 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -070067 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +090068
Ray Milkey269ffb92014-04-03 14:43:30 -070069 @Test
70 public void testSetActionSetVlanIdActionSetVlanId() {
71 FlowEntryAction act = new FlowEntryAction();
72 ActionSetVlanId actVlan = new FlowEntryAction.ActionSetVlanId((short) 42);
73 act.setActionSetVlanId(actVlan);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +090074
Ray Milkey269ffb92014-04-03 14:43:30 -070075 assertEquals("action type", FlowEntryAction.ActionValues.ACTION_SET_VLAN_VID, act.actionType());
76 assertEquals("vlanid should be the same", actVlan.vlanId(), act.actionSetVlanId().vlanId());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +090077
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -070078 FlowEntryAction actCopy = new FlowEntryAction(act);
79 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +090080
Ray Milkey269ffb92014-04-03 14:43:30 -070081 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -070082 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -070083 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -070084 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -070085 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +090086
Ray Milkey269ffb92014-04-03 14:43:30 -070087 @Test
88 public void testSetActionSetVlanIdShort() {
89 FlowEntryAction act = new FlowEntryAction();
90 act.setActionSetVlanId((short) 42);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +090091
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -070092 FlowEntryAction actCopy = new FlowEntryAction(act);
93 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +090094
Ray Milkey269ffb92014-04-03 14:43:30 -070095 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -070096 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -070097 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -070098 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -070099 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900100
Ray Milkey269ffb92014-04-03 14:43:30 -0700101 @Test
102 public void testSetActionSetVlanPriorityActionSetVlanPriority() {
103 FlowEntryAction act = new FlowEntryAction();
104 ActionSetVlanPriority actVlan = new FlowEntryAction.ActionSetVlanPriority((byte) 42);
105 act.setActionSetVlanPriority(actVlan);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900106
Ray Milkey269ffb92014-04-03 14:43:30 -0700107 assertEquals("action type", FlowEntryAction.ActionValues.ACTION_SET_VLAN_PCP, act.actionType());
108 assertEquals("vlan priority should be the same", actVlan.vlanPriority(), act.actionSetVlanPriority().vlanPriority());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900109
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700110 FlowEntryAction actCopy = new FlowEntryAction(act);
111 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900112
Ray Milkey269ffb92014-04-03 14:43:30 -0700113 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700114 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700115 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700116 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700117 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900118
Ray Milkey269ffb92014-04-03 14:43:30 -0700119 @Test
120 public void testSetActionSetVlanPriorityByte() {
121 FlowEntryAction act = new FlowEntryAction();
122 act.setActionSetVlanPriority((byte) 42);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900123
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700124 FlowEntryAction actCopy = new FlowEntryAction(act);
125 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900126
Ray Milkey269ffb92014-04-03 14:43:30 -0700127 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700128 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700129 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700130 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700131 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900132
Ray Milkey269ffb92014-04-03 14:43:30 -0700133 @Test
134 public void testSetActionStripVlanActionStripVlan() {
135 FlowEntryAction act = new FlowEntryAction();
136 ActionStripVlan actVlan = new FlowEntryAction.ActionStripVlan();
137 act.setActionStripVlan(actVlan);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900138
Ray Milkey269ffb92014-04-03 14:43:30 -0700139 assertEquals("action type", FlowEntryAction.ActionValues.ACTION_STRIP_VLAN, act.actionType());
140 assertEquals("vlanid should be the same", actVlan.stripVlan(), act.actionStripVlan().stripVlan());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900141
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700142 FlowEntryAction actCopy = new FlowEntryAction(act);
143 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900144
Ray Milkey269ffb92014-04-03 14:43:30 -0700145 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700146 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700147 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700148 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700149 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900150
Ray Milkey269ffb92014-04-03 14:43:30 -0700151 @Test
152 public void testSetActionStripVlanBoolean() {
153 FlowEntryAction act = new FlowEntryAction();
154 act.setActionStripVlan(true);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900155
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700156 FlowEntryAction actCopy = new FlowEntryAction(act);
157 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900158
Ray Milkey269ffb92014-04-03 14:43:30 -0700159 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700160 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700161 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700162 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700163 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900164
Ray Milkey269ffb92014-04-03 14:43:30 -0700165 @Test
166 public void testSetActionSetEthernetSrcAddrActionSetEthernetAddr() {
167 FlowEntryAction act = new FlowEntryAction();
168 byte[] mac = {1, 2, 3, 4, 5, 6};
169 ActionSetEthernetAddr setEth = new FlowEntryAction.ActionSetEthernetAddr(new MACAddress(mac));
170 act.setActionSetEthernetSrcAddr(setEth);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900171
Ray Milkey269ffb92014-04-03 14:43:30 -0700172 assertEquals("action type", FlowEntryAction.ActionValues.ACTION_SET_DL_SRC, act.actionType());
173 assertEquals("addr should be the same", setEth.addr(), act.actionSetEthernetSrcAddr().addr());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900174
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900175
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700176 FlowEntryAction actCopy = new FlowEntryAction(act);
177 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900178
Ray Milkey269ffb92014-04-03 14:43:30 -0700179 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700180 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700181 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700182 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700183 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900184
Ray Milkey269ffb92014-04-03 14:43:30 -0700185 @Test
186 public void testSetActionSetEthernetSrcAddrMACAddress() {
187 FlowEntryAction act = new FlowEntryAction();
188 byte[] mac = {1, 2, 3, 4, 5, 6};
189 act.setActionSetEthernetSrcAddr(new MACAddress(mac));
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900190
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700191 FlowEntryAction actCopy = new FlowEntryAction(act);
192 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900193
Ray Milkey269ffb92014-04-03 14:43:30 -0700194 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700195 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700196 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700197 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700198 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900199
Ray Milkey269ffb92014-04-03 14:43:30 -0700200 @Test
201 public void testSetActionSetEthernetDstAddrActionSetEthernetAddr() {
202 FlowEntryAction act = new FlowEntryAction();
203 byte[] mac = {1, 2, 3, 4, 5, 6};
204 ActionSetEthernetAddr setEth = new FlowEntryAction.ActionSetEthernetAddr(new MACAddress(mac));
205 act.setActionSetEthernetDstAddr(setEth);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900206
Ray Milkey269ffb92014-04-03 14:43:30 -0700207 assertEquals("action type", FlowEntryAction.ActionValues.ACTION_SET_DL_DST, act.actionType());
208 assertEquals("addr should be the same", setEth.addr(), act.actionSetEthernetDstAddr().addr());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900209
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700210 FlowEntryAction actCopy = new FlowEntryAction(act);
211 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900212
Ray Milkey269ffb92014-04-03 14:43:30 -0700213 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700214 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700215 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700216 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700217 }
218
219 @Test
220 public void testSetActionSetEthernetDstAddrMACAddress() {
221 FlowEntryAction act = new FlowEntryAction();
222 byte[] mac = {1, 2, 3, 4, 5, 6};
223 act.setActionSetEthernetDstAddr(new MACAddress(mac));
224
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700225 FlowEntryAction actCopy = new FlowEntryAction(act);
226 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900227
Ray Milkey269ffb92014-04-03 14:43:30 -0700228 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700229 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700230 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700231 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700232 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900233
Ray Milkey269ffb92014-04-03 14:43:30 -0700234 @Test
235 public void testSetActionSetIPv4SrcAddrActionSetIPv4Addr() {
236 FlowEntryAction act = new FlowEntryAction();
237 ActionSetIPv4Addr setIp = new FlowEntryAction.ActionSetIPv4Addr(new IPv4("127.0.0.1"));
238 act.setActionSetIPv4SrcAddr(setIp);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900239
Ray Milkey269ffb92014-04-03 14:43:30 -0700240 assertEquals("action type", FlowEntryAction.ActionValues.ACTION_SET_NW_SRC, act.actionType());
241 assertEquals("addr should be the same", setIp.addr(), act.actionSetIPv4SrcAddr().addr());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900242
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700243 FlowEntryAction actCopy = new FlowEntryAction(act);
244 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900245
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900246
Ray Milkey269ffb92014-04-03 14:43:30 -0700247 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700248 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700249 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700250 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700251 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900252
Ray Milkey269ffb92014-04-03 14:43:30 -0700253 @Test
254 public void testSetActionSetIPv4SrcAddrIPv4() {
255 FlowEntryAction act = new FlowEntryAction();
256 act.setActionSetIPv4SrcAddr(new IPv4("127.0.0.1"));
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900257
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700258 FlowEntryAction actCopy = new FlowEntryAction(act);
259 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900260
Ray Milkey269ffb92014-04-03 14:43:30 -0700261 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700262 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700263 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700264 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700265 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900266
Ray Milkey269ffb92014-04-03 14:43:30 -0700267 @Test
268 public void testSetActionSetIPv4DstAddrActionSetIPv4Addr() {
269 FlowEntryAction act = new FlowEntryAction();
270 ActionSetIPv4Addr setIp = new FlowEntryAction.ActionSetIPv4Addr(new IPv4("127.0.0.1"));
271 act.setActionSetIPv4DstAddr(setIp);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900272
Ray Milkey269ffb92014-04-03 14:43:30 -0700273 assertEquals("action type", FlowEntryAction.ActionValues.ACTION_SET_NW_DST, act.actionType());
274 assertEquals("addr should be the same", setIp.addr(), act.actionSetIPv4DstAddr().addr());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900275
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700276 FlowEntryAction actCopy = new FlowEntryAction(act);
277 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900278
Ray Milkey269ffb92014-04-03 14:43:30 -0700279 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700280 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700281 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700282 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700283 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900284
Ray Milkey269ffb92014-04-03 14:43:30 -0700285 @Test
286 public void testSetActionSetIPv4DstAddrIPv4() {
287 FlowEntryAction act = new FlowEntryAction();
288 act.setActionSetIPv4DstAddr(new IPv4("127.0.0.1"));
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900289
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700290 FlowEntryAction actCopy = new FlowEntryAction(act);
291 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900292
Ray Milkey269ffb92014-04-03 14:43:30 -0700293 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700294 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700295 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700296 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700297 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900298
Ray Milkey269ffb92014-04-03 14:43:30 -0700299 @Test
300 public void testSetActionSetIpToSActionSetIpToS() {
301 FlowEntryAction act = new FlowEntryAction();
302 ActionSetIpToS setIpTos = new FlowEntryAction.ActionSetIpToS((byte) 42);
303 act.setActionSetIpToS(setIpTos);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900304
Ray Milkey269ffb92014-04-03 14:43:30 -0700305 assertEquals("action type", FlowEntryAction.ActionValues.ACTION_SET_NW_TOS, act.actionType());
306 assertEquals("tos should be the same", setIpTos.ipToS(), act.actionSetIpToS().ipToS());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900307
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700308 FlowEntryAction actCopy = new FlowEntryAction(act);
309 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900310
Ray Milkey269ffb92014-04-03 14:43:30 -0700311 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700312 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700313 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700314 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700315 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900316
Ray Milkey269ffb92014-04-03 14:43:30 -0700317 @Test
318 public void testSetActionSetIpToSByte() {
319 FlowEntryAction act = new FlowEntryAction();
320 act.setActionSetIpToS((byte) 1);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900321
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700322 FlowEntryAction actCopy = new FlowEntryAction(act);
323 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900324
Ray Milkey269ffb92014-04-03 14:43:30 -0700325 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700326 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700327 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700328 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700329 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900330
Ray Milkey269ffb92014-04-03 14:43:30 -0700331 @Test
332 public void testSetActionSetTcpUdpSrcPortActionSetTcpUdpPort() {
333 FlowEntryAction act = new FlowEntryAction();
334 ActionSetTcpUdpPort setPorts = new FlowEntryAction.ActionSetTcpUdpPort((short) 42);
335 act.setActionSetTcpUdpSrcPort(setPorts);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900336
Ray Milkey269ffb92014-04-03 14:43:30 -0700337 assertEquals("action type", FlowEntryAction.ActionValues.ACTION_SET_TP_SRC, act.actionType());
338 assertEquals("port should be the same", setPorts.port(), act.actionSetTcpUdpSrcPort().port());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900339
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700340 FlowEntryAction actCopy = new FlowEntryAction(act);
341 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900342
Ray Milkey269ffb92014-04-03 14:43:30 -0700343 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700344 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700345 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700346 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700347 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900348
Ray Milkey269ffb92014-04-03 14:43:30 -0700349 @Test
350 public void testSetActionSetTcpUdpSrcPortShort() {
351 FlowEntryAction act = new FlowEntryAction();
352 act.setActionSetTcpUdpSrcPort((short) 1);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900353
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700354 FlowEntryAction actCopy = new FlowEntryAction(act);
355 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900356
Ray Milkey269ffb92014-04-03 14:43:30 -0700357 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700358 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700359 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700360 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700361 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900362
Ray Milkey269ffb92014-04-03 14:43:30 -0700363 @Test
364 public void testSetActionSetTcpUdpDstPortActionSetTcpUdpPort() {
365 FlowEntryAction act = new FlowEntryAction();
366 ActionSetTcpUdpPort setPorts = new FlowEntryAction.ActionSetTcpUdpPort((short) 42);
367 act.setActionSetTcpUdpDstPort(setPorts);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900368
Ray Milkey269ffb92014-04-03 14:43:30 -0700369 assertEquals("action type", FlowEntryAction.ActionValues.ACTION_SET_TP_DST, act.actionType());
370 assertEquals("port should be the same", setPorts.port(), act.actionSetTcpUdpDstPort().port());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900371
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700372 FlowEntryAction actCopy = new FlowEntryAction(act);
373 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900374
Ray Milkey269ffb92014-04-03 14:43:30 -0700375 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700376 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700377 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700378 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700379 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900380
Ray Milkey269ffb92014-04-03 14:43:30 -0700381 @Test
382 public void testSetActionSetTcpUdpDstPortShort() {
383 FlowEntryAction act = new FlowEntryAction();
384 act.setActionSetTcpUdpDstPort((short) 1);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900385
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700386 FlowEntryAction actCopy = new FlowEntryAction(act);
387 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900388
Ray Milkey269ffb92014-04-03 14:43:30 -0700389 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700390 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700391 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700392 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700393 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900394
Ray Milkey269ffb92014-04-03 14:43:30 -0700395 @Test
396 public void testSetActionEnqueueActionEnqueue() {
397 FlowEntryAction act = new FlowEntryAction();
398 ActionEnqueue enq = new FlowEntryAction.ActionEnqueue(new Port((short) 42), 1);
399 act.setActionEnqueue(enq);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900400
Ray Milkey269ffb92014-04-03 14:43:30 -0700401 assertEquals("action type", FlowEntryAction.ActionValues.ACTION_ENQUEUE, act.actionType());
402 assertEquals("port should be the same", enq.port(), act.actionEnqueue().port());
403 assertEquals("queue id should be the same", enq.queueId(), act.actionEnqueue().queueId());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900404
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700405 FlowEntryAction actCopy = new FlowEntryAction(act);
406 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900407
Ray Milkey269ffb92014-04-03 14:43:30 -0700408 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700409 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700410 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700411 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700412 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900413
Ray Milkey269ffb92014-04-03 14:43:30 -0700414 @Test
415 public void testSetActionEnqueuePortInt() {
416 FlowEntryAction act = new FlowEntryAction();
417 act.setActionEnqueue(new Port((short) 42), 1);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900418
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700419 FlowEntryAction actCopy = new FlowEntryAction(act);
420 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900421
Ray Milkey269ffb92014-04-03 14:43:30 -0700422 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700423 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700424 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700425 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700426 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900427
428}