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 613b15f..6dd990e 100644 (file)
@@ -45,6 +45,18 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     </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>
index 4e24c7d..6e06279 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 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 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;
@@ -30,6 +32,21 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsaltra
  */
 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() {

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.