Renamed controller.md.sal.dom.store.impl -> mdsal.dom.store.inmemory
[mdsal.git] / dom / mdsal-dom-inmemory-datastore / src / test / java / org / opendaylight / controller / md / sal / dom / store / impl / SchemaUpdateForTransactionTest.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.md.sal.dom.store.impl;
9
10 import static org.junit.Assert.assertNotNull;
11
12 import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore;
13
14 import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
15 import com.google.common.util.concurrent.MoreExecutors;
16 import java.util.concurrent.ExecutionException;
17 import org.junit.Before;
18 import org.junit.Ignore;
19 import org.junit.Test;
20 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
21 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
22
23 public class SchemaUpdateForTransactionTest {
24
25     private static final YangInstanceIdentifier TOP_PATH = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
26     private SchemaContext schemaContext;
27     private InMemoryDOMDataStore domStore;
28
29     @Before
30     public void setupStore() {
31         domStore = new InMemoryDOMDataStore("TEST", MoreExecutors.newDirectExecutorService());
32         // loadSchemas(RockTheHouseInput.class);
33     }
34
35     public void loadSchemas(final Class<?>... classes) {
36         // YangModuleInfo moduleInfo;
37         // try {
38         // ModuleInfoBackedContext context = ModuleInfoBackedContext.create();
39         // for (Class<?> clz : classes) {
40         // moduleInfo = BindingReflections.getModuleInfo(clz);
41         //
42         // context.registerModuleInfo(moduleInfo);
43         // }
44         // schemaContext = context.tryToCreateSchemaContext().get();
45         // domStore.onGlobalContextUpdated(schemaContext);
46         // } catch (Exception e) {
47         // Throwables.propagateIfPossible(e);
48         // }
49     }
50
51     /**
52      * Test suite tests allocating transaction when schema context
53      * does not contain module necessary for client write,
54      * then triggering update of global schema context
55      * and then performing write (according to new module).
56      *
57      * If transaction between allocation and schema context was
58      * unmodified, it is safe to change its schema context
59      * to new one (e.g. it will be same as if allocated after
60      * schema context update.)
61      *
62      * @throws InterruptedException
63      * @throws ExecutionException
64      */
65     @Ignore
66     @Test
67     public void testTransactionSchemaUpdate() throws InterruptedException, ExecutionException {
68         // FIXME: Rewrite this test to be pure DOM only.
69         assertNotNull(domStore);
70
71         // We allocate transaction, initial schema context does not
72         // contain Lists model
73         final DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
74         assertNotNull(writeTx);
75
76         // we trigger schema context update to contain Lists model
77         // loadSchemas(RockTheHouseInput.class, Top.class);
78
79         /**
80          *
81          * Writes /test in writeTx, this write should not fail
82          * with IllegalArgumentException since /test is in
83          * schema context.
84          *
85          */
86         // writeTx.write(TOP_PATH, ImmutableNodes.containerNode(Top.QNAME));
87
88     }
89
90 }