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.controller.md.sal.binding.test;
10 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
11 import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
12 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
13 import org.opendaylight.controller.md.sal.dom.broker.impl.DOMNotificationRouter;
14 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
15 import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
18 public class DataBrokerTestModule {
20 public static DataBroker dataBroker() {
21 return new DataBrokerTestModule(false).getDataBroker();
24 private final boolean useMTDataTreeChangeListenerExecutor;
25 private ConstantSchemaAbstractDataBrokerTest dataBrokerTest;
27 public DataBrokerTestModule(boolean useMTDataTreeChangeListenerExecutor) {
28 this.useMTDataTreeChangeListenerExecutor = useMTDataTreeChangeListenerExecutor;
31 // Suppress IllegalCatch because of AbstractDataBrokerTest (change later)
32 @SuppressWarnings({ "checkstyle:IllegalCatch", "checkstyle:IllegalThrows" })
33 public DataBroker getDataBroker() throws RuntimeException {
35 // This is a little bit "upside down" - in the future,
36 // we should probably put what is in AbstractDataBrokerTest
37 // into this DataBrokerTestModule, and make AbstractDataBrokerTest
38 // use it, instead of the way around it currently is (the opposite);
39 // this is just for historical reasons... and works for now.
40 dataBrokerTest = new ConstantSchemaAbstractDataBrokerTest(useMTDataTreeChangeListenerExecutor);
41 dataBrokerTest.setup();
42 return dataBrokerTest.getDataBroker();
43 } catch (Exception e) {
44 throw new RuntimeException(e);
48 public DOMDataBroker getDOMDataBroker() {
49 return dataBrokerTest.getDomBroker();
52 public BindingToNormalizedNodeCodec getBindingToNormalizedNodeCodec() {
53 return dataBrokerTest.getDataBrokerTestCustomizer().getBindingToNormalized();
56 public DOMNotificationRouter getDOMNotificationRouter() {
57 return dataBrokerTest.getDataBrokerTestCustomizer().getDomNotificationRouter();
60 public DOMSchemaService getSchemaService() {
61 return dataBrokerTest.getDataBrokerTestCustomizer().getSchemaService();
64 public SchemaContextProvider getSchemaContextProvider() {
65 return (SchemaContextProvider) dataBrokerTest.getDataBrokerTestCustomizer().getSchemaService();