Eliminate use of DataTreeFactory.create(TreeType)
[yangtools.git] / yang / yang-data-impl / src / test / java / org / opendaylight / yangtools / yang / data / impl / schema / tree / DataTreeTransactionTest.java
1 /*
2  * Copyright (c) 2015 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.yangtools.yang.data.impl.schema.tree;
9
10 import org.junit.Before;
11 import org.junit.Test;
12 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
13 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
14 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
15 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
16 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
17
18 public class DataTreeTransactionTest {
19     private DataTree tree;
20
21     @Before
22     public void setUp() throws ReactorException {
23         tree = InMemoryDataTreeFactory.getInstance().create(DataTreeConfiguration.DEFAULT_OPERATIONAL);
24         tree.setSchemaContext(TestModel.createTestContext());
25     }
26
27     @Test
28     public void testSealedValidate() throws DataValidationFailedException {
29         final DataTreeModification mod = tree.takeSnapshot().newModification();
30         mod.ready();
31         tree.validate(mod);
32     }
33
34     @Test
35     public void testSealedPrepare() {
36         final DataTreeModification mod = tree.takeSnapshot().newModification();
37         mod.ready();
38         tree.prepare(mod);
39     }
40
41     @Test(expected = IllegalArgumentException.class)
42     public void testUnsealedValidate() throws DataValidationFailedException {
43         final DataTreeModification mod = tree.takeSnapshot().newModification();
44         tree.validate(mod);
45     }
46
47     @Test(expected = IllegalArgumentException.class)
48     public void testUnsealedPrepare() {
49         final DataTreeModification mod = tree.takeSnapshot().newModification();
50         tree.prepare(mod);
51     }
52 }