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 {
}
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"));
}
}