blob: 60b32a1bdc58295cce5234fbdd8b5a8aa9732b70 [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 {
45 String defaultStrAgingMsec = "60000";
46 String defaultStrCleanupMsec = "60000";
47
48 ProxyArpManager arpManager;
49 FloodlightModuleContext context;
50 IFloodlightProviderService floodligthProviderService;
51 IConfigInfoService configInfoService;
52 IRestApiService restApiService;
53 IDatagridService datagridService;
54 IFlowPusherService flowPusherService;
Jonathan Harte37e4e22014-05-13 19:12:02 -070055 ITopologyService topologyService;
TeruU8b2d1672014-04-25 17:02:56 -070056 IOnosDeviceService onosDeviceService;
57 IPacketService packetService;
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -070058 Map<String, String> configMap;
TeruU8b2d1672014-04-25 17:02:56 -070059
60 String srcStrMac, dstStrMac, cachedStrMac1, cachedStrMac2, srcStrIp, dstStrIp, cachedStrIp1, cachedStrIp2;
61 byte[] srcByteMac, dstByteMac;
62 MACAddress dstMac, srcMac, cachedMac1, cachedMac2;
63 InetAddress srcIp, dstIp, cachedIp1, cachedIp2;
64 Long sw1Dpid;
65 Short sw1Inport, sw1Outport;
66 Short vlanId;
67 ARP arpRequest, arpReply, rarpRequest;
68 Ethernet ethArpRequest, ethArpReply, ethRarpRequest, ethArpOtherOp;
69
Jonathan Harte37e4e22014-05-13 19:12:02 -070070 Topology topology;
TeruU8b2d1672014-04-25 17:02:56 -070071 IEventChannel eg;
72 IEventChannelListener el;
73 Device dev1;
74 Port inPort1, outPort1;
75 Switch sw1;
76 ArpCache arpCache;
77 List<String> arpCacheComparisonList;
78
79 @Before
80 public void setUp() throws Exception {
81 makeTestedObject();
82 makeMock();
83 prepareExpectForInit();
84 prepareExpectForStartUp();
85 prepareExpectForGeneral();
86 }
87
Yuta HIGUCHI33a04972014-06-03 13:00:15 -070088 private void makeTestedObject() throws UnknownHostException {
TeruU8b2d1672014-04-25 17:02:56 -070089 //Made tested values
90 srcStrMac = "00:00:00:00:00:01";
91 dstStrMac = "00:00:00:00:00:02";
92 cachedStrMac1 = "00:00:00:00:00:03";
93 cachedStrMac2 = "00:00:00:00:00:04";
94 srcStrIp = "192.168.0.1";
95 dstStrIp = "192.168.0.2";
96 cachedStrIp1 = "192.168.0.3";
97 cachedStrIp2 = "192.168.0.4";
98 srcByteMac = Ethernet.toMACAddress(srcStrMac);
99 dstByteMac = Ethernet.toMACAddress(dstStrMac);
100 dstMac = new MACAddress(dstByteMac);
101 srcMac = new MACAddress(srcByteMac);
102 cachedMac1 = new MACAddress(Ethernet.toMACAddress(cachedStrMac1));
103 cachedMac2 = new MACAddress(Ethernet.toMACAddress(cachedStrMac2));
Yuta HIGUCHI33a04972014-06-03 13:00:15 -0700104
105 srcIp = InetAddress.getByAddress(IPv4.toIPv4AddressBytes(srcStrIp));
106 dstIp = InetAddress.getByAddress(IPv4.toIPv4AddressBytes(dstStrIp));
107 cachedIp1 = InetAddress.getByAddress(IPv4.toIPv4AddressBytes(cachedStrIp1));
108 cachedIp2 = InetAddress.getByAddress(IPv4.toIPv4AddressBytes(cachedStrIp2));
109
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700110 sw1Dpid = 1L;
TeruU8b2d1672014-04-25 17:02:56 -0700111 sw1Inport = 1;
112 sw1Outport = 2;
113 vlanId = 1;
114
115 //Made tested packets
116 arpRequest = new ARP()
117 .setHardwareType(ARP.HW_TYPE_ETHERNET)
118 .setProtocolType(ARP.PROTO_TYPE_IP)
119 .setHardwareAddressLength((byte) 6)
120 .setProtocolAddressLength((byte) 4)
121 .setOpCode(ARP.OP_REQUEST)
122 .setSenderHardwareAddress(srcByteMac)
123 .setSenderProtocolAddress(srcIp.getAddress())
124 .setTargetProtocolAddress(dstIp.getAddress())
125 .setTargetHardwareAddress(dstByteMac);
126
127 ethArpRequest = (Ethernet) new Ethernet()
128 .setSourceMACAddress(srcStrMac)
129 .setDestinationMACAddress(dstStrMac)
130 .setEtherType(Ethernet.TYPE_ARP)
131 .setVlanID((short) 0)
132 .setPayload(arpRequest);
133
134 arpReply = new ARP()
135 .setHardwareType(ARP.HW_TYPE_ETHERNET)
136 .setProtocolType(ARP.PROTO_TYPE_IP)
137 .setHardwareAddressLength((byte) 6)
138 .setProtocolAddressLength((byte) 4)
139 .setOpCode(ARP.OP_RARP_REPLY)
140 .setSenderHardwareAddress(srcByteMac)
141 .setSenderProtocolAddress(srcIp.getAddress())
142 .setTargetProtocolAddress(dstIp.getAddress())
143 .setTargetHardwareAddress(dstByteMac);
144
145 ethArpReply = (Ethernet) new Ethernet()
146 .setSourceMACAddress(srcStrMac)
147 .setDestinationMACAddress(dstStrMac)
148 .setEtherType(Ethernet.TYPE_ARP)
149 .setVlanID((short) 0)
150 .setPayload(arpReply);
151
152 rarpRequest = new ARP()
153 .setHardwareType(ARP.HW_TYPE_ETHERNET)
154 .setProtocolType(ARP.PROTO_TYPE_IP)
155 .setHardwareAddressLength((byte) 6)
156 .setProtocolAddressLength((byte) 4)
157 .setOpCode(ARP.OP_RARP_REQUEST)
158 .setSenderHardwareAddress(srcByteMac)
159 .setSenderProtocolAddress(srcIp.getAddress())
160 .setTargetProtocolAddress(dstIp.getAddress())
161 .setTargetHardwareAddress(dstByteMac);
162
163 ethRarpRequest = (Ethernet) new Ethernet()
164 .setSourceMACAddress(srcStrMac)
165 .setDestinationMACAddress(dstStrMac)
166 .setEtherType(Ethernet.TYPE_RARP)
167 .setVlanID((short) 0)
168 .setPayload(rarpRequest);
169
170 ethArpOtherOp = (Ethernet) new Ethernet()
171 .setSourceMACAddress(srcStrMac)
172 .setDestinationMACAddress(dstStrMac)
173 .setEtherType(Ethernet.TYPE_ARP)
174 .setVlanID((short) 0)
175 .setPayload(rarpRequest);
176
177 //Made tested objects
178 arpCache = new ArpCache();
Yuta HIGUCHI238fa2a2014-05-01 09:56:46 -0700179 arpCache.setArpEntryTimeoutConfig(Long.parseLong(defaultStrCleanupMsec));
TeruU8b2d1672014-04-25 17:02:56 -0700180 arpCache.update(cachedIp1, cachedMac1);
Yuta HIGUCHI238fa2a2014-05-01 09:56:46 -0700181 arpCache.update(cachedIp2, cachedMac2);
182
183 arpCacheComparisonList = new ArrayList<String>();
TeruU8b2d1672014-04-25 17:02:56 -0700184 arpCacheComparisonList.add(cachedStrIp1
185 + " => "
186 + cachedStrMac1
187 + " : VALID");
TeruU8b2d1672014-04-25 17:02:56 -0700188 arpCacheComparisonList.add(cachedStrIp2
189 + " => "
190 + cachedStrMac2
191 + " : VALID");
192
193 arpManager = new ProxyArpManager();
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700194 configMap = new HashMap<String, String>();
TeruU8b2d1672014-04-25 17:02:56 -0700195 }
196
197 private void makeMock() {
198 //Mock floodlight modules
199 context = EasyMock.createMock(FloodlightModuleContext.class);
200 floodligthProviderService = EasyMock.createMock(IFloodlightProviderService.class);
201 configInfoService = EasyMock.createMock(IConfigInfoService.class);
202 restApiService = EasyMock.createMock(IRestApiService.class);
203 datagridService = EasyMock.createMock(IDatagridService.class);
204 flowPusherService = EasyMock.createMock(IFlowPusherService.class);
Jonathan Harte37e4e22014-05-13 19:12:02 -0700205 topologyService = EasyMock.createMock(ITopologyService.class);
TeruU8b2d1672014-04-25 17:02:56 -0700206 onosDeviceService = EasyMock.createMock(IOnosDeviceService.class);
207 packetService = EasyMock.createMock(IPacketService.class);
208 eg = EasyMock.createMock(IEventChannel.class);
209 el = EasyMock.createMock(IEventChannelListener.class);
210
Jonathan Harte37e4e22014-05-13 19:12:02 -0700211 //Mock Topology related data
212 topology = EasyMock.createMock(Topology.class);
TeruU8b2d1672014-04-25 17:02:56 -0700213 dev1 = EasyMock.createMock(Device.class);
214 inPort1 = EasyMock.createMock(Port.class);
215 outPort1 = EasyMock.createMock(Port.class);
216 sw1 = EasyMock.createMock(Switch.class);
217 }
218
219 private void prepareExpectForGeneral() {
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700220 EasyMock.expect(inPort1.getNumber()).andReturn((long) sw1Inport).anyTimes();
221 EasyMock.expect(outPort1.getNumber()).andReturn((long) sw1Outport).anyTimes();
TeruU8b2d1672014-04-25 17:02:56 -0700222 EasyMock.expect(outPort1.getOutgoingLink()).andReturn(null).anyTimes();
223 EasyMock.expect(outPort1.getIncomingLink()).andReturn(null).anyTimes();
224 EasyMock.expect(outPort1.getSwitch()).andReturn(sw1).anyTimes();
225 EasyMock.expect(sw1.getDpid()).andReturn(sw1Dpid).anyTimes();
226 }
227
228 private void prepareExpectForInit() {
229 EasyMock.expect(context.getServiceImpl(IFloodlightProviderService.class)).andReturn(floodligthProviderService);
230 EasyMock.expect(context.getServiceImpl(IConfigInfoService.class)).andReturn(configInfoService);
231 EasyMock.expect(context.getServiceImpl(IRestApiService.class)).andReturn(restApiService);
232 EasyMock.expect(context.getServiceImpl(IDatagridService.class)).andReturn(datagridService);
233 EasyMock.expect(context.getServiceImpl(IFlowPusherService.class)).andReturn(flowPusherService);
Jonathan Harte37e4e22014-05-13 19:12:02 -0700234 EasyMock.expect(context.getServiceImpl(ITopologyService.class)).andReturn(topologyService);
TeruU8b2d1672014-04-25 17:02:56 -0700235 EasyMock.expect(context.getServiceImpl(IOnosDeviceService.class)).andReturn(onosDeviceService);
236 EasyMock.expect(context.getServiceImpl(IPacketService.class)).andReturn(packetService);
237 }
238
239 private void prepareExpectForStartUp() {
Yuta HIGUCHI33a04972014-06-03 13:00:15 -0700240 // XXX Commented out as workaround for PowerMock + Hazelcast issue.
241// try {
242// PowerMock.expectNew(ArpCache.class).andReturn(arpCache);
243// } catch (Exception e) {
244// fail("Exception:" + e.getMessage());
245// }
246// PowerMock.replayAll();
TeruU8b2d1672014-04-25 17:02:56 -0700247 EasyMock.expect(configInfoService.getVlan()).andReturn(vlanId);
248 restApiService.addRestletRoutable(EasyMock.isA(ArpWebRoutable.class));
249 EasyMock.expectLastCall();
250 packetService.registerPacketListener(arpManager);
251 EasyMock.expectLastCall();
Jonathan Harte37e4e22014-05-13 19:12:02 -0700252 EasyMock.expect(topologyService.getTopology()).andReturn(topology);
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700253 EasyMock.expect(datagridService.addListener(EasyMock.<String>anyObject(),
254 EasyMock.isA(IEventChannelListener.class),
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700255 (Class) EasyMock.anyObject(), (Class) EasyMock.anyObject())).andReturn(eg).anyTimes();
TeruU8b2d1672014-04-25 17:02:56 -0700256 List<ArpCacheNotification> list = new ArrayList<ArpCacheNotification>();
257 EasyMock.expect(eg.getAllEntries()).andReturn(list);
258 }
259
260 private void prepareExpectForLearnArp() {
261 eg.addEntry(EasyMock.eq(srcIp.toString()), EasyMock.isA(ArpCacheNotification.class));
262 EasyMock.expectLastCall();
263 }
264
265 @After
266 public void tearDown() throws Exception {
Yuta HIGUCHI238fa2a2014-05-01 09:56:46 -0700267 arpCache = null;
TeruU8b2d1672014-04-25 17:02:56 -0700268 }
269
270 @Test
271 public void testConfigTimeWithNoConfig() {
272 Map<String, String> config = new HashMap<String, String>();
273 EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
274
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700275 EasyMock.replay(context, floodligthProviderService, configInfoService,
276 restApiService, datagridService, flowPusherService,
277 topologyService, onosDeviceService, packetService, topology, eg,
278 el, dev1, inPort1, sw1);
TeruU8b2d1672014-04-25 17:02:56 -0700279 arpManager.init(context);
280 arpManager.startUp(context);
281 assertEquals(defaultStrAgingMsec, String.valueOf(arpManager.getArpEntryTimeout()));
282 assertEquals(defaultStrCleanupMsec, String.valueOf(arpManager.getArpCleaningTimerPeriod()));
283 }
284
285 @Test
286 public void testConfigTimeWithWrongParameter() {
287 Map<String, String> config = new HashMap<String, String>();
288 String strAgingMsec = "aaaaa";
289 String strCleanupMsec = "bbbbb";
290 config.put("agingmsec", strAgingMsec);
291 config.put("cleanupmsec", strCleanupMsec);
292 EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
293
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700294 EasyMock.replay(context, floodligthProviderService, configInfoService,
295 restApiService, datagridService, flowPusherService,
296 topologyService, onosDeviceService, packetService, topology,
297 eg, el, dev1, inPort1, sw1);
TeruU8b2d1672014-04-25 17:02:56 -0700298 arpManager.init(context);
299 arpManager.startUp(context);
300 assertEquals(defaultStrAgingMsec, String.valueOf(arpManager.getArpEntryTimeout()));
301 assertEquals(defaultStrCleanupMsec, String.valueOf(arpManager.getArpCleaningTimerPeriod()));
302 }
303
304 @Test
305 public void testConfigTime() {
306 String strAgingMsec = "10000";
307 String strCleanupMsec = "10000";
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700308 configMap.put("agingmsec", strAgingMsec);
309 configMap.put("cleanupmsec", strCleanupMsec);
310 EasyMock.expect(context.getConfigParams(arpManager)).andReturn(configMap);
TeruU8b2d1672014-04-25 17:02:56 -0700311
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700312 EasyMock.replay(context, floodligthProviderService, configInfoService,
313 restApiService, datagridService, flowPusherService,
314 topologyService, onosDeviceService, packetService, topology,
315 eg, el, dev1, inPort1, sw1);
TeruU8b2d1672014-04-25 17:02:56 -0700316 arpManager.init(context);
317 arpManager.startUp(context);
318 assertEquals(strAgingMsec, String.valueOf(arpManager.getArpEntryTimeout()));
319 assertEquals(strCleanupMsec, String.valueOf(arpManager.getArpCleaningTimerPeriod()));
320 }
321
322 @Test
323 public void testGetMacAddress() {
324 Map<String, String> config = new HashMap<String, String>();
325 EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
326
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700327 EasyMock.replay(context, floodligthProviderService, configInfoService,
328 restApiService, datagridService, flowPusherService,
329 topologyService, onosDeviceService, packetService, topology,
330 eg, el, dev1, inPort1, sw1);
TeruU8b2d1672014-04-25 17:02:56 -0700331 arpManager.init(context);
332 arpManager.startUp(context);
Yuta HIGUCHI33a04972014-06-03 13:00:15 -0700333
334 // XXX workaround for PowerMock + Hazelcast issue.
335 this.arpManager.debugReplaceArpCache(arpCache);
336
TeruU8b2d1672014-04-25 17:02:56 -0700337 MACAddress mac = arpManager.getMacAddress(cachedIp1);
338 assertEquals(cachedMac1, mac);
339 }
340
341 @Test
342 public void testGetMappings() {
343 Map<String, String> config = new HashMap<String, String>();
344 EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
345
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700346 EasyMock.replay(context, floodligthProviderService, configInfoService,
347 restApiService, datagridService, flowPusherService,
348 topologyService, onosDeviceService, packetService, topology,
349 eg, el, dev1, inPort1, sw1);
TeruU8b2d1672014-04-25 17:02:56 -0700350 arpManager.init(context);
351 arpManager.startUp(context);
352 List<String> list = arpManager.getMappings();
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700353 for (String str : list) {
TeruU8b2d1672014-04-25 17:02:56 -0700354 assertTrue(arpCacheComparisonList.contains(str));
355 }
356 }
357
358 @Test
359 public void testReceivePacketWithNoArpPacket() {
360 Map<String, String> config = new HashMap<String, String>();
361 EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
362
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700363 EasyMock.replay(context, floodligthProviderService, configInfoService,
364 restApiService, datagridService, flowPusherService,
365 topologyService, onosDeviceService, packetService, topology,
366 eg, el, dev1, inPort1, sw1);
TeruU8b2d1672014-04-25 17:02:56 -0700367 arpManager.init(context);
368 arpManager.startUp(context);
369 arpManager.receive(sw1, inPort1, ethRarpRequest);
370 }
371
372 @Test
373 public void testReceivePacketWithOtherOpCode() {
374 Map<String, String> config = new HashMap<String, String>();
375 EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
376
377 prepareExpectForLearnArp();
378
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700379 EasyMock.replay(context, floodligthProviderService, configInfoService,
380 restApiService, datagridService, flowPusherService,
381 topologyService, onosDeviceService, packetService, topology,
382 eg, el, dev1, inPort1, sw1);
TeruU8b2d1672014-04-25 17:02:56 -0700383 arpManager.init(context);
384 arpManager.startUp(context);
385 arpManager.receive(sw1, inPort1, ethArpOtherOp);
386 }
387
388 @Test
389 public void testClassifyPacketToSendArpReplyNotification() {
390 Map<String, String> config = new HashMap<String, String>();
391 EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
392
393 prepareExpectForLearnArp();
394
395 ArpReplyNotification value =
396 new ArpReplyNotification(ByteBuffer.wrap(dstIp.getAddress()).getInt(), dstMac);
397 eg.addTransientEntry(srcMac.toLong(), value);
398 EasyMock.expectLastCall();
399 EasyMock.expect(context.getServiceImpl(IDatagridService.class)).andReturn(datagridService);
400
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700401 EasyMock.replay(context, floodligthProviderService, configInfoService,
402 restApiService, datagridService, flowPusherService,
403 topologyService, onosDeviceService, packetService, topology,
404 eg, el, dev1, inPort1, sw1);
TeruU8b2d1672014-04-25 17:02:56 -0700405 arpManager.init(context);
406 arpManager.startUp(context);
407 arpManager.receive(sw1, inPort1, ethArpReply);
408 }
409
410 @Test
411 public void testClassifyPacketToHandleArpRequest() {
412 Map<String, String> config = new HashMap<String, String>();
413 EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
414
415 prepareExpectForLearnArp();
416
417 EasyMock.expect(configInfoService.fromExternalNetwork(EasyMock.anyLong(), EasyMock.anyShort())).andReturn(true);
418 EasyMock.expect(configInfoService.isInterfaceAddress(dstIp)).andReturn(false);
419
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700420 EasyMock.replay(context, floodligthProviderService, configInfoService,
421 restApiService, datagridService, flowPusherService,
422 topologyService, onosDeviceService, packetService, topology,
423 eg, el, dev1, inPort1, sw1);
TeruU8b2d1672014-04-25 17:02:56 -0700424 arpManager.init(context);
425 arpManager.startUp(context);
426 arpManager.receive(sw1, inPort1, ethArpRequest);
427 }
428
429 @Test
430 public void testClassifyPacketToHandleArpRequest2() {
431 List<Port> portList = new ArrayList<Port>();
432 portList.add(outPort1);
433
434 Map<String, String> config = new HashMap<String, String>();
435 EasyMock.expect(context.getConfigParams(arpManager)).andReturn(config);
436
437 prepareExpectForLearnArp();
438
Yuta HIGUCHI91a8f502014-06-17 10:15:29 -0700439 EasyMock.expect(configInfoService.fromExternalNetwork(
440 EasyMock.anyLong(), EasyMock.anyShort())).andReturn(false);
Jonathan Harte37e4e22014-05-13 19:12:02 -0700441 topology.acquireReadLock();
TeruU8b2d1672014-04-25 17:02:56 -0700442 EasyMock.expectLastCall();
Jonathan Harte37e4e22014-05-13 19:12:02 -0700443 EasyMock.expect(topology.getDeviceByMac(dstMac)).andReturn(dev1);
444 topology.releaseReadLock();
TeruU8b2d1672014-04-25 17:02:56 -0700445 EasyMock.expectLastCall();
446 EasyMock.expect(dev1.getAttachmentPoints()).andReturn(portList);
Yuta HIGUCHI44a0b352014-05-14 21:32:48 -0700447 eg.addTransientEntry(EasyMock.anyLong(), EasyMock.anyObject());
TeruU8b2d1672014-04-25 17:02:56 -0700448 EasyMock.expectLastCall();
449
450 EasyMock.replay(context, configInfoService, restApiService, floodligthProviderService,
Jonathan Harte37e4e22014-05-13 19:12:02 -0700451 topologyService, datagridService, eg, topology, dev1, inPort1, outPort1, sw1);
TeruU8b2d1672014-04-25 17:02:56 -0700452 arpManager.init(context);
453 arpManager.startUp(context);
454 arpManager.receive(sw1, inPort1, ethArpRequest);
455 }
456}