From: Michael Vorburger Date: Fri, 14 Dec 2018 15:22:49 +0000 (+0100) Subject: add real "end-to-end" coverage in TracingBrokerTest X-Git-Tag: release/neon~37 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=26a9c9959de71fc874f84ed9bf5b314ba125657c add real "end-to-end" coverage in TracingBrokerTest 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 --- diff --git a/opendaylight/md-sal/mdsal-trace/dom-impl/pom.xml b/opendaylight/md-sal/mdsal-trace/dom-impl/pom.xml index 613b15fd24..6dd990e7a4 100644 --- a/opendaylight/md-sal/mdsal-trace/dom-impl/pom.xml +++ b/opendaylight/md-sal/mdsal-trace/dom-impl/pom.xml @@ -45,6 +45,18 @@ and is available at http://www.eclipse.org/legal/epl-v10.html + + ${project.groupId} + sal-binding-broker-impl + ${project.version} + tests + test + + + ${project.groupId} + sal-binding-broker-impl + test + org.mockito mockito-core diff --git a/opendaylight/md-sal/mdsal-trace/dom-impl/src/test/java/org/opendaylight/controller/md/sal/trace/tests/TracingBrokerTest.java b/opendaylight/md-sal/mdsal-trace/dom-impl/src/test/java/org/opendaylight/controller/md/sal/trace/tests/TracingBrokerTest.java index 4e24c7d892..6e06279cd5 100644 --- a/opendaylight/md-sal/mdsal-trace/dom-impl/src/test/java/org/opendaylight/controller/md/sal/trace/tests/TracingBrokerTest.java +++ b/opendaylight/md-sal/mdsal-trace/dom-impl/src/test/java/org/opendaylight/controller/md/sal/trace/tests/TracingBrokerTest.java @@ -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() {