add real "end-to-end" coverage in TracingBrokerTest 01/78801/4
authorMichael Vorburger <vorburger@redhat.com>
Fri, 14 Dec 2018 15:22:49 +0000 (16:22 +0100)
committerStephen Kitt <skitt@redhat.com>
Tue, 18 Dec 2018 10:53:51 +0000 (10:53 +0000)
This reproduces the NPE from CONTROLLER-1877,
and fails without the fix from the previous commit.

JIRA: CONTROLLER-1877
Change-Id: Ia2fa6093f8a02c37e1ff04250dcd17ab069c1bd5
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
opendaylight/md-sal/mdsal-trace/dom-impl/pom.xml
opendaylight/md-sal/mdsal-trace/dom-impl/src/test/java/org/opendaylight/controller/md/sal/trace/tests/TracingBrokerTest.java

index 613b15fd24b9efe96aa581b63253a5ab311fe4e8..6dd990e7a46f5c01126ca09c9c7bd45c52978482 100644 (file)
@@ -45,6 +45,18 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     </dependency>
 
     <!-- Testing Dependencies -->
     </dependency>
 
     <!-- Testing Dependencies -->
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>sal-binding-broker-impl</artifactId>
+      <version>${project.version}</version>
+      <classifier>tests</classifier>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>sal-binding-broker-impl</artifactId>
+      <scope>test</scope>
+    </dependency>
     <dependency>
       <groupId>org.mockito</groupId>
       <artifactId>mockito-core</artifactId>
     <dependency>
       <groupId>org.mockito</groupId>
       <artifactId>mockito-core</artifactId>
index 4e24c7d892abfb3cffd40725b7d0d73a3b054739..6e06279cd52e3eaea406f172bd96271f62b053e8 100644 (file)
@@ -9,12 +9,14 @@ package org.opendaylight.controller.md.sal.trace.tests;
 
 import static com.google.common.truth.Truth.assertThat;
 import static java.nio.charset.StandardCharsets.UTF_8;
 
 import static com.google.common.truth.Truth.assertThat;
 import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.util.Collections.singletonList;
 import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 
 import java.io.ByteArrayOutputStream;
 import java.io.PrintStream;
 import org.junit.Test;
 import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 
 import java.io.ByteArrayOutputStream;
 import java.io.PrintStream;
 import org.junit.Test;
+import org.opendaylight.controller.md.sal.binding.test.DataBrokerTestModule;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
 import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
 import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
@@ -30,6 +32,21 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsaltra
  */
 public class TracingBrokerTest {
 
  */
 public class TracingBrokerTest {
 
+    @Test
+    public void testEnd2End() {
+        DataBrokerTestModule wiring = new DataBrokerTestModule(true);
+        wiring.getDataBroker(); // required so DataBrokerTestModule creates the DOMDataBroker
+        DOMDataBroker realDomBroker = wiring.getDOMDataBroker();
+        TracingBroker tracingDomBroker = new TracingBroker("Test", realDomBroker, new ConfigBuilder()
+                // CONTROLLER-1877: configure it like the default/initial mdsaltrace_config.xml in mdsal-trace-api
+                .setTransactionDebugContextEnabled(true)
+                .setWriteWatches(singletonList("/this/will/never/exist"))
+                .setRegistrationWatches(singletonList("/this/will/never/exist"))
+                .build(),
+                wiring.getBindingToNormalizedNodeCodec());
+        tracingDomBroker.newWriteOnlyTransaction().cancel();
+    }
+
     @Test
     @SuppressWarnings({ "resource", "unused" }) // Finding resource leaks is the point of this test
     public void testPrintOpenTransactions() {
     @Test
     @SuppressWarnings({ "resource", "unused" }) // Finding resource leaks is the point of this test
     public void testPrintOpenTransactions() {