blob: c93f1323151778fbdcc453ae6e4cac61970bd196 [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());
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700108 assertEquals("vlan priority should be the same", actVlan.vlanPriority(),
109 act.actionSetVlanPriority().vlanPriority());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900110
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700111 FlowEntryAction actCopy = new FlowEntryAction(act);
112 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900113
Ray Milkey269ffb92014-04-03 14:43:30 -0700114 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700115 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700116 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700117 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700118 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900119
Ray Milkey269ffb92014-04-03 14:43:30 -0700120 @Test
121 public void testSetActionSetVlanPriorityByte() {
122 FlowEntryAction act = new FlowEntryAction();
123 act.setActionSetVlanPriority((byte) 42);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900124
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700125 FlowEntryAction actCopy = new FlowEntryAction(act);
126 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900127
Ray Milkey269ffb92014-04-03 14:43:30 -0700128 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700129 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700130 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700131 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700132 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900133
Ray Milkey269ffb92014-04-03 14:43:30 -0700134 @Test
135 public void testSetActionStripVlanActionStripVlan() {
136 FlowEntryAction act = new FlowEntryAction();
137 ActionStripVlan actVlan = new FlowEntryAction.ActionStripVlan();
138 act.setActionStripVlan(actVlan);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900139
Ray Milkey269ffb92014-04-03 14:43:30 -0700140 assertEquals("action type", FlowEntryAction.ActionValues.ACTION_STRIP_VLAN, act.actionType());
141 assertEquals("vlanid should be the same", actVlan.stripVlan(), act.actionStripVlan().stripVlan());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900142
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700143 FlowEntryAction actCopy = new FlowEntryAction(act);
144 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900145
Ray Milkey269ffb92014-04-03 14:43:30 -0700146 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700147 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700148 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700149 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700150 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900151
Ray Milkey269ffb92014-04-03 14:43:30 -0700152 @Test
153 public void testSetActionStripVlanBoolean() {
154 FlowEntryAction act = new FlowEntryAction();
155 act.setActionStripVlan(true);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900156
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700157 FlowEntryAction actCopy = new FlowEntryAction(act);
158 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900159
Ray Milkey269ffb92014-04-03 14:43:30 -0700160 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700161 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700162 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700163 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700164 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900165
Ray Milkey269ffb92014-04-03 14:43:30 -0700166 @Test
167 public void testSetActionSetEthernetSrcAddrActionSetEthernetAddr() {
168 FlowEntryAction act = new FlowEntryAction();
169 byte[] mac = {1, 2, 3, 4, 5, 6};
170 ActionSetEthernetAddr setEth = new FlowEntryAction.ActionSetEthernetAddr(new MACAddress(mac));
171 act.setActionSetEthernetSrcAddr(setEth);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900172
Ray Milkey269ffb92014-04-03 14:43:30 -0700173 assertEquals("action type", FlowEntryAction.ActionValues.ACTION_SET_DL_SRC, act.actionType());
174 assertEquals("addr should be the same", setEth.addr(), act.actionSetEthernetSrcAddr().addr());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900175
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900176
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700177 FlowEntryAction actCopy = new FlowEntryAction(act);
178 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900179
Ray Milkey269ffb92014-04-03 14:43:30 -0700180 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700181 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700182 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700183 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700184 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900185
Ray Milkey269ffb92014-04-03 14:43:30 -0700186 @Test
187 public void testSetActionSetEthernetSrcAddrMACAddress() {
188 FlowEntryAction act = new FlowEntryAction();
189 byte[] mac = {1, 2, 3, 4, 5, 6};
190 act.setActionSetEthernetSrcAddr(new MACAddress(mac));
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900191
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700192 FlowEntryAction actCopy = new FlowEntryAction(act);
193 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900194
Ray Milkey269ffb92014-04-03 14:43:30 -0700195 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700196 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700197 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700198 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700199 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900200
Ray Milkey269ffb92014-04-03 14:43:30 -0700201 @Test
202 public void testSetActionSetEthernetDstAddrActionSetEthernetAddr() {
203 FlowEntryAction act = new FlowEntryAction();
204 byte[] mac = {1, 2, 3, 4, 5, 6};
205 ActionSetEthernetAddr setEth = new FlowEntryAction.ActionSetEthernetAddr(new MACAddress(mac));
206 act.setActionSetEthernetDstAddr(setEth);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900207
Ray Milkey269ffb92014-04-03 14:43:30 -0700208 assertEquals("action type", FlowEntryAction.ActionValues.ACTION_SET_DL_DST, act.actionType());
209 assertEquals("addr should be the same", setEth.addr(), act.actionSetEthernetDstAddr().addr());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900210
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700211 FlowEntryAction actCopy = new FlowEntryAction(act);
212 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900213
Ray Milkey269ffb92014-04-03 14:43:30 -0700214 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700215 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700216 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700217 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700218 }
219
220 @Test
221 public void testSetActionSetEthernetDstAddrMACAddress() {
222 FlowEntryAction act = new FlowEntryAction();
223 byte[] mac = {1, 2, 3, 4, 5, 6};
224 act.setActionSetEthernetDstAddr(new MACAddress(mac));
225
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700226 FlowEntryAction actCopy = new FlowEntryAction(act);
227 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900228
Ray Milkey269ffb92014-04-03 14:43:30 -0700229 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700230 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700231 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700232 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700233 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900234
Ray Milkey269ffb92014-04-03 14:43:30 -0700235 @Test
236 public void testSetActionSetIPv4SrcAddrActionSetIPv4Addr() {
237 FlowEntryAction act = new FlowEntryAction();
238 ActionSetIPv4Addr setIp = new FlowEntryAction.ActionSetIPv4Addr(new IPv4("127.0.0.1"));
239 act.setActionSetIPv4SrcAddr(setIp);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900240
Ray Milkey269ffb92014-04-03 14:43:30 -0700241 assertEquals("action type", FlowEntryAction.ActionValues.ACTION_SET_NW_SRC, act.actionType());
242 assertEquals("addr should be the same", setIp.addr(), act.actionSetIPv4SrcAddr().addr());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900243
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700244 FlowEntryAction actCopy = new FlowEntryAction(act);
245 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900246
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900247
Ray Milkey269ffb92014-04-03 14:43:30 -0700248 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700249 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700250 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700251 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700252 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900253
Ray Milkey269ffb92014-04-03 14:43:30 -0700254 @Test
255 public void testSetActionSetIPv4SrcAddrIPv4() {
256 FlowEntryAction act = new FlowEntryAction();
257 act.setActionSetIPv4SrcAddr(new IPv4("127.0.0.1"));
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900258
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700259 FlowEntryAction actCopy = new FlowEntryAction(act);
260 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900261
Ray Milkey269ffb92014-04-03 14:43:30 -0700262 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700263 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700264 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700265 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700266 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900267
Ray Milkey269ffb92014-04-03 14:43:30 -0700268 @Test
269 public void testSetActionSetIPv4DstAddrActionSetIPv4Addr() {
270 FlowEntryAction act = new FlowEntryAction();
271 ActionSetIPv4Addr setIp = new FlowEntryAction.ActionSetIPv4Addr(new IPv4("127.0.0.1"));
272 act.setActionSetIPv4DstAddr(setIp);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900273
Ray Milkey269ffb92014-04-03 14:43:30 -0700274 assertEquals("action type", FlowEntryAction.ActionValues.ACTION_SET_NW_DST, act.actionType());
275 assertEquals("addr should be the same", setIp.addr(), act.actionSetIPv4DstAddr().addr());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900276
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700277 FlowEntryAction actCopy = new FlowEntryAction(act);
278 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900279
Ray Milkey269ffb92014-04-03 14:43:30 -0700280 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700281 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700282 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700283 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700284 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900285
Ray Milkey269ffb92014-04-03 14:43:30 -0700286 @Test
287 public void testSetActionSetIPv4DstAddrIPv4() {
288 FlowEntryAction act = new FlowEntryAction();
289 act.setActionSetIPv4DstAddr(new IPv4("127.0.0.1"));
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900290
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700291 FlowEntryAction actCopy = new FlowEntryAction(act);
292 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900293
Ray Milkey269ffb92014-04-03 14:43:30 -0700294 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700295 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700296 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700297 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700298 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900299
Ray Milkey269ffb92014-04-03 14:43:30 -0700300 @Test
301 public void testSetActionSetIpToSActionSetIpToS() {
302 FlowEntryAction act = new FlowEntryAction();
303 ActionSetIpToS setIpTos = new FlowEntryAction.ActionSetIpToS((byte) 42);
304 act.setActionSetIpToS(setIpTos);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900305
Ray Milkey269ffb92014-04-03 14:43:30 -0700306 assertEquals("action type", FlowEntryAction.ActionValues.ACTION_SET_NW_TOS, act.actionType());
307 assertEquals("tos should be the same", setIpTos.ipToS(), act.actionSetIpToS().ipToS());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900308
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700309 FlowEntryAction actCopy = new FlowEntryAction(act);
310 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900311
Ray Milkey269ffb92014-04-03 14:43:30 -0700312 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700313 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700314 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700315 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700316 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900317
Ray Milkey269ffb92014-04-03 14:43:30 -0700318 @Test
319 public void testSetActionSetIpToSByte() {
320 FlowEntryAction act = new FlowEntryAction();
321 act.setActionSetIpToS((byte) 1);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900322
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700323 FlowEntryAction actCopy = new FlowEntryAction(act);
324 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900325
Ray Milkey269ffb92014-04-03 14:43:30 -0700326 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700327 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700328 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700329 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700330 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900331
Ray Milkey269ffb92014-04-03 14:43:30 -0700332 @Test
333 public void testSetActionSetTcpUdpSrcPortActionSetTcpUdpPort() {
334 FlowEntryAction act = new FlowEntryAction();
335 ActionSetTcpUdpPort setPorts = new FlowEntryAction.ActionSetTcpUdpPort((short) 42);
336 act.setActionSetTcpUdpSrcPort(setPorts);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900337
Ray Milkey269ffb92014-04-03 14:43:30 -0700338 assertEquals("action type", FlowEntryAction.ActionValues.ACTION_SET_TP_SRC, act.actionType());
339 assertEquals("port should be the same", setPorts.port(), act.actionSetTcpUdpSrcPort().port());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900340
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700341 FlowEntryAction actCopy = new FlowEntryAction(act);
342 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900343
Ray Milkey269ffb92014-04-03 14:43:30 -0700344 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700345 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700346 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700347 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700348 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900349
Ray Milkey269ffb92014-04-03 14:43:30 -0700350 @Test
351 public void testSetActionSetTcpUdpSrcPortShort() {
352 FlowEntryAction act = new FlowEntryAction();
353 act.setActionSetTcpUdpSrcPort((short) 1);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900354
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700355 FlowEntryAction actCopy = new FlowEntryAction(act);
356 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900357
Ray Milkey269ffb92014-04-03 14:43:30 -0700358 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700359 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700360 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700361 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700362 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900363
Ray Milkey269ffb92014-04-03 14:43:30 -0700364 @Test
365 public void testSetActionSetTcpUdpDstPortActionSetTcpUdpPort() {
366 FlowEntryAction act = new FlowEntryAction();
367 ActionSetTcpUdpPort setPorts = new FlowEntryAction.ActionSetTcpUdpPort((short) 42);
368 act.setActionSetTcpUdpDstPort(setPorts);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900369
Ray Milkey269ffb92014-04-03 14:43:30 -0700370 assertEquals("action type", FlowEntryAction.ActionValues.ACTION_SET_TP_DST, act.actionType());
371 assertEquals("port should be the same", setPorts.port(), act.actionSetTcpUdpDstPort().port());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900372
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700373 FlowEntryAction actCopy = new FlowEntryAction(act);
374 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900375
Ray Milkey269ffb92014-04-03 14:43:30 -0700376 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700377 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700378 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700379 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700380 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900381
Ray Milkey269ffb92014-04-03 14:43:30 -0700382 @Test
383 public void testSetActionSetTcpUdpDstPortShort() {
384 FlowEntryAction act = new FlowEntryAction();
385 act.setActionSetTcpUdpDstPort((short) 1);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900386
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700387 FlowEntryAction actCopy = new FlowEntryAction(act);
388 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900389
Ray Milkey269ffb92014-04-03 14:43:30 -0700390 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700391 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700392 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700393 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700394 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900395
Ray Milkey269ffb92014-04-03 14:43:30 -0700396 @Test
397 public void testSetActionEnqueueActionEnqueue() {
398 FlowEntryAction act = new FlowEntryAction();
399 ActionEnqueue enq = new FlowEntryAction.ActionEnqueue(new Port((short) 42), 1);
400 act.setActionEnqueue(enq);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900401
Ray Milkey269ffb92014-04-03 14:43:30 -0700402 assertEquals("action type", FlowEntryAction.ActionValues.ACTION_ENQUEUE, act.actionType());
403 assertEquals("port should be the same", enq.port(), act.actionEnqueue().port());
404 assertEquals("queue id should be the same", enq.queueId(), act.actionEnqueue().queueId());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900405
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700406 FlowEntryAction actCopy = new FlowEntryAction(act);
407 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900408
Ray Milkey269ffb92014-04-03 14:43:30 -0700409 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700410 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700411 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700412 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700413 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900414
Ray Milkey269ffb92014-04-03 14:43:30 -0700415 @Test
416 public void testSetActionEnqueuePortInt() {
417 FlowEntryAction act = new FlowEntryAction();
418 act.setActionEnqueue(new Port((short) 42), 1);
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900419
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700420 FlowEntryAction actCopy = new FlowEntryAction(act);
421 FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900422
Ray Milkey269ffb92014-04-03 14:43:30 -0700423 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700424 actCopy.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700425 assertEquals("toString must match between copies", act.toString(),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700426 actCopy2.toString());
Ray Milkey269ffb92014-04-03 14:43:30 -0700427 }
HIGUCHI Yutad8dc9c02013-08-04 06:16:30 +0900428
429}