blob: a38a90bf2add7fd5d754b21dea3d581196ade644 [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;
Yuta HIGUCHI238fa2a2014-05-01 09:56:46 -07005import static org.junit.Assert.fail;
TeruU8b2d1672014-04-25 17:02:56 -07006
7import java.net.InetAddress;
8import java.net.UnknownHostException;
9import java.nio.ByteBuffer;
10import java.util.ArrayList;
11import java.util.HashMap;
12import java.util.List;
13import java.util.Map;
14
TeruU8b2d1672014-04-25 17:02:56 -070015import net.floodlightcontroller.core.IFloodlightProviderService;
16import net.floodlightcontroller.core.module.FloodlightModuleContext;
17import net.floodlightcontroller.restserver.IRestApiService;
18import net.floodlightcontroller.util.MACAddress;
19import net.onrc.onos.api.packet.IPacketService;
Yuta HIGUCHI238fa2a2014-05-01 09:56:46 -070020import net.onrc.onos.apps.proxyarp.web.ArpWebRoutable;
TeruU8b2d1672014-04-25 17:02:56 -070021import net.onrc.onos.core.datagrid.IDatagridService;
22import net.onrc.onos.core.datagrid.IEventChannel;
23import net.onrc.onos.core.datagrid.IEventChannelListener;
24import net.onrc.onos.core.devicemanager.IOnosDeviceService;
25import net.onrc.onos.core.flowprogrammer.IFlowPusherService;
26import net.onrc.onos.core.main.config.IConfigInfoService;
27import net.onrc.onos.core.packet.ARP;
28import net.onrc.onos.core.packet.Ethernet;
29import net.onrc.onos.core.packet.IPv4;
TeruU8b2d1672014-04-25 17:02:56 -070030import net.onrc.onos.core.topology.Device;
Jonathan Harte37e4e22014-05-13 19:12:02 -070031import net.onrc.onos.core.topology.ITopologyService;
32import net.onrc.onos.core.topology.Topology;
TeruU8b2d1672014-04-25 17:02:56 -070033import net.onrc.onos.core.topology.Port;
34import net.onrc.onos.core.topology.Switch;
35
36import org.easymock.EasyMock;
37import org.junit.After;
38import org.junit.Before;
39import org.junit.Test;
40import org.junit.runner.RunWith;
41import org.powermock.api.easymock.PowerMock;
42import org.powermock.core.classloader.annotations.PrepareForTest;
43import org.powermock.modules.junit4.PowerMockRunner;
44
45@RunWith(PowerMockRunner.class)
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -070046@PrepareForTest({ ProxyArpManager.class, ArpCache.class })
Ray Milkeyff735142014-05-22 19:06:02 -070047@SuppressWarnings({ "rawtypes", "unchecked" })
TeruU8b2d1672014-04-25 17:02:56 -070048public class ProxyArpManagerTest {
49 String defaultStrAgingMsec = "60000";
50 String defaultStrCleanupMsec = "60000";
51
52 ProxyArpManager arpManager;
53 FloodlightModuleContext context;
54 IFloodlightProviderService floodligthProviderService;
55 IConfigInfoService configInfoService;
56 IRestApiService restApiService;
57 IDatagridService datagridService;
58 IFlowPusherService flowPusherService;
Jonathan Harte37e4e22014-05-13 19:12:02 -070059 ITopologyService topologyService;
TeruU8b2d1672014-04-25 17:02:56 -070060 IOnosDeviceService onosDeviceService;
61 IPacketService packetService;
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -070062 Map<String, String> configMap;
TeruU8b2d1672014-04-25 17:02:56 -070063
64 String srcStrMac, dstStrMac, cachedStrMac1, cachedStrMac2, srcStrIp, dstStrIp, cachedStrIp1, cachedStrIp2;
65 byte[] srcByteMac, dstByteMac;
66 MACAddress dstMac, srcMac, cachedMac1, cachedMac2;
67 InetAddress srcIp, dstIp, cachedIp1, cachedIp2;
68 Long sw1Dpid;
69 Short sw1Inport, sw1Outport;
70 Short vlanId;
71 ARP arpRequest, arpReply, rarpRequest;
72 Ethernet ethArpRequest, ethArpReply, ethRarpRequest, ethArpOtherOp;
73
Jonathan Harte37e4e22014-05-13 19:12:02 -070074 Topology topology;
TeruU8b2d1672014-04-25 17:02:56 -070075 IEventChannel eg;
76 IEventChannelListener el;
77 Device dev1;
78 Port inPort1, outPort1;
79 Switch sw1;
80 ArpCache arpCache;
81 List<String> arpCacheComparisonList;
82
83 @Before
84 public void setUp() throws Exception {
85 makeTestedObject();
86 makeMock();
87 prepareExpectForInit();
88 prepareExpectForStartUp();
89 prepareExpectForGeneral();
90 }
91
92 private void makeTestedObject() {
93 //Made tested values
94 srcStrMac = "00:00:00:00:00:01";
95 dstStrMac = "00:00:00:00:00:02";
96 cachedStrMac1 = "00:00:00:00:00:03";
97 cachedStrMac2 = "00:00:00:00:00:04";
98 srcStrIp = "192.168.0.1";
99 dstStrIp = "192.168.0.2";
100 cachedStrIp1 = "192.168.0.3";
101 cachedStrIp2 = "192.168.0.4";
102 srcByteMac = Ethernet.toMACAddress(srcStrMac);
103 dstByteMac = Ethernet.toMACAddress(dstStrMac);
104 dstMac = new MACAddress(dstByteMac);
105 srcMac = new MACAddress(srcByteMac);
106 cachedMac1 = new MACAddress(Ethernet.toMACAddress(cachedStrMac1));
107 cachedMac2 = new MACAddress(Ethernet.toMACAddress(cachedStrMac2));
108 srcIp = null;
109 dstIp = null;
110 cachedIp1 = null;
111 cachedIp2 = null;
112 try {
113 srcIp = InetAddress.getByAddress(IPv4.toIPv4AddressBytes(srcStrIp));
114 dstIp = InetAddress.getByAddress(IPv4.toIPv4AddressBytes(dstStrIp));
115 cachedIp1 = InetAddress.getByAddress(IPv4.toIPv4AddressBytes(cachedStrIp1));
116 cachedIp2 = InetAddress.getByAddress(IPv4.toIPv4AddressBytes(cachedStrIp2));
117 } catch (UnknownHostException e) {
118 e.printStackTrace();
119 }
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700120 sw1Dpid = 1L;
TeruU8b2d1672014-04-25 17:02:56 -0700121 sw1Inport = 1;
122 sw1Outport = 2;
123 vlanId = 1;
124
125 //Made tested packets
126 arpRequest = new ARP()
127 .setHardwareType(ARP.HW_TYPE_ETHERNET)
128 .setProtocolType(ARP.PROTO_TYPE_IP)
129 .setHardwareAddressLength((byte) 6)
130 .setProtocolAddressLength((byte) 4)
131 .setOpCode(ARP.OP_REQUEST)
132 .setSenderHardwareAddress(srcByteMac)
133 .setSenderProtocolAddress(srcIp.getAddress())
134 .setTargetProtocolAddress(dstIp.getAddress())
135 .setTargetHardwareAddress(dstByteMac);
136
137 ethArpRequest = (Ethernet) new Ethernet()
138 .setSourceMACAddress(srcStrMac)
139 .setDestinationMACAddress(dstStrMac)
140 .setEtherType(Ethernet.TYPE_ARP)
141 .setVlanID((short) 0)
142 .setPayload(arpRequest);
143
144 arpReply = new ARP()
145 .setHardwareType(ARP.HW_TYPE_ETHERNET)
146 .setProtocolType(ARP.PROTO_TYPE_IP)
147 .setHardwareAddressLength((byte) 6)
148 .setProtocolAddressLength((byte) 4)
149 .setOpCode(ARP.OP_RARP_REPLY)
150 .setSenderHardwareAddress(srcByteMac)
151 .setSenderProtocolAddress(srcIp.getAddress())
152 .setTargetProtocolAddress(dstIp.getAddress())
153 .setTargetHardwareAddress(dstByteMac);
154
155 ethArpReply = (Ethernet) new Ethernet()
156 .setSourceMACAddress(srcStrMac)
157 .setDestinationMACAddress(dstStrMac)
158 .setEtherType(Ethernet.TYPE_ARP)
159 .setVlanID((short) 0)
160 .setPayload(arpReply);
161
162 rarpRequest = new ARP()
163 .setHardwareType(ARP.HW_TYPE_ETHERNET)
164 .setProtocolType(ARP.PROTO_TYPE_IP)
165 .setHardwareAddressLength((byte) 6)
166 .setProtocolAddressLength((byte) 4)
167 .setOpCode(ARP.OP_RARP_REQUEST)
168 .setSenderHardwareAddress(srcByteMac)
169 .setSenderProtocolAddress(srcIp.getAddress())
170 .setTargetProtocolAddress(dstIp.getAddress())
171 .setTargetHardwareAddress(dstByteMac);
172
173 ethRarpRequest = (Ethernet) new Ethernet()
174 .setSourceMACAddress(srcStrMac)
175 .setDestinationMACAddress(dstStrMac)
176 .setEtherType(Ethernet.TYPE_RARP)
177 .setVlanID((short) 0)
178 .setPayload(rarpRequest);
179
180 ethArpOtherOp = (Ethernet) new Ethernet()
181 .setSourceMACAddress(srcStrMac)
182 .setDestinationMACAddress(dstStrMac)
183 .setEtherType(Ethernet.TYPE_ARP)
184 .setVlanID((short) 0)
185 .setPayload(rarpRequest);
186
187 //Made tested objects
188 arpCache = new ArpCache();
Yuta HIGUCHI238fa2a2014-05-01 09:56:46 -0700189 arpCache.setArpEntryTimeoutConfig(Long.parseLong(defaultStrCleanupMsec));
TeruU8b2d1672014-04-25 17:02:56 -0700190 arpCache.update(cachedIp1, cachedMac1);
Yuta HIGUCHI238fa2a2014-05-01 09:56:46 -0700191 arpCache.update(cachedIp2, cachedMac2);
192
193 arpCacheComparisonList = new ArrayList<String>();
TeruU8b2d1672014-04-25 17:02:56 -0700194 arpCacheComparisonList.add(cachedStrIp1
195 + " => "
196 + cachedStrMac1
197 + " : VALID");
TeruU8b2d1672014-04-25 17:02:56 -0700198 arpCacheComparisonList.add(cachedStrIp2
199 + " => "
200 + cachedStrMac2
201 + " : VALID");
202
203 arpManager = new ProxyArpManager();
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700204 configMap = new HashMap<String, String>();
TeruU8b2d1672014-04-25 17:02:56 -0700205 }
206
207 private void makeMock() {
208 //Mock floodlight modules
209 context = EasyMock.createMock(FloodlightModuleContext.class);
210 floodligthProviderService = EasyMock.createMock(IFloodlightProviderService.class);
211 configInfoService = EasyMock.createMock(IConfigInfoService.class);
212 restApiService = EasyMock.createMock(IRestApiService.class);
213 datagridService = EasyMock.createMock(IDatagridService.class);
214 flowPusherService = EasyMock.createMock(IFlowPusherService.class);
Jonathan Harte37e4e22014-05-13 19:12:02 -0700215 topologyService = EasyMock.createMock(ITopologyService.class);
TeruU8b2d1672014-04-25 17:02:56 -0700216 onosDeviceService = EasyMock.createMock(IOnosDeviceService.class);
217 packetService = EasyMock.createMock(IPacketService.class);
218 eg = EasyMock.createMock(IEventChannel.class);
219 el = EasyMock.createMock(IEventChannelListener.class);
220
Jonathan Harte37e4e22014-05-13 19:12:02 -0700221 //Mock Topology related data
222 topology = EasyMock.createMock(Topology.class);
TeruU8b2d1672014-04-25 17:02:56 -0700223 dev1 = EasyMock.createMock(Device.class);
224 inPort1 = EasyMock.createMock(Port.class);
225 outPort1 = EasyMock.createMock(Port.class);
226 sw1 = EasyMock.createMock(Switch.class);
227 }
228
229 private void prepareExpectForGeneral() {
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700230 EasyMock.expect(inPort1.getNumber()).andReturn((long) sw1Inport).anyTimes();
231 EasyMock.expect(outPort1.getNumber()).andReturn((long) sw1Outport).anyTimes();
TeruU8b2d1672014-04-25 17:02:56 -0700232 EasyMock.expect(outPort1.getOutgoingLink()).andReturn(null).anyTimes();
233 EasyMock.expect(outPort1.getIncomingLink()).andReturn(null).anyTimes();
234 EasyMock.expect(outPort1.getSwitch()).andReturn(sw1).anyTimes();
235 EasyMock.expect(sw1.getDpid()).andReturn(sw1Dpid).anyTimes();
236 }
237
238 private void prepareExpectForInit() {
239 EasyMock.expect(context.getServiceImpl(IFloodlightProviderService.class)).andReturn(floodligthProviderService);
240 EasyMock.expect(context.getServiceImpl(IConfigInfoService.class)).andReturn(configInfoService);
241 EasyMock.expect(context.getServiceImpl(IRestApiService.class)).andReturn(restApiService);
242 EasyMock.expect(context.getServiceImpl(IDatagridService.class)).andReturn(datagridService);
243 EasyMock.expect(context.getServiceImpl(IFlowPusherService.class)).andReturn(flowPusherService);
Jonathan Harte37e4e22014-05-13 19:12:02 -0700244 EasyMock.expect(context.getServiceImpl(ITopologyService.class)).andReturn(topologyService);
TeruU8b2d1672014-04-25 17:02:56 -0700245 EasyMock.expect(context.getServiceImpl(IOnosDeviceService.class)).andReturn(onosDeviceService);
246 EasyMock.expect(context.getServiceImpl(IPacketService.class)).andReturn(packetService);
247 }
248
249 private void prepareExpectForStartUp() {
250 try {
251 PowerMock.expectNew(ArpCache.class).andReturn(arpCache);
252 } catch (Exception e) {
Yuta HIGUCHI238fa2a2014-05-01 09:56:46 -0700253 fail("Exception:" + e.getMessage());
TeruU8b2d1672014-04-25 17:02:56 -0700254 }
255 PowerMock.replayAll();
256 EasyMock.expect(configInfoService.getVlan()).andReturn(vlanId);
257 restApiService.addRestletRoutable(EasyMock.isA(ArpWebRoutable.class));
258 EasyMock.expectLastCall();
259 packetService.registerPacketListener(arpManager);
260 EasyMock.expectLastCall();
Jonathan Harte37e4e22014-05-13 19:12:02 -0700261 EasyMock.expect(topologyService.getTopology()).andReturn(topology);
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700262 EasyMock.expect(datagridService.addListener(EasyMock.<String>anyObject(),
263 EasyMock.isA(IEventChannelListener.class),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700264 (Class) EasyMock.anyObject(), (Class) EasyMock.anyObject())).andReturn(eg).anyTimes();
TeruU8b2d1672014-04-25 17:02:56 -0700265 List<ArpCacheNotification> list = new ArrayList<ArpCacheNotification>();
266 EasyMock.expect(eg.getAllEntries()).andReturn(list);
267 }
268
269 private void prepareExpectForLearnArp() {
270 eg.addEntry(EasyMock.eq(srcIp.toString()), EasyMock.isA(ArpCacheNotification.class));
271 EasyMock.expectLastCall();
272 }
273
274 @After
275 public void tearDown() throws Exception {
Yuta HIGUCHI238fa2a2014-05-01 09:56:46 -0700276 arpCache = null;
TeruU8b2d1672014-04-25 17:02:56 -0700277 }
278
279 @Test
280 public void testConfigTimeWithNoConfig() {
281 Map<String, String> config = new HashMap<String, String>();
282 EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
283
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700284 EasyMock.replay(context, floodligthProviderService, configInfoService,
285 restApiService, datagridService, flowPusherService,
286 topologyService, onosDeviceService, packetService, topology, eg,
287 el, dev1, inPort1, sw1);
TeruU8b2d1672014-04-25 17:02:56 -0700288 arpManager.init(context);
289 arpManager.startUp(context);
290 assertEquals(defaultStrAgingMsec, String.valueOf(arpManager.getArpEntryTimeout()));
291 assertEquals(defaultStrCleanupMsec, String.valueOf(arpManager.getArpCleaningTimerPeriod()));
292 }
293
294 @Test
295 public void testConfigTimeWithWrongParameter() {
296 Map<String, String> config = new HashMap<String, String>();
297 String strAgingMsec = "aaaaa";
298 String strCleanupMsec = "bbbbb";
299 config.put("agingmsec", strAgingMsec);
300 config.put("cleanupmsec", strCleanupMsec);
301 EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
302
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700303 EasyMock.replay(context, floodligthProviderService, configInfoService,
304 restApiService, datagridService, flowPusherService,
305 topologyService, onosDeviceService, packetService, topology,
306 eg, el, dev1, inPort1, sw1);
TeruU8b2d1672014-04-25 17:02:56 -0700307 arpManager.init(context);
308 arpManager.startUp(context);
309 assertEquals(defaultStrAgingMsec, String.valueOf(arpManager.getArpEntryTimeout()));
310 assertEquals(defaultStrCleanupMsec, String.valueOf(arpManager.getArpCleaningTimerPeriod()));
311 }
312
313 @Test
314 public void testConfigTime() {
315 String strAgingMsec = "10000";
316 String strCleanupMsec = "10000";
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700317 configMap.put("agingmsec", strAgingMsec);
318 configMap.put("cleanupmsec", strCleanupMsec);
319 EasyMock.expect(context.getConfigParams(arpManager)).andReturn(configMap);
TeruU8b2d1672014-04-25 17:02:56 -0700320
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700321 EasyMock.replay(context, floodligthProviderService, configInfoService,
322 restApiService, datagridService, flowPusherService,
323 topologyService, onosDeviceService, packetService, topology,
324 eg, el, dev1, inPort1, sw1);
TeruU8b2d1672014-04-25 17:02:56 -0700325 arpManager.init(context);
326 arpManager.startUp(context);
327 assertEquals(strAgingMsec, String.valueOf(arpManager.getArpEntryTimeout()));
328 assertEquals(strCleanupMsec, String.valueOf(arpManager.getArpCleaningTimerPeriod()));
329 }
330
331 @Test
332 public void testGetMacAddress() {
333 Map<String, String> config = new HashMap<String, String>();
334 EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
335
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700336 EasyMock.replay(context, floodligthProviderService, configInfoService,
337 restApiService, datagridService, flowPusherService,
338 topologyService, onosDeviceService, packetService, topology,
339 eg, el, dev1, inPort1, sw1);
TeruU8b2d1672014-04-25 17:02:56 -0700340 arpManager.init(context);
341 arpManager.startUp(context);
342 MACAddress mac = arpManager.getMacAddress(cachedIp1);
343 assertEquals(cachedMac1, mac);
344 }
345
346 @Test
347 public void testGetMappings() {
348 Map<String, String> config = new HashMap<String, String>();
349 EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
350
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700351 EasyMock.replay(context, floodligthProviderService, configInfoService,
352 restApiService, datagridService, flowPusherService,
353 topologyService, onosDeviceService, packetService, topology,
354 eg, el, dev1, inPort1, sw1);
TeruU8b2d1672014-04-25 17:02:56 -0700355 arpManager.init(context);
356 arpManager.startUp(context);
357 List<String> list = arpManager.getMappings();
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700358 for (String str : list) {
TeruU8b2d1672014-04-25 17:02:56 -0700359 assertTrue(arpCacheComparisonList.contains(str));
360 }
361 }
362
363 @Test
364 public void testReceivePacketWithNoArpPacket() {
365 Map<String, String> config = new HashMap<String, String>();
366 EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
367
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700368 EasyMock.replay(context, floodligthProviderService, configInfoService,
369 restApiService, datagridService, flowPusherService,
370 topologyService, onosDeviceService, packetService, topology,
371 eg, el, dev1, inPort1, sw1);
TeruU8b2d1672014-04-25 17:02:56 -0700372 arpManager.init(context);
373 arpManager.startUp(context);
374 arpManager.receive(sw1, inPort1, ethRarpRequest);
375 }
376
377 @Test
378 public void testReceivePacketWithOtherOpCode() {
379 Map<String, String> config = new HashMap<String, String>();
380 EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
381
382 prepareExpectForLearnArp();
383
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700384 EasyMock.replay(context, floodligthProviderService, configInfoService,
385 restApiService, datagridService, flowPusherService,
386 topologyService, onosDeviceService, packetService, topology,
387 eg, el, dev1, inPort1, sw1);
TeruU8b2d1672014-04-25 17:02:56 -0700388 arpManager.init(context);
389 arpManager.startUp(context);
390 arpManager.receive(sw1, inPort1, ethArpOtherOp);
391 }
392
393 @Test
394 public void testClassifyPacketToSendArpReplyNotification() {
395 Map<String, String> config = new HashMap<String, String>();
396 EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
397
398 prepareExpectForLearnArp();
399
400 ArpReplyNotification value =
401 new ArpReplyNotification(ByteBuffer.wrap(dstIp.getAddress()).getInt(), dstMac);
402 eg.addTransientEntry(srcMac.toLong(), value);
403 EasyMock.expectLastCall();
404 EasyMock.expect(context.getServiceImpl(IDatagridService.class)).andReturn(datagridService);
405
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700406 EasyMock.replay(context, floodligthProviderService, configInfoService,
407 restApiService, datagridService, flowPusherService,
408 topologyService, onosDeviceService, packetService, topology,
409 eg, el, dev1, inPort1, sw1);
TeruU8b2d1672014-04-25 17:02:56 -0700410 arpManager.init(context);
411 arpManager.startUp(context);
412 arpManager.receive(sw1, inPort1, ethArpReply);
413 }
414
415 @Test
416 public void testClassifyPacketToHandleArpRequest() {
417 Map<String, String> config = new HashMap<String, String>();
418 EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
419
420 prepareExpectForLearnArp();
421
422 EasyMock.expect(configInfoService.fromExternalNetwork(EasyMock.anyLong(), EasyMock.anyShort())).andReturn(true);
423 EasyMock.expect(configInfoService.isInterfaceAddress(dstIp)).andReturn(false);
424
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700425 EasyMock.replay(context, floodligthProviderService, configInfoService,
426 restApiService, datagridService, flowPusherService,
427 topologyService, onosDeviceService, packetService, topology,
428 eg, el, dev1, inPort1, sw1);
TeruU8b2d1672014-04-25 17:02:56 -0700429 arpManager.init(context);
430 arpManager.startUp(context);
431 arpManager.receive(sw1, inPort1, ethArpRequest);
432 }
433
434 @Test
435 public void testClassifyPacketToHandleArpRequest2() {
436 List<Port> portList = new ArrayList<Port>();
437 portList.add(outPort1);
438
439 Map<String, String> config = new HashMap<String, String>();
440 EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
441
442 prepareExpectForLearnArp();
443
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700444 EasyMock.expect(configInfoService.fromExternalNetwork(
445 EasyMock.anyLong(), EasyMock.anyShort())).andReturn(false);
Jonathan Harte37e4e22014-05-13 19:12:02 -0700446 topology.acquireReadLock();
TeruU8b2d1672014-04-25 17:02:56 -0700447 EasyMock.expectLastCall();
Jonathan Harte37e4e22014-05-13 19:12:02 -0700448 EasyMock.expect(topology.getDeviceByMac(dstMac)).andReturn(dev1);
449 topology.releaseReadLock();
TeruU8b2d1672014-04-25 17:02:56 -0700450 EasyMock.expectLastCall();
451 EasyMock.expect(dev1.getAttachmentPoints()).andReturn(portList);
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700452 eg.addTransientEntry(EasyMock.anyLong(), EasyMock.anyObject());
TeruU8b2d1672014-04-25 17:02:56 -0700453 EasyMock.expectLastCall();
454
455 EasyMock.replay(context, configInfoService, restApiService, floodligthProviderService,
Jonathan Harte37e4e22014-05-13 19:12:02 -0700456 topologyService, datagridService, eg, topology, dev1, inPort1, outPort1, sw1);
TeruU8b2d1672014-04-25 17:02:56 -0700457 arpManager.init(context);
458 arpManager.startUp(context);
459 arpManager.receive(sw1, inPort1, ethArpRequest);
460 }
461}