70051b24e0955fa8f8830ee971434fc2692176d2
[genius.git] / cloudscaler / impl / src / test / java / org / opendaylight / genius / cloudscaler / tests / CloudScalerServiceTestModule.java
1 /*
2  * Copyright (c) 2019 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.genius.cloudscaler.tests;
9
10 import com.google.common.util.concurrent.ListeningExecutorService;
11 import com.google.common.util.concurrent.MoreExecutors;
12 import java.util.concurrent.Executors;
13 import org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker;
14 import org.opendaylight.infrautils.caches.CacheProvider;
15 import org.opendaylight.infrautils.caches.baseimpl.CacheManagersRegistry;
16 import org.opendaylight.infrautils.caches.baseimpl.internal.CacheManagersRegistryImpl;
17 import org.opendaylight.infrautils.caches.guava.internal.GuavaCacheProvider;
18 import org.opendaylight.infrautils.inject.guice.testutils.AbstractGuiceJsr250Module;
19 import org.opendaylight.mdsal.binding.api.DataBroker;
20 import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractBaseDataBrokerTest;
21 import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTestCustomizer;
22
23 public class CloudScalerServiceTestModule extends AbstractGuiceJsr250Module {
24
25     @Override
26     protected void configureBindings() throws Exception {
27         AbstractBaseDataBrokerTest test = new AbstractBaseDataBrokerTest() {
28             @Override
29             protected AbstractDataBrokerTestCustomizer createDataBrokerTestCustomizer() {
30                 return new AbstractDataBrokerTestCustomizer() {
31                     @Override
32                     public ListeningExecutorService getCommitCoordinatorExecutor() {
33                         return MoreExecutors.listeningDecorator(Executors.newCachedThreadPool());
34                     }
35                 };
36             }
37         };
38         test.setup();
39         DataBroker dataBroker = test.getDataBroker();
40         bind(DataBroker.class).toInstance(dataBroker);
41         bind(CacheManagersRegistry.class).to(CacheManagersRegistryImpl.class);
42         bind(CacheProvider.class).to(GuavaCacheProvider.class);
43         SingleTransactionDataBroker singleTransactionDataBroker = new SingleTransactionDataBroker(dataBroker);
44         bind(SingleTransactionDataBroker.class).toInstance(singleTransactionDataBroker);
45     }
46 }