Deprecate all MD-SAL APIs
[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 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;
16
17 @Deprecated
18 public class DataBrokerTestModule {
19
20     public static DataBroker dataBroker() {
21         return new DataBrokerTestModule(false).getDataBroker();
22     }
23
24     private final boolean useMTDataTreeChangeListenerExecutor;
25     private ConstantSchemaAbstractDataBrokerTest dataBrokerTest;
26
27     public DataBrokerTestModule(boolean useMTDataTreeChangeListenerExecutor) {
28         this.useMTDataTreeChangeListenerExecutor = useMTDataTreeChangeListenerExecutor;
29     }
30
31     // Suppress IllegalCatch because of AbstractDataBrokerTest (change later)
32     @SuppressWarnings({ "checkstyle:IllegalCatch", "checkstyle:IllegalThrows" })
33     public DataBroker getDataBroker() throws RuntimeException {
34         try {
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);
45         }
46     }
47
48     public DOMDataBroker getDOMDataBroker() {
49         return dataBrokerTest.getDomBroker();
50     }
51
52     public BindingToNormalizedNodeCodec getBindingToNormalizedNodeCodec() {
53         return dataBrokerTest.getDataBrokerTestCustomizer().getBindingToNormalized();
54     }
55
56     public DOMNotificationRouter getDOMNotificationRouter() {
57         return dataBrokerTest.getDataBrokerTestCustomizer().getDomNotificationRouter();
58     }
59
60     public DOMSchemaService getSchemaService() {
61         return dataBrokerTest.getDataBrokerTestCustomizer().getSchemaService();
62     }
63
64     public SchemaContextProvider getSchemaContextProvider() {
65         return (SchemaContextProvider) dataBrokerTest.getDataBrokerTestCustomizer().getSchemaService();
66     }
67 }