From: Robert Varga Date: Wed, 21 Oct 2020 21:14:06 +0000 (+0200) Subject: Change StmtTestUtils.sourceForResource() X-Git-Tag: v6.0.1~50 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=7ef4283929c5ac7a8bb7b90e0ec0f57edcaa9939;p=yangtools.git Change StmtTestUtils.sourceForResource() We have a number of test resources which are considered in JPMS world -- and hence we cannot rely on utilities to load them, as those utilities are not authorized to use them. Since we do not want to update massive amounts of tests, just change how we load resources -- go through Class.getResource() and turn that into a File and use that. That way StmtTestUtils is the caller and it is inside our module and is allowed to do that. JIRA: YANGTOOLS-1151 Change-Id: I6cd43e7cc7ddc1b6c3cbac5875dd9716d43be684 Signed-off-by: Robert Varga --- diff --git a/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/StmtTestUtils.java b/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/StmtTestUtils.java index 3c784d309e..13a1e12a98 100644 --- a/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/StmtTestUtils.java +++ b/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/StmtTestUtils.java @@ -79,9 +79,9 @@ public final class StmtTestUtils { public static StatementStreamSource sourceForResource(final String resourceName) { try { - return YangStatementStreamSource.create(YangTextSchemaSource.forResource( - StmtTestUtils.class, resourceName)); - } catch (IOException | YangSyntaxErrorException e) { + return YangStatementStreamSource.create(YangTextSchemaSource.forFile(new File( + StmtTestUtils.class.getResource(resourceName).toURI()))); + } catch (IOException | YangSyntaxErrorException | URISyntaxException e) { throw new IllegalArgumentException("Failed to create source", e); } }