Optimize IMDT tests
[yangtools.git] / yang / yang-data-impl / src / test / java / org / opendaylight / yangtools / yang / data / impl / schema / tree / CaseExclusionTest.java
index 89a2c0be84a73072b7d940a8b5f94e80e410cfff..4ac26ac68116fb8042e9430d02df8150714806a8 100644 (file)
@@ -7,11 +7,12 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.schema.tree;
 
-import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.leafNode;
 
+import org.junit.AfterClass;
 import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
@@ -27,22 +28,28 @@ import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 public class CaseExclusionTest {
+    private static SchemaContext SCHEMA_CONTEXT;
 
-    private SchemaContext schemaContext;
+    private DataTree inMemoryDataTree;
 
-    @Before
-    public void prepare() {
-        schemaContext = TestModel.createTestContext("/case-exclusion-test.yang");
-        assertNotNull("Schema context must not be null.", schemaContext);
+    @BeforeClass
+    public static void beforeClass() {
+        SCHEMA_CONTEXT = TestModel.createTestContext("/case-exclusion-test.yang");
+    }
+
+    @AfterClass
+    public static void afterClass() {
+        SCHEMA_CONTEXT = null;
     }
 
-    private DataTree initDataTree() {
-        return new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_CONFIGURATION, schemaContext);
+    @Before
+    public void before() {
+        inMemoryDataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_CONFIGURATION,
+            SCHEMA_CONTEXT);
     }
 
     @Test
     public void testCorrectCaseWrite() throws DataValidationFailedException {
-        final DataTree inMemoryDataTree = initDataTree();
         final NodeIdentifier choice1Id = new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "choice1"));
 
         final ContainerNode container = Builders
@@ -63,7 +70,6 @@ public class CaseExclusionTest {
 
     @Test(expected = IllegalArgumentException.class)
     public void testCaseExclusion() throws DataValidationFailedException {
-        final DataTree inMemoryDataTree = initDataTree();
         final NodeIdentifier choice1Id = new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "choice1"));
 
         final ContainerNode container = Builders
@@ -92,7 +98,6 @@ public class CaseExclusionTest {
 
     @Test(expected = IllegalArgumentException.class)
     public void testCaseExclusionOnChoiceWrite() throws DataValidationFailedException {
-        final DataTree inMemoryDataTree = initDataTree();
         // Container write
         final ContainerNode container = Builders.containerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)).build();