blob: fe64c9e36c09d11831c5d3aede21cdc63489a989 [file] [log] [blame]
TeruU8b2d1672014-04-25 17:02:56 -07001package net.onrc.onos.apps.proxyarp;
2
3import static org.junit.Assert.assertEquals;
4import static org.junit.Assert.assertTrue;
TeruU8b2d1672014-04-25 17:02:56 -07005import java.net.InetAddress;
6import java.net.UnknownHostException;
7import java.nio.ByteBuffer;
8import java.util.ArrayList;
9import java.util.HashMap;
10import java.util.List;
11import java.util.Map;
12
TeruU8b2d1672014-04-25 17:02:56 -070013import net.floodlightcontroller.core.IFloodlightProviderService;
14import net.floodlightcontroller.core.module.FloodlightModuleContext;
15import net.floodlightcontroller.restserver.IRestApiService;
16import net.floodlightcontroller.util.MACAddress;
17import net.onrc.onos.api.packet.IPacketService;
Yuta HIGUCHI238fa2a2014-05-01 09:56:46 -070018import net.onrc.onos.apps.proxyarp.web.ArpWebRoutable;
TeruU8b2d1672014-04-25 17:02:56 -070019import net.onrc.onos.core.datagrid.IDatagridService;
20import net.onrc.onos.core.datagrid.IEventChannel;
21import net.onrc.onos.core.datagrid.IEventChannelListener;
22import net.onrc.onos.core.devicemanager.IOnosDeviceService;
23import net.onrc.onos.core.flowprogrammer.IFlowPusherService;
24import net.onrc.onos.core.main.config.IConfigInfoService;
25import net.onrc.onos.core.packet.ARP;
26import net.onrc.onos.core.packet.Ethernet;
27import net.onrc.onos.core.packet.IPv4;
TeruU8b2d1672014-04-25 17:02:56 -070028import net.onrc.onos.core.topology.Device;
Jonathan Harte37e4e22014-05-13 19:12:02 -070029import net.onrc.onos.core.topology.ITopologyService;
30import net.onrc.onos.core.topology.Topology;
TeruU8b2d1672014-04-25 17:02:56 -070031import net.onrc.onos.core.topology.Port;
32import net.onrc.onos.core.topology.Switch;
33
34import org.easymock.EasyMock;
35import org.junit.After;
36import org.junit.Before;
37import org.junit.Test;
TeruU8b2d1672014-04-25 17:02:56 -070038
Yuta HIGUCHI33a04972014-06-03 13:00:15 -070039// XXX Commented out as workaround for PowerMock + Hazelcast issue.
40//@RunWith(PowerMockRunner.class)
41//@PowerMockIgnore({ "net.onrc.onos.core.datastore.*", "com.hazelcast.*" })
42//@PrepareOnlyThisForTest({ ProxyArpManager.class })
Ray Milkeyff735142014-05-22 19:06:02 -070043@SuppressWarnings({ "rawtypes", "unchecked" })
TeruU8b2d1672014-04-25 17:02:56 -070044public class ProxyArpManagerTest {
Yuta HIGUCHI1a1b44f2014-06-18 10:56:42 -070045
46 static {
47 // configuration to quickly fall back to instance mode for faster test run
48 System.setProperty("net.onrc.onos.core.datastore.hazelcast.client.attemptLimit", "0");
49 }
50
TeruU8b2d1672014-04-25 17:02:56 -070051 String defaultStrAgingMsec = "60000";
52 String defaultStrCleanupMsec = "60000";
53
54 ProxyArpManager arpManager;
55 FloodlightModuleContext context;
56 IFloodlightProviderService floodligthProviderService;
57 IConfigInfoService configInfoService;
58 IRestApiService restApiService;
59 IDatagridService datagridService;
60 IFlowPusherService flowPusherService;
Jonathan Harte37e4e22014-05-13 19:12:02 -070061 ITopologyService topologyService;
TeruU8b2d1672014-04-25 17:02:56 -070062 IOnosDeviceService onosDeviceService;
63 IPacketService packetService;
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -070064 Map<String, String> configMap;
TeruU8b2d1672014-04-25 17:02:56 -070065
66 String srcStrMac, dstStrMac, cachedStrMac1, cachedStrMac2, srcStrIp, dstStrIp, cachedStrIp1, cachedStrIp2;
67 byte[] srcByteMac, dstByteMac;
68 MACAddress dstMac, srcMac, cachedMac1, cachedMac2;
69 InetAddress srcIp, dstIp, cachedIp1, cachedIp2;
70 Long sw1Dpid;
71 Short sw1Inport, sw1Outport;
72 Short vlanId;
73 ARP arpRequest, arpReply, rarpRequest;
74 Ethernet ethArpRequest, ethArpReply, ethRarpRequest, ethArpOtherOp;
75
Jonathan Harte37e4e22014-05-13 19:12:02 -070076 Topology topology;
TeruU8b2d1672014-04-25 17:02:56 -070077 IEventChannel eg;
78 IEventChannelListener el;
79 Device dev1;
80 Port inPort1, outPort1;
81 Switch sw1;
82 ArpCache arpCache;
83 List<String> arpCacheComparisonList;
84
85 @Before
86 public void setUp() throws Exception {
87 makeTestedObject();
88 makeMock();
89 prepareExpectForInit();
90 prepareExpectForStartUp();
91 prepareExpectForGeneral();
92 }
93
Yuta HIGUCHI33a04972014-06-03 13:00:15 -070094 private void makeTestedObject() throws UnknownHostException {
TeruU8b2d1672014-04-25 17:02:56 -070095 //Made tested values
96 srcStrMac = "00:00:00:00:00:01";
97 dstStrMac = "00:00:00:00:00:02";
98 cachedStrMac1 = "00:00:00:00:00:03";
99 cachedStrMac2 = "00:00:00:00:00:04";
100 srcStrIp = "192.168.0.1";
101 dstStrIp = "192.168.0.2";
102 cachedStrIp1 = "192.168.0.3";
103 cachedStrIp2 = "192.168.0.4";
104 srcByteMac = Ethernet.toMACAddress(srcStrMac);
105 dstByteMac = Ethernet.toMACAddress(dstStrMac);
106 dstMac = new MACAddress(dstByteMac);
107 srcMac = new MACAddress(srcByteMac);
108 cachedMac1 = new MACAddress(Ethernet.toMACAddress(cachedStrMac1));
109 cachedMac2 = new MACAddress(Ethernet.toMACAddress(cachedStrMac2));
Yuta HIGUCHI33a04972014-06-03 13:00:15 -0700110
111 srcIp = InetAddress.getByAddress(IPv4.toIPv4AddressBytes(srcStrIp));
112 dstIp = InetAddress.getByAddress(IPv4.toIPv4AddressBytes(dstStrIp));
113 cachedIp1 = InetAddress.getByAddress(IPv4.toIPv4AddressBytes(cachedStrIp1));
114 cachedIp2 = InetAddress.getByAddress(IPv4.toIPv4AddressBytes(cachedStrIp2));
115
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700116 sw1Dpid = 1L;
TeruU8b2d1672014-04-25 17:02:56 -0700117 sw1Inport = 1;
118 sw1Outport = 2;
119 vlanId = 1;
120
121 //Made tested packets
122 arpRequest = new ARP()
123 .setHardwareType(ARP.HW_TYPE_ETHERNET)
124 .setProtocolType(ARP.PROTO_TYPE_IP)
125 .setHardwareAddressLength((byte) 6)
126 .setProtocolAddressLength((byte) 4)
127 .setOpCode(ARP.OP_REQUEST)
128 .setSenderHardwareAddress(srcByteMac)
129 .setSenderProtocolAddress(srcIp.getAddress())
130 .setTargetProtocolAddress(dstIp.getAddress())
131 .setTargetHardwareAddress(dstByteMac);
132
133 ethArpRequest = (Ethernet) new Ethernet()
134 .setSourceMACAddress(srcStrMac)
135 .setDestinationMACAddress(dstStrMac)
136 .setEtherType(Ethernet.TYPE_ARP)
137 .setVlanID((short) 0)
138 .setPayload(arpRequest);
139
140 arpReply = new ARP()
141 .setHardwareType(ARP.HW_TYPE_ETHERNET)
142 .setProtocolType(ARP.PROTO_TYPE_IP)
143 .setHardwareAddressLength((byte) 6)
144 .setProtocolAddressLength((byte) 4)
145 .setOpCode(ARP.OP_RARP_REPLY)
146 .setSenderHardwareAddress(srcByteMac)
147 .setSenderProtocolAddress(srcIp.getAddress())
148 .setTargetProtocolAddress(dstIp.getAddress())
149 .setTargetHardwareAddress(dstByteMac);
150
151 ethArpReply = (Ethernet) new Ethernet()
152 .setSourceMACAddress(srcStrMac)
153 .setDestinationMACAddress(dstStrMac)
154 .setEtherType(Ethernet.TYPE_ARP)
155 .setVlanID((short) 0)
156 .setPayload(arpReply);
157
158 rarpRequest = new ARP()
159 .setHardwareType(ARP.HW_TYPE_ETHERNET)
160 .setProtocolType(ARP.PROTO_TYPE_IP)
161 .setHardwareAddressLength((byte) 6)
162 .setProtocolAddressLength((byte) 4)
163 .setOpCode(ARP.OP_RARP_REQUEST)
164 .setSenderHardwareAddress(srcByteMac)
165 .setSenderProtocolAddress(srcIp.getAddress())
166 .setTargetProtocolAddress(dstIp.getAddress())
167 .setTargetHardwareAddress(dstByteMac);
168
169 ethRarpRequest = (Ethernet) new Ethernet()
170 .setSourceMACAddress(srcStrMac)
171 .setDestinationMACAddress(dstStrMac)
172 .setEtherType(Ethernet.TYPE_RARP)
173 .setVlanID((short) 0)
174 .setPayload(rarpRequest);
175
176 ethArpOtherOp = (Ethernet) new Ethernet()
177 .setSourceMACAddress(srcStrMac)
178 .setDestinationMACAddress(dstStrMac)
179 .setEtherType(Ethernet.TYPE_ARP)
180 .setVlanID((short) 0)
181 .setPayload(rarpRequest);
182
183 //Made tested objects
184 arpCache = new ArpCache();
Yuta HIGUCHI238fa2a2014-05-01 09:56:46 -0700185 arpCache.setArpEntryTimeoutConfig(Long.parseLong(defaultStrCleanupMsec));
TeruU8b2d1672014-04-25 17:02:56 -0700186 arpCache.update(cachedIp1, cachedMac1);
Yuta HIGUCHI238fa2a2014-05-01 09:56:46 -0700187 arpCache.update(cachedIp2, cachedMac2);
188
189 arpCacheComparisonList = new ArrayList<String>();
TeruU8b2d1672014-04-25 17:02:56 -0700190 arpCacheComparisonList.add(cachedStrIp1
191 + " => "
192 + cachedStrMac1
193 + " : VALID");
TeruU8b2d1672014-04-25 17:02:56 -0700194 arpCacheComparisonList.add(cachedStrIp2
195 + " => "
196 + cachedStrMac2
197 + " : VALID");
198
199 arpManager = new ProxyArpManager();
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700200 configMap = new HashMap<String, String>();
TeruU8b2d1672014-04-25 17:02:56 -0700201 }
202
203 private void makeMock() {
204 //Mock floodlight modules
205 context = EasyMock.createMock(FloodlightModuleContext.class);
206 floodligthProviderService = EasyMock.createMock(IFloodlightProviderService.class);
207 configInfoService = EasyMock.createMock(IConfigInfoService.class);
208 restApiService = EasyMock.createMock(IRestApiService.class);
209 datagridService = EasyMock.createMock(IDatagridService.class);
210 flowPusherService = EasyMock.createMock(IFlowPusherService.class);
Jonathan Harte37e4e22014-05-13 19:12:02 -0700211 topologyService = EasyMock.createMock(ITopologyService.class);
TeruU8b2d1672014-04-25 17:02:56 -0700212 onosDeviceService = EasyMock.createMock(IOnosDeviceService.class);
213 packetService = EasyMock.createMock(IPacketService.class);
214 eg = EasyMock.createMock(IEventChannel.class);
215 el = EasyMock.createMock(IEventChannelListener.class);
216
Jonathan Harte37e4e22014-05-13 19:12:02 -0700217 //Mock Topology related data
218 topology = EasyMock.createMock(Topology.class);
TeruU8b2d1672014-04-25 17:02:56 -0700219 dev1 = EasyMock.createMock(Device.class);
220 inPort1 = EasyMock.createMock(Port.class);
221 outPort1 = EasyMock.createMock(Port.class);
222 sw1 = EasyMock.createMock(Switch.class);
223 }
224
225 private void prepareExpectForGeneral() {
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700226 EasyMock.expect(inPort1.getNumber()).andReturn((long) sw1Inport).anyTimes();
227 EasyMock.expect(outPort1.getNumber()).andReturn((long) sw1Outport).anyTimes();
TeruU8b2d1672014-04-25 17:02:56 -0700228 EasyMock.expect(outPort1.getOutgoingLink()).andReturn(null).anyTimes();
229 EasyMock.expect(outPort1.getIncomingLink()).andReturn(null).anyTimes();
230 EasyMock.expect(outPort1.getSwitch()).andReturn(sw1).anyTimes();
231 EasyMock.expect(sw1.getDpid()).andReturn(sw1Dpid).anyTimes();
232 }
233
234 private void prepareExpectForInit() {
235 EasyMock.expect(context.getServiceImpl(IFloodlightProviderService.class)).andReturn(floodligthProviderService);
236 EasyMock.expect(context.getServiceImpl(IConfigInfoService.class)).andReturn(configInfoService);
237 EasyMock.expect(context.getServiceImpl(IRestApiService.class)).andReturn(restApiService);
238 EasyMock.expect(context.getServiceImpl(IDatagridService.class)).andReturn(datagridService);
239 EasyMock.expect(context.getServiceImpl(IFlowPusherService.class)).andReturn(flowPusherService);
Jonathan Harte37e4e22014-05-13 19:12:02 -0700240 EasyMock.expect(context.getServiceImpl(ITopologyService.class)).andReturn(topologyService);
TeruU8b2d1672014-04-25 17:02:56 -0700241 EasyMock.expect(context.getServiceImpl(IOnosDeviceService.class)).andReturn(onosDeviceService);
242 EasyMock.expect(context.getServiceImpl(IPacketService.class)).andReturn(packetService);
243 }
244
245 private void prepareExpectForStartUp() {
Yuta HIGUCHI33a04972014-06-03 13:00:15 -0700246 // XXX Commented out as workaround for PowerMock + Hazelcast issue.
247// try {
248// PowerMock.expectNew(ArpCache.class).andReturn(arpCache);
249// } catch (Exception e) {
250// fail("Exception:" + e.getMessage());
251// }
252// PowerMock.replayAll();
TeruU8b2d1672014-04-25 17:02:56 -0700253 EasyMock.expect(configInfoService.getVlan()).andReturn(vlanId);
254 restApiService.addRestletRoutable(EasyMock.isA(ArpWebRoutable.class));
255 EasyMock.expectLastCall();
256 packetService.registerPacketListener(arpManager);
257 EasyMock.expectLastCall();
Jonathan Harte37e4e22014-05-13 19:12:02 -0700258 EasyMock.expect(topologyService.getTopology()).andReturn(topology);
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700259 EasyMock.expect(datagridService.addListener(EasyMock.<String>anyObject(),
260 EasyMock.isA(IEventChannelListener.class),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700261 (Class) EasyMock.anyObject(), (Class) EasyMock.anyObject())).andReturn(eg).anyTimes();
TeruU8b2d1672014-04-25 17:02:56 -0700262 List<ArpCacheNotification> list = new ArrayList<ArpCacheNotification>();
263 EasyMock.expect(eg.getAllEntries()).andReturn(list);
264 }
265
266 private void prepareExpectForLearnArp() {
267 eg.addEntry(EasyMock.eq(srcIp.toString()), EasyMock.isA(ArpCacheNotification.class));
268 EasyMock.expectLastCall();
269 }
270
271 @After
272 public void tearDown() throws Exception {
Yuta HIGUCHI238fa2a2014-05-01 09:56:46 -0700273 arpCache = null;
TeruU8b2d1672014-04-25 17:02:56 -0700274 }
275
276 @Test
277 public void testConfigTimeWithNoConfig() {
278 Map<String, String> config = new HashMap<String, String>();
279 EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
280
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700281 EasyMock.replay(context, floodligthProviderService, configInfoService,
282 restApiService, datagridService, flowPusherService,
283 topologyService, onosDeviceService, packetService, topology, eg,
284 el, dev1, inPort1, sw1);
TeruU8b2d1672014-04-25 17:02:56 -0700285 arpManager.init(context);
286 arpManager.startUp(context);
287 assertEquals(defaultStrAgingMsec, String.valueOf(arpManager.getArpEntryTimeout()));
288 assertEquals(defaultStrCleanupMsec, String.valueOf(arpManager.getArpCleaningTimerPeriod()));
289 }
290
291 @Test
292 public void testConfigTimeWithWrongParameter() {
293 Map<String, String> config = new HashMap<String, String>();
294 String strAgingMsec = "aaaaa";
295 String strCleanupMsec = "bbbbb";
296 config.put("agingmsec", strAgingMsec);
297 config.put("cleanupmsec", strCleanupMsec);
298 EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
299
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700300 EasyMock.replay(context, floodligthProviderService, configInfoService,
301 restApiService, datagridService, flowPusherService,
302 topologyService, onosDeviceService, packetService, topology,
303 eg, el, dev1, inPort1, sw1);
TeruU8b2d1672014-04-25 17:02:56 -0700304 arpManager.init(context);
305 arpManager.startUp(context);
306 assertEquals(defaultStrAgingMsec, String.valueOf(arpManager.getArpEntryTimeout()));
307 assertEquals(defaultStrCleanupMsec, String.valueOf(arpManager.getArpCleaningTimerPeriod()));
308 }
309
310 @Test
311 public void testConfigTime() {
312 String strAgingMsec = "10000";
313 String strCleanupMsec = "10000";
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700314 configMap.put("agingmsec", strAgingMsec);
315 configMap.put("cleanupmsec", strCleanupMsec);
316 EasyMock.expect(context.getConfigParams(arpManager)).andReturn(configMap);
TeruU8b2d1672014-04-25 17:02:56 -0700317
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700318 EasyMock.replay(context, floodligthProviderService, configInfoService,
319 restApiService, datagridService, flowPusherService,
320 topologyService, onosDeviceService, packetService, topology,
321 eg, el, dev1, inPort1, sw1);
TeruU8b2d1672014-04-25 17:02:56 -0700322 arpManager.init(context);
323 arpManager.startUp(context);
324 assertEquals(strAgingMsec, String.valueOf(arpManager.getArpEntryTimeout()));
325 assertEquals(strCleanupMsec, String.valueOf(arpManager.getArpCleaningTimerPeriod()));
326 }
327
328 @Test
329 public void testGetMacAddress() {
330 Map<String, String> config = new HashMap<String, String>();
331 EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
332
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700333 EasyMock.replay(context, floodligthProviderService, configInfoService,
334 restApiService, datagridService, flowPusherService,
335 topologyService, onosDeviceService, packetService, topology,
336 eg, el, dev1, inPort1, sw1);
TeruU8b2d1672014-04-25 17:02:56 -0700337 arpManager.init(context);
338 arpManager.startUp(context);
Yuta HIGUCHI33a04972014-06-03 13:00:15 -0700339
340 // XXX workaround for PowerMock + Hazelcast issue.
341 this.arpManager.debugReplaceArpCache(arpCache);
342
TeruU8b2d1672014-04-25 17:02:56 -0700343 MACAddress mac = arpManager.getMacAddress(cachedIp1);
344 assertEquals(cachedMac1, mac);
345 }
346
347 @Test
348 public void testGetMappings() {
349 Map<String, String> config = new HashMap<String, String>();
350 EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
351
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700352 EasyMock.replay(context, floodligthProviderService, configInfoService,
353 restApiService, datagridService, flowPusherService,
354 topologyService, onosDeviceService, packetService, topology,
355 eg, el, dev1, inPort1, sw1);
TeruU8b2d1672014-04-25 17:02:56 -0700356 arpManager.init(context);
357 arpManager.startUp(context);
358 List<String> list = arpManager.getMappings();
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700359 for (String str : list) {
TeruU8b2d1672014-04-25 17:02:56 -0700360 assertTrue(arpCacheComparisonList.contains(str));
361 }
362 }
363
364 @Test
365 public void testReceivePacketWithNoArpPacket() {
366 Map<String, String> config = new HashMap<String, String>();
367 EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
368
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700369 EasyMock.replay(context, floodligthProviderService, configInfoService,
370 restApiService, datagridService, flowPusherService,
371 topologyService, onosDeviceService, packetService, topology,
372 eg, el, dev1, inPort1, sw1);
TeruU8b2d1672014-04-25 17:02:56 -0700373 arpManager.init(context);
374 arpManager.startUp(context);
375 arpManager.receive(sw1, inPort1, ethRarpRequest);
376 }
377
378 @Test
379 public void testReceivePacketWithOtherOpCode() {
380 Map<String, String> config = new HashMap<String, String>();
381 EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
382
383 prepareExpectForLearnArp();
384
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700385 EasyMock.replay(context, floodligthProviderService, configInfoService,
386 restApiService, datagridService, flowPusherService,
387 topologyService, onosDeviceService, packetService, topology,
388 eg, el, dev1, inPort1, sw1);
TeruU8b2d1672014-04-25 17:02:56 -0700389 arpManager.init(context);
390 arpManager.startUp(context);
391 arpManager.receive(sw1, inPort1, ethArpOtherOp);
392 }
393
394 @Test
395 public void testClassifyPacketToSendArpReplyNotification() {
396 Map<String, String> config = new HashMap<String, String>();
397 EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
398
399 prepareExpectForLearnArp();
400
401 ArpReplyNotification value =
402 new ArpReplyNotification(ByteBuffer.wrap(dstIp.getAddress()).getInt(), dstMac);
403 eg.addTransientEntry(srcMac.toLong(), value);
404 EasyMock.expectLastCall();
405 EasyMock.expect(context.getServiceImpl(IDatagridService.class)).andReturn(datagridService);
406
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700407 EasyMock.replay(context, floodligthProviderService, configInfoService,
408 restApiService, datagridService, flowPusherService,
409 topologyService, onosDeviceService, packetService, topology,
410 eg, el, dev1, inPort1, sw1);
TeruU8b2d1672014-04-25 17:02:56 -0700411 arpManager.init(context);
412 arpManager.startUp(context);
413 arpManager.receive(sw1, inPort1, ethArpReply);
414 }
415
416 @Test
417 public void testClassifyPacketToHandleArpRequest() {
418 Map<String, String> config = new HashMap<String, String>();
419 EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
420
421 prepareExpectForLearnArp();
422
423 EasyMock.expect(configInfoService.fromExternalNetwork(EasyMock.anyLong(), EasyMock.anyShort())).andReturn(true);
424 EasyMock.expect(configInfoService.isInterfaceAddress(dstIp)).andReturn(false);
425
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700426 EasyMock.replay(context, floodligthProviderService, configInfoService,
427 restApiService, datagridService, flowPusherService,
428 topologyService, onosDeviceService, packetService, topology,
429 eg, el, dev1, inPort1, sw1);
TeruU8b2d1672014-04-25 17:02:56 -0700430 arpManager.init(context);
431 arpManager.startUp(context);
432 arpManager.receive(sw1, inPort1, ethArpRequest);
433 }
434
435 @Test
436 public void testClassifyPacketToHandleArpRequest2() {
437 List<Port> portList = new ArrayList<Port>();
438 portList.add(outPort1);
439
440 Map<String, String> config = new HashMap<String, String>();
441 EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
442
443 prepareExpectForLearnArp();
444
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700445 EasyMock.expect(configInfoService.fromExternalNetwork(
446 EasyMock.anyLong(), EasyMock.anyShort())).andReturn(false);
Jonathan Harte37e4e22014-05-13 19:12:02 -0700447 topology.acquireReadLock();
TeruU8b2d1672014-04-25 17:02:56 -0700448 EasyMock.expectLastCall();
Jonathan Harte37e4e22014-05-13 19:12:02 -0700449 EasyMock.expect(topology.getDeviceByMac(dstMac)).andReturn(dev1);
450 topology.releaseReadLock();
TeruU8b2d1672014-04-25 17:02:56 -0700451 EasyMock.expectLastCall();
452 EasyMock.expect(dev1.getAttachmentPoints()).andReturn(portList);
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700453 eg.addTransientEntry(EasyMock.anyLong(), EasyMock.anyObject());
TeruU8b2d1672014-04-25 17:02:56 -0700454 EasyMock.expectLastCall();
455
456 EasyMock.replay(context, configInfoService, restApiService, floodligthProviderService,
Jonathan Harte37e4e22014-05-13 19:12:02 -0700457 topologyService, datagridService, eg, topology, dev1, inPort1, outPort1, sw1);
TeruU8b2d1672014-04-25 17:02:56 -0700458 arpManager.init(context);
459 arpManager.startUp(context);
460 arpManager.receive(sw1, inPort1, ethArpRequest);
461 }
462}