Bump upstreams
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / md / cluster / datastore / model / SchemaContextHelper.java
index 7f8b7483a42a62013a38fad7b1a2208373bba5b2..378c9089b70a40b1cd5d7eb2b3677d231249a43f 100644 (file)
@@ -5,12 +5,10 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.controller.md.cluster.datastore.model;
 
-import java.io.File;
 import java.io.InputStream;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public final class SchemaContextHelper {
@@ -19,6 +17,8 @@ public final class SchemaContextHelper {
     public static final String PEOPLE_YANG = "/people.yang";
     public static final String CARS_YANG = "/cars.yang";
 
+    private static volatile EffectiveModelContext FULL;
+
     private SchemaContextHelper() {
 
     }
@@ -27,22 +27,21 @@ public final class SchemaContextHelper {
         return SchemaContextHelper.class.getResourceAsStream(yangFileName);
     }
 
-    public static SchemaContext full() {
-        return select(ODL_DATASTORE_TEST_YANG, PEOPLE_YANG, CARS_YANG);
+    public static EffectiveModelContext full() {
+        EffectiveModelContext ret = FULL;
+        if (ret == null) {
+            synchronized (SchemaContextHelper.class) {
+                ret = FULL;
+                if (ret == null) {
+                    ret = FULL = select(ODL_DATASTORE_TEST_YANG, PEOPLE_YANG, CARS_YANG);
+                }
+            }
+        }
+
+        return ret;
     }
 
-    public static SchemaContext select(final String... schemaFiles) {
+    public static EffectiveModelContext select(final String... schemaFiles) {
         return YangParserTestUtils.parseYangResources(SchemaContextHelper.class, schemaFiles);
     }
-
-    public static SchemaContext distributedShardedDOMDataTreeSchemaContext() {
-        // we need prefix-shard-configuration and odl-datastore-test models
-        // for DistributedShardedDOMDataTree tests
-        return YangParserTestUtils.parseYangResources(SchemaContextHelper.class, ODL_DATASTORE_TEST_YANG,
-            "/META-INF/yang/prefix-shard-configuration@2017-01-10.yang");
-    }
-
-    public static SchemaContext entityOwners() {
-        return YangParserTestUtils.parseYangFiles(new File("src/main/yang/entity-owners.yang"));
-    }
 }