X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=dom%2Fmdsal-dom-inmemory-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fstore%2Fimpl%2FSchemaUpdateForTransactionTest.java;fp=dom%2Fmdsal-dom-inmemory-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fstore%2Fimpl%2FSchemaUpdateForTransactionTest.java;h=3f8da0ca0b844ccfc2bc55842fc091b9f08723a2;hb=c9e43c3fa7ecc66546afb7eda8a1b5d5b15f4120;hp=0000000000000000000000000000000000000000;hpb=ecf38b90583e84c6362aaf32c24fd356f25d5e46;p=mdsal.git diff --git a/dom/mdsal-dom-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaUpdateForTransactionTest.java b/dom/mdsal-dom-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaUpdateForTransactionTest.java new file mode 100644 index 0000000000..3f8da0ca0b --- /dev/null +++ b/dom/mdsal-dom-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaUpdateForTransactionTest.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.md.sal.dom.store.impl; + +import static org.junit.Assert.assertNotNull; + +import com.google.common.util.concurrent.MoreExecutors; +import java.util.concurrent.ExecutionException; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; + +public class SchemaUpdateForTransactionTest { + + private static final YangInstanceIdentifier TOP_PATH = YangInstanceIdentifier.of(TestModel.TEST_QNAME); + private SchemaContext schemaContext; + private InMemoryDOMDataStore domStore; + + @Before + public void setupStore() { + 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); + // + // context.registerModuleInfo(moduleInfo); + // } + // schemaContext = context.tryToCreateSchemaContext().get(); + // domStore.onGlobalContextUpdated(schemaContext); + // } catch (Exception e) { + // Throwables.propagateIfPossible(e); + // } + } + + /** + * Test suite tests allocating transaction when schema context + * does not contain module necessary for client write, + * 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 + */ + @Ignore + @Test + public void testTransactionSchemaUpdate() throws InterruptedException, ExecutionException { + // FIXME: Rewrite this test to be pure DOM only. + assertNotNull(domStore); + + // We allocate transaction, initial schema context does not + // contain Lists model + final DOMStoreReadWriteTransaction writeTx = 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)); + + } + +}