checkStyleViolationSeverity=error implemented for mdsal-dom-inmemory-datastore
[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.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
18 import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore;
19 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
20 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
21
22 public class SchemaUpdateForTransactionTest {
23
24     private static final YangInstanceIdentifier TOP_PATH = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
25     private SchemaContext schemaContext;
26     private InMemoryDOMDataStore domStore;
27
28     @Before
29     public void setupStore() {
30         domStore = new InMemoryDOMDataStore("TEST", MoreExecutors.newDirectExecutorService());
31         // loadSchemas(RockTheHouseInput.class);
32     }
33
34     public void loadSchemas(final Class<?>... classes) {
35         // YangModuleInfo moduleInfo;
36         // try {
37         // ModuleInfoBackedContext context = ModuleInfoBackedContext.create();
38         // for (Class<?> clz : classes) {
39         // moduleInfo = BindingReflections.getModuleInfo(clz);
40         //
41         // context.registerModuleInfo(moduleInfo);
42         // }
43         // schemaContext = context.tryToCreateSchemaContext().get();
44         // domStore.onGlobalContextUpdated(schemaContext);
45         // } catch (Exception e) {
46         // Throwables.propagateIfPossible(e);
47         // }
48     }
49
50     /**
51      * Test suite tests allocating transaction when schema context
52      * does not contain module necessary for client write,
53      * then triggering update of global schema context
54      * and then performing write (according to new module).
55      *
56      *<p>
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      *<p>
63      * @throws InterruptedException when this condition met
64      * @throws ExecutionException when execution fails
65      */
66     @Ignore
67     @Test
68     public void testTransactionSchemaUpdate() throws InterruptedException, ExecutionException {
69         // FIXME: Rewrite this test to be pure DOM only.
70         assertNotNull(domStore);
71
72         // We allocate transaction, initial schema context does not
73         // contain Lists model
74         final DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
75         assertNotNull(writeTx);
76
77         // we trigger schema context update to contain Lists model
78         // loadSchemas(RockTheHouseInput.class, Top.class);
79
80         /**
81          *
82          * Writes /test in writeTx, this write should not fail
83          * with IllegalArgumentException since /test is in
84          * schema context.
85          *
86          */
87         // writeTx.write(TOP_PATH, ImmutableNodes.containerNode(Top.QNAME));
88
89     }
90
91 }