96facbed9cdd3dbd9e95919fa91c2c6d208d55ff
[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 // @Module
13 public class DataBrokerTestModule {
14
15     // Suppress IllegalCatch because of AbstractDataBrokerTest (change later)
16     @SuppressWarnings({ "checkstyle:IllegalCatch", "checkstyle:IllegalThrows" })
17     public static /* @Provides @Singleton */ DataBroker dataBroker() throws RuntimeException {
18         try {
19             // This is a little bit "upside down" - in the future,
20             // we should probably put what is in AbstractDataBrokerTest
21             // into this DataBrokerTestModule, and make AbstractDataBrokerTest
22             // use it, instead of the way around it currently is (the opposite);
23             // this is just for historical reasons... and works for now.
24             AbstractDataBrokerTest dataBrokerTest = new AbstractDataBrokerTest();
25             dataBrokerTest.setup();
26             return dataBrokerTest.getDataBroker();
27         } catch (Exception e) {
28             throw new RuntimeException(e);
29         }
30     }
31 }