2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.mdsal.dom.store.inmemory;
10 import static org.junit.Assert.assertNotNull;
12 import com.google.common.util.concurrent.MoreExecutors;
13 import java.util.concurrent.ExecutionException;
14 import org.junit.Before;
15 import org.junit.Ignore;
16 import org.junit.Test;
17 import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
18 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
19 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
21 public class SchemaUpdateForTransactionTest {
22 private static final YangInstanceIdentifier TOP_PATH = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
24 private SchemaContext schemaContext;
25 private InMemoryDOMDataStore domStore;
28 public void setupStore() {
29 domStore = new InMemoryDOMDataStore("TEST", MoreExecutors.newDirectExecutorService());
30 // loadSchemas(RockTheHouseInput.class);
33 public void loadSchemas(final Class<?>... classes) {
34 // YangModuleInfo moduleInfo;
36 // ModuleInfoBackedContext context = ModuleInfoBackedContext.create();
37 // for (Class<?> clz : classes) {
38 // moduleInfo = BindingReflections.getModuleInfo(clz);
40 // context.registerModuleInfo(moduleInfo);
42 // schemaContext = context.tryToCreateSchemaContext().get();
43 // domStore.onGlobalContextUpdated(schemaContext);
44 // } catch (Exception e) {
45 // Throwables.propagateIfPossible(e);
50 * Test suite tests allocating transaction when schema context
51 * does not contain module necessary for client write,
52 * then triggering update of global schema context
53 * and then performing write (according to new module).
56 * If transaction between allocation and schema context was
57 * unmodified, it is safe to change its schema context
58 * to new one (e.g. it will be same as if allocated after
59 * schema context update.)
62 * @throws InterruptedException when this condition met
63 * @throws ExecutionException when execution fails
67 public void testTransactionSchemaUpdate() throws InterruptedException, ExecutionException {
68 // FIXME: Rewrite this test to be pure DOM only.
69 assertNotNull(domStore);
71 // We allocate transaction, initial schema context does not
72 // contain Lists model
73 final DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
74 assertNotNull(writeTx);
76 // we trigger schema context update to contain Lists model
77 // loadSchemas(RockTheHouseInput.class, Top.class);
81 * Writes /test in writeTx, this write should not fail
82 * with IllegalArgumentException since /test is in
86 // writeTx.write(TOP_PATH, ImmutableNodes.containerNode(Top.QNAME));