X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-broker%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fbinding%2Ftest%2Ftests%2FAbstractDataBrokerTestTest.java;h=5813a0c4e9d7946e5851cfece0093a37f5daf7de;hp=e46d442b217ada72231609928bad506063527fde;hb=8a8de0bffed5b6c9b4ac821dfafa7e944c70ef9d;hpb=e0819c56a40458d9eac0ebbbe1d2049f795cfe95 diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/tests/AbstractDataBrokerTestTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/tests/AbstractDataBrokerTestTest.java index e46d442b21..5813a0c4e9 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/tests/AbstractDataBrokerTestTest.java +++ b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/test/tests/AbstractDataBrokerTestTest.java @@ -8,15 +8,75 @@ package org.opendaylight.controller.md.sal.binding.test.tests; import static com.google.common.truth.Truth.assertThat; +import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.TOP_FOO_KEY; +import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.path; +import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.topLevelList; +import org.junit.Before; +import org.junit.FixMethodOrder; import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest; +import org.junit.runners.MethodSorters; +import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; +import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; +import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; +import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugmentBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ContainerWithUsesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TopBuilder; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -public class AbstractDataBrokerTestTest extends AbstractDataBrokerTest { +/** + * Integration tests the AbstractDataBrokerTest. + * + * @author Michael Vorburger + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class AbstractDataBrokerTestTest extends AbstractConcurrentDataBrokerTest { + + private static final InstanceIdentifier TOP_PATH = InstanceIdentifier.create(Top.class); + + @Before + public void before() { + assertThat(getDataBroker()).isNotNull(); + } @Test - public void ensureDataBrokerTestModuleWorksWithoutException() { + public void aEnsureDataBrokerIsNotNull() { assertThat(getDataBroker()).isNotNull(); } + @Test + public void bPutSomethingIntoDataStore() throws Exception { + writeInitialState(); + assertThat(isTopInDataStore()).isTrue(); + } + + @Test + public void cEnsureDataStoreIsEmptyAgainInNewTest() throws ReadFailedException { + assertThat(isTopInDataStore()).isFalse(); + } + + // copy/pasted from Bug1125RegressionTest.writeInitialState() + private void writeInitialState() throws TransactionCommitFailedException { + WriteTransaction initialTx = getDataBroker().newWriteOnlyTransaction(); + initialTx.put(LogicalDatastoreType.OPERATIONAL, TOP_PATH, new TopBuilder().build()); + TreeComplexUsesAugment fooAugment = new TreeComplexUsesAugmentBuilder() + .setContainerWithUses(new ContainerWithUsesBuilder().setLeafFromGrouping("foo").build()).build(); + initialTx.put(LogicalDatastoreType.OPERATIONAL, path(TOP_FOO_KEY), topLevelList(TOP_FOO_KEY, fooAugment)); + initialTx.submit().checkedGet(); + } + + private boolean isTopInDataStore() throws ReadFailedException { + ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction(); + try { + return readTx.read(LogicalDatastoreType.OPERATIONAL, TOP_PATH).checkedGet().isPresent(); + } finally { + readTx.close(); + } + } + }