X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=parser%2Fyang-parser-rfc7950%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fstmt%2FStmtTestUtils.java;h=72acef86ac112d0dcbcec47dcae55b18bde5a019;hb=1812c072a4d5c3ba77d9e6c0c7b70f399a6f900d;hp=5390bc4a96807a9e63d5ef3ee6f99efd1ca967d2;hpb=ea1cd91b2315b8756760f89e21280d7f346ca68d;p=yangtools.git diff --git a/parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/StmtTestUtils.java b/parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/StmtTestUtils.java index 5390bc4a96..72acef86ac 100644 --- a/parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/StmtTestUtils.java +++ b/parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/StmtTestUtils.java @@ -13,6 +13,7 @@ import java.io.FileFilter; import java.io.IOException; import java.net.URISyntaxException; import java.net.URL; +import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -20,14 +21,10 @@ import java.util.List; import java.util.Set; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.YangConstants; -import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.ModuleImport; -import org.opendaylight.yangtools.yang.model.api.ModuleLike; import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.Submodule; import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier; import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource; import org.opendaylight.yangtools.yang.model.repo.api.YinTextSchemaSource; @@ -80,36 +77,13 @@ public final class StmtTestUtils { public static YangStatementStreamSource sourceForResource(final String resourceName) { try { - return YangStatementStreamSource.create(YangTextSchemaSource.forFile(new File( + return YangStatementStreamSource.create(YangTextSchemaSource.forPath(Path.of( StmtTestUtils.class.getResource(resourceName).toURI()))); } catch (IOException | YangSyntaxErrorException | URISyntaxException e) { throw new IllegalArgumentException("Failed to create source", e); } } - public static void printReferences(final ModuleLike module, final boolean isSubmodule, final String indent) { - LOG.debug("{}{} {}", indent, isSubmodule ? "Submodule" : "Module", module.getName()); - for (final Submodule submodule : module.getSubmodules()) { - printReferences(submodule, true, indent + " "); - printChilds(submodule.getChildNodes(), indent + " "); - } - } - - public static void printChilds(final Collection childNodes, final String indent) { - - for (final DataSchemaNode child : childNodes) { - LOG.debug("{}{} {}", indent, "Child", child.getQName().getLocalName()); - if (child instanceof DataNodeContainer) { - printChilds(((DataNodeContainer) child).getChildNodes(), indent + " "); - } - } - } - - public static EffectiveModelContext parseYangSource(final String yangSourcePath) throws ReactorException, - URISyntaxException, IOException, YangSyntaxErrorException { - return parseYangSource(yangSourcePath, YangParserConfiguration.DEFAULT, null); - } - public static EffectiveModelContext parseYangSource(final String yangSourcePath, final Set supportedFeatures) throws ReactorException, URISyntaxException, IOException, YangSyntaxErrorException { return parseYangSource(yangSourcePath, YangParserConfiguration.DEFAULT, supportedFeatures); @@ -118,9 +92,8 @@ public final class StmtTestUtils { public static EffectiveModelContext parseYangSource(final String yangSourcePath, final YangParserConfiguration config, final Set supportedFeatures) throws ReactorException, URISyntaxException, IOException, YangSyntaxErrorException { - final URL source = StmtTestUtils.class.getResource(yangSourcePath); - final File sourceFile = new File(source.toURI()); - return parseYangSources(config, supportedFeatures, sourceFile); + return parseYangSources(config, supportedFeatures, + new File(StmtTestUtils.class.getResource(yangSourcePath).toURI())); } public static EffectiveModelContext parseYangSources(final StatementStreamSource... sources) @@ -154,7 +127,7 @@ public final class StmtTestUtils { final Collection sources = new ArrayList<>(files.length); for (File file : files) { - sources.add(YangStatementStreamSource.create(YangTextSchemaSource.forFile(file))); + sources.add(YangStatementStreamSource.create(YangTextSchemaSource.forPath(file.toPath()))); } return parseYangSources(config, supportedFeatures, sources); @@ -167,7 +140,7 @@ public final class StmtTestUtils { public static EffectiveModelContext parseYangSources(final Collection files, final YangParserConfiguration config) throws ReactorException, IOException, YangSyntaxErrorException { - return parseYangSources(config, null, files.toArray(new File[files.size()])); + return parseYangSources(config, null, files.toArray(new File[0])); } public static EffectiveModelContext parseYangSources(final String yangSourcesDirectoryPath)