X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fmd-sal%2Fsal-inmemory-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fstore%2Fimpl%2FSchemaUpdateForTransactionTest.java;h=0b5598098595d16056a7d88ee766faf3ca6be996;hb=c5f3be93482d6b06d95ebf22b2ef2723fd813f89;hp=5cba93a712f6b313d0a40bd9ece03ec88135d567;hpb=17d82f582a6bc13c78be3b19954ff8c021180e93;p=controller.git diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaUpdateForTransactionTest.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaUpdateForTransactionTest.java index 5cba93a712..0b55980985 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaUpdateForTransactionTest.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaUpdateForTransactionTest.java @@ -9,23 +9,19 @@ package org.opendaylight.controller.md.sal.dom.store.impl; import static org.junit.Assert.assertNotNull; -import java.util.concurrent.ExecutionException; - +import com.google.common.util.concurrent.MoreExecutors; import org.junit.Before; import org.junit.Test; import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction; +import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.RockTheHouseInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top; -import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext; import org.opendaylight.yangtools.yang.binding.YangModuleInfo; import org.opendaylight.yangtools.yang.binding.util.BindingReflections; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import com.google.common.base.Throwables; -import com.google.common.util.concurrent.MoreExecutors; - public class SchemaUpdateForTransactionTest { private static final YangInstanceIdentifier TOP_PATH = YangInstanceIdentifier.of(Top.QNAME); @@ -33,25 +29,20 @@ public class SchemaUpdateForTransactionTest { private InMemoryDOMDataStore domStore; @Before - public void setupStore() { - domStore = new InMemoryDOMDataStore("TEST", MoreExecutors.sameThreadExecutor()); + public void setupStore() throws Exception { + this.domStore = new InMemoryDOMDataStore("TEST", MoreExecutors.newDirectExecutorService()); loadSchemas(RockTheHouseInput.class); } - public void loadSchemas(final Class... classes) { - YangModuleInfo moduleInfo; - try { - ModuleInfoBackedContext context = ModuleInfoBackedContext.create(); - for (Class clz : classes) { - moduleInfo = BindingReflections.getModuleInfo(clz); + public void loadSchemas(final Class... classes) throws Exception { + final ModuleInfoBackedContext context = ModuleInfoBackedContext.create(); + for (final Class clz : classes) { + YangModuleInfo moduleInfo = BindingReflections.getModuleInfo(clz); - context.registerModuleInfo(moduleInfo); - } - schemaContext = context.tryToCreateSchemaContext().get(); - domStore.onGlobalContextUpdated(schemaContext); - } catch (Exception e) { - Throwables.propagateIfPossible(e); + context.registerModuleInfo(moduleInfo); } + this.schemaContext = context.tryToCreateSchemaContext().get(); + this.domStore.onGlobalContextUpdated(this.schemaContext); } /** @@ -60,36 +51,30 @@ public class SchemaUpdateForTransactionTest { * then triggering update of global schema context * and then performing write (according to new module). * + *

* If transaction between allocation and schema context was * unmodified, it is safe to change its schema context * to new one (e.g. it will be same as if allocated after * schema context update.) - * - * @throws InterruptedException - * @throws ExecutionException */ @Test - public void testTransactionSchemaUpdate() throws InterruptedException, ExecutionException { + public void testTransactionSchemaUpdate() throws Exception { - assertNotNull(domStore); + assertNotNull(this.domStore); // We allocate transaction, initial schema context does not // contain Lists model - DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction(); + final DOMStoreReadWriteTransaction writeTx = this.domStore.newReadWriteTransaction(); assertNotNull(writeTx); // we trigger schema context update to contain Lists model loadSchemas(RockTheHouseInput.class, Top.class); - /** - * + /* * Writes /test in writeTx, this write should not fail * with IllegalArgumentException since /test is in * schema context. - * */ writeTx.write(TOP_PATH, ImmutableNodes.containerNode(Top.QNAME)); - } - }