DataBrokerTestModule: use AbstractDataBrokerTest without inheritance
[mdsal.git] / binding / mdsal-binding-dom-adapter / src / test / java / org / opendaylight / mdsal / binding / dom / adapter / test / ConcurrentDataBrokerTestCustomizer.java
1 /*
2  * Copyright (c) 2017 Red Hat, Inc. 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.mdsal.binding.dom.adapter.test;
9
10 import com.google.common.util.concurrent.ListeningExecutorService;
11 import com.google.common.util.concurrent.MoreExecutors;
12 import java.util.concurrent.Executors;
13
14 /**
15  * AbstractDataBrokerTestCustomizer implementation that uses a single-threaded executor for commits.
16
17  * @author Michael Vorburger
18  */
19 public class ConcurrentDataBrokerTestCustomizer extends AbstractDataBrokerTestCustomizer {
20
21     private final ListeningExecutorService dataTreeChangeListenerExecutorSingleton;
22
23     public ConcurrentDataBrokerTestCustomizer(boolean useMTDataTreeChangeListenerExecutor) {
24         if (useMTDataTreeChangeListenerExecutor) {
25             dataTreeChangeListenerExecutorSingleton = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool());
26         } else {
27             dataTreeChangeListenerExecutorSingleton = MoreExecutors.newDirectExecutorService();
28         }
29     }
30
31     @Override
32     public ListeningExecutorService getCommitCoordinatorExecutor() {
33         return MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
34     }
35
36     @Override
37     public ListeningExecutorService getDataTreeChangeListenerExecutor() {
38         return dataTreeChangeListenerExecutorSingleton;
39     }
40 }