blob: 69d2c34ac36ec717fcc893b1b3164137b728e76d [file] [log] [blame]
gaurav36785932016-03-10 17:24:04 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
gaurav36785932016-03-10 17:24:04 +05303 *
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 */
16package org.onosproject.routing.impl;
17
Jonathan Hartf04b7d92016-03-29 09:39:11 -070018import com.google.common.collect.Sets;
gaurav36785932016-03-10 17:24:04 +053019import org.easymock.EasyMock;
20import org.junit.Before;
21import org.junit.Test;
22import org.onlab.packet.Ethernet;
gaurav36785932016-03-10 17:24:04 +053023import org.onlab.packet.Ip4Prefix;
24import org.onlab.packet.IpAddress;
25import org.onlab.packet.IpPrefix;
26import org.onlab.packet.MacAddress;
27import org.onlab.packet.VlanId;
28import org.onosproject.TestApplicationId;
gaurava2e61a52016-05-05 03:39:31 +053029import org.onosproject.app.ApplicationService;
Jonathan Hartf04b7d92016-03-29 09:39:11 -070030import org.onosproject.cfg.ComponentConfigService;
gaurav36785932016-03-10 17:24:04 +053031import org.onosproject.core.ApplicationId;
32import org.onosproject.core.CoreService;
gaurav36785932016-03-10 17:24:04 +053033import org.onosproject.incubator.net.intf.Interface;
gaurav164cf6d2016-03-25 21:43:04 +053034import org.onosproject.incubator.net.intf.InterfaceListener;
gaurav36785932016-03-10 17:24:04 +053035import org.onosproject.incubator.net.intf.InterfaceService;
gaurav164cf6d2016-03-25 21:43:04 +053036import org.onosproject.incubator.net.intf.InterfaceServiceAdapter;
Jonathan Harta2eb9ff2016-04-13 21:27:06 -070037import org.onosproject.incubator.net.routing.ResolvedRoute;
38import org.onosproject.incubator.net.routing.RouteEvent;
39import org.onosproject.incubator.net.routing.RouteListener;
40import org.onosproject.incubator.net.routing.RouteServiceAdapter;
gaurav36785932016-03-10 17:24:04 +053041import org.onosproject.net.ConnectPoint;
42import org.onosproject.net.DeviceId;
43import org.onosproject.net.PortNumber;
Charles Chand55e84d2016-03-30 17:54:24 -070044import org.onosproject.net.config.NetworkConfigRegistry;
gaurav36785932016-03-10 17:24:04 +053045import org.onosproject.net.config.NetworkConfigService;
46import org.onosproject.net.device.DeviceListener;
47import org.onosproject.net.device.DeviceService;
48import org.onosproject.net.device.DeviceServiceAdapter;
49import org.onosproject.net.flow.DefaultTrafficSelector;
50import org.onosproject.net.flow.DefaultTrafficTreatment;
51import org.onosproject.net.flow.TrafficSelector;
52import org.onosproject.net.flow.TrafficTreatment;
53import org.onosproject.net.flowobjective.DefaultForwardingObjective;
54import org.onosproject.net.flowobjective.DefaultNextObjective;
55import org.onosproject.net.flowobjective.FlowObjectiveService;
56import org.onosproject.net.flowobjective.ForwardingObjective;
57import org.onosproject.net.flowobjective.NextObjective;
58import org.onosproject.net.host.InterfaceIpAddress;
gaurav36785932016-03-10 17:24:04 +053059import org.onosproject.routing.RoutingService;
gaurav36785932016-03-10 17:24:04 +053060import org.onosproject.routing.config.RouterConfig;
Jonathan Hartf04b7d92016-03-29 09:39:11 -070061import org.osgi.service.component.ComponentContext;
62
63import java.util.ArrayList;
64import java.util.Collections;
Jonathan Hartf04b7d92016-03-29 09:39:11 -070065import java.util.List;
66import java.util.Set;
67
68import static org.easymock.EasyMock.anyObject;
Jonathan Harta2eb9ff2016-04-13 21:27:06 -070069import static org.easymock.EasyMock.anyString;
Jonathan Hartf04b7d92016-03-29 09:39:11 -070070import static org.easymock.EasyMock.createMock;
Jonathan Harta2eb9ff2016-04-13 21:27:06 -070071import static org.easymock.EasyMock.createNiceMock;
72import static org.easymock.EasyMock.eq;
Jonathan Hartf04b7d92016-03-29 09:39:11 -070073import static org.easymock.EasyMock.expect;
Jonathan Harta2eb9ff2016-04-13 21:27:06 -070074import static org.easymock.EasyMock.expectLastCall;
Jonathan Hartf04b7d92016-03-29 09:39:11 -070075import static org.easymock.EasyMock.replay;
76import static org.easymock.EasyMock.reset;
77import static org.easymock.EasyMock.verify;
gaurav36785932016-03-10 17:24:04 +053078
79/**
80 * Unit tests for SingleSwitchFibInstaller.
81 */
Jonathan Harta2eb9ff2016-04-13 21:27:06 -070082public class SingleSwitchFibInstallerTest {
gaurav36785932016-03-10 17:24:04 +053083
Jonathan Harta2eb9ff2016-04-13 21:27:06 -070084 private static final DeviceId DEVICE_ID = DeviceId.deviceId("of:0000000000000001");
85
gaurav36785932016-03-10 17:24:04 +053086 private static final ConnectPoint SW1_ETH1 = new ConnectPoint(
Jonathan Harta2eb9ff2016-04-13 21:27:06 -070087 DEVICE_ID, PortNumber.portNumber(1));
gaurav36785932016-03-10 17:24:04 +053088
Jonathan Harta2eb9ff2016-04-13 21:27:06 -070089 private static final ConnectPoint SW1_ETH2 = new ConnectPoint(
90 DEVICE_ID, PortNumber.portNumber(2));
gaurav36785932016-03-10 17:24:04 +053091
Jonathan Harta2eb9ff2016-04-13 21:27:06 -070092 private static final int NEXT_ID = 11;
gaurav36785932016-03-10 17:24:04 +053093
Jonathan Harta2eb9ff2016-04-13 21:27:06 -070094 private static final VlanId VLAN1 = VlanId.vlanId((short) 1);
95 private static final MacAddress MAC1 = MacAddress.valueOf("00:00:00:00:00:01");
96 private static final MacAddress MAC2 = MacAddress.valueOf("00:00:00:00:00:02");
gaurav36785932016-03-10 17:24:04 +053097
Jonathan Harta2eb9ff2016-04-13 21:27:06 -070098 private static final IpPrefix PREFIX1 = Ip4Prefix.valueOf("1.1.1.0/24");
99 private static final IpAddress NEXT_HOP1 = IpAddress.valueOf("192.168.10.1");
100 private static final IpAddress NEXT_HOP2 = IpAddress.valueOf("192.168.20.1");
101 private static final InterfaceIpAddress INTF1 =
102 InterfaceIpAddress.valueOf("192.168.10.2/24");
103 private static final InterfaceIpAddress INTF2 =
104 InterfaceIpAddress.valueOf("192.168.20.2/24");
105
gaurav36785932016-03-10 17:24:04 +0530106 private final Set<Interface> interfaces = Sets.newHashSet();
107 private InterfaceService interfaceService;
108 private NetworkConfigService networkConfigService;
Charles Chand55e84d2016-03-30 17:54:24 -0700109 private NetworkConfigRegistry networkConfigRegistry;
gaurav36785932016-03-10 17:24:04 +0530110 private FlowObjectiveService flowObjectiveService;
gaurava2e61a52016-05-05 03:39:31 +0530111 private ApplicationService applicationService;
gaurav36785932016-03-10 17:24:04 +0530112 private DeviceService deviceService;
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700113 private static final ApplicationId APPID = TestApplicationId.create("foo");
114
115 private RouteListener routeListener;
gaurav36785932016-03-10 17:24:04 +0530116 private DeviceListener deviceListener;
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700117
gaurav36785932016-03-10 17:24:04 +0530118 private RouterConfig routerConfig;
gaurav164cf6d2016-03-25 21:43:04 +0530119 private SingleSwitchFibInstaller sSfibInstaller;
120 private InterfaceListener interfaceListener;
gaurav36785932016-03-10 17:24:04 +0530121
122 @Before
123 public void setUp() throws Exception {
gaurav36785932016-03-10 17:24:04 +0530124 sSfibInstaller = new SingleSwitchFibInstaller();
125
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700126 sSfibInstaller.componentConfigService = createNiceMock(ComponentConfigService.class);
gaurav36785932016-03-10 17:24:04 +0530127
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700128 ComponentContext mockContext = createNiceMock(ComponentContext.class);
gaurav36785932016-03-10 17:24:04 +0530129
gaurav36785932016-03-10 17:24:04 +0530130 routerConfig = new TestRouterConfig();
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700131 interfaceService = createMock(InterfaceService.class);
132
gaurav36785932016-03-10 17:24:04 +0530133 networkConfigService = createMock(NetworkConfigService.class);
Charles Chand55e84d2016-03-30 17:54:24 -0700134 networkConfigRegistry = createMock(NetworkConfigRegistry.class);
gaurav36785932016-03-10 17:24:04 +0530135 flowObjectiveService = createMock(FlowObjectiveService.class);
gaurava2e61a52016-05-05 03:39:31 +0530136 applicationService = createNiceMock(ApplicationService.class);
137 replay(applicationService);
gaurav36785932016-03-10 17:24:04 +0530138 deviceService = new TestDeviceService();
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700139 CoreService coreService = createNiceMock(CoreService.class);
Charles Chand55e84d2016-03-30 17:54:24 -0700140 expect(coreService.registerApplication(anyString())).andReturn(APPID).anyTimes();
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700141 replay(coreService);
gaurav36785932016-03-10 17:24:04 +0530142
143 sSfibInstaller.networkConfigService = networkConfigService;
Charles Chand55e84d2016-03-30 17:54:24 -0700144 sSfibInstaller.networkConfigRegistry = networkConfigRegistry;
gaurav36785932016-03-10 17:24:04 +0530145 sSfibInstaller.interfaceService = interfaceService;
146 sSfibInstaller.flowObjectiveService = flowObjectiveService;
gaurava2e61a52016-05-05 03:39:31 +0530147 sSfibInstaller.applicationService = applicationService;
gaurav36785932016-03-10 17:24:04 +0530148 sSfibInstaller.coreService = coreService;
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700149 sSfibInstaller.routeService = new TestRouteService();
gaurav36785932016-03-10 17:24:04 +0530150 sSfibInstaller.deviceService = deviceService;
151
152 setUpNetworkConfigService();
153 setUpInterfaceService();
154 sSfibInstaller.activate(mockContext);
155 }
156
157 /**
158 * Sets up InterfaceService.
159 */
160 private void setUpInterfaceService() {
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700161 interfaceService.addListener(anyObject(InterfaceListener.class));
162 expectLastCall().andDelegateTo(new TestInterfaceService());
163
164 // Interface with no VLAN
165 Interface sw1Eth1 = new Interface("intf1", SW1_ETH1,
166 Collections.singletonList(INTF1), MAC1, VlanId.NONE);
167 expect(interfaceService.getMatchingInterface(NEXT_HOP1)).andReturn(sw1Eth1);
gaurav36785932016-03-10 17:24:04 +0530168 interfaces.add(sw1Eth1);
169
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700170 // Interface with a VLAN
171 Interface sw2Eth1 = new Interface("intf2", SW1_ETH2,
172 Collections.singletonList(INTF2), MAC2, VLAN1);
173 expect(interfaceService.getMatchingInterface(NEXT_HOP2)).andReturn(sw2Eth1);
gaurav36785932016-03-10 17:24:04 +0530174 interfaces.add(sw2Eth1);
175
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700176 expect(interfaceService.getInterfaces()).andReturn(interfaces);
gaurav36785932016-03-10 17:24:04 +0530177
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700178 replay(interfaceService);
gaurav36785932016-03-10 17:24:04 +0530179 }
180
181 /*
182 * Sets up NetworkConfigService.
Jonathan Hartf04b7d92016-03-29 09:39:11 -0700183 */
gaurav36785932016-03-10 17:24:04 +0530184 private void setUpNetworkConfigService() {
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700185 expect(networkConfigService.getConfig(
186 anyObject(ApplicationId.class), eq(RoutingService.ROUTER_CONFIG_CLASS))).
gaurav36785932016-03-10 17:24:04 +0530187 andReturn(routerConfig);
188 replay(networkConfigService);
189 }
190
191 /**
192 * Sets up FlowObjectiveService.
193 */
194 private void setUpFlowObjectiveService() {
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700195 expect(flowObjectiveService.allocateNextId()).andReturn(NEXT_ID);
gaurav36785932016-03-10 17:24:04 +0530196 replay(flowObjectiveService);
197 }
198
199 /**
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700200 * Creates a next objective with the given parameters.
gaurav36785932016-03-10 17:24:04 +0530201 *
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700202 * @param srcMac source MAC address
203 * @param dstMac destination MAC address
204 * @param port port number
205 * @param vlan vlan ID
206 * @param add whether to create an add objective or remove objective
207 * @return new next objective
gaurav36785932016-03-10 17:24:04 +0530208 */
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700209 private NextObjective createNextObjective(MacAddress srcMac,
210 MacAddress dstMac,
211 PortNumber port,
212 VlanId vlan,
213 boolean add) {
gaurav36785932016-03-10 17:24:04 +0530214 TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder()
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700215 .setEthSrc(srcMac)
216 .setEthDst(dstMac);
gaurav36785932016-03-10 17:24:04 +0530217 TrafficSelector.Builder metabuilder = null;
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700218 if (!vlan.equals(VlanId.NONE)) {
gaurav36785932016-03-10 17:24:04 +0530219 treatment.pushVlan()
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700220 .setVlanId(vlan)
221 .setVlanPcp((byte) 0);
gaurav36785932016-03-10 17:24:04 +0530222 } else {
223 metabuilder = DefaultTrafficSelector.builder();
224 metabuilder.matchVlanId(VlanId.vlanId(SingleSwitchFibInstaller.ASSIGNED_VLAN));
225 }
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700226
227 treatment.setOutput(port);
gaurav36785932016-03-10 17:24:04 +0530228 NextObjective.Builder nextBuilder = DefaultNextObjective.builder()
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700229 .withId(NEXT_ID)
gaurav36785932016-03-10 17:24:04 +0530230 .addTreatment(treatment.build())
231 .withType(NextObjective.Type.SIMPLE)
232 .fromApp(APPID);
233 if (metabuilder != null) {
234 nextBuilder.withMeta(metabuilder.build());
235 }
236
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700237 return add ? nextBuilder.add() : nextBuilder.remove();
238 }
gaurav36785932016-03-10 17:24:04 +0530239
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700240 /**
241 * Creates a new forwarding objective with the given parameters.
242 *
243 * @param prefix IP prefix
244 * @param add whether to create an add objective or a remove objective
245 * @return new forwarding objective
246 */
247 private ForwardingObjective createForwardingObjective(IpPrefix prefix,
248 boolean add) {
gaurav36785932016-03-10 17:24:04 +0530249 TrafficSelector selector = DefaultTrafficSelector.builder()
250 .matchEthType(Ethernet.TYPE_IPV4)
251 .matchIPDst(prefix)
252 .build();
253
254 int priority = prefix.prefixLength() * 5 + 100;
255 ForwardingObjective.Builder fwdBuilder = DefaultForwardingObjective.builder()
256 .fromApp(APPID)
257 .makePermanent()
258 .withSelector(selector)
259 .withPriority(priority)
260 .withFlag(ForwardingObjective.Flag.SPECIFIC);
261
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700262 if (add) {
263 fwdBuilder.nextStep(NEXT_ID);
264 } else {
265 fwdBuilder.withTreatment(DefaultTrafficTreatment.builder().build());
266 }
267
268 return add ? fwdBuilder.add() : fwdBuilder.remove();
269 }
270
271 /**
272 * Tests adding a route.
273 *
274 * We verify that the flowObjectiveService records the correct state and that the
275 * correct flow is submitted to the flowObjectiveService.
276 */
277 @Test
278 public void testRouteAdd() {
279 ResolvedRoute resolvedRoute = new ResolvedRoute(PREFIX1, NEXT_HOP1, MAC1);
280
281 // Create the next objective
282 NextObjective nextObjective = createNextObjective(MAC1, MAC1, SW1_ETH1.port(), VlanId.NONE, true);
283 flowObjectiveService.next(DEVICE_ID, nextObjective);
284
285 // Create the flow objective
286 ForwardingObjective fwd = createForwardingObjective(PREFIX1, true);
287 flowObjectiveService.forward(DEVICE_ID, fwd);
gaurav36785932016-03-10 17:24:04 +0530288 EasyMock.expectLastCall().once();
289 setUpFlowObjectiveService();
290
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700291 // Send in the add event
292 RouteEvent routeEvent = new RouteEvent(RouteEvent.Type.ROUTE_ADDED, resolvedRoute);
293 routeListener.event(routeEvent);
gaurav36785932016-03-10 17:24:04 +0530294 verify(flowObjectiveService);
295 }
296
297 /**
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700298 * Tests adding a route with to a next hop in a VLAN.
gaurav36785932016-03-10 17:24:04 +0530299 *
300 * We verify that the flowObjectiveService records the correct state and that the
301 * correct flowObjectiveService is submitted to the flowObjectiveService.
302 */
303 @Test
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700304 public void testRouteAddWithVlan() {
305 ResolvedRoute route = new ResolvedRoute(PREFIX1, NEXT_HOP2, MAC2);
gaurav36785932016-03-10 17:24:04 +0530306
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700307 // Create the next objective
308 NextObjective nextObjective = createNextObjective(MAC2, MAC2, SW1_ETH2.port(), VLAN1, true);
309 flowObjectiveService.next(DEVICE_ID, nextObjective);
gaurav36785932016-03-10 17:24:04 +0530310
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700311 // Create the flow objective
312 ForwardingObjective fwd = createForwardingObjective(PREFIX1, true);
313 flowObjectiveService.forward(DEVICE_ID, fwd);
gaurav36785932016-03-10 17:24:04 +0530314 EasyMock.expectLastCall().once();
315 setUpFlowObjectiveService();
316
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700317 // Send in the add event
318 routeListener.event(new RouteEvent(RouteEvent.Type.ROUTE_ADDED, route));
gaurav36785932016-03-10 17:24:04 +0530319
320 verify(flowObjectiveService);
321 }
322
323 /**
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700324 * Tests updating a route.
gaurav36785932016-03-10 17:24:04 +0530325 *
326 * We verify that the flowObjectiveService records the correct state and that the
327 * correct flow is submitted to the flowObjectiveService.
328 */
329 @Test
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700330 public void testRouteUpdate() {
gaurav36785932016-03-10 17:24:04 +0530331 // Firstly add a route
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700332 testRouteAdd();
gaurav36785932016-03-10 17:24:04 +0530333 reset(flowObjectiveService);
gaurav36785932016-03-10 17:24:04 +0530334
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700335 ResolvedRoute route = new ResolvedRoute(PREFIX1, NEXT_HOP2, MAC2);
gaurav36785932016-03-10 17:24:04 +0530336
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700337 // Create the next objective
338 NextObjective nextObjective = createNextObjective(MAC2, MAC2, SW1_ETH2.port(), VLAN1, true);
339 flowObjectiveService.next(DEVICE_ID, nextObjective);
gaurav36785932016-03-10 17:24:04 +0530340
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700341 // Create the flow objective
342 ForwardingObjective fwd = createForwardingObjective(PREFIX1, true);
343 flowObjectiveService.forward(DEVICE_ID, fwd);
gaurav36785932016-03-10 17:24:04 +0530344 EasyMock.expectLastCall().once();
345 setUpFlowObjectiveService();
346
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700347 // Send in the update event
348 routeListener.event(new RouteEvent(RouteEvent.Type.ROUTE_UPDATED, route));
gaurav36785932016-03-10 17:24:04 +0530349
350 verify(flowObjectiveService);
351 }
352
Jonathan Hartf04b7d92016-03-29 09:39:11 -0700353 /**
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700354 * Tests deleting a route.
gaurav36785932016-03-10 17:24:04 +0530355 *
356 * We verify that the flowObjectiveService records the correct state and that the
357 * correct flow is withdrawn from the flowObjectiveService.
358 */
gaurav36785932016-03-10 17:24:04 +0530359 @Test
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700360 public void testRouteDelete() {
gaurav36785932016-03-10 17:24:04 +0530361 // Firstly add a route
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700362 testRouteAdd();
gaurav36785932016-03-10 17:24:04 +0530363
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700364 // Construct the existing route
365 ResolvedRoute route = new ResolvedRoute(PREFIX1, null, null);
gaurav36785932016-03-10 17:24:04 +0530366
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700367 // Create the flow objective
gaurav36785932016-03-10 17:24:04 +0530368 reset(flowObjectiveService);
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700369 ForwardingObjective fwd = createForwardingObjective(PREFIX1, false);
370 flowObjectiveService.forward(DEVICE_ID, fwd);
gaurav36785932016-03-10 17:24:04 +0530371 replay(flowObjectiveService);
372
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700373 // Send in the delete event
374 routeListener.event(new RouteEvent(RouteEvent.Type.ROUTE_REMOVED, route));
gaurav36785932016-03-10 17:24:04 +0530375
376 verify(flowObjectiveService);
377 }
378
gaurav164cf6d2016-03-25 21:43:04 +0530379 private class TestInterfaceService extends InterfaceServiceAdapter {
gaurav164cf6d2016-03-25 21:43:04 +0530380 @Override
381 public void addListener(InterfaceListener listener) {
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700382 interfaceListener = listener;
gaurav164cf6d2016-03-25 21:43:04 +0530383 }
384 }
385
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700386 private class TestRouteService extends RouteServiceAdapter {
gaurav36785932016-03-10 17:24:04 +0530387 @Override
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700388 public void addListener(RouteListener listener) {
389 SingleSwitchFibInstallerTest.this.routeListener = listener;
gaurav36785932016-03-10 17:24:04 +0530390 }
391 }
392
393 private class TestRouterConfig extends RouterConfig {
394
395 @Override
396 public List<String> getInterfaces() {
397 ArrayList<String> interfaces = new ArrayList<>();
398 interfaces.add("of:0000000000000001/1");
Jonathan Harta2eb9ff2016-04-13 21:27:06 -0700399 interfaces.add("of:0000000000000001/2");
gaurav36785932016-03-10 17:24:04 +0530400 return interfaces;
401 }
402
403 @Override
404 public ConnectPoint getControlPlaneConnectPoint() {
405 return SW1_ETH1;
406 }
407
408 @Override
409 public boolean getOspfEnabled() {
410 return true;
411 }
412 }
413
414 private class TestDeviceService extends DeviceServiceAdapter {
415
416 @Override
417 public boolean isAvailable(DeviceId deviceId) {
418 return true;
419 }
420
421 @Override
422 public void addListener(DeviceListener listener) {
423 SingleSwitchFibInstallerTest.this.deviceListener = listener;
424 }
425 }
426}