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;
17 public class DataBrokerTestModule {
19 public static DataBroker dataBroker() {
20 return new DataBrokerTestModule(false).getDataBroker();
23 private final boolean useMTDataTreeChangeListenerExecutor;
24 private ConstantSchemaAbstractDataBrokerTest dataBrokerTest;
26 public DataBrokerTestModule(boolean useMTDataTreeChangeListenerExecutor) {
27 this.useMTDataTreeChangeListenerExecutor = useMTDataTreeChangeListenerExecutor;
30 // Suppress IllegalCatch because of AbstractDataBrokerTest (change later)
31 @SuppressWarnings({ "checkstyle:IllegalCatch", "checkstyle:IllegalThrows" })
32 public DataBroker getDataBroker() throws RuntimeException {
34 // This is a little bit "upside down" - in the future,
35 // we should probably put what is in AbstractDataBrokerTest
36 // into this DataBrokerTestModule, and make AbstractDataBrokerTest
37 // use it, instead of the way around it currently is (the opposite);
38 // this is just for historical reasons... and works for now.
39 dataBrokerTest = new ConstantSchemaAbstractDataBrokerTest(useMTDataTreeChangeListenerExecutor);
40 dataBrokerTest.setup();
41 return dataBrokerTest.getDataBroker();
42 } catch (Exception e) {
43 throw new RuntimeException(e);
47 public DOMDataBroker getDOMDataBroker() {
48 return dataBrokerTest.getDomBroker();
51 public BindingToNormalizedNodeCodec getBindingToNormalizedNodeCodec() {
52 return dataBrokerTest.getDataBrokerTestCustomizer().getBindingToNormalized();
55 public DOMNotificationRouter getDOMNotificationRouter() {
56 return dataBrokerTest.getDataBrokerTestCustomizer().getDomNotificationRouter();
59 public DOMSchemaService getSchemaService() {
60 return dataBrokerTest.getDataBrokerTestCustomizer().getSchemaService();
63 public SchemaContextProvider getSchemaContextProvider() {
64 return (SchemaContextProvider) dataBrokerTest.getDataBrokerTestCustomizer().getSchemaService();