X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-inmemory-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fstore%2Fimpl%2FSchemaUpdateForTransactionTest.java;h=0b5598098595d16056a7d88ee766faf3ca6be996;hp=e7af4dffae98b0b0543a8919c8ead80c6132512a;hb=258d8039ac144aeee2efa7943228c0fc6cdaf651;hpb=45757bbd6c220f0f805715c84025c75a9388770a 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 e7af4dffae..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 @@ -8,15 +8,14 @@ package org.opendaylight.controller.md.sal.dom.store.impl; import static org.junit.Assert.assertNotNull; -import com.google.common.base.Throwables; + import com.google.common.util.concurrent.MoreExecutors; -import java.util.concurrent.ExecutionException; 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; @@ -30,25 +29,20 @@ public class SchemaUpdateForTransactionTest { private InMemoryDOMDataStore domStore; @Before - public void setupStore() { - domStore = new InMemoryDOMDataStore("TEST", MoreExecutors.newDirectExecutorService()); + 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); } /** @@ -57,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)); - } - }