Cleaned up sal-common-* to common folder
[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 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.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
18 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
19 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
20
21 public class SchemaUpdateForTransactionTest {
22
23     private static final YangInstanceIdentifier TOP_PATH = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
24     private SchemaContext schemaContext;
25     private InMemoryDOMDataStore domStore;
26
27     @Before
28     public void setupStore() {
29         domStore = new InMemoryDOMDataStore("TEST", MoreExecutors.newDirectExecutorService());
30         // loadSchemas(RockTheHouseInput.class);
31     }
32
33     public void loadSchemas(final Class<?>... classes) {
34         // YangModuleInfo moduleInfo;
35         // try {
36         // ModuleInfoBackedContext context = ModuleInfoBackedContext.create();
37         // for (Class<?> clz : classes) {
38         // moduleInfo = BindingReflections.getModuleInfo(clz);
39         //
40         // context.registerModuleInfo(moduleInfo);
41         // }
42         // schemaContext = context.tryToCreateSchemaContext().get();
43         // domStore.onGlobalContextUpdated(schemaContext);
44         // } catch (Exception e) {
45         // Throwables.propagateIfPossible(e);
46         // }
47     }
48
49     /**
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).
54      *
55      * If transaction between allocation and schema context was
56      * unmodified, it is safe to change its schema context
57      * to new one (e.g. it will be same as if allocated after
58      * schema context update.)
59      *
60      * @throws InterruptedException
61      * @throws ExecutionException
62      */
63     @Ignore
64     @Test
65     public void testTransactionSchemaUpdate() throws InterruptedException, ExecutionException {
66         // FIXME: Rewrite this test to be pure DOM only.
67         assertNotNull(domStore);
68
69         // We allocate transaction, initial schema context does not
70         // contain Lists model
71         final DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
72         assertNotNull(writeTx);
73
74         // we trigger schema context update to contain Lists model
75         // loadSchemas(RockTheHouseInput.class, Top.class);
76
77         /**
78          *
79          * Writes /test in writeTx, this write should not fail
80          * with IllegalArgumentException since /test is in
81          * schema context.
82          *
83          */
84         // writeTx.write(TOP_PATH, ImmutableNodes.containerNode(Top.QNAME));
85
86     }
87
88 }