blob: d075b3232929cde31866ad6ca3020a516cd5c587 [file] [log] [blame]
Jonathan Hart6c2e7962016-04-11 13:54:09 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Jonathan Hart6c2e7962016-04-11 13:54:09 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Ray Milkey69ec8712017-08-08 13:00:43 -070017package org.onosproject.routeservice.impl;
Jonathan Hart6c2e7962016-04-11 13:54:09 -070018
Charles Chan2fde6d42017-08-23 14:46:43 -070019import java.util.Collection;
Ray Milkey69ec8712017-08-08 13:00:43 -070020import java.util.Collections;
21
pier8a86db22019-10-16 16:58:20 +020022import com.google.common.collect.Lists;
Jonathan Hart6c2e7962016-04-11 13:54:09 -070023import org.junit.Before;
24import org.junit.Test;
25import org.onlab.packet.Ip4Address;
26import org.onlab.packet.Ip4Prefix;
27import org.onlab.packet.Ip6Address;
28import org.onlab.packet.Ip6Prefix;
29import org.onlab.packet.IpAddress;
30import org.onlab.packet.IpPrefix;
31import org.onlab.packet.MacAddress;
32import org.onlab.packet.VlanId;
pier8a86db22019-10-16 16:58:20 +020033import org.onlab.util.PredictableExecutor;
Ray Milkey69ec8712017-08-08 13:00:43 -070034import org.onosproject.routeservice.ResolvedRoute;
35import org.onosproject.routeservice.Route;
36import org.onosproject.routeservice.RouteEvent;
37import org.onosproject.routeservice.RouteListener;
38import org.onosproject.routeservice.store.LocalRouteStore;
Jonathan Hartd4be52f2017-05-25 14:21:44 -070039import org.onosproject.cluster.ClusterService;
Jonathan Hart6c2e7962016-04-11 13:54:09 -070040import org.onosproject.net.ConnectPoint;
41import org.onosproject.net.DefaultHost;
42import org.onosproject.net.DeviceId;
43import org.onosproject.net.Host;
44import org.onosproject.net.HostId;
45import org.onosproject.net.HostLocation;
46import org.onosproject.net.PortNumber;
47import org.onosproject.net.host.HostEvent;
48import org.onosproject.net.host.HostListener;
49import org.onosproject.net.host.HostService;
50import org.onosproject.net.host.HostServiceAdapter;
51import org.onosproject.net.provider.ProviderId;
Charles Chan0cc44502018-01-29 15:25:52 -080052import org.onosproject.store.service.AsyncDistributedLock;
53import org.onosproject.store.service.DistributedLock;
54import org.onosproject.store.service.DistributedLockBuilder;
Jonathan Hartd4be52f2017-05-25 14:21:44 -070055import org.onosproject.store.service.StorageService;
56import org.onosproject.store.service.WorkQueue;
Jonathan Hart6c2e7962016-04-11 13:54:09 -070057
Ray Milkey69ec8712017-08-08 13:00:43 -070058import com.google.common.collect.Sets;
Jonathan Hart6c2e7962016-04-11 13:54:09 -070059
60import static org.easymock.EasyMock.anyObject;
Jonathan Hartd4be52f2017-05-25 14:21:44 -070061import static org.easymock.EasyMock.anyString;
Jonathan Hart6c2e7962016-04-11 13:54:09 -070062import static org.easymock.EasyMock.createMock;
Jonathan Hartd4be52f2017-05-25 14:21:44 -070063import static org.easymock.EasyMock.createNiceMock;
Jonathan Hart6c2e7962016-04-11 13:54:09 -070064import static org.easymock.EasyMock.expect;
65import static org.easymock.EasyMock.expectLastCall;
66import static org.easymock.EasyMock.replay;
67import static org.easymock.EasyMock.reset;
68import static org.easymock.EasyMock.verify;
pier8a86db22019-10-16 16:58:20 +020069import static org.onlab.util.Tools.groupedThreads;
Jonathan Hart6c2e7962016-04-11 13:54:09 -070070
71/**
72 * Unit tests for the route manager.
73 */
74public class RouteManagerTest {
75
76 private static final ConnectPoint CP1 = new ConnectPoint(
77 DeviceId.deviceId("of:0000000000000001"),
78 PortNumber.portNumber(1));
79
80 private static final IpPrefix V4_PREFIX1 = Ip4Prefix.valueOf("1.1.1.0/24");
Jonathan Hart7f2d5742016-04-13 16:22:50 -070081 private static final IpPrefix V4_PREFIX2 = Ip4Prefix.valueOf("2.2.2.0/24");
Jonathan Hart6c2e7962016-04-11 13:54:09 -070082 private static final IpPrefix V6_PREFIX1 = Ip6Prefix.valueOf("4000::/64");
83
84 private static final IpAddress V4_NEXT_HOP1 = Ip4Address.valueOf("192.168.10.1");
85 private static final IpAddress V4_NEXT_HOP2 = Ip4Address.valueOf("192.168.20.1");
86 private static final IpAddress V6_NEXT_HOP1 = Ip6Address.valueOf("1000::1");
87 private static final IpAddress V6_NEXT_HOP2 = Ip6Address.valueOf("2000::1");
88
89 private static final MacAddress MAC1 = MacAddress.valueOf("00:00:00:00:00:01");
90 private static final MacAddress MAC2 = MacAddress.valueOf("00:00:00:00:00:02");
91 private static final MacAddress MAC3 = MacAddress.valueOf("00:00:00:00:00:03");
92 private static final MacAddress MAC4 = MacAddress.valueOf("00:00:00:00:00:04");
93
94 private HostService hostService;
95
96 private RouteListener routeListener;
97 private HostListener hostListener;
98
99 private RouteManager routeManager;
100
101 @Before
102 public void setUp() throws Exception {
103 setUpHostService();
104
105 routeListener = createMock(RouteListener.class);
106
107 routeManager = new TestRouteManager();
108 routeManager.hostService = hostService;
109
Jonathan Hartd4be52f2017-05-25 14:21:44 -0700110 routeManager.clusterService = createNiceMock(ClusterService.class);
111 replay(routeManager.clusterService);
112 routeManager.storageService = createNiceMock(StorageService.class);
Charles Chan0cc44502018-01-29 15:25:52 -0800113
114 AsyncDistributedLock adl = createNiceMock(AsyncDistributedLock.class);
115 expect(adl.asLock()).andReturn(createNiceMock(DistributedLock.class));
116 replay(adl);
117
118 DistributedLockBuilder dlb = createNiceMock(DistributedLockBuilder.class);
119 expect(dlb.withName(anyString())).andReturn(dlb);
120 expect(dlb.build()).andReturn(adl);
121 replay(dlb);
122
123 expect(routeManager.storageService.lockBuilder())
124 .andReturn(dlb);
Jonathan Hartd4be52f2017-05-25 14:21:44 -0700125 expect(routeManager.storageService.getWorkQueue(anyString(), anyObject()))
126 .andReturn(createNiceMock(WorkQueue.class));
127 replay(routeManager.storageService);
128
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700129 LocalRouteStore routeStore = new LocalRouteStore();
130 routeStore.activate();
131 routeManager.routeStore = routeStore;
132 routeManager.activate();
133
pier8a86db22019-10-16 16:58:20 +0200134 routeManager.hostEventExecutors = new PredictableExecutor(
135 0, groupedThreads("onos/route-manager-test", "event-host-%d"), true);
136 routeManager.routeResolver.routeResolvers = new PredictableExecutor(
137 0, groupedThreads("onos/route-resolver-test", "route-resolver-%d"), true);
138
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700139 routeManager.addListener(routeListener);
140 }
141
142 /**
143 * Sets up the host service with details of some hosts.
144 */
145 private void setUpHostService() {
146 hostService = createMock(HostService.class);
147
148 hostService.addListener(anyObject(HostListener.class));
149 expectLastCall().andDelegateTo(new TestHostService()).anyTimes();
150
pier8a86db22019-10-16 16:58:20 +0200151 Host host1 = createHost(MAC1, Collections.singletonList(V4_NEXT_HOP1));
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700152 expectHost(host1);
153
pier8a86db22019-10-16 16:58:20 +0200154 Host host2 = createHost(MAC2, Collections.singletonList(V4_NEXT_HOP2));
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700155 expectHost(host2);
156
pier8a86db22019-10-16 16:58:20 +0200157 Host host3 = createHost(MAC3, Collections.singletonList(V6_NEXT_HOP1));
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700158 expectHost(host3);
159
pier8a86db22019-10-16 16:58:20 +0200160 Host host4 = createHost(MAC4, Collections.singletonList(V6_NEXT_HOP2));
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700161 expectHost(host4);
162
163 replay(hostService);
164 }
165
166 /**
167 * Sets expectations on the host service for a given host.
168 *
169 * @param host host
170 */
171 private void expectHost(Host host) {
172 // Assume the host only has one IP address
173 IpAddress ip = host.ipAddresses().iterator().next();
174
175 expect(hostService.getHostsByIp(ip))
176 .andReturn(Sets.newHashSet(host)).anyTimes();
177 hostService.startMonitoringIp(ip);
178 expectLastCall().anyTimes();
179 }
180
181 /**
182 * Creates a host with the given parameters.
183 *
184 * @param macAddress MAC address
pier8a86db22019-10-16 16:58:20 +0200185 * @param ipAddresses IP addresses
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700186 * @return new host
187 */
pier8a86db22019-10-16 16:58:20 +0200188 private Host createHost(MacAddress macAddress, Collection<IpAddress> ipAddresses) {
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700189 return new DefaultHost(ProviderId.NONE, HostId.NONE, macAddress,
190 VlanId.NONE, new HostLocation(CP1, 1),
pier8a86db22019-10-16 16:58:20 +0200191 Sets.newHashSet(ipAddresses));
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700192 }
193
194 /**
195 * Adds a route to the route service without expecting any specific events
196 * to be sent to the route listeners.
197 *
198 * @param route route to add
199 */
200 private void addRoute(Route route) {
201 reset(routeListener);
202
203 routeListener.event(anyObject(RouteEvent.class));
204 expectLastCall().once();
205 replay(routeListener);
206
207 routeManager.update(Collections.singleton(route));
208
209 reset(routeListener);
210 }
211
212 /**
213 * Tests adding routes to the route manager.
214 */
215 @Test
Jonathan Hart7f2d5742016-04-13 16:22:50 -0700216 public void testRouteAdd() {
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700217 Route route = new Route(Route.Source.STATIC, V4_PREFIX1, V4_NEXT_HOP1);
Ray Milkey69aad442018-09-14 16:24:26 -0700218 ResolvedRoute resolvedRoute = new ResolvedRoute(route, MAC1);
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700219
Jonathan Hart7f2d5742016-04-13 16:22:50 -0700220 verifyRouteAdd(route, resolvedRoute);
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700221
222 route = new Route(Route.Source.STATIC, V6_PREFIX1, V6_NEXT_HOP1);
Ray Milkey69aad442018-09-14 16:24:26 -0700223 resolvedRoute = new ResolvedRoute(route, MAC3);
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700224
Jonathan Hart7f2d5742016-04-13 16:22:50 -0700225 verifyRouteAdd(route, resolvedRoute);
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700226 }
227
228 /**
229 * Tests adding a new route and verifies that the correct event was sent
230 * to the route listener.
231 *
232 * @param route route to add
233 * @param resolvedRoute resolved route that should be sent to the route
234 * listener
235 */
Jonathan Hart7f2d5742016-04-13 16:22:50 -0700236 private void verifyRouteAdd(Route route, ResolvedRoute resolvedRoute) {
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700237 reset(routeListener);
238
Charles Chan2fde6d42017-08-23 14:46:43 -0700239 routeListener.event(event(RouteEvent.Type.ROUTE_ADDED, resolvedRoute, null,
240 Sets.newHashSet(resolvedRoute), null));
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700241
242 replay(routeListener);
243
244 routeManager.update(Collections.singleton(route));
245
246 verify(routeListener);
247 }
248
249 /**
250 * Tests updating routes in the route manager.
251 */
252 @Test
253 public void testRouteUpdate() {
254 Route route = new Route(Route.Source.STATIC, V4_PREFIX1, V4_NEXT_HOP1);
255 Route updatedRoute = new Route(Route.Source.STATIC, V4_PREFIX1, V4_NEXT_HOP2);
Ray Milkey69aad442018-09-14 16:24:26 -0700256 ResolvedRoute resolvedRoute = new ResolvedRoute(route, MAC1);
257 ResolvedRoute updatedResolvedRoute = new ResolvedRoute(updatedRoute, MAC2);
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700258
Jonathan Hart96c146b2017-02-24 16:32:00 -0800259 verifyRouteUpdated(route, updatedRoute, resolvedRoute, updatedResolvedRoute);
Jonathan Hart7f2d5742016-04-13 16:22:50 -0700260
261 // Different prefix pointing to the same next hop.
262 // In this case we expect to receive a ROUTE_UPDATED event.
263 route = new Route(Route.Source.STATIC, V4_PREFIX2, V4_NEXT_HOP1);
264 updatedRoute = new Route(Route.Source.STATIC, V4_PREFIX2, V4_NEXT_HOP2);
Ray Milkey69aad442018-09-14 16:24:26 -0700265 resolvedRoute = new ResolvedRoute(route, MAC1);
266 updatedResolvedRoute = new ResolvedRoute(updatedRoute, MAC2);
Jonathan Hart7f2d5742016-04-13 16:22:50 -0700267
Charles Chane4d13102016-11-08 15:38:44 -0800268 verifyRouteUpdated(route, updatedRoute, resolvedRoute, updatedResolvedRoute);
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700269
270 route = new Route(Route.Source.STATIC, V6_PREFIX1, V6_NEXT_HOP1);
271 updatedRoute = new Route(Route.Source.STATIC, V6_PREFIX1, V6_NEXT_HOP2);
Ray Milkey69aad442018-09-14 16:24:26 -0700272 resolvedRoute = new ResolvedRoute(route, MAC3);
273 updatedResolvedRoute = new ResolvedRoute(updatedRoute, MAC4);
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700274
Jonathan Hart96c146b2017-02-24 16:32:00 -0800275 verifyRouteUpdated(route, updatedRoute, resolvedRoute, updatedResolvedRoute);
Jonathan Hart7f2d5742016-04-13 16:22:50 -0700276 }
277
278 /**
279 * Tests updating a route and verifies that the route listener receives a
280 * route updated event.
281 *
282 * @param original original route
283 * @param updated updated route
Charles Chane4d13102016-11-08 15:38:44 -0800284 * @param resolvedRoute resolved route before update
Jonathan Hart7f2d5742016-04-13 16:22:50 -0700285 * @param updatedResolvedRoute resolved route that is expected to be sent to
286 * the route listener
287 */
288 private void verifyRouteUpdated(Route original, Route updated,
Charles Chane4d13102016-11-08 15:38:44 -0800289 ResolvedRoute resolvedRoute,
Jonathan Hart7f2d5742016-04-13 16:22:50 -0700290 ResolvedRoute updatedResolvedRoute) {
291 // First add the original route
292 addRoute(original);
293
Jonathan Hartf7021682017-03-22 18:17:21 -0700294 routeListener.event(event(RouteEvent.Type.ROUTE_UPDATED,
Charles Chan2fde6d42017-08-23 14:46:43 -0700295 updatedResolvedRoute, resolvedRoute,
296 Sets.newHashSet(updatedResolvedRoute), Sets.newHashSet(resolvedRoute)));
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700297 expectLastCall().once();
298
299 replay(routeListener);
300
301 routeManager.update(Collections.singleton(updated));
302
303 verify(routeListener);
304 }
305
306 /**
307 * Tests deleting routes from the route manager.
308 */
309 @Test
Jonathan Hart7f2d5742016-04-13 16:22:50 -0700310 public void testRouteDelete() {
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700311 Route route = new Route(Route.Source.STATIC, V4_PREFIX1, V4_NEXT_HOP1);
Ray Milkey69aad442018-09-14 16:24:26 -0700312 ResolvedRoute removedResolvedRoute = new ResolvedRoute(route, MAC1);
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700313
Charles Chane4d13102016-11-08 15:38:44 -0800314 verifyDelete(route, removedResolvedRoute);
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700315
316 route = new Route(Route.Source.STATIC, V6_PREFIX1, V6_NEXT_HOP1);
Ray Milkey69aad442018-09-14 16:24:26 -0700317 removedResolvedRoute = new ResolvedRoute(route, MAC3);
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700318
Charles Chane4d13102016-11-08 15:38:44 -0800319 verifyDelete(route, removedResolvedRoute);
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700320 }
321
322 /**
323 * Tests deleting a route and verifies that the correct event is sent to
324 * the route listener.
325 *
326 * @param route route to delete
Charles Chane4d13102016-11-08 15:38:44 -0800327 * @param removedResolvedRoute the resolved route being removed
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700328 */
Charles Chane4d13102016-11-08 15:38:44 -0800329 private void verifyDelete(Route route, ResolvedRoute removedResolvedRoute) {
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700330 addRoute(route);
331
332 RouteEvent withdrawRouteEvent = new RouteEvent(RouteEvent.Type.ROUTE_REMOVED,
Charles Chan2fde6d42017-08-23 14:46:43 -0700333 removedResolvedRoute, Sets.newHashSet(removedResolvedRoute));
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700334
335 reset(routeListener);
336 routeListener.event(withdrawRouteEvent);
337
338 replay(routeListener);
339
340 routeManager.withdraw(Collections.singleton(route));
341
342 verify(routeListener);
343 }
344
345 /**
Jonathan Hart7f2d5742016-04-13 16:22:50 -0700346 * Tests adding a route entry where the HostService does not immediately
347 * know the MAC address of the next hop, but this is learnt later.
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700348 */
349 @Test
350 public void testAsyncRouteAdd() {
351 Route route = new Route(Route.Source.STATIC, V4_PREFIX1, V4_NEXT_HOP1);
pier8a86db22019-10-16 16:58:20 +0200352 // 2nd route for the same nexthop
353 Route route2 = new Route(Route.Source.STATIC, V4_PREFIX2, V4_NEXT_HOP2);
354 // 3rd route with no valid nexthop
355 Route route3 = new Route(Route.Source.STATIC, V6_PREFIX1, V6_NEXT_HOP1);
356
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700357
358 // Host service will reply with no hosts when asked
359 reset(hostService);
360 expect(hostService.getHostsByIp(anyObject(IpAddress.class))).andReturn(
361 Collections.emptySet()).anyTimes();
362 hostService.startMonitoringIp(V4_NEXT_HOP1);
pier8a86db22019-10-16 16:58:20 +0200363 hostService.startMonitoringIp(V4_NEXT_HOP2);
364 hostService.startMonitoringIp(V6_NEXT_HOP1);
Jonathan Hart96c146b2017-02-24 16:32:00 -0800365 expectLastCall().anyTimes();
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700366 replay(hostService);
367
368 // Initially when we add the route, no route event will be sent because
369 // the host is not known
370 replay(routeListener);
371
pier8a86db22019-10-16 16:58:20 +0200372 routeManager.update(Lists.newArrayList(route, route2, route3));
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700373
374 verify(routeListener);
375
376 // Now when we send the event, we expect the FIB update to be sent
377 reset(routeListener);
Ray Milkey69aad442018-09-14 16:24:26 -0700378 ResolvedRoute resolvedRoute = new ResolvedRoute(route, MAC1);
Charles Chan2fde6d42017-08-23 14:46:43 -0700379 routeListener.event(event(RouteEvent.Type.ROUTE_ADDED, resolvedRoute, null,
380 Sets.newHashSet(resolvedRoute), null));
pier8a86db22019-10-16 16:58:20 +0200381 ResolvedRoute resolvedRoute2 = new ResolvedRoute(route2, MAC1);
382 routeListener.event(event(RouteEvent.Type.ROUTE_ADDED, resolvedRoute2, null,
383 Sets.newHashSet(resolvedRoute2), null));
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700384 replay(routeListener);
385
pier8a86db22019-10-16 16:58:20 +0200386 Host host = createHost(MAC1, Lists.newArrayList(V4_NEXT_HOP1, V4_NEXT_HOP2));
Jonathan Hart96c146b2017-02-24 16:32:00 -0800387
388 // Set up the host service with a host
389 reset(hostService);
390 expect(hostService.getHostsByIp(V4_NEXT_HOP1)).andReturn(
391 Collections.singleton(host)).anyTimes();
392 hostService.startMonitoringIp(V4_NEXT_HOP1);
pier8a86db22019-10-16 16:58:20 +0200393 expect(hostService.getHostsByIp(V4_NEXT_HOP2)).andReturn(
394 Collections.singleton(host)).anyTimes();
395 hostService.startMonitoringIp(V4_NEXT_HOP2);
Jonathan Hart96c146b2017-02-24 16:32:00 -0800396 expectLastCall().anyTimes();
397 replay(hostService);
398
399 // Send in the host event
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700400 hostListener.event(new HostEvent(HostEvent.Type.HOST_ADDED, host));
401
402 verify(routeListener);
403 }
404
Charles Chan2fde6d42017-08-23 14:46:43 -0700405 private static RouteEvent event(RouteEvent.Type type, ResolvedRoute subject, ResolvedRoute prevSubject,
406 Collection<ResolvedRoute> alternatives,
407 Collection<ResolvedRoute> prevAlternatives) {
408 return new RouteEvent(type, subject, prevSubject, alternatives, prevAlternatives);
Jonathan Hartf7021682017-03-22 18:17:21 -0700409 }
410
Jonathan Hart6c2e7962016-04-11 13:54:09 -0700411 /**
412 * Test host service that stores a reference to the host listener.
413 */
414 private class TestHostService extends HostServiceAdapter {
415 @Override
416 public void addListener(HostListener listener) {
417 hostListener = listener;
418 }
419 }
420
421 /**
422 * Test route manager that extends the real route manager and injects a test
423 * listener queue instead of the real listener queue.
424 */
425 private static class TestRouteManager extends RouteManager {
426 @Override
427 ListenerQueue createListenerQueue(RouteListener listener) {
428 return new TestListenerQueue(listener);
429 }
430 }
431
432 /**
433 * Test listener queue that simply passes route events straight through to
434 * the route listener on the caller's thread.
435 */
436 private static class TestListenerQueue implements ListenerQueue {
437
438 private final RouteListener listener;
439
440 public TestListenerQueue(RouteListener listener) {
441 this.listener = listener;
442 }
443
444 @Override
445 public void post(RouteEvent event) {
446 listener.event(event);
447 }
448
449 @Override
450 public void start() {
451 }
452
453 @Override
454 public void stop() {
455 }
456 }
457
458}