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.mdsal.binding.testutils;
10 import org.opendaylight.mdsal.binding.api.DataBroker;
11 import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest;
13 public class DataBrokerTestModule {
14 private final boolean useMTDataTreeChangeListenerExecutor;
16 public DataBrokerTestModule(final boolean useMTDataTreeChangeListenerExecutor) {
17 this.useMTDataTreeChangeListenerExecutor = useMTDataTreeChangeListenerExecutor;
20 public static DataBroker dataBroker() {
21 return new DataBrokerTestModule(false).getDataBroker();
24 // Suppress IllegalCatch because of AbstractDataBrokerTest (change later)
25 @SuppressWarnings({ "checkstyle:IllegalCatch", "checkstyle:IllegalThrows" })
26 public DataBroker getDataBroker() throws RuntimeException {
28 // This is a little bit "upside down" - in the future,
29 // we should probably put what is in AbstractDataBrokerTest
30 // into this DataBrokerTestModule, and make AbstractDataBrokerTest
31 // use it, instead of the way around it currently is (the opposite);
32 // this is just for historical reasons... and works for now.
33 AbstractConcurrentDataBrokerTest dataBrokerTest =
34 new AbstractConcurrentDataBrokerTest(useMTDataTreeChangeListenerExecutor) { };
35 dataBrokerTest.setup();
36 return dataBrokerTest.getDataBroker();
37 } catch (Exception e) {
38 throw new RuntimeException(e);