Bug 8163: getDataTreeChangeListenerExecutor() & DataBrokerTestModule 82/90082/1
authorMichael Vorburger <vorburger@redhat.com>
Thu, 13 Jul 2017 21:17:24 +0000 (02:47 +0530)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 29 May 2020 11:59:00 +0000 (13:59 +0200)
Adjust AbstractDataBrokerTestCustomizer with a
getDataTreeChangeListenerExecutor() instead of a
setDataTreeChangeListenerExecutor(), just for more consistency with the
existing getCommitCoordinatorExecutor() method.  Also less confusing (to
me) than seeing the private Executor set by default which may get
changed by the setter later.

Adjust ConcurrentDataBrokerTestCustomizer with the
useMTDataTreeChangeListenerExecutor as a constructor argument, instead
of an useMTDataTreeChangeListenerExecutor() method, just for consistency
for how you already have it in AbstractConcurrentDataBrokerTest.

Extend ConstantSchemaAbstractDataBrokerTest and DataBrokerTestModule to
allow passing through this new opt-in tweak flag, so that tests in
downstream projects such as genius and netvirt can staring exploring
enabling this.

JIRA: MDSAL-556
Change-Id: I4ad85ac48163d2f4bac865f46a3b047d5b7d333a
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 2224375d3c22043958c31195044b4169cb1caff7)

binding/mdsal-binding-test-utils/pom.xml
binding/mdsal-binding-test-utils/src/main/java/org/opendaylight/mdsal/binding/testutils/DataBrokerTestModule.java

index f94ba427913116aaa1c1c183c732aa1833ea5238..db1cbe57513ff6dbc9dd381c44a42241f944f060 100644 (file)
@@ -66,6 +66,7 @@
             <groupId>org.opendaylight.mdsal</groupId>
             <artifactId>mdsal-binding-dom-adapter</artifactId>
             <type>test-jar</type>
+            <scope>compile</scope>
         </dependency>
         <!-- The following are dependencies which are listed
              as scope test in mdsal-binding-dom-adapter; we
index 311f0e795b6833b97ad9b34957983ae45734e1f6..938195b2181b30e060372c03abce410ea2c53cfc 100644 (file)
@@ -8,20 +8,30 @@
 package org.opendaylight.mdsal.binding.testutils;
 
 import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest;
 
-// @Module
 public class DataBrokerTestModule {
+    private final boolean useMTDataTreeChangeListenerExecutor;
+
+    public DataBrokerTestModule(final boolean useMTDataTreeChangeListenerExecutor) {
+        this.useMTDataTreeChangeListenerExecutor = useMTDataTreeChangeListenerExecutor;
+    }
+
+    public static DataBroker dataBroker() {
+        return new DataBrokerTestModule(false).getDataBroker();
+    }
 
     // Suppress IllegalCatch because of AbstractDataBrokerTest (change later)
     @SuppressWarnings({ "checkstyle:IllegalCatch", "checkstyle:IllegalThrows" })
-    public static /* @Provides @Singleton */ DataBroker dataBroker() throws RuntimeException {
+    public DataBroker getDataBroker() throws RuntimeException {
         try {
             // This is a little bit "upside down" - in the future,
             // we should probably put what is in AbstractDataBrokerTest
             // into this DataBrokerTestModule, and make AbstractDataBrokerTest
             // use it, instead of the way around it currently is (the opposite);
             // this is just for historical reasons... and works for now.
-            AbstractDataBrokerTest dataBrokerTest = new AbstractDataBrokerTest();
+            AbstractConcurrentDataBrokerTest dataBrokerTest =
+                    new AbstractConcurrentDataBrokerTest(useMTDataTreeChangeListenerExecutor) { };
             dataBrokerTest.setup();
             return dataBrokerTest.getDataBroker();
         } catch (Exception e) {