Bug 8163: getDataTreeChangeListenerExecutor() & DataBrokerTestModule
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / test / java / org / opendaylight / controller / md / sal / binding / test / DataBrokerTestModule.java
1 /*
2  * Copyright (c) 2016 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.controller.md.sal.binding.test;
9
10 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
11
12 public class DataBrokerTestModule {
13
14     public static DataBroker dataBroker() {
15         return new DataBrokerTestModule(false).getDataBroker();
16     }
17
18     private final boolean useMTDataTreeChangeListenerExecutor;
19
20     public DataBrokerTestModule(boolean useMTDataTreeChangeListenerExecutor) {
21         this.useMTDataTreeChangeListenerExecutor = useMTDataTreeChangeListenerExecutor;
22     }
23
24     // Suppress IllegalCatch because of AbstractDataBrokerTest (change later)
25     @SuppressWarnings({ "checkstyle:IllegalCatch", "checkstyle:IllegalThrows" })
26     public DataBroker getDataBroker() throws RuntimeException {
27         try {
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             ConstantSchemaAbstractDataBrokerTest dataBrokerTest
34                 = new ConstantSchemaAbstractDataBrokerTest(useMTDataTreeChangeListenerExecutor);
35             dataBrokerTest.setup();
36             return dataBrokerTest.getDataBroker();
37         } catch (Exception e) {
38             throw new RuntimeException(e);
39         }
40     }
41 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.