Adjust to yangtools-2.0.0 changes
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / md / cluster / datastore / model / SchemaContextHelper.java
index f2d23e0059ccafa91f5ab469fb1ed306138bf6c8..7f8b7483a42a62013a38fad7b1a2208373bba5b2 100644 (file)
@@ -9,14 +9,8 @@
 package org.opendaylight.controller.md.cluster.datastore.model;
 
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
 import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public final class SchemaContextHelper {
@@ -38,37 +32,17 @@ public final class SchemaContextHelper {
     }
 
     public static SchemaContext select(final String... schemaFiles) {
-        List<InputStream> streams = new ArrayList<>(schemaFiles.length);
-
-        for (String schemaFile : schemaFiles) {
-            streams.add(getInputStream(schemaFile));
-        }
-
-        try {
-            return YangParserTestUtils.parseYangStreams(streams);
-        } catch (ReactorException e) {
-            throw new RuntimeException("Unable to build schema context from " + streams, e);
-        }
+        return YangParserTestUtils.parseYangResources(SchemaContextHelper.class, schemaFiles);
     }
 
     public static SchemaContext distributedShardedDOMDataTreeSchemaContext() {
-        final List<InputStream> streams = new ArrayList<>();
-        try {
-            // we need prefix-shard-configuration and odl-datastore-test models
-            // for DistributedShardedDOMDataTree tests
-            streams.add(getInputStream(ODL_DATASTORE_TEST_YANG));
-            streams.add(new FileInputStream("src/main/yang/prefix-shard-configuration.yang"));
-            return YangParserTestUtils.parseYangStreams(streams);
-        } catch (FileNotFoundException | ReactorException e) {
-            throw new RuntimeException(e);
-        }
+        // 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() {
-        try {
-            return YangParserTestUtils.parseYangSources(new File("src/main/yang/entity-owners.yang"));
-        } catch (IOException | ReactorException e) {
-            throw new RuntimeException(e);
-        }
+        return YangParserTestUtils.parseYangFiles(new File("src/main/yang/entity-owners.yang"));
     }
 }