2 * Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.genius.interfacemanager.test;
10 import static org.mockito.Mockito.mock;
12 import java.net.UnknownHostException;
13 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
14 import org.opendaylight.controller.md.sal.binding.test.DataBrokerTestModule;
15 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
16 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
17 import org.opendaylight.genius.idmanager.IdManager;
18 import org.opendaylight.genius.idmanager.IdUtils;
19 import org.opendaylight.genius.interfacemanager.listeners.CacheBridgeEntryConfigListener;
20 import org.opendaylight.genius.interfacemanager.listeners.CacheBridgeRefEntryListener;
21 import org.opendaylight.genius.interfacemanager.listeners.CacheInterfaceConfigListener;
22 import org.opendaylight.genius.interfacemanager.listeners.CacheInterfaceStateListener;
23 import org.opendaylight.genius.interfacemanager.listeners.HwVTEPConfigListener;
24 import org.opendaylight.genius.interfacemanager.listeners.HwVTEPTunnelsStateListener;
25 import org.opendaylight.genius.interfacemanager.listeners.InterfaceConfigListener;
26 import org.opendaylight.genius.interfacemanager.listeners.InterfaceInventoryStateListener;
27 import org.opendaylight.genius.interfacemanager.listeners.InterfaceStateListener;
28 import org.opendaylight.genius.interfacemanager.listeners.InterfaceTopologyStateListener;
29 import org.opendaylight.genius.interfacemanager.listeners.TerminationPointStateListener;
30 import org.opendaylight.genius.interfacemanager.listeners.VlanMemberConfigListener;
31 import org.opendaylight.genius.interfacemanager.rpcservice.InterfaceManagerRpcService;
32 import org.opendaylight.genius.interfacemanager.servicebindings.flowbased.listeners.FlowBasedServicesConfigListener;
33 import org.opendaylight.genius.interfacemanager.servicebindings.flowbased.listeners.FlowBasedServicesInterfaceStateListener;
34 import org.opendaylight.genius.interfacemanager.test.infra.TestEntityOwnershipService;
35 import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
36 import org.opendaylight.genius.mdsalutil.interfaces.testutils.TestIMdsalApiManager;
37 import org.opendaylight.infrautils.inject.ModuleSetupRuntimeException;
38 import org.opendaylight.infrautils.inject.guice.testutils.AbstractGuiceJsr250Module;
39 import org.opendaylight.lockmanager.LockManager;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.AlivenessMonitorService;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.LockManagerService;
44 import org.slf4j.Logger;
45 import org.slf4j.LoggerFactory;
48 * Dependency Injection Wiring for {@link InterfaceManagerConfigurationTest}.
50 * <p>This class looks a little bit more complicated than it could and later will be
51 * just because interfacemanager is still using CSS instead of BP with @Inject.
53 * <p>Please DO NOT copy/paste this class as-is into other projects; this is intended
54 * to be temporary, until interfacemanager is switch from CSS to BP.
56 * <p>For "proper" *Module examples, please see the AclServiceModule and
57 * AclServiceTestModule or ElanServiceTestModule instead.
59 * @author Michael Vorburger
61 public class InterfaceManagerTestModule extends AbstractGuiceJsr250Module {
63 private static final Logger LOG = LoggerFactory.getLogger(InterfaceManagerTestModule.class);
66 protected void configureBindings() throws UnknownHostException {
67 // TODO Ordering as below.. hard to do currently, because of interdeps. due to CSS
68 // Bindings for services from this project
69 // Bindings for external services to "real" implementations
70 // Bindings to test infra (fakes & mocks)
72 DataBroker dataBroker = DataBrokerTestModule.dataBroker();
73 bind(DataBroker.class).toInstance(dataBroker);
75 LockManagerService lockManager = new LockManager(dataBroker);
76 bind(LockManagerService.class).toInstance(lockManager);
78 IdUtils idUtils = new IdUtils();
79 IdManagerService idManager;
81 idManager = new IdManager(dataBroker, lockManager, idUtils);
82 } catch (ReadFailedException e) {
83 // TODO Support AbstractGuiceJsr250Module
84 throw new ModuleSetupRuntimeException(e);
86 bind(IdManagerService.class).toInstance(idManager);
88 TestIMdsalApiManager mdsalManager = TestIMdsalApiManager.newInstance();
89 bind(IMdsalApiManager.class).toInstance(mdsalManager);
90 bind(TestIMdsalApiManager.class).toInstance(mdsalManager);
92 EntityOwnershipService entityOwnershipService = TestEntityOwnershipService.newInstance();
93 bind(EntityOwnershipService.class).toInstance(entityOwnershipService);
95 bind(AlivenessMonitorService.class).toInstance(mock(AlivenessMonitorService.class));
96 bind(OdlInterfaceRpcService.class).to(InterfaceManagerRpcService.class);
97 bind(CacheBridgeEntryConfigListener.class);
98 bind(CacheBridgeRefEntryListener.class);
99 bind(CacheInterfaceConfigListener.class);
100 bind(CacheInterfaceStateListener.class);
101 bind(FlowBasedServicesConfigListener.class);
102 bind(FlowBasedServicesInterfaceStateListener.class);
103 bind(HwVTEPConfigListener.class);
104 bind(HwVTEPTunnelsStateListener.class);
105 bind(InterfaceConfigListener.class);
106 bind(InterfaceInventoryStateListener.class);
107 bind(InterfaceTopologyStateListener.class);
108 bind(TerminationPointStateListener.class);
109 bind(VlanMemberConfigListener.class);
110 bind(InterfaceStateListener.class);