Remove deprecated Yin/YangStatementSourceImpl 37/62537/22
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 1 Sep 2017 09:46:18 +0000 (11:46 +0200)
committerRobert Varga <nite@hq.sk>
Wed, 27 Sep 2017 13:26:14 +0000 (13:26 +0000)
These classes have been superseded by Yin/YangStatementStreamSource,
which have better semantics. Remove them and fixup former call sites.

Change-Id: I9f16e62da8cf38ce35703de6a93b1d5d9dcdf2e8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
127 files changed:
yang-validation-tool/src/main/java/org/opendaylight/yangtools/yang/validation/tool/Main.java
yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/AnyXmlSupportTest.java
yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/Bug4501Test.java
yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/Bug4969Test.java
yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/Bug5446Test.java
yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/Bug6112Test.java
yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/Bug7246Test.java
yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/Bug8083Test.java
yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/JsonStreamToNormalizedNodeTest.java
yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/NormalizedNodeToJsonStreamTest.java
yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/StreamToNormalizedNodeTest.java
yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/YangModeledAnyXmlSupportTest.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/Bug5396Test.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/Bug5446Test.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/Bug8083Test.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/Bug8675Test.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/Bug8745Test.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/Bug8803Test.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/DOMSourceXMLStreamReaderTest.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/NormalizedNodeXmlTranslationTest.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/NormalizedNodesToXmlTest.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/StrictParsingModeTest.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlStreamUtilsTest.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlToNormalizedNodesTest.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/YangModeledAnyXMLDeserializationTest.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/YangModeledAnyXMLSerializationTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/xml/Bug2964Test.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/xml/InstanceIdentifierForXmlCodecTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/xml/XmlDocumentUtilsTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/xml/XmlStreamUtilsTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codecs/StringPatternCheckingCodecTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/leafref/Bug7844Test.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/leafref/context/Bug8713Test.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/leafref/context/DataTreeCandidateValidatorTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/leafref/context/DataTreeCandidateValidatorTest2.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/leafref/context/DataTreeCandidateValidatorTest3.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/leafref/context/LeafRefContextTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/leafref/context/LeafRefContextTreeBuilderTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/BuilderTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/InstanceIdToNodesTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/NormalizedDataBuilderTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/SchemaOrderedNormalizedNodeWriterTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/SchemaUtilsTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/transform/dom/parser/DomToNormalizedNodeParserFactoryTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/transform/dom/serializer/Bug5396.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/transform/dom/serializer/Bug5446Test.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/transform/dom/serializer/Bug6392Test.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/transform/dom/serializer/DomSerializerTestUtils.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/transform/dom/serializer/NormalizedNodeXmlTranslationTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/transform/dom/serializer/YangModeledAnyXMLDeserializationTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/transform/dom/serializer/YangModeledAnyXMLSerializationTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/Bug2690Test.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/Bug3674Test.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/Bug4295Test.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/Bug4454Test.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/Bug5830Test.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/DataTreeCandidatesTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/ListConstraintsValidation.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/OrderedListTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/TestModel.java
yang/yang-data-jaxen/src/test/java/org/opendaylight/yangtools/yang/data/jaxen/BitIsSetXPathFunctionTest.java
yang/yang-data-jaxen/src/test/java/org/opendaylight/yangtools/yang/data/jaxen/DerefXPathFunctionTest.java
yang/yang-data-jaxen/src/test/java/org/opendaylight/yangtools/yang/data/jaxen/DerivedFromXPathFunctionTest.java
yang/yang-data-jaxen/src/test/java/org/opendaylight/yangtools/yang/data/jaxen/EnumValueXPathFunctionTest.java
yang/yang-data-jaxen/src/test/java/org/opendaylight/yangtools/yang/data/jaxen/JaxenTest.java
yang/yang-maven-plugin/src/test/java/org/opendaylight/yangtools/yang2sources/plugin/UtilTest.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/SchemaContext.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/ResourceYangTextSchemaSource.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/ResourceYinTextSchemaSource.java [new file with mode: 0644]
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/YangTextSchemaSource.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/YinTextFileSchemaSource.java [new file with mode: 0644]
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/YinTextSchemaSource.java
yang/yang-model-export/src/test/java/org/opendaylight/yangtools/yang/model/export/test/Bug2444Test.java
yang/yang-model-export/src/test/java/org/opendaylight/yangtools/yang/model/export/test/Bug4504Test.java
yang/yang-model-export/src/test/java/org/opendaylight/yangtools/yang/model/export/test/Bug5531Test.java
yang/yang-model-export/src/test/java/org/opendaylight/yangtools/yang/model/export/test/Bug6856Test.java
yang/yang-model-export/src/test/java/org/opendaylight/yangtools/yang/model/export/test/SchemaContextEmitterTest.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/YangModelDependencyInfo.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/SharedSchemaContextFactory.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/rfc6020/repo/YangStatementStreamSource.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/rfc6020/repo/YinTextToDomTransformer.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/CrossSourceStatementReactor.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/YangStatementSourceImpl.java [deleted file]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/YinStatementSourceImpl.java [deleted file]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/YangParseException.java [deleted file]
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/impl/util/YangModelDependencyInfoTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/DependencyResolverTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ConstraintDefinitionsTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/AugmentTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/AugmentToExtensionTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug1412Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug1413Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug3859Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug394Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5693Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveSchemaContextTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/GroupingTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/OrderingTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/StmtTestUtils.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/SubstatementValidatorTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/TestUtils.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/TwoRevisionsTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/TypesResolutionTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/UsesAugmentTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserIdentityTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserNegativeTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserSimpleTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserWithContextTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/openconfigver/yin/YinOpenconfigVersionTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileAugmentStmtTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileChoiceStmtTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileExtensionStmtTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileFeatureStmtTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileGroupingStmtTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileHeaderStmtsTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileIdentityStmtTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileImportStmtTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileIncludeStmtTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileLeafListStmtTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileListStmtTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileMetaStmtsTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileRpcStmtTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileStmtTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileTypeDefStmtTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileUsesStmtTest.java
yang/yang-test-util/src/main/java/org/opendaylight/yangtools/yang/test/util/YangParserTestUtils.java

index 5eab866e83d9bf135810a3ccce916d3429c8d0c4..3703f496ab0db4f812b2200b741eddb575768249 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.yangtools.yang.validation.tool;
 
 import java.io.File;
 import java.net.URISyntaxException;
-import java.util.Arrays;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -28,7 +27,7 @@ public final class Main {
             final File[] yangModels = params.getYangSourceDir().listFiles();
 
             try {
-                YangParserTestUtils.parseYangSources(Arrays.asList(yangModels));
+                YangParserTestUtils.parseYangFiles(yangModels);
             } catch (Exception e) {
                 LOG.error("Yang files could not be parsed.", e);
             }
index 0970dde218eed3f1af071bce01a32103c09aeb1d..28ffdb8a7ece08f5d1fc76a7b39ae24f072ca034 100644 (file)
@@ -37,7 +37,6 @@ import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeS
 import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -53,8 +52,8 @@ public class AnyXmlSupportTest {
     private static SchemaContext schemaContext;
 
     @BeforeClass
-    public static void setup() throws IOException, URISyntaxException, ReactorException {
-        schemaContext = YangParserTestUtils.parseYangSources("/complexjson/yang");
+    public static void setup() {
+        schemaContext = YangParserTestUtils.parseYangResourceDirectory("/complexjson/yang");
     }
 
     @Test
index f4157ea535ea6081f61161561d8e2e19c0180223..da3da859995fd7c664aeb8af0c89a9cd721d3889 100644 (file)
@@ -30,7 +30,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStre
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter;
 import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult;
 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 class Bug4501Test {
@@ -38,8 +37,8 @@ public class Bug4501Test {
     private static SchemaContext schemaContext;
 
     @BeforeClass
-    public static void initialization() throws IOException, URISyntaxException, ReactorException {
-        schemaContext = YangParserTestUtils.parseYangSources("/bug-4501/yang");
+    public static void initialization() {
+        schemaContext = YangParserTestUtils.parseYangResourceDirectory("/bug-4501/yang");
     }
 
     @Test
index 945cd3c55efaa585d524197e5ac3aafd644e90a6..0077fb575f48eee4202e14c1703b23fc172a11a8 100644 (file)
@@ -13,7 +13,6 @@ import static org.junit.Assert.assertTrue;
 
 import com.google.common.base.Optional;
 import com.google.gson.stream.JsonReader;
-import java.io.File;
 import java.io.IOException;
 import java.io.StringReader;
 import java.net.URISyntaxException;
@@ -29,16 +28,13 @@ import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStre
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter;
 import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class Bug4969Test {
 
     @Test
-    public void newParserLeafRefTest() throws SourceException, ReactorException, URISyntaxException, IOException {
-        File sourceDir = new File(Bug4969Test.class.getResource("/bug-4969/yang").toURI());
-        SchemaContext context = YangParserTestUtils.parseYangSources(sourceDir.listFiles());
+    public void newParserLeafRefTest() throws IOException, URISyntaxException {
+        SchemaContext context = YangParserTestUtils.parseYangResourceDirectory("/bug-4969/yang");
         assertNotNull(context);
 
         verifyNormalizedNodeResult(context);
@@ -95,9 +91,8 @@ public class Bug4969Test {
     }
 
     @Test
-    public void newParserLeafRefTest2() throws SourceException, ReactorException, URISyntaxException, IOException {
-        File sourceDir = new File(Bug4969Test.class.getResource("/leafref/yang").toURI());
-        SchemaContext context = YangParserTestUtils.parseYangSources(sourceDir.listFiles());
+    public void newParserLeafRefTest2() throws URISyntaxException, IOException {
+        SchemaContext context = YangParserTestUtils.parseYangResourceDirectory("/leafref/yang");
         assertNotNull(context);
 
         parseJsonToNormalizedNodes(context);
index 4c937f2fcb695277a0674313715857e2cba5e521..55ce9c74a2bf305231167e69b26d3aef2da610fe 100644 (file)
@@ -54,8 +54,7 @@ public class Bug5446Test {
         rootQName = QName.create(fooModuleQName, "root");
         ipAddressQName = QName.create(fooModuleQName, "ip-address");
 
-        schemaContext = YangParserTestUtils.parseYangSources(
-                new File(Bug5446Test.class.getResource("/bug5446/yang/foo.yang").toURI()));
+        schemaContext = YangParserTestUtils.parseYangResources(Bug5446Test.class, "/bug5446/yang/foo.yang");
     }
 
     @Test
index 8c4f14cc865504f88bb45aa4c12276fc7ce34f92..5e14e6eced8300917191adf2c4deecf0fbda1309 100644 (file)
@@ -28,15 +28,14 @@ import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStre
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter;
 import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult;
 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 class Bug6112Test {
     private static SchemaContext schemaContext;
 
     @BeforeClass
-    public static void initialization() throws IOException, URISyntaxException, ReactorException {
-        schemaContext = YangParserTestUtils.parseYangSources("/bug-6112/yang");
+    public static void initialization() {
+        schemaContext = YangParserTestUtils.parseYangResourceDirectory("/bug-6112/yang");
     }
 
     private static NormalizedNode<?, ?> readJson(final String jsonPath) throws IOException, URISyntaxException {
index 511ab97bbef0f1005938781b515e93e9ca0e9c6c..912b89a334d24fbcdafae6f42d78a8737594dead 100644 (file)
@@ -38,7 +38,7 @@ public class Bug7246Test {
 
     @Test
     public void test() throws Exception {
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSource("/bug7246/yang/rpc-test.yang");
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResource("/bug7246/yang/rpc-test.yang");
         final JsonParser parser = new JsonParser();
         final JsonElement expextedJson = parser
                 .parse(new FileReader(new File(getClass().getResource("/bug7246/json/expected-output.json").toURI())));
index 618dca1e5519d82802a32856418ef7ec80825737..98858d396e4895f3e275d4bd1dbcb6f9147368d9 100644 (file)
@@ -12,7 +12,9 @@ import static org.junit.Assert.assertNotNull;
 import static org.opendaylight.yangtools.yang.data.codec.gson.TestUtils.loadTextFile;
 
 import com.google.gson.stream.JsonReader;
+import java.io.IOException;
 import java.io.StringReader;
+import java.net.URISyntaxException;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -26,8 +28,8 @@ public class Bug8083Test {
 
     @Ignore("Instance-identifier codec has to be modified according to the RFC7951 to correctly parse this.")
     @Test
-    public void testRFC7951InstanceIdentifierPath() throws Exception {
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSources("/bug8083/yang/");
+    public void testRFC7951InstanceIdentifierPath() throws IOException, URISyntaxException {
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResourceDirectory("/bug8083/yang/");
         final String inputJson = loadTextFile("/bug8083/json/foo.json");
 
         // deserialization
@@ -41,8 +43,8 @@ public class Bug8083Test {
 
     @Ignore("JSONEmptyCodec needs to be fixed first.")
     @Test
-    public void testInstanceIdentifierPathWithEmptyListKey() throws Exception {
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSource("/bug8083/yang/baz.yang");
+    public void testInstanceIdentifierPathWithEmptyListKey() throws IOException, URISyntaxException {
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResource("/bug8083/yang/baz.yang");
         final String inputJson = loadTextFile("/bug8083/json/baz.json");
 
         // deserialization
@@ -55,8 +57,8 @@ public class Bug8083Test {
     }
 
     @Test
-    public void testInstanceIdentifierPathWithIdentityrefListKey() throws Exception {
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSource("/bug8083/yang/zab.yang");
+    public void testInstanceIdentifierPathWithIdentityrefListKey() throws IOException, URISyntaxException {
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResource("/bug8083/yang/zab.yang");
         final String inputJson = loadTextFile("/bug8083/json/zab.json");
 
         // deserialization
@@ -69,8 +71,8 @@ public class Bug8083Test {
     }
 
     @Test
-    public void testInstanceIdentifierPathWithInstanceIdentifierListKey() throws Exception {
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSource("/bug8083/yang/foobar.yang");
+    public void testInstanceIdentifierPathWithInstanceIdentifierListKey() throws IOException, URISyntaxException {
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResource("/bug8083/yang/foobar.yang");
         final String inputJson = loadTextFile("/bug8083/json/foobar.json");
 
         // deserialization
index bd852e288b88b80f826ed4ff58e00d311d07417c..c2fb1fdcb059de753dc8c820342a6820cdc6d6c3 100644 (file)
@@ -33,7 +33,6 @@ import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeS
 import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 /**
@@ -46,8 +45,8 @@ public class JsonStreamToNormalizedNodeTest {
     private static SchemaContext schemaContext;
 
     @BeforeClass
-    public static void initialization() throws IOException, URISyntaxException, ReactorException {
-        schemaContext = YangParserTestUtils.parseYangSources("/complexjson/yang");
+    public static void initialization() {
+        schemaContext = YangParserTestUtils.parseYangResourceDirectory("/complexjson/yang");
     }
 
     @Test
index 7271c929b339ff041fa9e4a8a504a09a099ac383..a07868646dc5b13b9f1e45c15c7c91579ecb5265 100644 (file)
@@ -39,7 +39,6 @@ import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 /**
@@ -54,8 +53,8 @@ public class NormalizedNodeToJsonStreamTest {
     private static SchemaContext schemaContext;
 
     @BeforeClass
-    public static void initialization() throws IOException, URISyntaxException, ReactorException {
-        schemaContext = YangParserTestUtils.parseYangSources("/complexjson/yang");
+    public static void initialization() {
+        schemaContext = YangParserTestUtils.parseYangResourceDirectory("/complexjson/yang");
     }
 
     @Test
index 0cfefdcbd3e88c81a8515b8af7ba1dbe09918a6d..0591c5e2c774c6eb6369d800f794981efc809543 100644 (file)
@@ -28,7 +28,6 @@ import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeS
 import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -39,8 +38,8 @@ public class StreamToNormalizedNodeTest {
     private static String streamAsString;
 
     @BeforeClass
-    public static void initialization() throws IOException, URISyntaxException, ReactorException {
-        schemaContext = YangParserTestUtils.parseYangSources("/complexjson/yang");
+    public static void initialization() throws IOException, URISyntaxException {
+        schemaContext = YangParserTestUtils.parseYangResourceDirectory("/complexjson/yang");
         streamAsString = loadTextFile(new File(StreamToNormalizedNodeTest.class.getResource(
                 "/complexjson/complex-json.json").toURI()));
     }
index d4914959570d2efea1795701258259a121ad125e..34f9661d7f225d86a4f563ca8f99ffd5082415c1 100644 (file)
@@ -43,7 +43,6 @@ import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.xml.sax.SAXException;
 
@@ -53,9 +52,9 @@ public class YangModeledAnyXmlSupportTest {
     private static ContainerNode data;
 
     @BeforeClass
-    public static void init() throws IOException, URISyntaxException, ReactorException, SAXException,
-            XMLStreamException, ParserConfigurationException {
-        schemaContext = YangParserTestUtils.parseYangSources("/yang-modeled-anyxml/yang");
+    public static void init() throws XMLStreamException, URISyntaxException, IOException, ParserConfigurationException,
+            SAXException {
+        schemaContext = YangParserTestUtils.parseYangResourceDirectory("/yang-modeled-anyxml/yang");
         final Module bazModule = schemaContext.findModuleByName("baz", null);
         final ContainerSchemaNode bazCont = (ContainerSchemaNode) bazModule.getDataChildByName(
                 QName.create(bazModule.getQNameModule(), "baz"));
index 938962e75e08324037c03cf7b1e7abfbcb70bbb1..75cf4b42eb3c26dc5c75620388c4a0e435ae17bc 100644 (file)
@@ -45,8 +45,7 @@ public class Bug5396Test {
     public void setUp() throws Exception {
         fooModuleQName = QNameModule.create(new URI("foo"), SimpleDateFormatUtil.getRevisionFormat().parse(
                     "2016-03-22"));
-
-        schemaContext = YangParserTestUtils.parseYangSource("/bug5396/yang/foo.yang");
+        schemaContext = YangParserTestUtils.parseYangResource("/bug5396/yang/foo.yang");
     }
 
     @Test
index c6cfe00cafb0c636362c91ba8109cbb6f3399636..e922752f97f63aebc6f42995ecc0618802adc1b2 100644 (file)
@@ -68,7 +68,7 @@ public class Bug5446Test extends XMLTestCase {
         rootQName = QName.create(fooModuleQName, "root");
         ipAddressQName = QName.create(fooModuleQName, "ip-address");
 
-        schemaContext = YangParserTestUtils.parseYangSource("/bug5446/yang/foo.yang");
+        schemaContext = YangParserTestUtils.parseYangResource("/bug5446/yang/foo.yang");
     }
 
     @Test
index 7d91be07580710b75a26c60a142b07e1140c0194..83c2107c612aa0cfb5a1d87033cd9bfcff88aef0 100644 (file)
@@ -30,7 +30,7 @@ public class Bug8083Test {
     @Ignore("XMLEmptyCodec needs to be fixed first.")
     @Test
     public void testInstanceIdentifierPathWithEmptyListKey() throws Exception {
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSource("/bug8083/yang/baz.yang");
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResource("/bug8083/yang/baz.yang");
         final Module bazModule = schemaContext.getModules().iterator().next();
         final ContainerSchemaNode topCont = (ContainerSchemaNode) bazModule.getDataChildByName(
                 QName.create(bazModule.getQNameModule(), "top-cont"));
@@ -52,7 +52,7 @@ public class Bug8083Test {
 
     @Test
     public void testInstanceIdentifierPathWithIdentityrefListKey() throws Exception {
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSource("/bug8083/yang/zab.yang");
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResource("/bug8083/yang/zab.yang");
         final Module zabModule = schemaContext.getModules().iterator().next();
         final ContainerSchemaNode topCont = (ContainerSchemaNode) zabModule.getDataChildByName(
                 QName.create(zabModule.getQNameModule(), "top-cont"));
@@ -74,7 +74,7 @@ public class Bug8083Test {
 
     @Test
     public void testInstanceIdentifierPathWithInstanceIdentifierListKey() throws Exception {
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSource("/bug8083/yang/foobar.yang");
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResource("/bug8083/yang/foobar.yang");
         final Module foobarModule = schemaContext.getModules().iterator().next();
         final ContainerSchemaNode topCont = (ContainerSchemaNode) foobarModule.getDataChildByName(
                 QName.create(foobarModule.getQNameModule(), "top-cont"));
index 86fa2f2c227db9dde8b8fe89004ff504fdec0b8b..55e2c06cddef6eeb05a358ccfdd137aa0946f957 100644 (file)
@@ -36,7 +36,7 @@ public class Bug8675Test {
 
     @BeforeClass
     public static void setup() throws Exception {
-        schemaContext = YangParserTestUtils.parseYangSource("/bug8675/foo.yang");
+        schemaContext = YangParserTestUtils.parseYangResource("/bug8675/foo.yang");
         fooModule = schemaContext.getModules().iterator().next();
     }
 
index c975fb7d95f74b7d48b4467d793733d58db72a0a..39ea5ea75429ceb4a74882143d0e6cd26c51ef4d 100644 (file)
@@ -44,7 +44,7 @@ public class Bug8745Test {
 
     @Test
     public void testParsingAttributes() throws Exception {
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSource("/bug8745/foo.yang");
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResource("/bug8745/foo.yang");
         final QName contWithAttributes = QName.create("foo", "1970-01-01", "cont-with-attributes");
         final ContainerSchemaNode contWithAttr = (ContainerSchemaNode) SchemaContextUtil.findDataSchemaNode(
                 schemaContext, SchemaPath.create(true, contWithAttributes));
index d708e176d371e90d156e4fca945f92200b6436b6..c0a9f657cfd4fb192d1cadf409ccea9a2d89f02f 100644 (file)
@@ -35,7 +35,7 @@ public class Bug8803Test {
 
     @Test
     public void test() throws Exception {
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSources("/bug8803");
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResourceDirectory("/bug8803");
         final SchemaPath topContPath = SchemaPath.create(true, QName.create("foo-ns", "1970-01-01", "top-cont"));
         final SchemaNode dataSchemaNode = SchemaContextUtil.findDataSchemaNode(schemaContext, topContPath);
         assertTrue(dataSchemaNode instanceof ContainerSchemaNode);
index 1165293ad28924ed17916cfd7e3f5e74b73229e6..d2b22b032767bd724828e8a113042216f1a4b5b3 100644 (file)
@@ -47,7 +47,7 @@ public class DOMSourceXMLStreamReaderTest {
 
     @Test
     public void test() throws Exception {
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSources("/dom-reader-test");
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResourceDirectory("/dom-reader-test");
         final ContainerSchemaNode outerContainerSchema = (ContainerSchemaNode) SchemaContextUtil
                 .findNodeInSchemaContext(schemaContext, ImmutableList.of(QName.create("foo-ns", "1970-01-01",
                         "top-cont")));
index 26268bdd2594fbcf6b2571bfdfe346adba47f5d8..e86d1a47d57cde66ddf064c3c85bc25a1cc9f347 100644 (file)
@@ -16,12 +16,10 @@ import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.le
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableSet;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.StringWriter;
 import java.net.URI;
-import java.net.URISyntaxException;
 import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -79,7 +77,6 @@ import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 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;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
@@ -263,8 +260,8 @@ public class NormalizedNodeXmlTranslationTest {
     }
 
     public NormalizedNodeXmlTranslationTest(final String yangPath, final String xmlPath,
-            final ContainerNode expectedNode) throws ReactorException, FileNotFoundException, URISyntaxException {
-        this.schema = YangParserTestUtils.parseYangSource(yangPath);
+            final ContainerNode expectedNode) {
+        this.schema = YangParserTestUtils.parseYangResource(yangPath);
         this.xmlPath = xmlPath;
         this.containerNode = (ContainerSchemaNode) getSchemaNode(schema, "test", "container");
         this.expectedNode = expectedNode;
index cc5b9e91d522599713d4491c0e22f26068d73144..3cacbc3eb2d89de6f0b5bd9069e8c2013acbbd41 100644 (file)
@@ -55,7 +55,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStre
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 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;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
@@ -118,9 +117,8 @@ public class NormalizedNodesToXmlTest {
     }
 
     @Test
-    public void testNormalizedNodeToXmlSerialization() throws ReactorException, XMLStreamException, IOException,
-            SAXException, URISyntaxException {
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSource("/baz.yang");
+    public void testNormalizedNodeToXmlSerialization() throws XMLStreamException, IOException, SAXException {
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResource("/baz.yang");
 
         final Document doc = loadDocument("/baz.xml");
 
index cdc6f0a81335fb234e69b6f094b9d0c007730619..fd15f68ba554d06aa0d8efb41c56a2b989767eb4 100644 (file)
@@ -31,7 +31,7 @@ public class StrictParsingModeTest {
     @Test
     public void testLenientParsing() throws Exception {
         // unknown child nodes in the top-level-container node will be skipped when the strictParsing is set to false
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSource(
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResource(
                 "/strict-parsing-mode-test/foo.yang");
         final Module fooModule = schemaContext.getModules().iterator().next();
         final ContainerSchemaNode topLevelContainer = (ContainerSchemaNode) fooModule.getDataChildByName(
@@ -58,7 +58,7 @@ public class StrictParsingModeTest {
     public void testStrictParsing() throws Exception {
         // should fail because strictParsing is switched on and the top-level-container node contains child nodes
         // which are not defined in the provided YANG model
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSource(
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResource(
                 "/strict-parsing-mode-test/foo.yang");
         final Module fooModule = schemaContext.getModules().iterator().next();
         final ContainerSchemaNode topLevelContainer = (ContainerSchemaNode) fooModule.getDataChildByName(
index 7868c2203a854cf2433d98cade1e4d63089b568b..f901a856f14bcd47a84acbc79de3ea5ee2683506 100644 (file)
@@ -57,7 +57,7 @@ public class XmlStreamUtilsTest {
 
     @BeforeClass
     public static void initialize() throws URISyntaxException, FileNotFoundException, ReactorException {
-        schemaContext = YangParserTestUtils.parseYangSource("/leafref-test.yang");
+        schemaContext = YangParserTestUtils.parseYangResource("/leafref-test.yang");
         assertNotNull(schemaContext);
         assertEquals(1, schemaContext.getModules().size());
         leafRefModule = schemaContext.getModules().iterator().next();
index 6ac565531e3d3d8a8ce19237d2da61147f893bee..a09362fc5b7512818d4501f53fe91179f34db2b7 100644 (file)
@@ -116,7 +116,7 @@ public class XmlToNormalizedNodesTest {
         mySecondKeyLeaf = QName.create(bazModule, "my-second-key-leaf");
         myLeafInList3 = QName.create(bazModule, "my-leaf-in-list-3");
 
-        schemaContext = YangParserTestUtils.parseYangSources("/");
+        schemaContext = YangParserTestUtils.parseYangResourceDirectory("/");
         parentContainerSchema = (ContainerSchemaNode) SchemaContextUtil.findNodeInSchemaContext(schemaContext,
                 ImmutableList.of(parentContainer));
         outerContainerSchema = (ContainerSchemaNode) SchemaContextUtil.findNodeInSchemaContext(schemaContext,
index fc062e46fa311141f74bb27895984e944c0f3d5e..f214feafa6e6c6b84f4a2cb9cee512d37e90b0c7 100644 (file)
@@ -75,7 +75,7 @@ public class YangModeledAnyXMLDeserializationTest {
         myLeaf2 = QName.create(fooModuleQName, "my-leaf-2");
         myAnyXMLDataFoo = QName.create(fooModuleQName, "my-anyxml-data");
 
-        schemaContext = YangParserTestUtils.parseYangSources("/anyxml-support/yang");
+        schemaContext = YangParserTestUtils.parseYangResourceDirectory("/anyxml-support/yang");
     }
 
     @Test
index 98e2a6c4d9044646eaccc10d2947b1160522a8c1..a6fe3062b0ff428cc5718430b8d420b4c3a785be 100644 (file)
@@ -70,7 +70,7 @@ public class YangModeledAnyXMLSerializationTest extends XMLTestCase {
         myContainer2QName = QName.create(bazModuleQName, "my-container-2");
         myAnyXMLDataBaz = QName.create(bazModuleQName, "my-anyxml-data");
 
-        schemaContext = YangParserTestUtils.parseYangSources("/anyxml-support/serialization");
+        schemaContext = YangParserTestUtils.parseYangResourceDirectory("/anyxml-support/serialization");
     }
 
     @Test
index dc8287a35a1880ff52b50fa5513cbafa8aebf514..b54848fffa96431a5733a1cd4bf55f356b134021 100644 (file)
@@ -48,7 +48,7 @@ public class Bug2964Test {
     @Before
     public void setUp() throws Exception {
         final File leafRefTestYang = new File(getClass().getResource("/leafref-test.yang").toURI());
-        schema = YangParserTestUtils.parseYangSources(leafRefTestYang);
+        schema = YangParserTestUtils.parseYangFiles(leafRefTestYang);
     }
 
     public static Document readXmlToDocument(final String xmlContent) throws SAXException, IOException {
index 4bf8e35875cb0dfd40befda640fac54c1df8fcf3..9ccd604382fbf5dcea12a42d365132e3925f7daa 100644 (file)
@@ -40,7 +40,7 @@ public class InstanceIdentifierForXmlCodecTest {
     @Before
     public void setup() throws Exception {
         final File rpcTestYang = new File(getClass().getResource("iid-test.yang").toURI());
-        this.schemaContext = YangParserTestUtils.parseYangSources(rpcTestYang);
+        this.schemaContext = YangParserTestUtils.parseYangFiles(rpcTestYang);
 
         final YangInstanceIdentifier.NodeIdentifier container = new YangInstanceIdentifier.NodeIdentifier(
                 QName.create(InstanceIdentifierForXmlCodecTest.NS, InstanceIdentifierForXmlCodecTest.REVISION, "cont"));
index a00976309fc0a204ac2b56b1054879f544f1b116..ec7201b76da5fa9db12db616b0a12e0a467ce4d4 100644 (file)
@@ -66,7 +66,7 @@ public class XmlDocumentUtilsTest {
         final File rpcTestYang1 = new File(getClass().getResource("xml-doc-test.yang").toURI());
         final File rpcTestYang2 = new File(getClass().getResource("xml-doc-test2.yang").toURI());
 
-        this.schema = YangParserTestUtils.parseYangSources(rpcTestYang1, rpcTestYang2);
+        this.schema = YangParserTestUtils.parseYangFiles(rpcTestYang1, rpcTestYang2);
     }
 
     public static Document readXmlToDocument(final String xmlContent) throws SAXException, IOException {
index 32965e2dcc4b651fccbf9ac2f78e8c02d2c68996..b116753856ab3553e3819e7b9e75a37d3ae8de3b 100644 (file)
@@ -59,7 +59,7 @@ public class XmlStreamUtilsTest {
     @BeforeClass
     public static void initialize() throws URISyntaxException, FileNotFoundException, ReactorException {
         final File file = new File(XmlStreamUtils.class.getResource("/leafref-test.yang").toURI());
-        schemaContext = YangParserTestUtils.parseYangSources(file);
+        schemaContext = YangParserTestUtils.parseYangFiles(file);
         assertNotNull(schemaContext);
         assertEquals(1, schemaContext.getModules().size());
         leafRefModule = schemaContext.getModules().iterator().next();
index 19e53794c80a7538deb671047b650bad41d5cdc4..322de0e655a055e339900cfffb22ac9a288ce7d2 100644 (file)
@@ -39,7 +39,7 @@ public class StringPatternCheckingCodecTest {
     @Test
     public void testStringPatternCheckingCodec() throws ReactorException, ParseException, URISyntaxException,
             FileNotFoundException {
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSource("/string-pattern-checking-codec-test.yang");
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResource("/string-pattern-checking-codec-test.yang");
         assertNotNull(schemaContext);
 
         final QNameModule testModuleQName = QNameModule.create(new URI("string-pattern-checking-codec-test"),
index 1736e27360cdef86a0795da8e211ab43f34d3b02..96a8475bd932aa0d7c320c68df5ed999af66ca70 100644 (file)
@@ -30,7 +30,7 @@ public class Bug7844Test {
 
     @Test
     public void test() throws Exception {
-        final SchemaContext context = YangParserTestUtils.parseYangSources("/bug7844");
+        final SchemaContext context = YangParserTestUtils.parseYangResourceDirectory("/bug7844");
         assertNotNull(context);
 
         final LeafRefContext leafRefContext = LeafRefContext.create(context);
index e32335f80eb1790a4afe495b45cbbd57539e4612..24163dadef629f24c2a986b3f409347597f3856e 100644 (file)
@@ -31,7 +31,7 @@ public class Bug8713Test {
 
     @Test
     public void dataTreeCanditateValidationTest() throws Exception {
-        final SchemaContext context = YangParserTestUtils.parseYangSources("/bug8713/");
+        final SchemaContext context = YangParserTestUtils.parseYangResourceDirectory("/bug8713/");
         final LeafRefContext rootLeafRefContext = LeafRefContext.create(context);
         final TipProducingDataTree inMemoryDataTree = InMemoryDataTreeFactory.getInstance()
                 .create(DataTreeConfiguration.DEFAULT_OPERATIONAL);
@@ -49,7 +49,7 @@ public class Bug8713Test {
         inMemoryDataTree.commit(writeContributorsCandidate);
     }
 
-    private ContainerNode createRootContainer() {
+    private static ContainerNode createRootContainer() {
         return Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(foo("root")))
                 .withChild(ImmutableNodes.leafNode(bar("target"), "target value"))
                 .withChild(ImmutableNodes.leafNode(bar("ref"), "target value")).build();
index ac6a35f389394fa6154ac2c8041dfec6e5ec92b7..d2663b1de98900bba94e0099db25a0311299951c 100644 (file)
@@ -9,10 +9,9 @@ package org.opendaylight.yangtools.yang.data.impl.leafref.context;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
-import java.io.File;
+
 import java.io.FileNotFoundException;
 import java.net.URISyntaxException;
-import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
@@ -115,15 +114,8 @@ public class DataTreeCandidateValidatorTest {
 
     }
 
-    private static void initSchemaContext() throws URISyntaxException,
-            FileNotFoundException, ReactorException {
-        final File resourceFile = new File(DataTreeCandidateValidatorTest.class
-                .getResource("/leafref-validation/leafref-validation.yang")
-                .toURI());
-        final File resourceDir = resourceFile.getParentFile();
-
-        context = YangParserTestUtils.parseYangSources(Arrays.asList(resourceDir
-                .listFiles()));
+    private static void initSchemaContext() {
+        context = YangParserTestUtils.parseYangResourceDirectory("/leafref-validation");
 
         final Set<Module> modules = context.getModules();
         for (final Module module : modules) {
index 9f0f0b31365b28c50540c3d65b9d71086b074aa3..a81594812dd431ac49afd50e567858a0f533f873 100644 (file)
@@ -9,10 +9,9 @@ package org.opendaylight.yangtools.yang.data.impl.leafref.context;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
-import java.io.File;
+
 import java.io.FileNotFoundException;
 import java.net.URISyntaxException;
-import java.util.Arrays;
 import java.util.Set;
 import org.apache.log4j.BasicConfigurator;
 import org.junit.BeforeClass;
@@ -153,13 +152,8 @@ public class DataTreeCandidateValidatorTest2 {
         desc = QName.create(rootModuleQname, "desc");
     }
 
-    private static void initSchemaContext() throws URISyntaxException, FileNotFoundException, ReactorException {
-
-        final File resourceFile = new File(DataTreeCandidateValidatorTest.class.getResource(
-                "/leafref-validation/leafref-validation2.yang").toURI());
-        final File resourceDir = resourceFile.getParentFile();
-
-        context = YangParserTestUtils.parseYangSources(Arrays.asList(resourceDir.listFiles()));
+    private static void initSchemaContext() {
+        context = YangParserTestUtils.parseYangResourceDirectory("/leafref-validation");
 
         final Set<Module> modules = context.getModules();
         for (final Module module : modules) {
index 7aca4447d257485a2de33d6f91ce5cd261de3722..736b889395553e1a78cde6ade1ae33534c2c39f1 100644 (file)
@@ -9,10 +9,7 @@ package org.opendaylight.yangtools.yang.data.impl.leafref.context;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.net.URISyntaxException;
-import java.util.Arrays;
+
 import java.util.Set;
 import org.apache.log4j.BasicConfigurator;
 import org.junit.BeforeClass;
@@ -42,7 +39,6 @@ import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 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;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -84,8 +80,7 @@ public class DataTreeCandidateValidatorTest3 {
     }
 
     @BeforeClass
-    public static void init() throws FileNotFoundException, ReactorException, URISyntaxException {
-
+    public static void init() {
         initSchemaContext();
         initLeafRefContext();
         initQnames();
@@ -200,13 +195,8 @@ public class DataTreeCandidateValidatorTest3 {
         desc = QName.create(rootModuleQname, "desc");
     }
 
-    private static void initSchemaContext() throws URISyntaxException, FileNotFoundException, ReactorException {
-
-        final File resourceFile = new File(DataTreeCandidateValidatorTest.class.getResource(
-                "/leafref-validation/leafref-validation3.yang").toURI());
-        final File resourceDir = resourceFile.getParentFile();
-
-        context = YangParserTestUtils.parseYangSources(Arrays.asList(resourceDir.listFiles()));
+    private static void initSchemaContext() {
+        context = YangParserTestUtils.parseYangResourceDirectory("/leafref-validation");
 
         final Set<Module> modules = context.getModules();
         for (final Module module : modules) {
index 35c3bc44933d7b74c4942954110323923f17f603..b76940c5ae5c0c99c0b8a1d7a5295e2e054f1570 100644 (file)
@@ -10,10 +10,7 @@ package org.opendaylight.yangtools.yang.data.impl.leafref.context;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.net.URISyntaxException;
-import java.util.Arrays;
+
 import java.util.Map;
 import java.util.Set;
 import org.junit.BeforeClass;
@@ -26,7 +23,6 @@ import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 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 class LeafRefContextTest {
@@ -37,14 +33,8 @@ public class LeafRefContextTest {
     private static LeafRefContext rootLeafRefContext;
 
     @BeforeClass
-    public static void init() throws URISyntaxException, FileNotFoundException, ReactorException {
-
-        final File resourceFile = new File(LeafRefContextTreeBuilderTest.class.getResource(
-                "/leafref-context-test/correct-modules/leafref-test2.yang").toURI());
-
-        final File resourceDir = resourceFile.getParentFile();
-
-        context = YangParserTestUtils.parseYangSources(Arrays.asList(resourceDir.listFiles()));
+    public static void init() {
+        context = YangParserTestUtils.parseYangResourceDirectory("/leafref-context-test/correct-modules");
 
         final Set<Module> modules = context.getModules();
         for (final Module module : modules) {
index 9fb1add6bcab5dd66405194b2a34d960cefaae20..7252e3b01b1f51f30f6bc0ab74e359f684798eda 100644 (file)
@@ -12,10 +12,7 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.net.URISyntaxException;
-import java.util.Arrays;
+
 import java.util.List;
 import java.util.Set;
 import org.junit.BeforeClass;
@@ -29,7 +26,6 @@ import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 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 class LeafRefContextTreeBuilderTest {
@@ -42,12 +38,8 @@ public class LeafRefContextTreeBuilderTest {
     private static LeafRefContext rootLeafRefContext;
 
     @BeforeClass
-    public static void init() throws URISyntaxException, FileNotFoundException, ReactorException {
-        final File resourceFile = new File(LeafRefContextTreeBuilderTest.class.getResource(
-                "/leafref-context-test/correct-modules/leafref-test.yang").toURI());
-        final File resourceDir = resourceFile.getParentFile();
-
-        context = YangParserTestUtils.parseYangSources(Arrays.asList(resourceDir.listFiles()));
+    public static void init() {
+        context = YangParserTestUtils.parseYangResourceDirectory("/leafref-context-test/correct-modules");
 
         final Set<Module> modules = context.getModules();
         for (final Module module : modules) {
@@ -239,15 +231,10 @@ public class LeafRefContextTreeBuilderTest {
 
     @Test(expected = IllegalArgumentException.class)
     @Ignore
-    public void incorrectLeafRefPathTest() throws URISyntaxException, FileNotFoundException, ReactorException {
-        final File resourceFile = new File(getClass().getResource(
-                "/leafref-context-test/incorrect-modules/leafref-test.yang").toURI());
-        final File resourceDir = resourceFile.getParentFile();
-
-        final SchemaContext context = YangParserTestUtils.parseYangSources(Arrays.asList(resourceDir.listFiles()));
-
+    public void incorrectLeafRefPathTest() {
+        final SchemaContext context = YangParserTestUtils.parseYangResourceDirectory(
+            "/leafref-context-test/incorrect-modules");
         LeafRefContext.create(context);
-
     }
 
 }
index e4ede1f76e8ed059e3df8750755747a7958ee74f..864ecd8d857e4d7feba4049740ce60e9e444229a 100644 (file)
@@ -93,7 +93,7 @@ public class BuilderTest {
     public void setup() throws FileNotFoundException, ReactorException, URISyntaxException {
         final File leafRefTestYang = new File(getClass().getResource("/builder-test/immutable-ordered-map-node.yang")
                 .toURI());
-        final SchemaContext schema = YangParserTestUtils.parseYangSources(leafRefTestYang);
+        final SchemaContext schema = YangParserTestUtils.parseYangFiles(leafRefTestYang);
         final Module module = schema.getModules().iterator().next();
         final DataSchemaNode root = module.getDataChildByName(ROOT_CONTAINER);
         list = (ListSchemaNode)((ContainerEffectiveStatementImpl) root).getDataChildByName(LIST_MAIN);
index c362d44d3bdac7a774b0388b9dd2761eabd48acc..24081209befc582f1eaa8edc5e05f21a4da64b2e 100644 (file)
@@ -8,8 +8,8 @@
 package org.opendaylight.yangtools.yang.data.impl.schema;
 
 import static org.junit.Assert.assertEquals;
-import java.io.File;
-import java.io.FileNotFoundException;
+
+import java.io.IOException;
 import java.net.URISyntaxException;
 import java.util.Collections;
 import org.junit.BeforeClass;
@@ -26,6 +26,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
@@ -53,9 +54,9 @@ public class InstanceIdToNodesTest {
     private final NodeWithValue<?> leafListWithValue = new NodeWithValue<>(
             leafList.getNodeType(), "abcd");
 
-    static SchemaContext createTestContext() throws URISyntaxException, FileNotFoundException, ReactorException {
-        final File resourceFile = new File(InstanceIdToNodesTest.class.getResource("/filter-test.yang").toURI());
-        return YangParserTestUtils.parseYangSources(resourceFile);
+    static SchemaContext createTestContext() throws URISyntaxException, ReactorException, IOException,
+            YangSyntaxErrorException {
+        return YangParserTestUtils.parseYangResources(InstanceIdToNodesTest.class, "/filter-test.yang");
     }
 
     @BeforeClass
index e7799ba4a16d4967e58e1e857f569df67a20610a..6c3dc7f56b6616235102cda358e69b0a6893ee5c 100644 (file)
@@ -55,7 +55,7 @@ public class NormalizedDataBuilderTest {
     public void setUp() throws URISyntaxException, FileNotFoundException, ReactorException {
         final File resourceFile = new File(getClass().getResource(
                 "test.yang").toURI());
-        schema = YangParserTestUtils.parseYangSources(resourceFile);
+        schema = YangParserTestUtils.parseYangFiles(resourceFile);
         containerNode = (ContainerSchemaNode) getSchemaNode(schema, "test", "container");
     }
 
index 4b5e7ba2ea4a2c189199ac94834cc302a5769461..982be2afc35ca2aafb3c0acfa2ba8532a042a5a2 100644 (file)
@@ -155,7 +155,7 @@ public class SchemaOrderedNormalizedNodeWriterTest {
 
     private static SchemaContext getSchemaContext(final String filePath) throws URISyntaxException,
             ReactorException, FileNotFoundException {
-        return YangParserTestUtils.parseYangSource(filePath);
+        return YangParserTestUtils.parseYangResource(filePath);
     }
 
     private static YangInstanceIdentifier.NodeIdentifier getNodeIdentifier(final String ns, final String name) {
index 7fb8e4aebb5659a431f004e19ac3a1ce73c59925..9358db5866484700fbf7e904bcccfcdade331ea1 100644 (file)
@@ -28,7 +28,7 @@ public class SchemaUtilsTest {
 
     @Test
     public void test() throws Exception {
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSource("/schema-utils-test/foo.yang");
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResource("/schema-utils-test/foo.yang");
         assertTrue(SchemaUtils.findDataParentSchemaOnPath(schemaContext,
                 SchemaPath.create(true, qN("my-name"), qN("my-name"))) instanceof ContainerSchemaNode);
         assertTrue(SchemaUtils.findDataParentSchemaOnPath(schemaContext,
@@ -40,7 +40,7 @@ public class SchemaUtilsTest {
     @Test
     public void testNameConflicts() throws Exception {
         final SchemaContext schemaContext = YangParserTestUtils
-                .parseYangSource("/schema-utils-test/name-conflicts.yang");
+                .parseYangResource("/schema-utils-test/name-conflicts.yang");
         // test my-name conflicts
         assertEquals(8, SchemaUtils.findParentSchemaNodesOnPath(schemaContext,
                 SchemaPath.create(true, qN("my-name"), qN("my-name"), qN("my-name"))).size());
index 0891f9b43df56c5d3e37cdf652112b3f448a66d4..4e6387d5f28bb18f46a757af3f14f7e54feb7bb1 100644 (file)
@@ -30,7 +30,7 @@ public class DomToNormalizedNodeParserFactoryTest {
 
     @Test
     public void testFactoryInstantiation() throws ReactorException, FileNotFoundException, URISyntaxException {
-        SchemaContext schemaContext = YangParserTestUtils.parseYangSource("/foo.yang");
+        SchemaContext schemaContext = YangParserTestUtils.parseYangResource("/foo.yang");
 
         DomToNormalizedNodeParserFactory factory = DomToNormalizedNodeParserFactory.getInstance(
                 DomUtils.defaultValueCodecProvider(), schemaContext,
index 83a09a8f3c82641356a312a85ed881950e5a6978..04dffb88faba4565cf0f3d6ecedc65829c14dd43 100644 (file)
@@ -56,7 +56,7 @@ public class Bug5396 {
                 .parse("2016-03-22"));
         root = QName.create(fooModuleQName, "root");
         schemaContext = YangParserTestUtils
-                .parseYangSources(new File(getClass().getResource("/bug5396/yang/foo.yang").toURI()));
+                .parseYangFiles(new File(getClass().getResource("/bug5396/yang/foo.yang").toURI()));
     }
 
     @Test
index 748bfddf545c11115b1943a227b071757410453c..0cad60066097486dbb16493e098385b16004eefe 100644 (file)
@@ -70,7 +70,7 @@ public class Bug5446Test extends XMLTestCase {
         rootQName = QName.create(fooModuleQName, "root");
         ipAddressQName = QName.create(fooModuleQName, "ip-address");
 
-        schemaContext = YangParserTestUtils.parseYangSources(new File(getClass().getResource("/bug5446/yang/foo.yang").toURI()));
+        schemaContext = YangParserTestUtils.parseYangFiles(new File(getClass().getResource("/bug5446/yang/foo.yang").toURI()));
     }
 
     @Test
index 12935833a7387ba72e9c96e83e78f80eb7ac7cf6..dbefd0f9c29bd8c583454bd35d2f076426e889c6 100644 (file)
@@ -46,7 +46,7 @@ public class Bug6392Test {
 
     @Test
     public void testLenientParsingOfUnkeyedListEntries() throws Exception {
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSource("/bug6392/foo.yang");
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResource("/bug6392/foo.yang");
         assertNotNull(schemaContext);
 
         final Date revision = SimpleDateFormatUtil.getRevisionFormat().parse("2017-03-10");
index ad46a7891d7587aeef3dc45bac0c712765fb55d4..2c4c46e5704b329507ae778656d73af47630ce79 100644 (file)
@@ -49,7 +49,7 @@ public class DomSerializerTestUtils {
 
     public static SchemaContext getSchemaContext() throws ReactorException, IOException, YangSyntaxErrorException,
             URISyntaxException {
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSource("/dom-serializer-test/serializer-test.yang");
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResource("/dom-serializer-test/serializer-test.yang");
 
         assertNotNull("Schema context must not be null.", schemaContext);
         return schemaContext;
index 0ff7aeda256293527c7570b8aaa10a9afeaf4446..ca738c644c301862fa07d8b4027fc0afb53de580 100644 (file)
@@ -13,8 +13,6 @@ import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.containe
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.leafNode;
 
 import com.google.common.base.Preconditions;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import java.io.IOException;
 import java.io.InputStream;
@@ -27,7 +25,6 @@ import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import javax.xml.stream.XMLOutputFactory;
@@ -74,7 +71,6 @@ import org.opendaylight.yangtools.yang.data.impl.schema.transform.dom.parser.Dom
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -251,8 +247,8 @@ public class NormalizedNodeXmlTranslationTest {
     }
 
     public NormalizedNodeXmlTranslationTest(final String yangPath, final String xmlPath,
-            final ContainerNode expectedNode) throws ReactorException {
-        schema = parseTestSchema(yangPath);
+            final ContainerNode expectedNode) {
+        schema = YangParserTestUtils.parseYangResources(NormalizedDataBuilderTest.class, yangPath);
         this.xmlPath = xmlPath;
         this.containerNode = (ContainerSchemaNode) NormalizedDataBuilderTest.getSchemaNode(schema, "test", "container");
         this.expectedNode = expectedNode;
@@ -262,19 +258,6 @@ public class NormalizedNodeXmlTranslationTest {
     private final ContainerSchemaNode containerNode;
     private final String xmlPath;
 
-    SchemaContext parseTestSchema(final String... yangPath) throws ReactorException {
-        return YangParserTestUtils.parseYangStreams(getTestYangs(yangPath));
-    }
-
-    List<InputStream> getTestYangs(final String... yangPaths) {
-        return ImmutableList.copyOf(Collections2.transform(Arrays.asList(yangPaths),
-                input -> {
-                    final InputStream resourceAsStream = NormalizedDataBuilderTest.class.getResourceAsStream(input);
-                    Preconditions.checkNotNull(resourceAsStream, "File %s was null", resourceAsStream);
-                    return resourceAsStream;
-                }));
-    }
-
     @Test
     public void testTranslation() throws Exception {
         final Document doc = loadDocument(xmlPath);
index ba3a26bce9ea6d18531230a5ab8368556abdd560..0e79aed76b62d93019ab5f386f1f8d31e1fd5e4e 100644 (file)
@@ -82,7 +82,7 @@ public class YangModeledAnyXMLDeserializationTest {
         myLeaf3 = QName.create(fooModuleQName, "my-leaf-3");
         myLeaf2 = QName.create(fooModuleQName, "my-leaf-2");
         myAnyXMLDataFoo = QName.create(fooModuleQName, "my-anyxml-data");
-        schemaContext = YangParserTestUtils.parseYangSources("/anyxml-support/yang");
+        schemaContext = YangParserTestUtils.parseYangResourceDirectory("/anyxml-support/yang");
     }
 
     @Test
index 3aadcd16f2869343ac818c6439b53c41f4b6c3bb..24fca2453fa49f832f2f64c582253f69200b2413 100644 (file)
@@ -76,7 +76,7 @@ public class YangModeledAnyXMLSerializationTest extends XMLTestCase {
         myContainer2QName = QName.create(bazModuleQName, "my-container-2");
         myAnyXMLDataBaz = QName.create(bazModuleQName, "my-anyxml-data");
 
-        schemaContext = YangParserTestUtils.parseYangSources("/anyxml-support/serialization");
+        schemaContext = YangParserTestUtils.parseYangResourceDirectory("/anyxml-support/serialization");
     }
 
     @Test
index 1177d49897fd68cd0f12e01ed34d049df0fadf83..16af3c2517ba6b9a23d696c3281b39b6a1019da5 100644 (file)
@@ -11,9 +11,8 @@ package org.opendaylight.yangtools.yang.data.impl.schema.tree;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
+
 import com.google.common.base.Optional;
-import java.io.InputStream;
-import java.util.Collections;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -44,16 +43,8 @@ public class Bug2690Test {
         inMemoryDataTree.setSchemaContext(schemaContext);
     }
 
-    public static InputStream getDatastoreTestInputStream() {
-        return getInputStream(ODL_DATASTORE_TEST_YANG);
-    }
-
-    private static InputStream getInputStream(final String resourceName) {
-        return TestModel.class.getResourceAsStream(ODL_DATASTORE_TEST_YANG);
-    }
-
     public static SchemaContext createTestContext() throws ReactorException {
-        return YangParserTestUtils.parseYangStreams(Collections.singletonList(getDatastoreTestInputStream()));
+        return YangParserTestUtils.parseYangResource(ODL_DATASTORE_TEST_YANG);
     }
 
     @Test
@@ -89,7 +80,5 @@ public class Bug2690Test {
         final Optional<NormalizedNode<?, ?>> readNode = modificationAfterTx.readNode(TestModel.OUTER_LIST_PATH);
         assertTrue(readNode.isPresent());
         assertEquals(2, ((NormalizedNodeContainer<?,?,?>)readNode.get()).getValue().size());
-
     }
-
 }
index 479f7658f34b660c8003283be7bfc681a3bfc3d6..8769d2365903c309426b0c7cf97ea5ec0ff4bfd3 100644 (file)
@@ -8,6 +8,8 @@
 package org.opendaylight.yangtools.yang.data.impl.schema.tree;
 
 import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
@@ -17,6 +19,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification
 import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
 /**
@@ -28,7 +31,7 @@ public class Bug3674Test {
     private DataTree tree;
 
     @Before
-    public void setUp() throws ReactorException {
+    public void setUp() throws ReactorException, IOException, YangSyntaxErrorException {
         tree = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL);
         tree.setSchemaContext(TestModel.createTestContext());
 
index 4801cb79de9263b28a48a44610e0515a61c5b253..2751882a45de791df5281b5bc42c0690046657c6 100644 (file)
@@ -51,7 +51,7 @@ public class Bug4295Test {
     public void init() throws Exception {
         final File resourceFile = new File(Bug4295Test.class.getResource("/bug-4295/foo.yang")
                 .toURI());
-        context = YangParserTestUtils.parseYangSources(resourceFile);
+        context = YangParserTestUtils.parseYangFiles(resourceFile);
         foo = QNameModule.create(new URI("foo"), SimpleDateFormatUtil.getRevisionFormat().parse("1970-01-01"));
         root = QName.create(foo, "root");
         subRoot = QName.create(foo, "sub-root");
index 6d5d808919abc929d30af1ace201dfa3e5e5518e..5313144dd0b5df22019bdfa739a1dd5cd889430f 100644 (file)
@@ -122,7 +122,7 @@ public class Bug4454Test {
 
     public static SchemaContext createTestContext() throws IOException, YangSyntaxErrorException, ReactorException,
             URISyntaxException {
-        return YangParserTestUtils.parseYangSource("/bug-4454-test.yang");
+        return YangParserTestUtils.parseYangResource("/bug-4454-test.yang");
     }
 
     @Test
index 8d956a363b5a18f57101b3620343c45e61c2899d..f16bdc5630a423c37e37bb4b8b1d2b0017238748 100644 (file)
@@ -205,7 +205,7 @@ public class Bug5830Test {
         inMemoryDataTree.commit(prepare);
     }
 
-    private static void testMandatoryLeaf2IsPresent(final SchemaContext schemaContext, boolean withPresenceContianer)
+    private static void testMandatoryLeaf2IsPresent(final SchemaContext schemaContext, final boolean withPresenceContianer)
             throws DataValidationFailedException {
         final InMemoryDataTree inMemoryDataTree = initDataTree(schemaContext);
 
@@ -226,7 +226,7 @@ public class Bug5830Test {
         inMemoryDataTree.commit(prepare);
     }
 
-    private static DataContainerChild<?, ?> createTaskDataContainer(boolean withMandatoryNode) {
+    private static DataContainerChild<?, ?> createTaskDataContainer(final boolean withMandatoryNode) {
         DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> taskDataBuilder = Builders.containerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(TASK_DATA))
                 .withChild(ImmutableNodes.leafNode(OTHER_DATA, "foo"));
@@ -236,7 +236,7 @@ public class Bug5830Test {
         return taskDataBuilder.build();
     }
 
-    private static DataContainerChild<?, ?> createTaskDataMultipleContainer(boolean withPresenceContianer) {
+    private static DataContainerChild<?, ?> createTaskDataMultipleContainer(final boolean withPresenceContianer) {
         DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> nonPresenceContainerBuilder = Builders
                 .containerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(NON_PRESENCE_CONTAINER))
index c1ccfebfcb8e6dc3b83729c3cb01883951ea0d39..e3160a839c4f096ef811e8247b65c5d6eabccf7c 100644 (file)
@@ -26,7 +26,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -34,15 +33,7 @@ public class DataTreeCandidatesTest {
 
     private static final Logger LOG = LoggerFactory.getLogger(DataTreeCandidates.class);
 
-    private static final SchemaContext SCHEMA_CONTEXT;
-
-    static {
-        try {
-            SCHEMA_CONTEXT = TestModel.createTestContext();
-        } catch (ReactorException e) {
-            throw new ExceptionInInitializerError(e);
-        }
-    }
+    private static final SchemaContext SCHEMA_CONTEXT = TestModel.createTestContext();
 
     private DataTree dataTree;
 
index 244fda31c5b30a9c9b836d10827a58a72810adc0..539e90f84d9fcc8c66e28702c26a01d8c0e47e91 100644 (file)
@@ -9,10 +9,9 @@ package org.opendaylight.yangtools.yang.data.impl.schema.tree;
 
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
+
 import com.google.common.base.Optional;
-import java.io.InputStream;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 import org.junit.Before;
 import org.junit.Test;
@@ -38,7 +37,6 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLe
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUnkeyedListEntryNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUnkeyedListNodeBuilder;
 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;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -77,7 +75,7 @@ public class ListConstraintsValidation {
             .builder(MASTER_CONTAINER_PATH).node(UNKEYED_LIST_QNAME).build();
 
     @Before
-    public void prepare() throws ReactorException {
+    public void prepare() {
         schemaContext = createTestContext();
         assertNotNull("Schema context must not be null.", schemaContext);
         inMemoryDataTree =  (InMemoryDataTree) InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL);
@@ -90,16 +88,8 @@ public class ListConstraintsValidation {
         inMemoryDataTree.commit(inMemoryDataTree.prepare(modificationTree));
     }
 
-    public static InputStream getDatastoreTestInputStream() {
-        return getInputStream(CONSTRAINTS_VALIDATION_TEST_YANG);
-    }
-
-    private static InputStream getInputStream(final String resourceName) {
-        return TestModel.class.getResourceAsStream(CONSTRAINTS_VALIDATION_TEST_YANG);
-    }
-
-    public static SchemaContext createTestContext() throws ReactorException {
-        return YangParserTestUtils.parseYangStreams(Collections.singletonList(getDatastoreTestInputStream()));
+    public static SchemaContext createTestContext() {
+        return YangParserTestUtils.parseYangResource(CONSTRAINTS_VALIDATION_TEST_YANG);
     }
 
     @Test
index b6bf61b7b260b5afd4b9d65ef95e0f0c44ab92d2..8ac4fe86bbe69b0b90e629f869c4375913b82329 100644 (file)
@@ -60,7 +60,7 @@ public class OrderedListTest {
     public void setup() throws Exception {
         final File resourceFile = new File(Bug4295Test.class.getResource("/ordered-list-modification-test.yang")
                 .toURI());
-        context = YangParserTestUtils.parseYangSources(resourceFile);
+        context = YangParserTestUtils.parseYangFiles(resourceFile);
         testModule = QNameModule.create(new URI("ordered-list-modification-test"),
                 SimpleDateFormatUtil.getRevisionFormat().parse("1970-01-01"));
         parentContainer = QName.create(testModule, "parent-container");
index 669f46cbcc5ac1bf2edfe66432f6798798e3354d..b325136f3960e9d19015c7e469ac6131bbc7751b 100644 (file)
@@ -7,14 +7,9 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.schema.tree;
 
-import java.io.InputStream;
-import java.util.Arrays;
-import java.util.Collections;
-
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 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 class TestModel {
@@ -39,16 +34,11 @@ public class TestModel {
     public static final QName TWO_QNAME = QName.create(TEST_QNAME, "two");
     public static final QName THREE_QNAME = QName.create(TEST_QNAME, "three");
 
-    public static InputStream getDatastoreTestInputStream() {
-        return TestModel.class.getResourceAsStream(DATASTORE_TEST_YANG);
-    }
-
-    public static SchemaContext createTestContext() throws ReactorException {
-        return YangParserTestUtils.parseYangStreams(Arrays.asList(getDatastoreTestInputStream()));
+    public static SchemaContext createTestContext() {
+        return createTestContext(DATASTORE_TEST_YANG);
     }
 
-    public static SchemaContext createTestContext(String resourcePath) throws ReactorException {
-        InputStream yangStream = TestModel.class.getResourceAsStream(resourcePath);
-        return YangParserTestUtils.parseYangStreams(Collections.singletonList(yangStream));
+    public static SchemaContext createTestContext(final String resourcePath) {
+        return YangParserTestUtils.parseYangResources(TestModel.class, resourcePath);
     }
 }
index 687472518dbf3e3179a2b4f186b2de303a9f3164..d1c61840f3d160d6cd8b56321578a13a730d54c8 100644 (file)
@@ -70,7 +70,7 @@ public class BitIsSetXPathFunctionTest {
     public void testBitIsSetFunction() throws Exception {
         final Set<String> setOfBits = ImmutableSet.of("UP", "PROMISCUOUS");
 
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSource(
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(BitIsSetXPathFunctionTest.class,
                 "/yang-xpath-functions-test/bit-is-set-function/foo.yang");
         assertNotNull(schemaContext);
 
@@ -100,7 +100,7 @@ public class BitIsSetXPathFunctionTest {
     public void testInvalidTypeOfCorrespondingSchemaNode() throws Exception {
         final Set<String> setOfBits = ImmutableSet.of("UP", "PROMISCUOUS");
 
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSource(
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(BitIsSetXPathFunctionTest.class,
                 "/yang-xpath-functions-test/bit-is-set-function/foo-invalid.yang");
         assertNotNull(schemaContext);
 
@@ -126,7 +126,7 @@ public class BitIsSetXPathFunctionTest {
     public void testInvalidNormalizedNodeValueType() throws Exception {
         final String invalidNodeValueType = "value of invalid type";
 
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSource(
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(BitIsSetXPathFunctionTest.class,
                 "/yang-xpath-functions-test/bit-is-set-function/foo.yang");
         assertNotNull(schemaContext);
 
@@ -153,7 +153,7 @@ public class BitIsSetXPathFunctionTest {
     public void shouldFailOnUnknownBitArgument() throws Exception {
         final Set<String> setOfBits = ImmutableSet.of("UP", "PROMISCUOUS");
 
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSource(
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(BitIsSetXPathFunctionTest.class,
                 "/yang-xpath-functions-test/bit-is-set-function/foo.yang");
         assertNotNull(schemaContext);
 
index 507b522b910db6bd1544d899d9f3aee4a7a7355d..4ec1e25a34b4f43d1f9541f19763e7dcbba85076 100644 (file)
@@ -84,7 +84,7 @@ public class DerefXPathFunctionTest {
 
     @Test
     public void testDerefFunctionForInstanceIdentifier() throws Exception {
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSource(
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(DerefXPathFunctionTest.class,
                 "/yang-xpath-functions-test/deref-function-iid/foo.yang");
         assertNotNull(schemaContext);
 
@@ -116,7 +116,7 @@ public class DerefXPathFunctionTest {
     @Test
     public void testDerefFunctionForLeafref() throws Exception {
         // tests absolute and relative leafref that references a leaf node
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSource(
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(DerefXPathFunctionTest.class,
                 "/yang-xpath-functions-test/deref-function-leafref/foo.yang");
         assertNotNull(schemaContext);
 
@@ -156,7 +156,7 @@ public class DerefXPathFunctionTest {
     @Test
     public void testDerefFunctionForLeafref2() throws Exception {
         // tests leafref that references a leaf-list node
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSource(
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(DerefXPathFunctionTest.class,
                 "/yang-xpath-functions-test/deref-function-leafref/foo.yang");
         assertNotNull(schemaContext);
 
index b53de5aae1ab716717bfd662338ea668d59579f4..7598cc3cb2488376a505fe91d5685c149b42732d 100644 (file)
@@ -69,9 +69,9 @@ public class DerivedFromXPathFunctionTest {
     @Test
     public void testDerivedFromFunction() throws Exception {
         // also includes test for derived-from-or-self function
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSources(ImmutableList.of(
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(DerivedFromXPathFunctionTest.class,
                 "/yang-xpath-functions-test/derived-from-function/foo.yang",
-                "/yang-xpath-functions-test/derived-from-function/bar.yang"));
+                "/yang-xpath-functions-test/derived-from-function/bar.yang");
         assertNotNull(schemaContext);
 
         final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
@@ -108,7 +108,7 @@ public class DerivedFromXPathFunctionTest {
 
     @Test
     public void testInvalidTypeOfCorrespondingSchemaNode() throws Exception {
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSource(
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(DerivedFromXPathFunctionTest.class,
                 "/yang-xpath-functions-test/derived-from-function/bar-invalid.yang");
         assertNotNull(schemaContext);
 
@@ -132,9 +132,9 @@ public class DerivedFromXPathFunctionTest {
 
     @Test
     public void testInvalidNormalizedNodeValueType() throws Exception {
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSources(ImmutableList.of(
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(DerivedFromXPathFunctionTest.class,
                 "/yang-xpath-functions-test/derived-from-function/foo.yang",
-                "/yang-xpath-functions-test/derived-from-function/bar.yang"));
+                "/yang-xpath-functions-test/derived-from-function/bar.yang");
         assertNotNull(schemaContext);
 
         final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
@@ -157,9 +157,9 @@ public class DerivedFromXPathFunctionTest {
 
     @Test
     public void shouldFailOnUnknownPrefixOfIdentity() throws Exception {
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSources(ImmutableList.of(
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(DerivedFromXPathFunctionTest.class,
                 "/yang-xpath-functions-test/derived-from-function/foo.yang",
-                "/yang-xpath-functions-test/derived-from-function/bar.yang"));
+                "/yang-xpath-functions-test/derived-from-function/bar.yang");
         assertNotNull(schemaContext);
 
         final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
@@ -188,9 +188,9 @@ public class DerivedFromXPathFunctionTest {
 
     @Test
     public void shouldFailOnMalformedIdentityArgument() throws Exception {
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSources(ImmutableList.of(
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(DerivedFromXPathFunctionTest.class,
                 "/yang-xpath-functions-test/derived-from-function/foo.yang",
-                "/yang-xpath-functions-test/derived-from-function/bar.yang"));
+                "/yang-xpath-functions-test/derived-from-function/bar.yang");
         assertNotNull(schemaContext);
 
         final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
@@ -218,9 +218,9 @@ public class DerivedFromXPathFunctionTest {
 
     @Test
     public void shouldFailOnUnknownIdentityArgument() throws Exception {
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSources(ImmutableList.of(
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(DerivedFromXPathFunctionTest.class,
                 "/yang-xpath-functions-test/derived-from-function/foo.yang",
-                "/yang-xpath-functions-test/derived-from-function/bar.yang"));
+                "/yang-xpath-functions-test/derived-from-function/bar.yang");
         assertNotNull(schemaContext);
 
         final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
index 0e42f875e5bf43e7084ef8e26e4ace5a438898a2..3a860d84b80e779bff864cb8eec510691ff54253 100644 (file)
@@ -65,7 +65,7 @@ public class EnumValueXPathFunctionTest {
 
     @Test
     public void testEnumValueFunction() throws Exception {
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSource(
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(EnumValueXPathFunctionTest.class,
                 "/yang-xpath-functions-test/enum-value-function/foo.yang");
         assertNotNull(schemaContext);
 
@@ -89,7 +89,7 @@ public class EnumValueXPathFunctionTest {
 
     @Test
     public void testInvalidTypeOfCorrespondingSchemaNode() throws Exception {
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSource(
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(EnumValueXPathFunctionTest.class,
                 "/yang-xpath-functions-test/enum-value-function/foo-invalid.yang");
         assertNotNull(schemaContext);
 
@@ -113,7 +113,7 @@ public class EnumValueXPathFunctionTest {
 
     @Test
     public void testInvalidNormalizedNodeValueType() throws Exception {
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSource(
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(EnumValueXPathFunctionTest.class,
                 "/yang-xpath-functions-test/enum-value-function/foo.yang");
         assertNotNull(schemaContext);
 
@@ -137,7 +137,7 @@ public class EnumValueXPathFunctionTest {
 
     @Test
     public void shouldFailOnUnknownEnumNodeValue() throws Exception {
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSource(
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(EnumValueXPathFunctionTest.class,
                 "/yang-xpath-functions-test/enum-value-function/foo.yang");
         assertNotNull(schemaContext);
 
index d7c62fdd7baaee87124267350147127bcac33b51..1578c2cdffd94bdf5ce6e088a10a7cdbd03b77e4 100644 (file)
@@ -212,7 +212,7 @@ public class JaxenTest {
     }
 
     private static SchemaContext createSchemaContext() throws IOException, URISyntaxException, ReactorException {
-        return YangParserTestUtils.parseYangSources("/test/documentTest");
+        return YangParserTestUtils.parseYangResourceDirectory("/test/documentTest");
     }
 
     private static NormalizedNode<?, ?> createNormalizedNodes() {
index a6df5bdb2526e88e366dc27b3a4e711b7aca76bd..088a440cec6afb9e10bcbbac4c20b40215533264 100644 (file)
@@ -134,9 +134,7 @@ public class UtilTest {
 
     @Test
     public void contextHolderTest() throws Exception {
-        final File testYang1 = new File(getClass().getResource("/test.yang").toURI());
-        final File testYang2 = new File(getClass().getResource("/test2.yang").toURI());
-        final SchemaContext context = YangParserTestUtils.parseYangSources(testYang1, testYang2);
+        final SchemaContext context = YangParserTestUtils.parseYangResources(getClass(), "/test.yang", "/test2.yang");
         final Set<Module> yangModules = new HashSet<>();
         final ContextHolder cxH = new ContextHolder(context, yangModules, ImmutableSet.of());
         assertEquals(context, cxH.getContext());
index dbc2c8e17a07db84e596d476a00ad5236892898f..f56e67ef0dba611642bcc4b963f273c4d69590a9 100644 (file)
@@ -80,6 +80,10 @@ public interface SchemaContext extends ContainerSchemaNode {
      */
     Module findModuleByName(String name, Date revision);
 
+    default Optional<Module> findAnyModuleByName(final String name) {
+        return Optional.fromNullable(findModuleByName(name, null));
+    }
+
     /**
      * Returns module instance (from the context) with concrete namespace.
      *
index 6e870689e639066cdd0d58ff3cfa909dd05c16c2..a488c5731dfe728ae107d310a1e5dd84bb59f313 100644 (file)
@@ -16,7 +16,7 @@ import java.util.Optional;
 import org.opendaylight.yangtools.concepts.Delegator;
 
 /**
- * A resource-backed {@link YangTextSchemaSource}.
+ * A resource-backed {@link YinTextSchemaSource}.
  */
 final class ResourceYangTextSchemaSource extends YangTextSchemaSource implements Delegator<URL> {
     private final URL url;
diff --git a/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/ResourceYinTextSchemaSource.java b/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/ResourceYinTextSchemaSource.java
new file mode 100644 (file)
index 0000000..b548ebb
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * 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.yangtools.yang.model.repo.api;
+
+import com.google.common.base.MoreObjects.ToStringHelper;
+import com.google.common.base.Preconditions;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Optional;
+import org.opendaylight.yangtools.concepts.Delegator;
+
+/**
+ * A resource-backed {@link YangTextSchemaSource}.
+ */
+final class ResourceYinTextSchemaSource extends YinTextSchemaSource implements Delegator<URL> {
+    private final URL url;
+
+    ResourceYinTextSchemaSource(final SourceIdentifier identifier, final URL url) {
+        super(identifier);
+        this.url = Preconditions.checkNotNull(url);
+    }
+
+    @Override
+    public URL getDelegate() {
+        return url;
+    }
+
+    @Override
+    protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
+        return toStringHelper.add("url", url);
+    }
+
+    @Override
+    public InputStream openStream() throws IOException {
+        return url.openStream();
+    }
+
+    @Override
+    public Optional<String> getSymbolicName() {
+        return Optional.of(url.toString());
+    }
+}
index 1b424c8714e2908c186fcf2394a4145259e3df0a..24c921eb56ed72aba57160d829981cb0726c0e26 100644 (file)
@@ -81,7 +81,7 @@ public abstract class YangTextSchemaSource extends ByteSource implements YangSch
      * @throws NullPointerException if file is null
      */
     public static YangTextSchemaSource forFile(final File file) {
-        Preconditions.checkArgument(file.isFile(), "Supplied file %s is not a file");
+        Preconditions.checkArgument(file.isFile(), "Supplied file %s is not a file", file);
         return new YangTextFileSchemaSource(identifierFromFilename(file.getName()), file);
     }
 
diff --git a/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/YinTextFileSchemaSource.java b/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/YinTextFileSchemaSource.java
new file mode 100644 (file)
index 0000000..5beabfa
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * 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.yangtools.yang.model.repo.api;
+
+import com.google.common.base.MoreObjects.ToStringHelper;
+import com.google.common.base.Preconditions;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.util.Optional;
+import org.opendaylight.yangtools.concepts.Delegator;
+
+/**
+ * A {@link YinTextSchemaSource} backed by a file.
+ *
+ * @author Robert Varga
+ */
+final class YinTextFileSchemaSource extends YinTextSchemaSource implements Delegator<File> {
+    private final File file;
+
+    YinTextFileSchemaSource(final SourceIdentifier identifier, final File file) {
+        super(identifier);
+        this.file = Preconditions.checkNotNull(file);
+    }
+
+    @Override
+    public File getDelegate() {
+        return file;
+    }
+
+    @Override
+    public InputStream openStream() throws IOException {
+        return Files.newInputStream(file.toPath());
+    }
+
+    @Override
+    protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
+        return toStringHelper.add("file", file);
+    }
+
+    @Override
+    public Optional<String> getSymbolicName() {
+        return Optional.of(file.toString());
+    }
+}
index 0b64f6ef37cac876287950c9e16291e8ad951600..20ce3b6ff69ae6999793fffe025f89b95345463a 100644 (file)
@@ -13,8 +13,11 @@ import com.google.common.base.MoreObjects.ToStringHelper;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.io.ByteSource;
+import com.google.common.io.Resources;
+import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.URL;
 import java.util.Map.Entry;
 import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.concepts.Delegator;
@@ -93,6 +96,18 @@ public abstract class YinTextSchemaSource extends ByteSource implements YinSchem
         return new DelegatedYinTextSchemaSource(identifier, delegate);
     }
 
+    public static YinTextSchemaSource forFile(final File file) {
+        Preconditions.checkArgument(file.isFile(), "Supplied file %s is not a file", file);
+        return new YinTextFileSchemaSource(identifierFromFilename(file.getName()), file);
+    }
+
+    public static YinTextSchemaSource forResource(final Class<?> clazz, final String resourceName) {
+        final String fileName = resourceName.substring(resourceName.lastIndexOf('/') + 1);
+        final SourceIdentifier identifier = identifierFromFilename(fileName);
+        final URL url = Resources.getResource(clazz, resourceName);
+        return new ResourceYinTextSchemaSource(identifier, url);
+    }
+
     private static final class DelegatedYinTextSchemaSource extends YinTextSchemaSource
             implements Delegator<ByteSource> {
         private final ByteSource delegate;
index f629b96b970d12e1703374e0e625eeddcf1da442..c9bbcc6a3f9271d29e67237561f15188291d8b64 100644 (file)
@@ -32,7 +32,7 @@ import org.xml.sax.SAXException;
 public class Bug2444Test {
     @Test
     public void test() throws Exception {
-        final SchemaContext schema = YangParserTestUtils.parseYangSources("/bugs/bug2444/yang");
+        final SchemaContext schema = YangParserTestUtils.parseYangResourceDirectory("/bugs/bug2444/yang");
         assertNotNull(schema);
 
         final File outDir = new File("target/bug2444-export");
index 72514b4e5a300cd4067e183938ece57e834c173c..c4d0a7b498333ab9f1ac90e40d229bd6575d1362 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.yangtools.yang.model.export.test;
 
 import static org.junit.Assert.assertNotNull;
+
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.OutputStream;
@@ -20,7 +21,7 @@ import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 public class Bug4504Test {
     @Test
     public void test() throws Exception {
-        SchemaContext schema = YangParserTestUtils.parseYangSources("/bugs/bug4504");
+        SchemaContext schema = YangParserTestUtils.parseYangResourceDirectory("/bugs/bug4504");
         assertNotNull(schema);
         final File outDir = new File("target/bug4504-export");
         outDir.mkdirs();
index 39e4eeba861a3e2c6823f7f85e8e955acc9bfcac..0f79efca0bb7c28f876491c2c34e5123abda5af7 100644 (file)
@@ -23,7 +23,7 @@ import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 public class Bug5531Test {
     @Test
     public void test() throws Exception {
-        SchemaContext schema = YangParserTestUtils.parseYangSources("/bugs/bug5531");
+        SchemaContext schema = YangParserTestUtils.parseYangResourceDirectory("/bugs/bug5531");
 
         assertNotNull(schema);
         assertNotNull(schema.getModules());
index 2b6cc409b2469f8e8e07e9f4e7fec202c5c881af..1f56603869501806736e60ed7fde2c9452abcccf 100644 (file)
@@ -27,7 +27,8 @@ public class Bug6856Test {
 
     @Test
     public void testImplicitInputAndOutputInRpc() throws Exception {
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSource("/bugs/bug6856/foo.yang");
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(Bug6856Test.class,
+            "/bugs/bug6856/foo.yang");
         assertNotNull(schemaContext);
 
         final OutputStream byteArrayOutputStream = new ByteArrayOutputStream();
@@ -48,7 +49,8 @@ public class Bug6856Test {
 
     @Test
     public void testExplicitInputAndOutputInRpc() throws Exception {
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSource("/bugs/bug6856/bar.yang");
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(Bug6856Test.class,
+            "/bugs/bug6856/bar.yang");
         assertNotNull(schemaContext);
 
         final OutputStream byteArrayOutputStream = new ByteArrayOutputStream();
index 1b421f793f4d754065d361cffcf2608eca843e64..1ef59e0b9fdc2c4d416a60ac4519b32e7ec65c77 100644 (file)
@@ -36,7 +36,8 @@ public class SchemaContextEmitterTest {
     @Test
     public void testSchemaContextEmitter() throws ReactorException, IOException, URISyntaxException,
             XMLStreamException, SAXException {
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangSources("/schema-context-emitter-test");
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResourceDirectory(
+            "/schema-context-emitter-test");
         assertNotNull(schemaContext);
         assertEquals(1, schemaContext.getModules().size());
 
index c0cc5ba9d4cb025b19d0f11811af267af710a6fc..f8c6a229d38dc04b3f01df398a4bec76cd614f23 100644 (file)
@@ -11,7 +11,7 @@ import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
 import com.google.common.collect.ImmutableSet;
-import java.io.InputStream;
+import java.io.IOException;
 import java.util.Date;
 import java.util.HashSet;
 import java.util.Objects;
@@ -24,12 +24,12 @@ import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
 import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
+import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YangStatementStreamSource;
 import org.opendaylight.yangtools.yang.parser.spi.source.DeclarationInTextSource;
 import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.SupportedExtensionsMapping;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
-import org.opendaylight.yangtools.yang.parser.util.NamedInputStream;
 
 /**
  * Helper transfer object which holds basic and dependency information for YANG
@@ -204,13 +204,21 @@ public abstract class YangModelDependencyInfo {
      * Extracts {@link YangModelDependencyInfo} from input stream containing a YANG model. This parsing does not
      * validate full YANG module, only parses header up to the revisions and imports.
      *
-     * @param yangStream Opened Input stream containing text source of YANG model
+     * @param refClass Base search class
+     * @param resourceName resource name, relative to refClass
      * @return {@link YangModelDependencyInfo}
-     * @throws IllegalArgumentException If input stream is not valid YANG stream
+     * @throws YangSyntaxErrorException If the resource does not pass syntactic analysis
+     * @throws IOException When the resource cannot be read
+     * @throws IllegalArgumentException
+     *             If input stream is not valid YANG stream
      */
-    public static YangModelDependencyInfo fromInputStream(final InputStream yangStream) {
-        final StatementContext yangAST = new YangStatementSourceImpl(yangStream).getYangAST();
-        return parseAST(yangAST, yangStream instanceof NamedInputStream ? yangStream.toString() : null);
+    public static YangModelDependencyInfo forResource(final Class<?> refClass, final String resourceName)
+            throws IOException, YangSyntaxErrorException {
+        final YangStatementStreamSource source = YangStatementStreamSource.create(
+            YangTextSchemaSource.forResource(refClass, resourceName));
+        final ParserRuleContext ast = source.getYangAST();
+        Preconditions.checkArgument(ast instanceof StatementContext);
+        return parseAST((StatementContext) ast, source.getIdentifier().toYangFilename());
     }
 
     private static YangModelDependencyInfo parseModuleContext(final StatementContext module, final String sourceName) {
@@ -232,7 +240,7 @@ public abstract class YangModelDependencyInfo {
                         getReference(sourceName, subStatementContext));
                 final Date revisionDate = revisionDateStr == null ? null : QName.parseRevision(revisionDateStr);
                 final Optional<SemVer> importSemVer = Optional.fromNullable(findSemanticVersion(subStatementContext,
-                    sourceName));
+                            sourceName));
                 result.add(new ModuleImportImpl(importedModuleName, revisionDate, importSemVer));
             }
         }
index ce9ed357762ef57ca0b8e83aade54f6e3a2f0bc2..c5c6bdec5d6065b8ceb3398bc96b59e4eb021589 100644 (file)
@@ -42,10 +42,10 @@ import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceFilter;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
 import org.opendaylight.yangtools.yang.parser.impl.util.YangModelDependencyInfo;
+import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YangStatementStreamSource;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
 import org.opendaylight.yangtools.yang.parser.util.ASTSchemaSource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -214,16 +214,17 @@ final class SharedSchemaContextFactory implements SchemaContextFactory {
                         res.getResolvedSources(), res.getUnsatisfiedImports());
             }
 
-            final Map<SourceIdentifier, ParserRuleContext> asts = Maps.transformValues(srcs, ASTSchemaSource::getAST);
             final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(
                 statementParserMode, supportedFeatures);
 
-            for (final Entry<SourceIdentifier, ParserRuleContext> e : asts.entrySet()) {
-                final ParserRuleContext parserRuleCtx = e.getValue();
+            for (final Entry<SourceIdentifier, ASTSchemaSource> e : srcs.entrySet()) {
+                final ASTSchemaSource ast = e.getValue();
+                final ParserRuleContext parserRuleCtx = ast.getAST();
                 Preconditions.checkArgument(parserRuleCtx instanceof StatementContext,
                         "Unsupported context class %s for source %s", parserRuleCtx.getClass(), e.getKey());
 
-                reactor.addSource(new YangStatementSourceImpl(e.getKey(), (StatementContext) parserRuleCtx));
+                reactor.addSource(YangStatementStreamSource.create(e.getKey(), (StatementContext) parserRuleCtx,
+                    ast.getSymbolicName().orElse(null)));
             }
 
             final SchemaContext schemaContext;
index ada4ca21b40c5e0ff455f5f7cffa24c2bfaa912f..d7388e03c0980bea41f95b0279aeabdaee9ebf10 100644 (file)
@@ -87,6 +87,11 @@ public final class YangStatementStreamSource implements Identifiable<SourceIdent
         return new YangStatementStreamSource(source.getIdentifier(), parser, context);
     }
 
+    public static YangStatementStreamSource create(final SourceIdentifier identifier, final StatementContext context,
+        final String symbolicName) {
+        return new YangStatementStreamSource(identifier, new YangStatementParserListenerImpl(symbolicName), context);
+    }
+
     @Override
     public void writePreLinkage(final StatementWriter writer, final QNameToStatementDefinition stmtDef) {
         yangStatementModelParser.setAttributes(writer, stmtDef);
index 95937d22f31db608d1519e6e7cfdd1ecf5d692d4..ad167121bdbac584f7ec46254ebaae65a3bf0836 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.yangtools.yang.parser.rfc6020.repo;
 
 import com.google.common.annotations.Beta;
 import com.google.common.util.concurrent.Futures;
+import java.io.IOException;
 import javax.xml.parsers.SAXParser;
 import javax.xml.transform.dom.DOMSource;
 import org.opendaylight.yangtools.util.xml.UntrustedXML;
@@ -18,6 +19,7 @@ import org.opendaylight.yangtools.yang.model.repo.api.YinTextSchemaSource;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistry;
 import org.opendaylight.yangtools.yang.model.repo.util.SchemaSourceTransformer;
 import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
 import org.xml.sax.helpers.DefaultHandler;
 
 /**
@@ -28,23 +30,21 @@ import org.xml.sax.helpers.DefaultHandler;
  */
 @Beta
 public final class YinTextToDomTransformer extends SchemaSourceTransformer<YinTextSchemaSource, YinDomSchemaSource> {
-
-    @Deprecated
-    public static final Transformation<YinTextSchemaSource, YinDomSchemaSource> TRANSFORMATION = input -> {
-        final Document doc = UntrustedXML.newDocumentBuilder().newDocument();
-        final SAXParser parser = UntrustedXML.newSAXParser();
-        final DefaultHandler handler = new StatementSourceReferenceHandler(doc, null);
-        parser.parse(input.openStream(), handler);
-
-        return Futures.immediateCheckedFuture(YinDomSchemaSource.create(input.getIdentifier(), new DOMSource(doc)));
-    };
-
     private YinTextToDomTransformer(final SchemaRepository provider, final SchemaSourceRegistry consumer) {
-        super(provider, YinTextSchemaSource.class, consumer, YinDomSchemaSource.class, TRANSFORMATION);
+        super(provider, YinTextSchemaSource.class, consumer, YinDomSchemaSource.class,
+            input -> Futures.immediateCheckedFuture(transformSource(input)));
     }
 
     public static YinTextToDomTransformer create(final SchemaRepository provider, final SchemaSourceRegistry consumer) {
         return new YinTextToDomTransformer(provider, consumer);
     }
 
+    public static YinDomSchemaSource transformSource(final YinTextSchemaSource source) throws SAXException, IOException {
+        final Document doc = UntrustedXML.newDocumentBuilder().newDocument();
+        final SAXParser parser = UntrustedXML.newSAXParser();
+        final DefaultHandler handler = new StatementSourceReferenceHandler(doc, null);
+        parser.parse(source.openStream(), handler);
+        return YinDomSchemaSource.create(source.getIdentifier(), new DOMSource(doc));
+    }
+
 }
index 3e4ff416403947fead54af1a82cb3ddef8f7cae3..7ac2bc6c12a9c980df639b9f42949490080ec822 100644 (file)
@@ -9,30 +9,21 @@ package org.opendaylight.yangtools.yang.parser.stmt.reactor;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableMap;
-import com.google.common.io.ByteSource;
-import java.io.IOException;
-import java.io.InputStream;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.EnumMap;
-import java.util.List;
 import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
 import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
 import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
-import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YangStatementStreamSource;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupportBundle;
 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
 import org.opendaylight.yangtools.yang.parser.spi.validation.ValidationBundlesNamespace.ValidationBundleType;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
 
 public final class CrossSourceStatementReactor {
     private final Map<ModelProcessingPhase, StatementSupportBundle> supportedTerminology;
@@ -276,42 +267,5 @@ public final class CrossSourceStatementReactor {
         public EffectiveSchemaContext buildEffective() throws ReactorException {
             return context.buildEffective();
         }
-
-        /**
-         * Add specified sources and assemble the resulting SchemaContext.
-         *
-         * @deprecated Use {@link #addSources(Collection)} and {@link #buildEffective()} instead.
-         */
-        @Deprecated
-        public SchemaContext buildEffective(final Collection<ByteSource> yangByteSources) throws ReactorException,
-                IOException {
-            for (final ByteSource source : yangByteSources) {
-                if (source instanceof YangTextSchemaSource) {
-                    try {
-                        addSource(YangStatementStreamSource.create((YangTextSchemaSource) source));
-                    } catch (YangSyntaxErrorException e) {
-                        throw new IOException("Source " + source + " failed to parse", e);
-                    }
-                } else {
-                    addSource(new YangStatementSourceImpl(source.openStream()));
-                }
-            }
-
-            return buildEffective();
-        }
-
-        /**
-         * Add specified sources and assemble the resulting SchemaContext.
-         *
-         * @deprecated Use {@link #addSources(Collection)} and {@link #buildEffective()} instead.
-         */
-        @Deprecated
-        public SchemaContext buildEffective(final List<InputStream> yangInputStreams) throws ReactorException {
-            for (final InputStream yangInputStream : yangInputStreams) {
-                addSource(new YangStatementSourceImpl(yangInputStream));
-            }
-
-            return buildEffective();
-        }
     }
 }
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/YangStatementSourceImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/YangStatementSourceImpl.java
deleted file mode 100644 (file)
index 8463c81..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.yangtools.yang.parser.stmt.rfc6020;
-
-import com.google.common.base.Throwables;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URISyntaxException;
-import org.antlr.v4.runtime.tree.ParseTreeWalker;
-import org.opendaylight.yangtools.antlrv4.code.gen.YangStatementParser.StatementContext;
-import org.opendaylight.yangtools.yang.common.YangVersion;
-import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.parser.impl.YangStatementParserListenerImpl;
-import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YangStatementStreamSource;
-import org.opendaylight.yangtools.yang.parser.spi.source.PrefixToModule;
-import org.opendaylight.yangtools.yang.parser.spi.source.QNameToStatementDefinition;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementWriter;
-import org.opendaylight.yangtools.yang.parser.util.NamedFileInputStream;
-import org.opendaylight.yangtools.yang.parser.util.NamedInputStream;
-
-/**
- * This class represents implementation of StatementStreamSource in order to emit YANG statements using supplied
- * StatementWriter.
- *
- * @deprecated Use {@link YangStatementStreamSource} instead.
- */
-@Deprecated
-public final class YangStatementSourceImpl implements StatementStreamSource {
-    private final YangStatementParserListenerImpl yangStatementModelParser;
-    private final StatementContext statementContext;
-    private final String sourceName;
-
-    public YangStatementSourceImpl(final String fileName, final boolean isAbsolute) {
-        try {
-            final NamedFileInputStream is = loadFile(fileName, isAbsolute);
-            sourceName = is.toString();
-            statementContext = YangStatementStreamSource.parseYangSource(is);
-            yangStatementModelParser = new YangStatementParserListenerImpl(sourceName);
-        } catch (IOException | URISyntaxException | YangSyntaxErrorException e) {
-            throw Throwables.propagate(e);
-        }
-    }
-
-    public YangStatementSourceImpl(final InputStream inputStream) {
-        try {
-            sourceName = inputStream instanceof NamedInputStream ? inputStream.toString() : null;
-            statementContext = YangStatementStreamSource.parseYangSource(inputStream);
-            yangStatementModelParser = new YangStatementParserListenerImpl(sourceName);
-        } catch (IOException | YangSyntaxErrorException e) {
-            throw Throwables.propagate(e);
-        }
-    }
-
-    public YangStatementSourceImpl(final SourceIdentifier identifier, final StatementContext statementContext) {
-        this.statementContext = statementContext;
-        this.sourceName = identifier.getName();
-        yangStatementModelParser = new YangStatementParserListenerImpl(sourceName);
-    }
-
-    @Override
-    public void writePreLinkage(final StatementWriter writer, final QNameToStatementDefinition stmtDef) {
-        yangStatementModelParser.setAttributes(writer, stmtDef);
-        ParseTreeWalker.DEFAULT.walk(yangStatementModelParser, statementContext);
-    }
-
-    @Override
-    public void writeLinkage(final StatementWriter writer, final QNameToStatementDefinition stmtDef,
-            final PrefixToModule preLinkagePrefixes) {
-        writeLinkage(writer, stmtDef, preLinkagePrefixes, YangVersion.VERSION_1);
-    }
-
-    @Override
-    public void writeLinkage(final StatementWriter writer, final QNameToStatementDefinition stmtDef,
-            final PrefixToModule preLinkagePrefixes, final YangVersion yangVersion) {
-        yangStatementModelParser.setAttributes(writer, stmtDef, preLinkagePrefixes, yangVersion);
-        ParseTreeWalker.DEFAULT.walk(yangStatementModelParser, statementContext);
-    }
-
-    @Override
-    public void writeLinkageAndStatementDefinitions(final StatementWriter writer,
-            final QNameToStatementDefinition stmtDef, final PrefixToModule prefixes) {
-        writeLinkageAndStatementDefinitions(writer, stmtDef, prefixes, YangVersion.VERSION_1);
-    }
-
-    @Override
-    public void writeLinkageAndStatementDefinitions(final StatementWriter writer,
-            final QNameToStatementDefinition stmtDef, final PrefixToModule prefixes, final YangVersion yangVersion) {
-        yangStatementModelParser.setAttributes(writer, stmtDef, prefixes, yangVersion);
-        ParseTreeWalker.DEFAULT.walk(yangStatementModelParser, statementContext);
-    }
-
-    @Override
-    public void writeFull(final StatementWriter writer, final QNameToStatementDefinition stmtDef,
-            final PrefixToModule prefixes) {
-        writeFull(writer, stmtDef, prefixes, YangVersion.VERSION_1);
-    }
-
-    @Override
-    public void writeFull(final StatementWriter writer, final QNameToStatementDefinition stmtDef,
-            final PrefixToModule prefixes, final YangVersion yangVersion) {
-        yangStatementModelParser.setAttributes(writer, stmtDef, prefixes, yangVersion);
-        ParseTreeWalker.DEFAULT.walk(yangStatementModelParser, statementContext);
-    }
-
-    private NamedFileInputStream loadFile(final String fileName, final boolean isAbsolute)
-            throws URISyntaxException, IOException {
-        //TODO: we need absolute path first!
-        return isAbsolute ? new NamedFileInputStream(new File(fileName), fileName)
-                : new NamedFileInputStream(new File(getClass().getResource(fileName).toURI()), fileName);
-    }
-
-    public StatementContext getYangAST() {
-        return statementContext;
-    }
-
-    @Override
-    public String toString() {
-        return sourceName;
-    }
-}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/YinStatementSourceImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/YinStatementSourceImpl.java
deleted file mode 100644 (file)
index 24dace3..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.yangtools.yang.parser.stmt.rfc6020;
-
-import com.google.common.base.Throwables;
-import com.google.common.collect.ForwardingObject;
-import com.google.common.io.ByteSource;
-import com.google.common.io.ByteStreams;
-import com.google.common.io.Files;
-import java.io.File;
-import java.io.InputStream;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YinDomSchemaSource;
-import org.opendaylight.yangtools.yang.model.repo.api.YinTextSchemaSource;
-import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YinStatementStreamSource;
-import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YinTextToDomTransformer;
-import org.opendaylight.yangtools.yang.parser.spi.source.PrefixToModule;
-import org.opendaylight.yangtools.yang.parser.spi.source.QNameToStatementDefinition;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementWriter;
-
-/**
- * This class represents implementation of StatementStreamSource
- * in order to emit YIN statements using supplied StatementWriter.
- *
- * @deprecated Scheduled for removal. Use {@link YinStatementStreamSource} instead.
- */
-@Deprecated
-public final class YinStatementSourceImpl extends ForwardingObject implements StatementStreamSource {
-    private final StatementStreamSource delegate;
-
-    private YinStatementSourceImpl(final YinDomSchemaSource source) {
-        this.delegate = YinStatementStreamSource.create(source);
-    }
-
-    @Override
-    public StatementStreamSource delegate() {
-        return delegate;
-    }
-
-    public YinStatementSourceImpl(final InputStream inputStream) {
-        this(newStreamSource(inputStream));
-    }
-
-    private static YinDomSchemaSource newStreamSource(final InputStream inputStream) {
-        final SourceIdentifier id = YinTextSchemaSource.identifierFromFilename(inputStream.toString());
-
-        try {
-            final YinTextSchemaSource text = YinTextSchemaSource.delegateForByteSource(id,
-                ByteSource.wrap(ByteStreams.toByteArray(inputStream)));
-            return YinTextToDomTransformer.TRANSFORMATION.apply(text).get();
-        } catch (Exception e) {
-            throw Throwables.propagate(e);
-        }
-    }
-
-    private static YinDomSchemaSource newStreamSource(final String fileName, final boolean isAbsolute) {
-        try {
-            final File file;
-            if (isAbsolute) {
-                file = new File(fileName);
-            } else {
-                file = new File(YinStatementSourceImpl.class.getResource(fileName).toURI());
-            }
-
-            final YinTextSchemaSource text = YinTextSchemaSource.delegateForByteSource(
-                YinTextSchemaSource.identifierFromFilename(file.getName()), Files.asByteSource(file));
-
-            return YinTextToDomTransformer.TRANSFORMATION.apply(text).get();
-        } catch (Exception e) {
-            throw Throwables.propagate(e);
-        }
-    }
-
-    public YinStatementSourceImpl(final String fileName, final boolean isAbsolute) {
-        this(newStreamSource(fileName, isAbsolute));
-    }
-
-    @Override
-    public void writePreLinkage(final StatementWriter writer, final QNameToStatementDefinition stmtDef) {
-        delegate.writePreLinkage(writer, stmtDef);
-    }
-
-    @Override
-    public void writeLinkage(final StatementWriter writer, final QNameToStatementDefinition stmtDef,
-            final PrefixToModule preLinkagePrefixes) {
-        delegate.writeLinkage(writer, stmtDef, preLinkagePrefixes);
-
-    }
-
-    @Override
-    public void writeLinkageAndStatementDefinitions(final StatementWriter writer, final QNameToStatementDefinition stmtDef,
-            final PrefixToModule prefixes) {
-        delegate.writeLinkageAndStatementDefinitions(writer, stmtDef, prefixes);
-    }
-
-    @Override
-    public void writeFull(final StatementWriter writer, final QNameToStatementDefinition stmtDef,
-            final PrefixToModule prefixes) {
-        delegate().writeFull(writer, stmtDef, prefixes);
-    }
-
-}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/YangParseException.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/YangParseException.java
deleted file mode 100644 (file)
index aac1bfb..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.yangtools.yang.parser.util;
-
-/**
- * @deprecated This exception is not produced anywhere and is scheduled for removal.
- */
-// TODO: switch to checked exception, add YangSemanticException
-@Deprecated
-public class YangParseException extends RuntimeException {
-    private static final long serialVersionUID = 1239548963471793178L;
-
-    public YangParseException(final String errorMsg) {
-        super(errorMsg);
-    }
-
-    public YangParseException(final String errorMsg, final Exception exception) {
-        super(errorMsg, exception);
-    }
-
-    public YangParseException(final String moduleName, final int line, final String errorMsg) {
-        super("Error in module '" + moduleName + "' at line " + line + ": " + errorMsg);
-    }
-
-    public YangParseException(final String moduleName, final int line, final String errorMsg, final Exception exception) {
-        super("Error in module '" + moduleName + "' at line " + line + ": " + errorMsg, exception);
-    }
-}
index de0e17ff4314cc8c7ed1e42e112a9d0f61f6dbe0..c843ae7c78c6f187d06f13d20e30b0cd9275736e 100644 (file)
@@ -13,15 +13,17 @@ import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
-import java.io.InputStream;
+
+import java.io.IOException;
 import org.junit.Test;
+import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
 
 public class YangModelDependencyInfoTest {
 
     @Test
-    public void testModuleWithNoImports() {
-        InputStream stream = getClass().getResourceAsStream("/ietf/ietf-inet-types@2010-09-24.yang");
-        YangModelDependencyInfo info = YangModelDependencyInfo.fromInputStream(stream);
+    public void testModuleWithNoImports() throws IOException, YangSyntaxErrorException {
+        YangModelDependencyInfo info = YangModelDependencyInfo.forResource(getClass(),
+            "/ietf/ietf-inet-types@2010-09-24.yang");
         assertNotNull(info);
         assertEquals("ietf-inet-types", info.getName());
         assertEquals("2010-09-24", info.getFormattedRevision());
@@ -31,9 +33,9 @@ public class YangModelDependencyInfoTest {
     }
 
     @Test
-    public void testModuleWithImports() {
-        InputStream stream = getClass().getResourceAsStream("/parse-methods/dependencies/m2@2013-09-30.yang");
-        YangModelDependencyInfo info = YangModelDependencyInfo.fromInputStream(stream);
+    public void testModuleWithImports() throws IOException, YangSyntaxErrorException {
+        YangModelDependencyInfo info = YangModelDependencyInfo.forResource(getClass(),
+                "/parse-methods/dependencies/m2@2013-09-30.yang");
         assertNotNull(info);
         assertEquals("m2", info.getName());
         assertEquals("2013-09-30", info.getFormattedRevision());
@@ -42,32 +44,30 @@ public class YangModelDependencyInfoTest {
     }
 
     @Test
-    public void testModuleWithoutRevision() {
-        InputStream stream = getClass().getResourceAsStream("/no-revision/module-without-revision.yang");
-        YangModelDependencyInfo info = YangModelDependencyInfo.fromInputStream(stream);
+    public void testModuleWithoutRevision() throws IOException, YangSyntaxErrorException {
+        YangModelDependencyInfo info = YangModelDependencyInfo.forResource(getClass(),
+                "/no-revision/module-without-revision.yang");
         assertNotNull(info);
         assertEquals("module-without-revision", info.getName());
         assertNull(info.getFormattedRevision());
     }
 
     @Test
-    public void testEquals() {
-        InputStream stream1 = getClass().getResourceAsStream("/ietf/ietf-inet-types@2010-09-24.yang");
-        YangModelDependencyInfo info1 = YangModelDependencyInfo.fromInputStream(stream1);
-        InputStream stream2 = getClass().getResourceAsStream("/no-revision/module-without-revision.yang");
-        YangModelDependencyInfo info2 = YangModelDependencyInfo.fromInputStream(stream2);
+    public void testEquals() throws IOException, YangSyntaxErrorException {
+        YangModelDependencyInfo info1 = YangModelDependencyInfo.forResource(getClass(),
+            "/ietf/ietf-inet-types@2010-09-24.yang");
+        YangModelDependencyInfo info2 = YangModelDependencyInfo.forResource(getClass(),
+            "/no-revision/module-without-revision.yang");
 
         assertTrue(info1.equals(info1));
         assertFalse(info1.equals(null));
-        assertFalse(info1.equals(stream1));
         assertFalse(info1.equals(info2));
     }
 
     @Test
-    public void testHashcode() {
-        InputStream stream = getClass().getResourceAsStream("/no-revision/module-without-revision.yang");
-        YangModelDependencyInfo info = YangModelDependencyInfo.fromInputStream(stream);
-
+    public void testHashcode() throws IOException, YangSyntaxErrorException {
+        YangModelDependencyInfo info = YangModelDependencyInfo.forResource(getClass(),
+                "/no-revision/module-without-revision.yang");
         assertNotEquals("hashcode", 31, info.hashCode());
     }
 }
index b85d2d4cb3f4f582a743cabb7dfb45953bcd19a8..1fff2ff3b4bba501e0e843e9a74dea94f57ec5af 100644 (file)
@@ -10,12 +10,11 @@ package org.opendaylight.yangtools.yang.parser.repo;
 
 import static org.junit.Assert.assertEquals;
 
-import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
-
 import com.google.common.base.Optional;
 import java.util.HashMap;
 import java.util.Map;
 import org.junit.Test;
+import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.parser.impl.util.YangModelDependencyInfo;
 
@@ -26,9 +25,9 @@ public class DependencyResolverTest {
     public void testModulesWithoutRevisionAndImport() throws Exception {
         final Map<SourceIdentifier, YangModelDependencyInfo> map = new HashMap<>();
 
-        addToMap(map, YangModelDependencyInfo.ModuleDependencyInfo.fromInputStream(getClass().getResourceAsStream("/no-revision/imported.yang")));
-        addToMap(map, YangModelDependencyInfo.ModuleDependencyInfo.fromInputStream(getClass().getResourceAsStream("/no-revision/imported@2012-12-12.yang")));
-        addToMap(map, YangModelDependencyInfo.ModuleDependencyInfo.fromInputStream(getClass().getResourceAsStream("/no-revision/top@2012-10-10.yang")));
+        addToMap(map, YangModelDependencyInfo.ModuleDependencyInfo.forResource(getClass(), "/no-revision/imported.yang"));
+        addToMap(map, YangModelDependencyInfo.ModuleDependencyInfo.forResource(getClass(), "/no-revision/imported@2012-12-12.yang"));
+        addToMap(map, YangModelDependencyInfo.ModuleDependencyInfo.forResource(getClass(), "/no-revision/top@2012-10-10.yang"));
 
         final DependencyResolver resolved = RevisionDependencyResolver.create(map);
 
@@ -41,9 +40,9 @@ public class DependencyResolverTest {
         final Map<SourceIdentifier, YangModelDependencyInfo> map = new HashMap<>();
 
         // Subfoo does not have parent in reactor
-        addToMap(map, YangModelDependencyInfo.ModuleDependencyInfo.fromInputStream(getClass().getResourceAsStream("/model/subfoo.yang")));
-        addToMap(map, YangModelDependencyInfo.ModuleDependencyInfo.fromInputStream(getClass().getResourceAsStream("/model/bar.yang")));
-        addToMap(map, YangModelDependencyInfo.ModuleDependencyInfo.fromInputStream(getClass().getResourceAsStream("/model/baz.yang")));
+        addToMap(map, YangModelDependencyInfo.ModuleDependencyInfo.forResource(getClass(), "/model/subfoo.yang"));
+        addToMap(map, YangModelDependencyInfo.ModuleDependencyInfo.forResource(getClass(), "/model/bar.yang"));
+        addToMap(map, YangModelDependencyInfo.ModuleDependencyInfo.forResource(getClass(), "/model/baz.yang"));
 
         final DependencyResolver resolved = RevisionDependencyResolver.create(map);
 
@@ -56,10 +55,10 @@ public class DependencyResolverTest {
     public void testSubmodule() throws Exception {
         final Map<SourceIdentifier, YangModelDependencyInfo> map = new HashMap<>();
 
-        addToMap(map, YangModelDependencyInfo.ModuleDependencyInfo.fromInputStream(getClass().getResourceAsStream("/model/subfoo.yang")));
-        addToMap(map, YangModelDependencyInfo.ModuleDependencyInfo.fromInputStream(getClass().getResourceAsStream("/model/foo.yang")));
-        addToMap(map, YangModelDependencyInfo.ModuleDependencyInfo.fromInputStream(getClass().getResourceAsStream("/model/bar.yang")));
-        addToMap(map, YangModelDependencyInfo.ModuleDependencyInfo.fromInputStream(getClass().getResourceAsStream("/model/baz.yang")));
+        addToMap(map, YangModelDependencyInfo.ModuleDependencyInfo.forResource(getClass(), "/model/subfoo.yang"));
+        addToMap(map, YangModelDependencyInfo.ModuleDependencyInfo.forResource(getClass(), "/model/foo.yang"));
+        addToMap(map, YangModelDependencyInfo.ModuleDependencyInfo.forResource(getClass(), "/model/bar.yang"));
+        addToMap(map, YangModelDependencyInfo.ModuleDependencyInfo.forResource(getClass(), "/model/baz.yang"));
 
         final DependencyResolver resolved = RevisionDependencyResolver.create(map);
 
index e896f1c34f91fa7307111671ee6bace75231b729..3d3baa895826dd08161f4bcd68c7fe5b716720f6 100644 (file)
@@ -17,7 +17,6 @@ import static org.junit.Assert.assertTrue;
 import java.io.IOException;
 import java.net.URISyntaxException;
 import java.text.ParseException;
-import java.util.Arrays;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
@@ -27,7 +26,9 @@ import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YangStatementStreamSource;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
@@ -35,12 +36,13 @@ import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline
 public class ConstraintDefinitionsTest {
 
     @Test
-    public void testConstraintDefinitions() throws ParseException, ReactorException, URISyntaxException, IOException {
+    public void testConstraintDefinitions() throws ParseException, ReactorException, URISyntaxException, IOException,
+            YangSyntaxErrorException {
         final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
 
-        final YangTextSchemaSource source = YangTextSchemaSource.forResource("/constraint-definitions-test/foo.yang");
-
-        final SchemaContext schemaContext = reactor.buildEffective(Arrays.asList(source));
+        reactor.addSource(YangStatementStreamSource.create(
+            YangTextSchemaSource.forResource("/constraint-definitions-test/foo.yang")));
+        final SchemaContext schemaContext = reactor.buildEffective();
         assertNotNull(schemaContext);
 
         final Module testModule = schemaContext.findModuleByName("foo",
index 495e6ee01a25281525110f19be5202ba0fe1fdc1..5e87187f83e5d676da036c57e453ae01fde16002 100644 (file)
@@ -12,10 +12,7 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
-import java.io.FileNotFoundException;
 import java.net.URI;
-import java.text.DateFormat;
-import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -23,9 +20,9 @@ import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 import java.util.Set;
-import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
 import org.opendaylight.yangtools.yang.common.YangConstants;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
@@ -38,45 +35,34 @@ import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.TypeUtils;
 
 public class AugmentTest {
-    private static final URI fooNS = URI.create("urn:opendaylight.foo");
-    private static final URI barNS = URI.create("urn:opendaylight.bar");
-    private static final URI bazNS = URI.create("urn:opendaylight.baz");
-    private static Date fooRev;
-    private static Date barRev;
-    private static Date bazRev;
-    private static QName q0;
-    private static QName q1;
-    private static QName q2;
-
-    private Set<Module> modules;
-
-    @BeforeClass
-    public static void init() throws FileNotFoundException, ParseException {
-        final DateFormat simpleDateFormat = SimpleDateFormatUtil.getRevisionFormat();
-        fooRev = simpleDateFormat.parse("2013-10-13");
-        barRev = simpleDateFormat.parse("2013-10-14");
-        bazRev = simpleDateFormat.parse("2013-10-15");
-
-        q0 = QName.create(barNS, barRev, "interfaces");
-        q1 = QName.create(barNS, barRev, "ifEntry");
-        q2 = QName.create(bazNS, bazRev, "augment-holder");
-    }
+    private static final QNameModule FOO = QNameModule.create(
+        URI.create("urn:opendaylight.foo"), QName.parseRevision("2013-10-13"));
+    private static final QNameModule BAR = QNameModule.create(
+        URI.create("urn:opendaylight.bar"), QName.parseRevision("2013-10-14"));
+    private static final QNameModule BAZ = QNameModule.create(
+        URI.create("urn:opendaylight.baz"), QName.parseRevision("2013-10-15"));
+
+    private static final QName Q0 = QName.create(BAR, "interfaces");
+    private static final QName Q1 = QName.create(BAR, "ifEntry");
+    private static final QName Q2 = QName.create(BAZ, "augment-holder");
 
     @Test
     public void testAugmentParsing() throws Exception {
-        modules = TestUtils.loadModules(getClass().getResource("/augment-test/augment-in-augment").toURI());
+        final SchemaContext context = TestUtils.loadModules(getClass().getResource("/augment-test/augment-in-augment")
+            .toURI());
         SchemaPath expectedSchemaPath;
         final List<QName> qnames = new ArrayList<>();
-        qnames.add(q0);
-        qnames.add(q1);
-        qnames.add(q2);
+        qnames.add(Q0);
+        qnames.add(Q1);
+        qnames.add(Q2);
 
         // foo.yang
-        final Module module1 = TestUtils.findModule(modules, "foo");
+        final Module module1 = TestUtils.findModule(context, "foo").get();
         Set<AugmentationSchema> augmentations = module1.getAugmentations();
         assertEquals(1, augmentations.size());
         final AugmentationSchema augment = augmentations.iterator().next();
@@ -106,7 +92,7 @@ public class AugmentTest {
         assertNotNull(odl);
 
         // leaf ds0ChannelNumber
-        QName qname = QName.create(fooNS, fooRev, "ds0ChannelNumber");
+        QName qname = QName.create(FOO, "ds0ChannelNumber");
         qnames.add(qname);
         assertEquals(qname, ds0ChannelNumber.getQName());
         expectedSchemaPath = SchemaPath.create(qnames, true);
@@ -119,7 +105,7 @@ public class AugmentTest {
         assertEquals(expectedSchemaPath, ds0ChannelNumber.getType().getPath());
 
         // leaf interface-id
-        qname = QName.create(fooNS, fooRev, "interface-id");
+        qname = QName.create(FOO, "interface-id");
         assertEquals(qname, interfaceId.getQName());
         qnames.set(3, qname);
         expectedSchemaPath = SchemaPath.create(qnames, true);
@@ -127,7 +113,7 @@ public class AugmentTest {
         assertFalse(interfaceId.isAugmenting());
 
         // container schemas
-        qname = QName.create(fooNS, fooRev, "schemas");
+        qname = QName.create(FOO, "schemas");
         assertEquals(qname, schemas.getQName());
         qnames.set(3, qname);
         expectedSchemaPath = SchemaPath.create(qnames, true);
@@ -135,7 +121,7 @@ public class AugmentTest {
         assertFalse(schemas.isAugmenting());
 
         // choice odl
-        qname = QName.create(fooNS, fooRev, "odl");
+        qname = QName.create(FOO, "odl");
         assertEquals(qname, odl.getQName());
         qnames.set(3, qname);
         expectedSchemaPath = SchemaPath.create(qnames, true);
@@ -143,7 +129,7 @@ public class AugmentTest {
         assertFalse(odl.isAugmenting());
 
         // baz.yang
-        final Module module3 = TestUtils.findModule(modules, "baz");
+        final Module module3 = TestUtils.findModule(context, "baz").get();
         augmentations = module3.getAugmentations();
         assertEquals(3, augmentations.size());
         AugmentationSchema augment1 = null;
@@ -180,8 +166,9 @@ public class AugmentTest {
 
     @Test
     public void testAugmentResolving() throws Exception {
-        modules = TestUtils.loadModules(getClass().getResource("/augment-test/augment-in-augment").toURI());
-        final Module module2 = TestUtils.findModule(modules, "bar");
+        final SchemaContext context = TestUtils.loadModules(getClass().getResource("/augment-test/augment-in-augment")
+            .toURI());
+        final Module module2 = TestUtils.findModule(context, "bar").get();
         final ContainerSchemaNode interfaces = (ContainerSchemaNode) module2.getDataChildByName(QName.create(
                 module2.getQNameModule(), "interfaces"));
         final ListSchemaNode ifEntry = (ListSchemaNode) interfaces.getDataChildByName(QName.create(
@@ -189,29 +176,28 @@ public class AugmentTest {
 
         SchemaPath expectedPath;
         final List<QName> qnames = new ArrayList<>();
-        qnames.add(q0);
-        qnames.add(q1);
-        qnames.add(q2);
+        qnames.add(Q0);
+        qnames.add(Q1);
+        qnames.add(Q2);
 
         // baz.yang
         // augment "/br:interfaces/br:ifEntry" {
-        final ContainerSchemaNode augmentHolder = (ContainerSchemaNode) ifEntry.getDataChildByName(QName.create(bazNS,
-                bazRev, "augment-holder"));
+        final ContainerSchemaNode augmentHolder = (ContainerSchemaNode) ifEntry.getDataChildByName(QName.create(BAZ,
+                "augment-holder"));
         TestUtils.checkIsAugmenting(augmentHolder, true);
-        assertEquals(q2, augmentHolder.getQName());
+        assertEquals(Q2, augmentHolder.getQName());
         expectedPath = SchemaPath.create(qnames, true);
         assertEquals(expectedPath, augmentHolder.getPath());
 
         // foo.yang
         // augment "/br:interfaces/br:ifEntry/bz:augment-holder"
-        final LeafSchemaNode ds0ChannelNumber = (LeafSchemaNode) augmentHolder.getDataChildByName(QName.create(fooNS,
-                fooRev, "ds0ChannelNumber"));
-        final LeafSchemaNode interfaceId = (LeafSchemaNode) augmentHolder.getDataChildByName(QName.create(fooNS,
-                fooRev, "interface-id"));
-        final ContainerSchemaNode schemas = (ContainerSchemaNode) augmentHolder.getDataChildByName(QName.create(fooNS,
-                fooRev, "schemas"));
-        final ChoiceSchemaNode odl = (ChoiceSchemaNode) augmentHolder.getDataChildByName(QName.create(fooNS, fooRev,
-                "odl"));
+        final LeafSchemaNode ds0ChannelNumber = (LeafSchemaNode) augmentHolder.getDataChildByName(QName.create(FOO,
+                "ds0ChannelNumber"));
+        final LeafSchemaNode interfaceId = (LeafSchemaNode) augmentHolder.getDataChildByName(QName.create(FOO,
+                "interface-id"));
+        final ContainerSchemaNode schemas = (ContainerSchemaNode) augmentHolder.getDataChildByName(QName.create(FOO,
+                "schemas"));
+        final ChoiceSchemaNode odl = (ChoiceSchemaNode) augmentHolder.getDataChildByName(QName.create(FOO, "odl"));
 
         assertNotNull(ds0ChannelNumber);
         assertNotNull(interfaceId);
@@ -219,28 +205,28 @@ public class AugmentTest {
         assertNotNull(odl);
 
         // leaf ds0ChannelNumber
-        QName qname = QName.create(fooNS, fooRev, "ds0ChannelNumber");
+        QName qname = QName.create(FOO, "ds0ChannelNumber");
         assertEquals(qname, ds0ChannelNumber.getQName());
         qnames.add(qname);
         expectedPath = SchemaPath.create(qnames, true);
         assertEquals(expectedPath, ds0ChannelNumber.getPath());
 
         // leaf interface-id
-        qname = QName.create(fooNS, fooRev, "interface-id");
+        qname = QName.create(FOO, "interface-id");
         assertEquals(qname, interfaceId.getQName());
         qnames.set(3, qname);
         expectedPath = SchemaPath.create(qnames, true);
         assertEquals(expectedPath, interfaceId.getPath());
 
         // container schemas
-        qname = QName.create(fooNS, fooRev, "schemas");
+        qname = QName.create(FOO, "schemas");
         assertEquals(qname, schemas.getQName());
         qnames.set(3, qname);
         expectedPath = SchemaPath.create(qnames, true);
         assertEquals(expectedPath, schemas.getPath());
 
         // choice odl
-        qname = QName.create(fooNS, fooRev, "odl");
+        qname = QName.create(FOO, "odl");
         assertEquals(qname, odl.getQName());
         qnames.set(3, qname);
         expectedPath = SchemaPath.create(qnames, true);
@@ -249,20 +235,20 @@ public class AugmentTest {
 
     @Test
     public void testAugmentedChoice() throws Exception {
-        modules = TestUtils.loadModules(getClass().getResource("/augment-test/augment-in-augment").toURI());
-        final Module module2 = TestUtils.findModule(modules, "bar");
+        final SchemaContext context = TestUtils.loadModules(getClass().getResource("/augment-test/augment-in-augment")
+            .toURI());
+        final Module module2 = TestUtils.findModule(context, "bar").get();
         final ContainerSchemaNode interfaces = (ContainerSchemaNode) module2.getDataChildByName(QName.create(
                 module2.getQNameModule(), "interfaces"));
         final ListSchemaNode ifEntry = (ListSchemaNode) interfaces.getDataChildByName(QName.create(
                 module2.getQNameModule(), "ifEntry"));
         final ContainerSchemaNode augmentedHolder = (ContainerSchemaNode) ifEntry.getDataChildByName(QName.create(
-                bazNS, bazRev, "augment-holder"));
+                BAZ, "augment-holder"));
         TestUtils.checkIsAugmenting(augmentedHolder, true);
 
         // foo.yang
         // augment "/br:interfaces/br:ifEntry/bz:augment-holder"
-        final ChoiceSchemaNode odl = (ChoiceSchemaNode) augmentedHolder.getDataChildByName(QName.create(fooNS, fooRev,
-                "odl"));
+        final ChoiceSchemaNode odl = (ChoiceSchemaNode) augmentedHolder.getDataChildByName(QName.create(FOO, "odl"));
         assertNotNull(odl);
         final Set<ChoiceCaseNode> cases = odl.getCases();
         assertEquals(4, cases.size());
@@ -291,13 +277,13 @@ public class AugmentTest {
 
         SchemaPath expectedPath;
         final List<QName> qnames = new ArrayList<>();
-        qnames.add(q0);
-        qnames.add(q1);
-        qnames.add(q2);
-        qnames.add(QName.create(fooNS, fooRev, "odl"));
+        qnames.add(Q0);
+        qnames.add(Q1);
+        qnames.add(Q2);
+        qnames.add(QName.create(FOO, "odl"));
 
         // case id
-        QName qname = QName.create(fooNS, fooRev, "id");
+        QName qname = QName.create(FOO, "id");
         assertEquals(qname, id.getQName());
         qnames.add(qname);
         expectedPath = SchemaPath.create(qnames, true);
@@ -306,7 +292,7 @@ public class AugmentTest {
         assertEquals(1, idChildren.size());
 
         // case node1
-        qname = QName.create(fooNS, fooRev, "node1");
+        qname = QName.create(FOO, "node1");
         assertEquals(qname, node1.getQName());
         qnames.set(4, qname);
         expectedPath = SchemaPath.create(qnames, true);
@@ -315,7 +301,7 @@ public class AugmentTest {
         assertTrue(node1Children.isEmpty());
 
         // case node2
-        qname = QName.create(fooNS, fooRev, "node2");
+        qname = QName.create(FOO, "node2");
         assertEquals(qname, node2.getQName());
         qnames.set(4, qname);
         expectedPath = SchemaPath.create(qnames, true);
@@ -324,7 +310,7 @@ public class AugmentTest {
         assertTrue(node2Children.isEmpty());
 
         // case node3
-        qname = QName.create(fooNS, fooRev, "node3");
+        qname = QName.create(FOO, "node3");
         assertEquals(qname, node3.getQName());
         qnames.set(4, qname);
         expectedPath = SchemaPath.create(qnames, true);
@@ -334,22 +320,22 @@ public class AugmentTest {
 
         // test cases
         qnames.clear();
-        qnames.add(q0);
-        qnames.add(q1);
-        qnames.add(q2);
-        qnames.add(QName.create(fooNS, fooRev, "odl"));
+        qnames.add(Q0);
+        qnames.add(Q1);
+        qnames.add(Q2);
+        qnames.add(QName.create(FOO, "odl"));
 
         // case id child
-        qnames.add(QName.create(fooNS, fooRev, "id"));
-        qnames.add(QName.create(fooNS, fooRev, "id"));
+        qnames.add(QName.create(FOO, "id"));
+        qnames.add(QName.create(FOO, "id"));
         final LeafSchemaNode caseIdChild = (LeafSchemaNode) idChildren.iterator().next();
         assertNotNull(caseIdChild);
         expectedPath = SchemaPath.create(qnames, true);
         assertEquals(expectedPath, caseIdChild.getPath());
 
         // case node3 child
-        qnames.set(4, QName.create(fooNS, fooRev, "node3"));
-        qnames.set(5, QName.create(fooNS, fooRev, "node3"));
+        qnames.set(4, QName.create(FOO, "node3"));
+        qnames.set(5, QName.create(FOO, "node3"));
         final ContainerSchemaNode caseNode3Child = (ContainerSchemaNode) node3Children.iterator().next();
         assertNotNull(caseNode3Child);
         expectedPath = SchemaPath.create(qnames, true);
@@ -358,12 +344,12 @@ public class AugmentTest {
 
     @Test
     public void testAugmentRpc() throws Exception {
-        modules = TestUtils.loadModules(getClass().getResource("/augment-test/rpc").toURI());
+        final SchemaContext context = TestUtils.loadModules(getClass().getResource("/augment-test/rpc").toURI());
         final URI NS_BAR = URI.create("urn:opendaylight:bar");
         final URI NS_FOO = URI.create("urn:opendaylight:foo");
         final Date revision = SimpleDateFormatUtil.getRevisionFormat().parse("2013-10-11");
 
-        final Module bar = TestUtils.findModule(modules, "bar");
+        final Module bar = TestUtils.findModule(context, "bar").get();
         final Set<RpcDefinition> rpcs = bar.getRpcs();
         assertEquals(2, rpcs.size());
 
@@ -442,10 +428,11 @@ public class AugmentTest {
 
     @Test
     public void testAugmentInUsesResolving() throws Exception {
-        modules = TestUtils.loadModules(getClass().getResource("/augment-test/augment-in-uses").toURI());
-        assertEquals(1, modules.size());
+        final SchemaContext context = TestUtils.loadModules(getClass().getResource("/augment-test/augment-in-uses")
+            .toURI());
+        assertEquals(1, context.getModules().size());
 
-        final Module test = modules.iterator().next();
+        final Module test = context.getModules().iterator().next();
         final DataNodeContainer links = (DataNodeContainer) test.getDataChildByName(QName.create(test.getQNameModule(),
                 "links"));
         final DataNodeContainer link = (DataNodeContainer) links.getDataChildByName(QName.create(test.getQNameModule(),
index 3872378faa0c871111d26bbe7394fbbf600d67f1..99ef2831d1c61a50ac7037bc41ed5545bd8427a8 100644 (file)
@@ -15,15 +15,16 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.UsesNode;
 import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
 
 public class AugmentToExtensionTest {
-    private Set<Module> modules;
+    private SchemaContext context;
 
     @Test(expected = SomeModifiersUnresolvedException.class)
     public void testIncorrectPath() throws Exception {
-        modules = TestUtils.loadModules(getClass().getResource("/augment-to-extension-test/incorrect-path").toURI());
+        context = TestUtils.loadModules(getClass().getResource("/augment-to-extension-test/incorrect-path").toURI());
     }
 
     /*
@@ -34,14 +35,14 @@ public class AugmentToExtensionTest {
     public void testCorrectPathIntoUnsupportedTarget() throws Exception {
 
         try {
-        modules = TestUtils.loadModules(getClass().getResource(
+        context = TestUtils.loadModules(getClass().getResource(
                 "/augment-to-extension-test/correct-path-into-unsupported-target").toURI());
         } catch (final Exception e) {
             StmtTestUtils.log(e, "    ");
             throw e;
         }
 
-        final Module devicesModule = TestUtils.findModule(modules, "augment-module");
+        final Module devicesModule = TestUtils.findModule(context, "augment-module").get();
 
         final ContainerSchemaNode devicesContainer = (ContainerSchemaNode) devicesModule.getDataChildByName(QName
                 .create(devicesModule.getQNameModule(), "my-container"));
@@ -55,9 +56,9 @@ public class AugmentToExtensionTest {
 
     @Test
     public void testCorrectAugment() throws Exception {
-        modules = TestUtils.loadModules(getClass().getResource("/augment-to-extension-test/correct-augment").toURI());
+        context = TestUtils.loadModules(getClass().getResource("/augment-to-extension-test/correct-augment").toURI());
 
-        final Module devicesModule = TestUtils.findModule(modules, "augment-module");
+        final Module devicesModule = TestUtils.findModule(context, "augment-module").get();
 
         final ContainerSchemaNode devicesContainer = (ContainerSchemaNode) devicesModule.getDataChildByName(QName
                 .create(devicesModule.getQNameModule(), "my-container"));
index 43f475617c54d6b46a3aa4b38a8ea36aca0a6b4c..b9f5f62403ccb7be7d999663cb7f4e39b09a9aec 100644 (file)
@@ -13,7 +13,6 @@ import static org.junit.Assert.assertNotNull;
 import java.net.URI;
 import java.util.Date;
 import java.util.List;
-import java.util.Set;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
@@ -31,15 +30,8 @@ public class Bug1412Test {
 
     @Test
     public void test() throws Exception {
-
-        Set<Module> modules = null;
-
-
-        modules = TestUtils.loadModules(getClass().getResource("/bugs/bug1412").toURI());
-
-
-        final Module bug1412 = TestUtils.findModule(modules, "bug1412");
-        assertNotNull(bug1412);
+        final Module bug1412 = TestUtils.findModule(
+            TestUtils.loadModules(getClass().getResource("/bugs/bug1412").toURI()), "bug1412").get();
 
         final ContainerSchemaNode node = (ContainerSchemaNode) bug1412.getDataChildByName(QName.create(
                 bug1412.getQNameModule(), "node"));
index 22d196712bd91607b38b2cf6072585eb1bb83688..f3fb19ec71456b9f5781818926449782e285ee26 100644 (file)
@@ -12,7 +12,6 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import java.util.List;
-import java.util.Set;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
 import org.opendaylight.yangtools.yang.model.api.Module;
@@ -27,8 +26,8 @@ public class Bug1413Test {
 
     @Test
     public void test() throws Exception {
-        Set<Module> modules = TestUtils.loadModules(getClass().getResource("/bugs/bug1413").toURI());
-        Module bug1413 = TestUtils.findModule(modules, "bug1413");
+        final Module bug1413 = TestUtils.findModule(
+            TestUtils.loadModules(getClass().getResource("/bugs/bug1413").toURI()), "bug1413").get();
         assertNotNull(bug1413);
 
         List<ExtensionDefinition> extensions = bug1413.getExtensionSchemaNodes();
index 012cc1fa5500f2926c1390354cb248bad4ba69ed..a67fdae6d2a9af1535d53416af625742acbab0be 100644 (file)
@@ -9,17 +9,14 @@ package org.opendaylight.yangtools.yang.stmt;
 
 import static org.junit.Assert.assertNotNull;
 
-import java.util.Set;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.model.api.Module;
 
 public class Bug3859Test {
-
     @Test
     public void test() throws Exception {
-        Set<Module> modules = TestUtils.loadModules(getClass().getResource("/bugs/bug3859").toURI());
-        Module bug3859 = TestUtils.findModule(modules, "reference-in-unknown");
+        final Module bug3859 = TestUtils.findModule(
+            TestUtils.loadModules(getClass().getResource("/bugs/bug3859").toURI()), "reference-in-unknown").get();
         assertNotNull(bug3859);
     }
-
 }
index 27d98c6cb72ae5d8a2a5ec0f3c6624773b525284..94cf0b3f0c57ae38f56668ec7b47bb0304c06ba5 100644 (file)
@@ -12,12 +12,12 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import java.util.List;
-import java.util.Set;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
 import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 
 /**
@@ -27,11 +27,9 @@ public class Bug394Test {
 
     @Test
     public void testParseList() throws Exception {
-        final Set<Module> modules = TestUtils.loadModules(getClass().getResource("/bugs/bug394-retest").toURI());
-        final Module bug394 = TestUtils.findModule(modules, "bug394");
-        assertNotNull(bug394);
-        final Module bug394_ext = TestUtils.findModule(modules, "bug394-ext");
-        assertNotNull(bug394_ext);
+        final SchemaContext context = TestUtils.loadModules(getClass().getResource("/bugs/bug394-retest").toURI());
+        final Module bug394 = TestUtils.findModule(context, "bug394").get();
+        final Module bug394_ext = TestUtils.findModule(context, "bug394-ext").get();
 
         final ContainerSchemaNode logrecords = (ContainerSchemaNode) bug394.getDataChildByName(QName.create(
                 bug394.getQNameModule(), "logrecords"));
index 604084d73df6dba60e647a6c5d1d204e3f0a614f..292a6c753bfaa544fa381f3c5b69962087361b44 100644 (file)
@@ -11,26 +11,24 @@ package org.opendaylight.yangtools.yang.stmt;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
-import java.io.File;
-import java.io.FileNotFoundException;
+import java.io.IOException;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.repo.api.YinTextSchemaSource;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.util.NamedFileInputStream;
+import org.xml.sax.SAXException;
 
 public class Bug5693Test {
 
-    private final String pathToModuleFoo = getClass().getResource("/bugs/bug5693/foo.yin").getPath();
     private Module foo;
 
     /**
      * Use input stream to load Yin module.
      */
     @Before
-    public void initTest() throws FileNotFoundException, ReactorException {
-        foo = TestUtils.loadYinModule(new NamedFileInputStream(new File(pathToModuleFoo), pathToModuleFoo));
-        assertNotNull(foo);
+    public void initTest() throws ReactorException, SAXException, IOException {
+        foo = TestUtils.loadYinModule(YinTextSchemaSource.forResource(getClass(), "/bugs/bug5693/foo.yin"));
     }
 
     /**
index f8b01a921ed1aa2d804d878af1f0c5a6a634122d..8b6b1c499b1e9f1d04fb3a042d8ea69067d25b6a 100644 (file)
@@ -18,7 +18,6 @@ import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.text.ParseException;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
 import java.util.Set;
@@ -34,7 +33,9 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YangStatementStreamSource;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.EffectiveSchemaContext;
@@ -43,17 +44,19 @@ import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline
 public class EffectiveSchemaContextTest {
 
     @Test
-    public void testEffectiveSchemaContext() throws ReactorException, ParseException, URISyntaxException, IOException {
+    public void testEffectiveSchemaContext() throws ReactorException, ParseException, URISyntaxException, IOException,
+            YangSyntaxErrorException {
         final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
 
-        final YangTextSchemaSource source1 = YangTextSchemaSource.forResource(
-            "/effective-schema-context-test/foo.yang");
-        final YangTextSchemaSource source2 = YangTextSchemaSource.forResource(
-            "/effective-schema-context-test/bar.yang");
-        final YangTextSchemaSource source3 = YangTextSchemaSource.forResource(
-            "/effective-schema-context-test/baz.yang");
+        final YangStatementStreamSource source1 = YangStatementStreamSource.create(YangTextSchemaSource.forResource(
+            "/effective-schema-context-test/foo.yang"));
+        final YangStatementStreamSource source2 = YangStatementStreamSource.create(YangTextSchemaSource.forResource(
+            "/effective-schema-context-test/bar.yang"));
+        final YangStatementStreamSource source3 = YangStatementStreamSource.create(YangTextSchemaSource.forResource(
+            "/effective-schema-context-test/baz.yang"));
 
-        final SchemaContext schemaContext = reactor.buildEffective(Arrays.asList(source1, source2, source3));
+        reactor.addSources(source1, source2, source3);
+        final SchemaContext schemaContext = reactor.buildEffective();
         assertNotNull(schemaContext);
 
         final Set<DataSchemaNode> dataDefinitions = schemaContext.getDataDefinitions();
index 66000237f7d658cb82b41e8fb6c14e1e3079828b..2e7ca27eb13c2c72f56ae76232e25d0870892052 100644 (file)
@@ -13,18 +13,17 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
+import java.io.IOException;
 import java.net.URI;
 import java.text.ParseException;
 import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
@@ -36,26 +35,32 @@ import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.MustDefinition;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.UsesNode;
+import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
 import org.opendaylight.yangtools.yang.model.util.SchemaNodeUtils;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
 public class GroupingTest {
-    private Set<Module> modules;
+    private SchemaContext ctx;
+    private Module foo;
+    private Module baz;
 
     @Before
     public void init() throws Exception {
-        modules = TestUtils.loadModules(getClass().getResource("/model").toURI());
-        assertEquals(3, modules.size());
+        ctx = TestUtils.loadModules(getClass().getResource("/model").toURI());
+        foo = TestUtils.findModule(ctx, "foo").get();
+        baz = TestUtils.findModule(ctx, "baz").get();
+        assertEquals(3, ctx.getModules().size());
     }
 
     @Test
     public void testRefine() {
-        final Module testModule = TestUtils.findModule(modules, "foo");
+        final Module testModule = TestUtils.findModule(ctx, "foo").get();
         final ContainerSchemaNode peer = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(
                 testModule.getQNameModule(), "peer"));
         final ContainerSchemaNode destination = (ContainerSchemaNode) peer.getDataChildByName(QName.create(
@@ -125,7 +130,7 @@ public class GroupingTest {
 
     @Test
     public void testGrouping() {
-        final Module testModule = TestUtils.findModule(modules, "baz");
+        final Module testModule = TestUtils.findModule(ctx, "baz").get();
         final Set<GroupingDefinition> groupings = testModule.getGroupings();
         assertEquals(1, groupings.size());
         final GroupingDefinition grouping = groupings.iterator().next();
@@ -138,15 +143,12 @@ public class GroupingTest {
         // suffix _u = added by uses
         // suffix _g = defined in grouping
 
-        final Module baz = TestUtils.findModule(modules, "baz");
 
         // get grouping
         final Set<GroupingDefinition> groupings = baz.getGroupings();
         assertEquals(1, groupings.size());
         final GroupingDefinition grouping = groupings.iterator().next();
 
-        final Module foo = TestUtils.findModule(modules, "foo");
-
         // get node containing uses
         final ContainerSchemaNode peer = (ContainerSchemaNode) foo.getDataChildByName(QName.create(
                 foo.getQNameModule(), "peer"));
@@ -260,16 +262,11 @@ public class GroupingTest {
         // suffix _u = added by uses
         // suffix _g = defined in grouping
 
-        final Module testModule = TestUtils.findModule(modules, "baz");
-
         // get grouping
-        final Set<GroupingDefinition> groupings = testModule.getGroupings();
+        final Set<GroupingDefinition> groupings = baz.getGroupings();
         assertEquals(1, groupings.size());
         final GroupingDefinition grouping = groupings.iterator().next();
 
-        // get node containing uses
-        final Module foo = TestUtils.findModule(modules, "foo");
-
         // check uses
         final Set<UsesNode> uses = foo.getUses();
         assertEquals(1, uses.size());
@@ -281,7 +278,7 @@ public class GroupingTest {
         assertTrue(data_u.isAddedByUses());
 
         final AnyXmlSchemaNode data_g = (AnyXmlSchemaNode) grouping.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "data"));
+            baz.getQNameModule(), "data"));
         assertNotNull(data_g);
         assertFalse(data_g.isAddedByUses());
         assertFalse(data_u.equals(data_g));
@@ -304,7 +301,7 @@ public class GroupingTest {
         assertFalse(intervalLeaf.isAugmenting());
 
         final ChoiceSchemaNode how_g = (ChoiceSchemaNode) grouping.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "how"));
+                baz.getQNameModule(), "how"));
         assertNotNull(how_g);
         TestUtils.checkIsAddedByUses(how_g, false);
         assertFalse(how_u.equals(how_g));
@@ -320,7 +317,7 @@ public class GroupingTest {
         assertTrue(address_u.isAddedByUses());
 
         final LeafSchemaNode address_g = (LeafSchemaNode) grouping.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "address"));
+                baz.getQNameModule(), "address"));
         assertNotNull(address_g);
         assertFalse(address_g.isAddedByUses());
         assertNull(address_g.getDefault());
@@ -336,7 +333,7 @@ public class GroupingTest {
         TestUtils.checkIsAddedByUses(port_u, true);
 
         final ContainerSchemaNode port_g = (ContainerSchemaNode) grouping.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "port"));
+                baz.getQNameModule(), "port"));
         assertNotNull(port_g);
         TestUtils.checkIsAddedByUses(port_g, false);
         assertFalse(port_u.equals(port_g));
@@ -348,7 +345,7 @@ public class GroupingTest {
         TestUtils.checkIsAddedByUses(addresses_u, true);
 
         final ListSchemaNode addresses_g = (ListSchemaNode) grouping.getDataChildByName(QName.create(
-                testModule.getQNameModule(), "addresses"));
+                baz.getQNameModule(), "addresses"));
         assertNotNull(addresses_g);
         TestUtils.checkIsAddedByUses(addresses_g, false);
         assertFalse(addresses_u.equals(addresses_g));
@@ -391,12 +388,11 @@ public class GroupingTest {
     }
 
     @Test
-    public void testCascadeUses() throws ReactorException, ParseException {
-        modules = TestUtils.loadModules(Collections.singletonList(getClass().getResourceAsStream(
-                "/grouping-test/cascade-uses.yang")));
-        assertEquals(1, modules.size());
+    public void testCascadeUses() throws ReactorException, ParseException, IOException, YangSyntaxErrorException {
+        ctx = TestUtils.loadModuleResources(getClass(), "/grouping-test/cascade-uses.yang");
+        assertEquals(1, ctx.getModules().size());
 
-        final Module testModule = TestUtils.findModule(modules, "cascade-uses");
+        final Module testModule = TestUtils.findModule(ctx, "cascade-uses").get();
         final Set<GroupingDefinition> groupings = testModule.getGroupings();
 
         GroupingDefinition gu = null;
@@ -435,9 +431,8 @@ public class GroupingTest {
         assertNotNull(gz);
         assertNotNull(gzz);
 
-        final URI expectedNS = URI.create("urn:grouping:cascade-uses");
-        final Date expectedRev = SimpleDateFormatUtil.getRevisionFormat().parse("2013-07-18");
-        final String expectedPref = "cu";
+        final QNameModule expectedModule = QNameModule.create(
+            URI.create("urn:grouping:cascade-uses"), QName.parseRevision("2013-07-18"));
         SchemaPath expectedPath;
 
         // grouping-U
@@ -451,7 +446,7 @@ public class GroupingTest {
         assertFalse(SchemaNodeUtils.getOriginalIfPossible(leafGroupingU).isPresent());
 
         for (final DataSchemaNode childNode : childNodes) {
-            if (!(childNode.getQName().equals(leafGroupingU.getQName()))) {
+            if (!childNode.getQName().equals(leafGroupingU.getQName())) {
                 TestUtils.checkIsAddedByUses(childNode, true);
             }
         }
@@ -476,8 +471,7 @@ public class GroupingTest {
         // grouping-V/container-grouping-V
         assertNotNull(containerGroupingV);
         assertFalse(containerGroupingV.isAddedByUses());
-        expectedPath = TestUtils.createPath(true, expectedNS, expectedRev, expectedPref, "grouping-V",
-                "container-grouping-V");
+        expectedPath = TestUtils.createPath(true, expectedModule, "grouping-V", "container-grouping-V");
         assertEquals(expectedPath, containerGroupingV.getPath());
         childNodes = containerGroupingV.getChildNodes();
         assertEquals(2, childNodes.size());
@@ -489,15 +483,15 @@ public class GroupingTest {
         final LeafSchemaNode leafXinContainerV = (LeafSchemaNode) containerGroupingV.getDataChildByName(QName.create(
                 testModule.getQNameModule(), "leaf-grouping-X"));
         assertNotNull(leafXinContainerV);
-        expectedPath = TestUtils.createPath(true, expectedNS, expectedRev, expectedPref, "grouping-V",
-                "container-grouping-V", "leaf-grouping-X");
+        expectedPath = TestUtils.createPath(true, expectedModule, "grouping-V", "container-grouping-V",
+            "leaf-grouping-X");
         assertEquals(expectedPath, leafXinContainerV.getPath());
         // grouping-V/container-grouping-V/leaf-grouping-Y
         final LeafSchemaNode leafYinContainerV = (LeafSchemaNode) containerGroupingV.getDataChildByName(QName.create(
                 testModule.getQNameModule(), "leaf-grouping-Y"));
         assertNotNull(leafYinContainerV);
-        expectedPath = TestUtils.createPath(true, expectedNS, expectedRev, expectedPref, "grouping-V",
-                "container-grouping-V", "leaf-grouping-Y");
+        expectedPath = TestUtils.createPath(true, expectedModule, "grouping-V", "container-grouping-V",
+            "leaf-grouping-Y");
         assertEquals(expectedPath, leafYinContainerV.getPath());
 
         // grouping-X
@@ -509,8 +503,7 @@ public class GroupingTest {
                 testModule.getQNameModule(), "leaf-grouping-X"));
         assertNotNull(leafXinGX);
         assertFalse(leafXinGX.isAddedByUses());
-        expectedPath = TestUtils.createPath(true, expectedNS, expectedRev, expectedPref, "grouping-X",
-                "leaf-grouping-X");
+        expectedPath = TestUtils.createPath(true, expectedModule, "grouping-X", "leaf-grouping-X");
         assertEquals(expectedPath, leafXinGX.getPath());
 
         // grouping-X/leaf-grouping-Y
@@ -518,8 +511,7 @@ public class GroupingTest {
                 testModule.getQNameModule(), "leaf-grouping-Y"));
         assertNotNull(leafYinGX);
         assertTrue(leafYinGX.isAddedByUses());
-        expectedPath = TestUtils.createPath(true, expectedNS, expectedRev, expectedPref, "grouping-X",
-                "leaf-grouping-Y");
+        expectedPath = TestUtils.createPath(true, expectedModule, "grouping-X", "leaf-grouping-Y");
         assertEquals(expectedPath, leafYinGX.getPath());
 
         // grouping-Y
@@ -531,8 +523,7 @@ public class GroupingTest {
                 testModule.getQNameModule(), "leaf-grouping-Y"));
         assertNotNull(leafYinGY);
         assertFalse(leafYinGY.isAddedByUses());
-        expectedPath = TestUtils.createPath(true, expectedNS, expectedRev, expectedPref, "grouping-Y",
-                "leaf-grouping-Y");
+        expectedPath = TestUtils.createPath(true, expectedModule, "grouping-Y", "leaf-grouping-Y");
         assertEquals(expectedPath, leafYinGY.getPath());
 
         // grouping-Z
@@ -544,8 +535,7 @@ public class GroupingTest {
                 testModule.getQNameModule(), "leaf-grouping-Z"));
         assertNotNull(leafZinGZ);
         assertFalse(leafZinGZ.isAddedByUses());
-        expectedPath = TestUtils.createPath(true, expectedNS, expectedRev, expectedPref, "grouping-Z",
-                "leaf-grouping-Z");
+        expectedPath = TestUtils.createPath(true, expectedModule, "grouping-Z", "leaf-grouping-Z");
         assertEquals(expectedPath, leafZinGZ.getPath());
 
         // grouping-ZZ
@@ -557,8 +547,7 @@ public class GroupingTest {
                 testModule.getQNameModule(), "leaf-grouping-ZZ"));
         assertNotNull(leafZZinGZZ);
         assertFalse(leafZZinGZZ.isAddedByUses());
-        expectedPath = TestUtils.createPath(true, expectedNS, expectedRev, expectedPref, "grouping-ZZ",
-                "leaf-grouping-ZZ");
+        expectedPath = TestUtils.createPath(true, expectedModule, "grouping-ZZ", "leaf-grouping-ZZ");
         assertEquals(expectedPath, leafZZinGZZ.getPath());
 
         // TEST getOriginal from grouping-U
@@ -607,25 +596,11 @@ public class GroupingTest {
 
     @Test
     public void testAddedByUsesLeafTypeQName() throws Exception {
-
-        final Set<Module> loadModules = TestUtils.loadModules(getClass().getResource("/added-by-uses-leaf-test")
+        final SchemaContext loadModules = TestUtils.loadModules(getClass().getResource("/added-by-uses-leaf-test")
                 .toURI());
-
-        assertEquals(2, loadModules.size());
-
-        Module foo = null;
-        Module imp = null;
-        for (final Module module : loadModules) {
-            if (module.getName().equals("foo")) {
-                foo = module;
-            }
-            if (module.getName().equals("import-module")) {
-                imp = module;
-            }
-        }
-
-        assertNotNull(foo);
-        assertNotNull(imp);
+        assertEquals(2, loadModules.getModules().size());
+        foo = TestUtils.findModule(loadModules, "foo").get();
+        final Module imp = TestUtils.findModule(loadModules, "import-module").get();
 
         final LeafSchemaNode leaf = (LeafSchemaNode) ((ContainerSchemaNode) foo.getDataChildByName(QName.create(
                 foo.getQNameModule(), "my-container")))
index bd44ddb54505f8e7868f72107b151f00988a09f2..612f6306bc94b38e030a180741bfb97657240257 100644 (file)
@@ -11,8 +11,11 @@ import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
+import java.io.IOException;
+import java.net.URISyntaxException;
 import java.util.Collection;
 import java.util.Set;
+import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
@@ -20,14 +23,28 @@ import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
 import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
+import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
 public class OrderingTest {
 
+    private SchemaContext context;
+    private Module foo;
+    private Module bar;
+    private Module baz;
+
+    @Before
+    public void setup() throws ReactorException, IOException, YangSyntaxErrorException, URISyntaxException {
+        context = TestUtils.loadModules(getClass().getResource("/model").toURI());
+        foo = TestUtils.findModule(context, "foo").get();
+        bar = TestUtils.findModule(context, "bar").get();
+        baz = TestUtils.findModule(context, "baz").get();
+    }
+
     @Test
     public void testOrderingTypedef() throws Exception {
-        final Set<Module> modules = TestUtils.loadModules(getClass().getResource("/model").toURI());
-        final Module bar = TestUtils.findModule(modules, "bar");
         final Set<TypeDefinition<?>> typedefs = bar.getTypeDefinitions();
         final String[] expectedOrder = new String[] { "int32-ext1", "int32-ext2",
                 "string-ext1", "string-ext2", "string-ext3", "string-ext4",
@@ -45,8 +62,6 @@ public class OrderingTest {
 
     @Test
     public void testOrderingChildNodes() throws Exception {
-        final Set<Module> modules = TestUtils.loadModules(getClass().getResource("/model").toURI());
-        final Module foo = TestUtils.findModule(modules, "foo");
         AugmentationSchema augment1 = null;
         for (final AugmentationSchema as : foo.getAugmentations()) {
             if (as.getChildNodes().size() == 5) {
@@ -71,9 +86,6 @@ public class OrderingTest {
 
     @Test
     public void testOrderingNestedChildNodes1() throws Exception {
-        final Set<Module> modules = TestUtils.loadModules(getClass().getResource("/model").toURI());
-        final Module foo = TestUtils.findModule(modules, "foo");
-
         final Collection<DataSchemaNode> childNodes = foo.getChildNodes();
         final String[] expectedOrder = new String[] { "int32-leaf", "string-leaf",
                 "invalid-pattern-string-leaf",
@@ -96,8 +108,6 @@ public class OrderingTest {
 
     @Test
     public void testOrderingNestedChildNodes2() throws Exception {
-        final Set<Module> modules = TestUtils.loadModules(getClass().getResource("/model").toURI());
-        final Module baz = TestUtils.findModule(modules, "baz");
         final Set<GroupingDefinition> groupings = baz.getGroupings();
         assertEquals(1, groupings.size());
         final GroupingDefinition target = groupings.iterator().next();
@@ -117,8 +127,8 @@ public class OrderingTest {
 
     @Test
     public void testOrderingNestedChildNodes3() throws Exception {
-        final Module baz = TestUtils.loadModule(getClass().getResourceAsStream(
-                "/ordering/foo.yang"));
+        final Module baz = TestUtils.loadModuleResources(getClass(), "/ordering/foo.yang")
+                .getModules().iterator().next();
         final ContainerSchemaNode x = (ContainerSchemaNode) baz
                 .getDataChildByName(QName.create(baz.getQNameModule(), "x"));
         final Collection<DataSchemaNode> childNodes = x.getChildNodes();
@@ -134,5 +144,4 @@ public class OrderingTest {
         }
         assertArrayEquals(expectedOrder, actualOrder);
     }
-
 }
index fe86a265d9bbb57bbbb5d742fc09cbb5cae2f5ea..61f2615f5b7bf570b5ec5c6fc82e8ce686954c23 100644 (file)
@@ -8,9 +8,9 @@
 
 package org.opendaylight.yangtools.yang.stmt;
 
+import com.google.common.io.Files;
 import java.io.File;
 import java.io.FileFilter;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.net.URISyntaxException;
 import java.net.URL;
@@ -27,18 +27,21 @@ import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
+import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.repo.api.YinTextSchemaSource;
 import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YangStatementStreamSource;
+import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YinStatementStreamSource;
+import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YinTextToDomTransformer;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YinStatementSourceImpl;
-import org.opendaylight.yangtools.yang.parser.util.NamedFileInputStream;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.xml.sax.SAXException;
 
 public class StmtTestUtils {
 
@@ -191,28 +194,22 @@ public class StmtTestUtils {
     }
 
     public static SchemaContext parseYinSources(final String yinSourcesDirectoryPath, final StatementParserMode statementParserMode)
-            throws SourceException, ReactorException, FileNotFoundException, URISyntaxException {
-
+            throws URISyntaxException, SAXException, IOException, ReactorException {
         final URL resourceDir = StmtTestUtils.class.getResource(yinSourcesDirectoryPath);
-        final File testSourcesDir = new File(resourceDir.toURI());
-
-        return parseYinSources(statementParserMode, testSourcesDir.listFiles(YIN_FILE_FILTER));
-    }
-
-    public static SchemaContext parseYinSources(final StatementParserMode statementParserMode, final File... files)
-            throws SourceException, ReactorException, FileNotFoundException {
-
+        final File[] files = new File(resourceDir.toURI()).listFiles(YIN_FILE_FILTER);
         final StatementStreamSource[] sources = new StatementStreamSource[files.length];
-
         for (int i = 0; i < files.length; i++) {
-            sources[i] = new YinStatementSourceImpl(new NamedFileInputStream(files[i], files[i].getPath()));
+            final SourceIdentifier identifier = YinTextSchemaSource.identifierFromFilename(files[i].getName());
+
+            sources[i] = YinStatementStreamSource.create(YinTextToDomTransformer.transformSource(
+                YinTextSchemaSource.delegateForByteSource(identifier, Files.asByteSource(files[i]))));
         }
 
         return parseYinSources(statementParserMode, sources);
     }
 
     public static SchemaContext parseYinSources(final StatementParserMode statementParserMode, final StatementStreamSource... sources)
-            throws SourceException, ReactorException {
+            throws ReactorException {
 
         final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(statementParserMode);
         reactor.addSources(sources);
index 9beb2b9e29642884f0d767cedcc50f09a07939d3..29ee3350587d94f91f262aa93747812ff9f75aec 100644 (file)
@@ -46,9 +46,7 @@ public class SubstatementValidatorTest {
 
     @Test
     public void noException() throws Exception {
-        final Set<Module> modules = TestUtils.loadModules(getClass().getResource("/augment-test/augment-in-augment")
-                .toURI());
-        assertNotNull(modules);
+        assertNotNull(TestUtils.loadModules(getClass().getResource("/augment-test/augment-in-augment").toURI()));
     }
 
     @Test
@@ -83,7 +81,7 @@ public class SubstatementValidatorTest {
     @Test
     public void bug6173Test() throws Exception {
         final Set<Module> loadModules = TestUtils.loadModules(getClass().getResource(
-                "/substatement-validator/empty-element").toURI());
+                "/substatement-validator/empty-element").toURI()).getModules();
         assertEquals(1, loadModules.size());
     }
 
index 45be98ed549430d1bdd8f495d7b5562b821ff557..0333dc25795c5f96bbf8a61dfd2e085f07a59719 100644 (file)
@@ -11,7 +11,6 @@ import static org.junit.Assert.assertEquals;
 
 import java.io.File;
 import java.io.IOException;
-import java.io.InputStream;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
@@ -21,8 +20,10 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
 import java.util.List;
+import java.util.Optional;
 import java.util.Set;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
 import org.opendaylight.yangtools.yang.common.YangConstants;
 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
@@ -37,16 +38,19 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.repo.api.YinTextSchemaSource;
 import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YangStatementStreamSource;
+import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YinStatementStreamSource;
+import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YinTextToDomTransformer;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor.BuildAction;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YinStatementSourceImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.xml.sax.SAXException;
 
 public final class TestUtils {
     private static final Logger LOG = LoggerFactory.getLogger(TestUtils.class);
@@ -54,8 +58,8 @@ public final class TestUtils {
     private TestUtils() {
     }
 
-    public static Set<Module> loadModules(final URI resourceDirectory)
-            throws SourceException, ReactorException, IOException, YangSyntaxErrorException {
+    public static SchemaContext loadModules(final URI resourceDirectory)
+            throws ReactorException, IOException, YangSyntaxErrorException {
         final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
                 .newBuild();
         File[] files = new File(resourceDirectory).listFiles();
@@ -68,73 +72,44 @@ public final class TestUtils {
             }
         }
 
-        SchemaContext ctx = reactor.buildEffective();
-        return ctx.getModules();
+        return reactor.buildEffective();
     }
 
-    public static Set<Module> loadModules(final List<InputStream> streams)
-        throws SourceException, ReactorException {
-        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
-            .newBuild();
-        for (InputStream inputStream : streams) {
-            reactor.addSource(new YangStatementSourceImpl(inputStream));
+    public static SchemaContext loadModuleResources(final Class<?> refClass, final String... resourceNames)
+            throws IOException, ReactorException, YangSyntaxErrorException {
+        final BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+
+        for (String resourceName : resourceNames) {
+            reactor.addSource(YangStatementStreamSource.create(YangTextSchemaSource.forResource(refClass, resourceName)));
         }
 
-        SchemaContext ctx = reactor.buildEffective();
-        return ctx.getModules();
+        return reactor.buildEffective();
     }
 
-    public static Set<Module> loadYinModules(final URI resourceDirectory) throws ReactorException {
-        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+    public static SchemaContext loadYinModules(final URI resourceDirectory) throws ReactorException, SAXException,
+            IOException {
+        final BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
 
         for (File file : new File(resourceDirectory).listFiles()) {
-            reactor.addSource(new YinStatementSourceImpl(file.getPath(), true));
-        }
-
-        SchemaContext ctx = reactor.buildEffective();
-        return ctx.getModules();
-    }
-
-    public static Set<Module> loadYinModules(final List<InputStream> streams) throws SourceException, ReactorException {
-        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        for (InputStream inputStream : streams) {
-            reactor.addSource(new YinStatementSourceImpl(inputStream));
+            reactor.addSource(YinStatementStreamSource.create(YinTextToDomTransformer.transformSource(
+                YinTextSchemaSource.forFile(file))));
         }
 
-        SchemaContext ctx = reactor.buildEffective();
-        return ctx.getModules();
-    }
-
-    public static Module loadModule(final InputStream stream)
-        throws SourceException, ReactorException {
-        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
-            .newBuild();
-        reactor.addSource(new YangStatementSourceImpl(stream));
-        SchemaContext ctx = reactor.buildEffective();
-        return ctx.getModules().iterator().next();
+        return reactor.buildEffective();
     }
 
-    public static Module loadYinModule(final InputStream stream) throws SourceException, ReactorException {
+    public static Module loadYinModule(final YinTextSchemaSource source) throws ReactorException, SAXException, IOException {
         final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        reactor.addSources(new YinStatementSourceImpl(stream));
+        reactor.addSources(YinStatementStreamSource.create(YinTextToDomTransformer.transformSource(source)));
         SchemaContext ctx = reactor.buildEffective();
         return ctx.getModules().iterator().next();
     }
 
-    public static Module findModule(final Set<Module> modules,
-        final String moduleName) {
-        Module result = null;
-        for (Module module : modules) {
-            if (module.getName().equals(moduleName)) {
-                result = module;
-                break;
-            }
-        }
-        return result;
+    public static Optional<Module> findModule(final SchemaContext context, final String moduleName) {
+        return context.getModules().stream().filter(module -> moduleName.equals(module.getName())).findAny();
     }
 
-    public static ModuleImport findImport(final Set<ModuleImport> imports,
-            final String prefix) {
+    public static ModuleImport findImport(final Set<ModuleImport> imports, final String prefix) {
         ModuleImport result = null;
         for (ModuleImport moduleImport : imports) {
             if (moduleImport.getPrefix().equals(prefix)) {
@@ -145,8 +120,7 @@ public final class TestUtils {
         return result;
     }
 
-    public static TypeDefinition<?> findTypedef(
-            final Set<TypeDefinition<?>> typedefs, final String name) {
+    public static TypeDefinition<?> findTypedef(final Set<TypeDefinition<?>> typedefs, final String name) {
         TypeDefinition<?> result = null;
         for (TypeDefinition<?> td : typedefs) {
             if (td.getQName().getLocalName().equals(name)) {
@@ -157,12 +131,10 @@ public final class TestUtils {
         return result;
     }
 
-    public static SchemaPath createPath(final boolean absolute,
-            final URI namespace, final Date revision, final String prefix,
-            final String... names) {
-        List<QName> path = new ArrayList<>();
+    public static SchemaPath createPath(final boolean absolute, final QNameModule module, final String... names) {
+        List<QName> path = new ArrayList<>(names.length);
         for (String name : names) {
-            path.add(QName.create(namespace, revision, name));
+            path.add(QName.create(module, name));
         }
         return SchemaPath.create(path, absolute);
     }
@@ -187,8 +159,7 @@ public final class TestUtils {
      * @param expected
      *            expected value
      */
-    public static void checkIsAugmenting(final DataSchemaNode node,
-            final boolean expected) {
+    public static void checkIsAugmenting(final DataSchemaNode node, final boolean expected) {
         assertEquals(expected, node.isAugmenting());
         if (node instanceof DataNodeContainer) {
             for (DataSchemaNode child : ((DataNodeContainer) node)
@@ -211,8 +182,7 @@ public final class TestUtils {
      * @param expected
      *            expected value
      */
-    public static void checkIsAddedByUses(final DataSchemaNode node,
-            final boolean expected) {
+    public static void checkIsAddedByUses(final DataSchemaNode node, final boolean expected) {
         assertEquals(expected, node.isAddedByUses());
         if (node instanceof DataNodeContainer) {
             for (DataSchemaNode child : ((DataNodeContainer) node)
@@ -226,8 +196,7 @@ public final class TestUtils {
         }
     }
 
-    public static void checkIsAddedByUses(final GroupingDefinition node,
-            final boolean expected) {
+    public static void checkIsAddedByUses(final GroupingDefinition node, final boolean expected) {
         assertEquals(expected, node.isAddedByUses());
         for (DataSchemaNode child : node.getChildNodes()) {
             checkIsAddedByUses(child, expected);
@@ -274,8 +243,7 @@ public final class TestUtils {
     public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath)
             throws SourceException, ReactorException, URISyntaxException, IOException, YangSyntaxErrorException {
 
-        URL resourceDir = StmtTestUtils.class
-                .getResource(yangSourcesDirectoryPath);
+        URL resourceDir = StmtTestUtils.class.getResource(yangSourcesDirectoryPath);
         File testSourcesDir = new File(resourceDir.toURI());
 
         return parseYangSources(testSourcesDir.listFiles());
index edd46fe8489c8492a45a0c9ac49bed6cbf50f116..cd1e06801419f6314ca75bcf7057c2f775e65c5d 100644 (file)
@@ -17,7 +17,7 @@ public class TwoRevisionsTest {
 
     @Test
     public void testTwoRevisions() throws Exception {
-        Set<Module> modules = TestUtils.loadModules(getClass().getResource("/ietf").toURI());
+        Set<Module> modules = TestUtils.loadModules(getClass().getResource("/ietf").toURI()).getModules();
         //FIXME: following assert needs module revisions .equals() solution first
         assertEquals(2, TestUtils.findModules(modules, "network-topology").size());
     }
index 49dbba72b6c8d882cd47c46e7507b295aed8f052..24bc9a2ba5f22edd3b9e8f85b911041e5e617576 100644 (file)
@@ -45,7 +45,7 @@ import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementR
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
 
 public class TypesResolutionTest {
-    private Set<Module> testedModules;
+    private SchemaContext context;
 
     @Before
     public void init() throws Exception {
@@ -53,15 +53,13 @@ public class TypesResolutionTest {
         final StatementStreamSource yangFileDependency1 = sourceForResource("/ietf/iana-timezones@2012-07-09.yang");
         final StatementStreamSource yangFileDependency2 = sourceForResource("/ietf/ietf-inet-types@2010-09-24.yang");
         final StatementStreamSource yangFileDependency3 = sourceForResource("/ietf/ietf-yang-types@2010-09-24.yang");
-
-        testedModules = TestUtils.parseYangSources(yangFile, yangFileDependency1, yangFileDependency2,
-                yangFileDependency3).getModules();
-        assertEquals(4, testedModules.size());
+        context = TestUtils.parseYangSources(yangFile, yangFileDependency1, yangFileDependency2, yangFileDependency3);
+        assertEquals(4, context.getModules().size());
     }
 
     @Test
     public void testIPVersion() {
-        Module tested = TestUtils.findModule(testedModules, "ietf-inet-types");
+        Module tested = TestUtils.findModule(context, "ietf-inet-types").get();
         Set<TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
         assertEquals(14, typedefs.size());
 
@@ -91,7 +89,7 @@ public class TypesResolutionTest {
 
     @Test
     public void testEnumeration() {
-        Module tested = TestUtils.findModule(testedModules, "custom-types-test");
+        Module tested = TestUtils.findModule(context, "custom-types-test").get();
         Set<TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
 
         TypeDefinition<?> type = TestUtils.findTypedef(typedefs, "ip-version");
@@ -122,7 +120,7 @@ public class TypesResolutionTest {
 
     @Test
     public void testIpAddress() {
-        Module tested = TestUtils.findModule(testedModules, "ietf-inet-types");
+        Module tested = TestUtils.findModule(context, "ietf-inet-types").get();
         Set<TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
         TypeDefinition<?> type = TestUtils.findTypedef(typedefs, "ip-address");
         UnionTypeDefinition baseType = (UnionTypeDefinition) type.getBaseType();
@@ -149,7 +147,7 @@ public class TypesResolutionTest {
 
     @Test
     public void testDomainName() {
-        Module tested = TestUtils.findModule(testedModules, "ietf-inet-types");
+        Module tested = TestUtils.findModule(context, "ietf-inet-types").get();
         Set<TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
         StringTypeDefinition type = (StringTypeDefinition) TestUtils.findTypedef(typedefs, "domain-name");
         assertNotNull(type.getBaseType());
@@ -168,7 +166,7 @@ public class TypesResolutionTest {
 
     @Test
     public void testInstanceIdentifier1() {
-        Module tested = TestUtils.findModule(testedModules, "custom-types-test");
+        Module tested = TestUtils.findModule(context, "custom-types-test").get();
         LeafSchemaNode leaf = (LeafSchemaNode) tested.getDataChildByName(
                 QName.create(tested.getQNameModule(), "inst-id-leaf1"));
         InstanceIdentifierTypeDefinition leafType = (InstanceIdentifierTypeDefinition) leaf.getType();
@@ -178,7 +176,7 @@ public class TypesResolutionTest {
 
     @Test
     public void testInstanceIdentifier2() {
-        Module tested = TestUtils.findModule(testedModules, "custom-types-test");
+        Module tested = TestUtils.findModule(context, "custom-types-test").get();
         LeafSchemaNode leaf = (LeafSchemaNode) tested.getDataChildByName(
                 QName.create(tested.getQNameModule(), "inst-id-leaf2"));
         InstanceIdentifierTypeDefinition leafType = (InstanceIdentifierTypeDefinition) leaf.getType();
@@ -187,7 +185,7 @@ public class TypesResolutionTest {
 
     @Test
     public void testIdentity() {
-        Module tested = TestUtils.findModule(testedModules, "custom-types-test");
+        Module tested = TestUtils.findModule(context, "custom-types-test").get();
         Set<IdentitySchemaNode> identities = tested.getIdentities();
         assertEquals(5, identities.size());
         IdentitySchemaNode cryptoAlg = null;
@@ -218,7 +216,7 @@ public class TypesResolutionTest {
 
     @Test
     public void testBitsType1() {
-        Module tested = TestUtils.findModule(testedModules, "custom-types-test");
+        Module tested = TestUtils.findModule(context, "custom-types-test").get();
         LeafSchemaNode leaf = (LeafSchemaNode) tested.getDataChildByName(
                 QName.create(tested.getQNameModule(), "mybits"));
         BitsTypeDefinition leafType = (BitsTypeDefinition) leaf.getType();
@@ -240,7 +238,7 @@ public class TypesResolutionTest {
 
     @Test
     public void testBitsType2() {
-        Module tested = TestUtils.findModule(testedModules, "custom-types-test");
+        Module tested = TestUtils.findModule(context, "custom-types-test").get();
         Set<TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
         TypeDefinition<?> testedType = TestUtils.findTypedef(typedefs, "access-operations-type");
 
@@ -271,7 +269,7 @@ public class TypesResolutionTest {
 
     @Test
     public void testIanaTimezones() {
-        Module tested = TestUtils.findModule(testedModules, "iana-timezones");
+        Module tested = TestUtils.findModule(context, "iana-timezones").get();
         Set<TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
         TypeDefinition<?> testedType = TestUtils.findTypedef(typedefs, "iana-timezone");
 
@@ -302,7 +300,7 @@ public class TypesResolutionTest {
 
     @Test
     public void testObjectId128() {
-        Module tested = TestUtils.findModule(testedModules, "ietf-yang-types");
+        Module tested = TestUtils.findModule(context, "ietf-yang-types").get();
         Set<TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
         StringTypeDefinition testedType = (StringTypeDefinition) TestUtils.findTypedef(typedefs,
                 "object-identifier-128");
@@ -333,7 +331,7 @@ public class TypesResolutionTest {
 
     @Test
     public void testIdentityref() {
-        Module tested = TestUtils.findModule(testedModules, "custom-types-test");
+        Module tested = TestUtils.findModule(context, "custom-types-test").get();
         Set<TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
         TypeDefinition<?> testedType = TestUtils.findTypedef(typedefs, "service-type-ref");
         IdentityrefTypeDefinition baseType = (IdentityrefTypeDefinition) testedType.getBaseType();
index 4d2b1a2277972f5c8edf97744770cc9c218e1495..69da4c5cf44d57079904f45574fa0ef8a174faf5 100644 (file)
@@ -12,19 +12,17 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
-import java.io.FileNotFoundException;
+import java.io.IOException;
 import java.net.URI;
-import java.text.DateFormat;
-import java.text.ParseException;
+import java.net.URISyntaxException;
 import java.util.ArrayDeque;
 import java.util.Collection;
-import java.util.Date;
 import java.util.Deque;
 import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
@@ -32,25 +30,27 @@ import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
+import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
 import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
 public class UsesAugmentTest {
-    private static final URI UG_NS = URI.create("urn:opendaylight:params:xml:ns:yang:uses-grouping");
-    private static final URI GD_NS = URI.create("urn:opendaylight:params:xml:ns:yang:grouping-definitions");
-    private Date UG_REV;
-    private Date GD_REV;
 
-    private Set<Module> modules;
+    private static final QNameModule UG = QNameModule.create(
+        URI.create("urn:opendaylight:params:xml:ns:yang:uses-grouping"), QName.parseRevision("2013-07-30"));
+    private static final QNameModule GD = QNameModule.create(
+        URI.create("urn:opendaylight:params:xml:ns:yang:grouping-definitions"), QName.parseRevision("2013-09-04"));
+
+    private SchemaContext context;
 
     @Before
-    public void init() throws FileNotFoundException, ParseException {
-        final DateFormat simpleDateFormat = SimpleDateFormatUtil.getRevisionFormat();
-        UG_REV = simpleDateFormat.parse("2013-07-30");
-        GD_REV = simpleDateFormat.parse("2013-09-04");
+    public void init() throws ReactorException, IOException, YangSyntaxErrorException, URISyntaxException {
+        context = TestUtils.loadModules(getClass().getResource("/grouping-test").toURI());
     }
 
     /**
@@ -111,8 +111,7 @@ public class UsesAugmentTest {
      */
     @Test
     public void testAugmentInUses() throws Exception {
-        modules = TestUtils.loadModules(getClass().getResource("/grouping-test").toURI());
-        final Module testModule = TestUtils.findModule(modules, "uses-grouping");
+        final Module testModule = TestUtils.findModule(context, "uses-grouping").get();
 
         final Deque<QName> path = new ArrayDeque<>();
 
@@ -121,7 +120,7 @@ public class UsesAugmentTest {
         assertEquals(1, notifications.size());
         final NotificationDefinition pcreq = notifications.iterator().next();
         assertNotNull(pcreq);
-        QName expectedQName = QName.create(UG_NS, UG_REV, "pcreq");
+        QName expectedQName = QName.create(UG, "pcreq");
         path.offer(expectedQName);
         SchemaPath expectedPath = SchemaPath.create(path, true);
         assertEquals(expectedPath, pcreq.getPath());
@@ -131,11 +130,11 @@ public class UsesAugmentTest {
         LeafSchemaNode version = (LeafSchemaNode) pcreq.getDataChildByName(QName.create(testModule.getQNameModule(),
                 "version"));
         assertNotNull(version);
-        expectedQName = QName.create(UG_NS, UG_REV, "version");
+        expectedQName = QName.create(UG, "version");
         path.offer(expectedQName);
         expectedPath = SchemaPath.create(path, true);
         assertEquals(expectedPath, version.getPath());
-        expectedQName = QName.create(UG_NS, UG_REV, "version");
+        expectedQName = QName.create(UG, "version");
         path.offer(expectedQName);
         expectedPath = SchemaPath.create(true, pcreq.getQName(), expectedQName);
         assertEquals(expectedPath, version.getType().getPath());
@@ -145,14 +144,14 @@ public class UsesAugmentTest {
         LeafSchemaNode type = (LeafSchemaNode) pcreq.getDataChildByName(QName.create(testModule.getQNameModule(),
                 "type"));
         assertNotNull(type);
-        expectedQName = QName.create(UG_NS, UG_REV, "type");
+        expectedQName = QName.create(UG, "type");
         assertTrue(type.isAddedByUses());
         path.pollLast();
         path.pollLast();
         path.offer(expectedQName);
         expectedPath = SchemaPath.create(path, true);
         assertEquals(expectedPath, type.getPath());
-        expectedQName = QName.create(GD_NS, GD_REV, "int-ext");
+        expectedQName = QName.create(GD, "int-ext");
         path.offer(expectedQName);
         expectedPath = SchemaPath.create(true, expectedQName);
         assertEquals(expectedPath, type.getType().getPath());
@@ -163,7 +162,7 @@ public class UsesAugmentTest {
         final ListSchemaNode requests = (ListSchemaNode) pcreq.getDataChildByName(QName.create(
                 testModule.getQNameModule(), "requests"));
         assertNotNull(requests);
-        expectedQName = QName.create(UG_NS, UG_REV, "requests");
+        expectedQName = QName.create(UG, "requests");
         assertEquals(expectedQName, requests.getQName());
         path.pollLast();
         path.pollLast();
@@ -177,7 +176,7 @@ public class UsesAugmentTest {
         final ContainerSchemaNode rp = (ContainerSchemaNode) requests.getDataChildByName(QName.create(
                 testModule.getQNameModule(), "rp"));
         assertNotNull(rp);
-        expectedQName = QName.create(UG_NS, UG_REV, "rp");
+        expectedQName = QName.create(UG, "rp");
         path.offer(expectedQName);
         expectedPath = SchemaPath.create(path, true);
         assertEquals(expectedPath, rp.getPath());
@@ -188,7 +187,7 @@ public class UsesAugmentTest {
         LeafSchemaNode processingRule = (LeafSchemaNode) rp.getDataChildByName(QName.create(
                 testModule.getQNameModule(), "processing-rule"));
         assertNotNull(processingRule);
-        expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
+        expectedQName = QName.create(UG, "processing-rule");
         assertEquals(expectedQName, processingRule.getQName());
         path.offer(expectedQName);
         expectedPath = SchemaPath.create(path, true);
@@ -199,7 +198,7 @@ public class UsesAugmentTest {
         LeafSchemaNode ignore = (LeafSchemaNode) rp.getDataChildByName(QName.create(testModule.getQNameModule(),
                 "ignore"));
         assertNotNull(ignore);
-        expectedQName = QName.create(UG_NS, UG_REV, "ignore");
+        expectedQName = QName.create(UG, "ignore");
         assertEquals(expectedQName, ignore.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -211,13 +210,13 @@ public class UsesAugmentTest {
         final LeafSchemaNode priority = (LeafSchemaNode) rp.getDataChildByName(QName.create(
                 testModule.getQNameModule(), "priority"));
         assertNotNull(priority);
-        expectedQName = QName.create(UG_NS, UG_REV, "priority");
+        expectedQName = QName.create(UG, "priority");
         assertEquals(expectedQName, priority.getQName());
         path.pollLast();
         path.offer(expectedQName);
         expectedPath = SchemaPath.create(path, true);
         assertEquals(expectedPath, priority.getPath());
-        expectedQName = QName.create(UG_NS, UG_REV, "uint8");
+        expectedQName = QName.create(UG, "uint8");
         path.offer(expectedQName);
         expectedPath = SchemaPath.create(path, true);
         // TODO
@@ -228,7 +227,7 @@ public class UsesAugmentTest {
         ContainerSchemaNode box = (ContainerSchemaNode) rp.getDataChildByName(QName.create(testModule.getQNameModule(),
                 "box"));
         assertNotNull(box);
-        expectedQName = QName.create(UG_NS, UG_REV, "box");
+        expectedQName = QName.create(UG, "box");
         assertEquals(expectedQName, box.getQName());
         path.pollLast();
         path.pollLast();
@@ -240,7 +239,7 @@ public class UsesAugmentTest {
         final ContainerSchemaNode order = (ContainerSchemaNode) box.getDataChildByName(QName.create(
                 testModule.getQNameModule(), "order"));
         assertNotNull(order);
-        expectedQName = QName.create(UG_NS, UG_REV, "order");
+        expectedQName = QName.create(UG, "order");
         assertEquals(expectedQName, order.getQName());
         path.offer(expectedQName);
         expectedPath = SchemaPath.create(path, true);
@@ -252,7 +251,7 @@ public class UsesAugmentTest {
         final LeafSchemaNode delete = (LeafSchemaNode) order.getDataChildByName(QName.create(
                 testModule.getQNameModule(), "delete"));
         assertNotNull(delete);
-        expectedQName = QName.create(UG_NS, UG_REV, "delete");
+        expectedQName = QName.create(UG, "delete");
         assertEquals(expectedQName, delete.getQName());
         path.offer(expectedQName);
         expectedPath = SchemaPath.create(path, true);
@@ -263,7 +262,7 @@ public class UsesAugmentTest {
         final LeafSchemaNode setup = (LeafSchemaNode) order.getDataChildByName(QName.create(
                 testModule.getQNameModule(), "setup"));
         assertNotNull(setup);
-        expectedQName = QName.create(UG_NS, UG_REV, "setup");
+        expectedQName = QName.create(UG, "setup");
         assertEquals(expectedQName, setup.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -275,7 +274,7 @@ public class UsesAugmentTest {
         final ContainerSchemaNode pke = (ContainerSchemaNode) requests.getDataChildByName(QName.create(
                 testModule.getQNameModule(), "path-key-expansion"));
         assertNotNull(pke);
-        expectedQName = QName.create(UG_NS, UG_REV, "path-key-expansion");
+        expectedQName = QName.create(UG, "path-key-expansion");
         assertEquals(expectedQName, pke.getQName());
         path.pollLast();
         path.pollLast();
@@ -289,7 +288,7 @@ public class UsesAugmentTest {
         final ContainerSchemaNode pathKey = (ContainerSchemaNode) pke.getDataChildByName(QName.create(
                 testModule.getQNameModule(), "path-key"));
         assertNotNull(pathKey);
-        expectedQName = QName.create(UG_NS, UG_REV, "path-key");
+        expectedQName = QName.create(UG, "path-key");
         assertEquals(expectedQName, pathKey.getQName());
         path.offer(expectedQName);
         expectedPath = SchemaPath.create(path, true);
@@ -300,7 +299,7 @@ public class UsesAugmentTest {
         processingRule = (LeafSchemaNode) pathKey.getDataChildByName(QName.create(testModule.getQNameModule(),
                 "processing-rule"));
         assertNotNull(processingRule);
-        expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
+        expectedQName = QName.create(UG, "processing-rule");
         assertEquals(expectedQName, processingRule.getQName());
         path.offer(expectedQName);
         expectedPath = SchemaPath.create(path, true);
@@ -310,7 +309,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- |-- leaf ignore
         ignore = (LeafSchemaNode) pathKey.getDataChildByName(QName.create(testModule.getQNameModule(), "ignore"));
         assertNotNull(ignore);
-        expectedQName = QName.create(UG_NS, UG_REV, "ignore");
+        expectedQName = QName.create(UG, "ignore");
         assertEquals(expectedQName, ignore.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -322,7 +321,7 @@ public class UsesAugmentTest {
         final ListSchemaNode pathKeys = (ListSchemaNode) pathKey.getDataChildByName(QName.create(
                 testModule.getQNameModule(), "path-keys"));
         assertNotNull(pathKeys);
-        expectedQName = QName.create(UG_NS, UG_REV, "path-keys");
+        expectedQName = QName.create(UG, "path-keys");
         assertEquals(expectedQName, pathKeys.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -334,7 +333,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- |-- |-- leaf version
         version = (LeafSchemaNode) pathKeys.getDataChildByName(QName.create(testModule.getQNameModule(), "version"));
         assertNotNull(version);
-        expectedQName = QName.create(UG_NS, UG_REV, "version");
+        expectedQName = QName.create(UG, "version");
         assertEquals(expectedQName, version.getQName());
         path.offer(expectedQName);
         expectedPath = SchemaPath.create(path, true);
@@ -346,7 +345,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- |-- |-- leaf type
         type = (LeafSchemaNode) pathKeys.getDataChildByName(QName.create(testModule.getQNameModule(), "type"));
         assertNotNull(type);
-        expectedQName = QName.create(UG_NS, UG_REV, "type");
+        expectedQName = QName.create(UG, "type");
         assertEquals(expectedQName, type.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -359,7 +358,7 @@ public class UsesAugmentTest {
         final ContainerSchemaNode sc = (ContainerSchemaNode) requests.getDataChildByName(QName.create(
                 testModule.getQNameModule(), "segment-computation"));
         assertNotNull(sc);
-        expectedQName = QName.create(UG_NS, UG_REV, "segment-computation");
+        expectedQName = QName.create(UG, "segment-computation");
         assertEquals(expectedQName, sc.getQName());
         path.pollLast();
         path.pollLast();
@@ -373,7 +372,7 @@ public class UsesAugmentTest {
         final ContainerSchemaNode p2p = (ContainerSchemaNode) sc.getDataChildByName(QName.create(
                 testModule.getQNameModule(), "p2p"));
         assertNotNull(p2p);
-        expectedQName = QName.create(UG_NS, UG_REV, "p2p");
+        expectedQName = QName.create(UG, "p2p");
         assertEquals(expectedQName, p2p.getQName());
         path.offer(expectedQName);
         expectedPath = SchemaPath.create(path, true);
@@ -383,7 +382,7 @@ public class UsesAugmentTest {
         final ContainerSchemaNode endpoints = (ContainerSchemaNode) p2p.getDataChildByName(QName.create(
                 testModule.getQNameModule(), "endpoints"));
         assertNotNull(endpoints);
-        expectedQName = QName.create(UG_NS, UG_REV, "endpoints");
+        expectedQName = QName.create(UG, "endpoints");
         assertEquals(expectedQName, endpoints.getQName());
         path.offer(expectedQName);
         expectedPath = SchemaPath.create(path, true);
@@ -393,7 +392,7 @@ public class UsesAugmentTest {
         processingRule = (LeafSchemaNode) endpoints.getDataChildByName(QName.create(testModule.getQNameModule(),
                 "processing-rule"));
         assertNotNull(processingRule);
-        expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
+        expectedQName = QName.create(UG, "processing-rule");
         assertEquals(expectedQName, processingRule.getQName());
         path.offer(expectedQName);
         expectedPath = SchemaPath.create(path, true);
@@ -403,7 +402,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- |-- |-- leaf ignore
         ignore = (LeafSchemaNode) endpoints.getDataChildByName(QName.create(testModule.getQNameModule(), "ignore"));
         assertNotNull(ignore);
-        expectedQName = QName.create(UG_NS, UG_REV, "ignore");
+        expectedQName = QName.create(UG, "ignore");
         assertEquals(expectedQName, ignore.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -414,7 +413,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- |-- |-- container box
         box = (ContainerSchemaNode) endpoints.getDataChildByName(QName.create(testModule.getQNameModule(), "box"));
         assertNotNull(box);
-        expectedQName = QName.create(UG_NS, UG_REV, "box");
+        expectedQName = QName.create(UG, "box");
         assertEquals(expectedQName, box.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -425,7 +424,7 @@ public class UsesAugmentTest {
         final ChoiceSchemaNode af = (ChoiceSchemaNode) endpoints.getDataChildByName(QName.create(
                 testModule.getQNameModule(), "address-family"));
         assertNotNull(af);
-        expectedQName = QName.create(UG_NS, UG_REV, "address-family");
+        expectedQName = QName.create(UG, "address-family");
         assertEquals(expectedQName, af.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -436,7 +435,7 @@ public class UsesAugmentTest {
         final ContainerSchemaNode reportedRoute = (ContainerSchemaNode) p2p.getDataChildByName(QName.create(
                 testModule.getQNameModule(), "reported-route"));
         assertNotNull(reportedRoute);
-        expectedQName = QName.create(UG_NS, UG_REV, "reported-route");
+        expectedQName = QName.create(UG, "reported-route");
         assertEquals(expectedQName, reportedRoute.getQName());
         path.pollLast();
         path.pollLast();
@@ -448,7 +447,7 @@ public class UsesAugmentTest {
         processingRule = (LeafSchemaNode) reportedRoute.getDataChildByName(QName.create(testModule.getQNameModule(),
                 "processing-rule"));
         assertNotNull(processingRule);
-        expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
+        expectedQName = QName.create(UG, "processing-rule");
         assertEquals(expectedQName, processingRule.getQName());
         path.offer(expectedQName);
         expectedPath = SchemaPath.create(path, true);
@@ -458,7 +457,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- |-- |-- leaf ignore
         ignore = (LeafSchemaNode) reportedRoute.getDataChildByName(QName.create(testModule.getQNameModule(), "ignore"));
         assertNotNull(ignore);
-        expectedQName = QName.create(UG_NS, UG_REV, "ignore");
+        expectedQName = QName.create(UG, "ignore");
         assertEquals(expectedQName, ignore.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -470,7 +469,7 @@ public class UsesAugmentTest {
         final ListSchemaNode subobjects = (ListSchemaNode) reportedRoute.getDataChildByName(QName.create(
                 testModule.getQNameModule(), "subobjects"));
         assertNotNull(subobjects);
-        expectedQName = QName.create(UG_NS, UG_REV, "subobjects");
+        expectedQName = QName.create(UG, "subobjects");
         assertEquals(expectedQName, subobjects.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -481,7 +480,7 @@ public class UsesAugmentTest {
         ContainerSchemaNode bandwidth = (ContainerSchemaNode) reportedRoute.getDataChildByName(QName.create(
                 testModule.getQNameModule(), "bandwidth"));
         assertNotNull(bandwidth);
-        expectedQName = QName.create(UG_NS, UG_REV, "bandwidth");
+        expectedQName = QName.create(UG, "bandwidth");
         assertEquals(expectedQName, bandwidth.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -492,7 +491,7 @@ public class UsesAugmentTest {
         bandwidth = (ContainerSchemaNode) p2p
                 .getDataChildByName(QName.create(testModule.getQNameModule(), "bandwidth"));
         assertNotNull(bandwidth);
-        expectedQName = QName.create(UG_NS, UG_REV, "bandwidth");
+        expectedQName = QName.create(UG, "bandwidth");
         assertEquals(expectedQName, bandwidth.getQName());
         path.pollLast();
         path.pollLast();
@@ -504,7 +503,7 @@ public class UsesAugmentTest {
         processingRule = (LeafSchemaNode) bandwidth.getDataChildByName(QName.create(testModule.getQNameModule(),
                 "processing-rule"));
         assertNotNull(processingRule);
-        expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
+        expectedQName = QName.create(UG, "processing-rule");
         assertEquals(expectedQName, processingRule.getQName());
         path.offer(expectedQName);
         expectedPath = SchemaPath.create(path, true);
@@ -514,7 +513,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- |-- |-- leaf ignore
         ignore = (LeafSchemaNode) bandwidth.getDataChildByName(QName.create(testModule.getQNameModule(), "ignore"));
         assertNotNull(ignore);
-        expectedQName = QName.create(UG_NS, UG_REV, "ignore");
+        expectedQName = QName.create(UG, "ignore");
         assertEquals(expectedQName, ignore.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -526,7 +525,7 @@ public class UsesAugmentTest {
         final ContainerSchemaNode bandwidthInner = (ContainerSchemaNode) bandwidth.getDataChildByName(QName.create(
                 testModule.getQNameModule(), "bandwidth"));
         assertNotNull(bandwidthInner);
-        expectedQName = QName.create(UG_NS, UG_REV, "bandwidth");
+        expectedQName = QName.create(UG, "bandwidth");
         assertEquals(expectedQName, bandwidth.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -537,7 +536,7 @@ public class UsesAugmentTest {
         final ListSchemaNode svec = (ListSchemaNode) pcreq.getDataChildByName(QName.create(testModule.getQNameModule(),
                 "svec"));
         assertNotNull(svec);
-        expectedQName = QName.create(UG_NS, UG_REV, "svec");
+        expectedQName = QName.create(UG, "svec");
         assertEquals(expectedQName, svec.getQName());
         path.pollLast();
         path.pollLast();
@@ -552,7 +551,7 @@ public class UsesAugmentTest {
         final LeafSchemaNode linkDiverse = (LeafSchemaNode) svec.getDataChildByName(QName.create(
                 testModule.getQNameModule(), "link-diverse"));
         assertNotNull(linkDiverse);
-        expectedQName = QName.create(UG_NS, UG_REV, "link-diverse");
+        expectedQName = QName.create(UG, "link-diverse");
         assertEquals(expectedQName, linkDiverse.getQName());
         path.offer(expectedQName);
         expectedPath = SchemaPath.create(path, true);
@@ -563,7 +562,7 @@ public class UsesAugmentTest {
         processingRule = (LeafSchemaNode) svec.getDataChildByName(QName.create(testModule.getQNameModule(),
                 "processing-rule"));
         assertNotNull(processingRule);
-        expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
+        expectedQName = QName.create(UG, "processing-rule");
         assertEquals(expectedQName, processingRule.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -574,7 +573,7 @@ public class UsesAugmentTest {
         // * |-- |-- leaf ignore
         ignore = (LeafSchemaNode) svec.getDataChildByName(QName.create(testModule.getQNameModule(), "ignore"));
         assertNotNull(ignore);
-        expectedQName = QName.create(UG_NS, UG_REV, "ignore");
+        expectedQName = QName.create(UG, "ignore");
         assertEquals(expectedQName, ignore.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -586,7 +585,7 @@ public class UsesAugmentTest {
         final ListSchemaNode metric = (ListSchemaNode) svec.getDataChildByName(QName.create(
                 testModule.getQNameModule(), "metric"));
         assertNotNull(metric);
-        expectedQName = QName.create(UG_NS, UG_REV, "metric");
+        expectedQName = QName.create(UG, "metric");
         assertEquals(expectedQName, metric.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -597,7 +596,7 @@ public class UsesAugmentTest {
         final LeafSchemaNode metricType = (LeafSchemaNode) metric.getDataChildByName(QName.create(
                 testModule.getQNameModule(), "metric-type"));
         assertNotNull(metricType);
-        expectedQName = QName.create(UG_NS, UG_REV, "metric-type");
+        expectedQName = QName.create(UG, "metric-type");
         assertEquals(expectedQName, metricType.getQName());
         path.offer(expectedQName);
         expectedPath = SchemaPath.create(path, true);
@@ -607,7 +606,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- box
         box = (ContainerSchemaNode) metric.getDataChildByName(QName.create(testModule.getQNameModule(), "box"));
         assertNotNull(box);
-        expectedQName = QName.create(UG_NS, UG_REV, "box");
+        expectedQName = QName.create(UG, "box");
         assertEquals(expectedQName, box.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -618,7 +617,7 @@ public class UsesAugmentTest {
         processingRule = (LeafSchemaNode) metric.getDataChildByName(QName.create(testModule.getQNameModule(),
                 "processing-rule"));
         assertNotNull(processingRule);
-        expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
+        expectedQName = QName.create(UG, "processing-rule");
         assertEquals(expectedQName, processingRule.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -629,7 +628,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- leaf ignore
         ignore = (LeafSchemaNode) metric.getDataChildByName(QName.create(testModule.getQNameModule(), "ignore"));
         assertNotNull(ignore);
-        expectedQName = QName.create(UG_NS, UG_REV, "ignore");
+        expectedQName = QName.create(UG, "ignore");
         assertEquals(expectedQName, ignore.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -641,8 +640,7 @@ public class UsesAugmentTest {
 
     @Test
     public void testTypedefs() throws Exception {
-        modules = TestUtils.loadModules(getClass().getResource("/grouping-test").toURI());
-        final Module testModule = TestUtils.findModule(modules, "grouping-definitions");
+        final Module testModule = TestUtils.findModule(context, "grouping-definitions").get();
         final Set<TypeDefinition<?>> types = testModule.getTypeDefinitions();
 
         TypeDefinition<?> intExt = null;
@@ -653,7 +651,7 @@ public class UsesAugmentTest {
         }
         assertNotNull(intExt);
 
-        SchemaPath expectedPath = SchemaPath.create(true, QName.create(GD_NS, GD_REV, "int-ext"));
+        SchemaPath expectedPath = SchemaPath.create(true, QName.create(GD, "int-ext"));
         assertEquals(expectedPath, intExt.getPath());
 
         final UnionTypeDefinition union = (UnionTypeDefinition) intExt.getBaseType();
@@ -670,8 +668,7 @@ public class UsesAugmentTest {
         assertNotNull(uint8);
         assertNotNull(pv);
 
-        expectedPath = SchemaPath.create(true, QName.create(GD_NS, GD_REV, "int-ext"),
-                QName.create(GD_NS, GD_REV, "union"));
+        expectedPath = SchemaPath.create(true, QName.create(GD, "int-ext"), QName.create(GD, "union"));
         assertEquals(expectedPath, union.getPath());
     }
 
index a432b85a3bf0a5e35e073772ac56a8cb11551bc0..4b2d78add262eba05b9bb5b1bb59355fe2cfaeca 100644 (file)
@@ -11,27 +11,22 @@ package org.opendaylight.yangtools.yang.stmt;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotEquals;
 
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.net.URISyntaxException;
+import java.io.IOException;
 import java.util.Set;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
+import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
-import org.opendaylight.yangtools.yang.parser.util.NamedFileInputStream;
 
 public class YangParserIdentityTest {
 
     // base identity name equals identity name
     @Test(expected = SomeModifiersUnresolvedException.class)
-    public void testParsingIdentityTestModule() throws URISyntaxException, ReactorException, FileNotFoundException {
-        File yang = new File(getClass().getResource("/identity/identitytest.yang").toURI());
-        InputStream stream = new NamedFileInputStream(yang, yang.getPath());
+    public void testParsingIdentityTestModule() throws IOException, ReactorException, YangSyntaxErrorException {
         try {
-            TestUtils.loadModule(stream);
+            TestUtils.loadModuleResources(getClass(), "/identity/identitytest.yang");
         } catch (SomeModifiersUnresolvedException e) {
             StmtTestUtils.log(e, "      ");
             throw e;
@@ -40,12 +35,9 @@ public class YangParserIdentityTest {
 
     // same module prefixed base identity name equals identity name
     @Test(expected = SomeModifiersUnresolvedException.class)
-    public void testParsingPrefixIdentityTestModule() throws URISyntaxException,
-            ReactorException, FileNotFoundException {
-        File yang = new File(getClass().getResource("/identity/prefixidentitytest.yang").toURI());
-        InputStream stream = new NamedFileInputStream(yang, yang.getPath());
+    public void testParsingPrefixIdentityTestModule() throws IOException, ReactorException, YangSyntaxErrorException  {
         try {
-            TestUtils.loadModule(stream);
+            TestUtils.loadModuleResources(getClass(), "/identity/prefixidentitytest.yang");
         } catch (SomeModifiersUnresolvedException e) {
             StmtTestUtils.log(e, "      ");
             throw e;
@@ -56,8 +48,8 @@ public class YangParserIdentityTest {
     // prefix differs
     @Test
     public void testParsingImportPrefixIdentityTestModule() throws Exception {
-        Set<Module> modules = TestUtils.loadModules(getClass().getResource("/identity/import").toURI());
-        Module module = TestUtils.findModule(modules, "prefiximportidentitytest");
+        Module module = TestUtils.findModule(TestUtils.loadModules(getClass().getResource("/identity/import").toURI()),
+            "prefiximportidentitytest").get();
         Set<ModuleImport> imports = module.getImports();
         assertEquals(imports.size(), 1);
         ModuleImport dummy = TestUtils.findImport(imports, "dummy");
index 45c74ba6b8b036c1ca74d5cf83c35250d1efeaaf..dbc00013ddcf7e1349f843fd21faff35461ca9b7 100644 (file)
@@ -7,26 +7,21 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import com.google.common.base.Throwables;
 import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.InputStream;
+import java.io.IOException;
 import java.io.PrintStream;
 import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
-import org.opendaylight.yangtools.yang.parser.util.NamedFileInputStream;
 
 public class YangParserNegativeTest {
 
@@ -45,13 +40,10 @@ public class YangParserNegativeTest {
     }
 
     @Test
-    public void testInvalidImport() throws Exception {
-        final File yang = new File(getClass().getResource("/negative-scenario/testfile1.yang").toURI());
+    public void testInvalidImport() throws IOException, ReactorException, YangSyntaxErrorException {
         try {
-            try (InputStream stream = new NamedFileInputStream(yang, yang.getPath())) {
-                TestUtils.loadModule(stream);
-                fail("SomeModifiersUnresolvedException should be thrown");
-            }
+            TestUtils.loadModuleResources(getClass(), "/negative-scenario/testfile1.yang");
+            fail("SomeModifiersUnresolvedException should be thrown");
         } catch (final SomeModifiersUnresolvedException e) {
             final Throwable rootCause = Throwables.getRootCause(e);
             assertTrue(rootCause instanceof InferenceException);
@@ -61,13 +53,10 @@ public class YangParserNegativeTest {
     }
 
     @Test
-    public void testTypeNotFound() throws Exception {
-        final File yang = new File(getClass().getResource("/negative-scenario/testfile2.yang").toURI());
+    public void testTypeNotFound() throws IOException, ReactorException, YangSyntaxErrorException {
         try {
-            try (InputStream stream = new NamedFileInputStream(yang, yang.getPath())) {
-                TestUtils.loadModule(stream);
-                fail("InferenceException should be thrown");
-            }
+            TestUtils.loadModuleResources(getClass(), "/negative-scenario/testfile2.yang");
+            fail("InferenceException should be thrown");
         } catch (final SomeModifiersUnresolvedException e) {
             final Throwable rootCause = Throwables.getRootCause(e);
             assertTrue(rootCause instanceof InferenceException);
@@ -77,20 +66,12 @@ public class YangParserNegativeTest {
     }
 
     @Test
-    public void testInvalidAugmentTarget() throws Exception {
-        final File yang1 = new File(getClass().getResource("/negative-scenario/testfile0.yang").toURI());
-        final File yang2 = new File(getClass().getResource("/negative-scenario/testfile3.yang").toURI());
+    public void testInvalidAugmentTarget() throws IOException, ReactorException, YangSyntaxErrorException {
         try {
-            final List<InputStream> streams = new ArrayList<>(2);
-            try (InputStream testFile0 = new NamedFileInputStream(yang1, yang1.getPath())) {
-                streams.add(testFile0);
-                try (InputStream testFile3 = new NamedFileInputStream(yang2, yang2.getPath())) {
-                    streams.add(testFile3);
-                    assertEquals("Expected loaded files count is 2", 2, streams.size());
-                    TestUtils.loadModules(streams);
-                    fail("SomeModifiersUnresolvedException should be thrown");
-                }
-            }
+            TestUtils.loadModuleResources(getClass(),
+                "/negative-scenario/testfile0.yang",
+                "/negative-scenario/testfile3.yang");
+            fail("SomeModifiersUnresolvedException should be thrown");
         } catch (final SomeModifiersUnresolvedException e) {
             final Throwable rootCause = Throwables.getRootCause(e);
             assertTrue(rootCause instanceof InferenceException);
@@ -100,13 +81,10 @@ public class YangParserNegativeTest {
     }
 
     @Test
-    public void testInvalidRefine() throws Exception {
-        final File yang = new File(getClass().getResource("/negative-scenario/testfile4.yang").toURI());
+    public void testInvalidRefine() throws IOException, ReactorException, YangSyntaxErrorException {
         try {
-            try (InputStream stream = new NamedFileInputStream(yang, yang.getPath())) {
-                TestUtils.loadModule(stream);
-                fail("SourceException should be thrown");
-            }
+            TestUtils.loadModuleResources(getClass(), "/negative-scenario/testfile4.yang");
+            fail("ReactorException should be thrown");
         } catch (final ReactorException e) {
             assertTrue(e.getCause().getMessage().contains("Error in module 'test4' in the refine of uses " +
                     "'Relative{path=[(urn:simple.container.demo?revision=1970-01-01)node]}': can not perform refine of 'PRESENCE' for" +
@@ -115,39 +93,30 @@ public class YangParserNegativeTest {
     }
 
     @Test
-    public void testInvalidLength() throws Exception {
-        final File yang = new File(getClass().getResource("/negative-scenario/testfile5.yang").toURI());
+    public void testInvalidLength() throws IOException, YangSyntaxErrorException {
         try {
-            try (InputStream stream = new NamedFileInputStream(yang, yang.getPath())) {
-                TestUtils.loadModule(stream);
-                fail("YangParseException should be thrown");
-            }
+            TestUtils.loadModuleResources(getClass(), "/negative-scenario/testfile5.yang");
+            fail("ReactorException should be thrown");
         } catch (final ReactorException e) {
             assertTrue(e.getCause().getMessage().contains("Invalid length constraint: <4, 10>"));
         }
     }
 
     @Test
-    public void testInvalidRange() throws Exception {
-        final File yang = new File(getClass().getResource("/negative-scenario/testfile6.yang").toURI());
+    public void testInvalidRange() throws IOException, YangSyntaxErrorException {
         try {
-            try (InputStream stream = new NamedFileInputStream(yang, yang.getPath())) {
-                TestUtils.loadModule(stream);
-                fail("Exception should be thrown");
-            }
+            TestUtils.loadModuleResources(getClass(), "/negative-scenario/testfile6.yang");
+            fail("ReactorException should be thrown");
         } catch (final ReactorException e) {
             assertTrue(e.getCause().getMessage().contains("Invalid range constraint: <5, 20>"));
         }
     }
 
     @Test
-    public void testDuplicateContainer() throws Exception {
-        final File yang = new File(getClass().getResource("/negative-scenario/duplicity/container.yang").toURI());
+    public void testDuplicateContainer() throws IOException, YangSyntaxErrorException {
         try {
-            try (InputStream stream = new NamedFileInputStream(yang, yang.getPath())) {
-                TestUtils.loadModule(stream);
-                fail("SourceException should be thrown");
-            }
+            TestUtils.loadModuleResources(getClass(), "/negative-scenario/duplicity/container.yang");
+            fail("SourceException should be thrown");
         } catch (final ReactorException e) {
             final String expected = "Error in module 'container': cannot add '(urn:simple.container" +
                     ".demo?revision=1970-01-01)foo'. Node name collision: '(urn:simple.container" +
@@ -157,13 +126,10 @@ public class YangParserNegativeTest {
     }
 
     @Test
-    public void testDuplicateContainerList() throws Exception {
-        final File yang = new File(getClass().getResource("/negative-scenario/duplicity/container-list.yang").toURI());
+    public void testDuplicateContainerList() throws IOException, YangSyntaxErrorException {
         try {
-            try (InputStream stream = new NamedFileInputStream(yang, yang.getPath())) {
-                TestUtils.loadModule(stream);
-                fail("SourceException should be thrown");
-            }
+            TestUtils.loadModuleResources(getClass(), "/negative-scenario/duplicity/container-list.yang");
+            fail("SourceException should be thrown");
         } catch (final ReactorException e) {
             final String expected = "Error in module 'container-list': cannot add '(urn:simple.container" +
                     ".demo?revision=1970-01-01)foo'. Node name collision: '(urn:simple.container" +
@@ -173,13 +139,10 @@ public class YangParserNegativeTest {
     }
 
     @Test
-    public void testDuplicateContainerLeaf() throws Exception {
-        final File yang = new File(getClass().getResource("/negative-scenario/duplicity/container-leaf.yang").toURI());
+    public void testDuplicateContainerLeaf() throws IOException, YangSyntaxErrorException {
         try {
-            try (InputStream stream = new NamedFileInputStream(yang, yang.getPath())) {
-                TestUtils.loadModule(stream);
-                fail("SourceException should be thrown");
-            }
+            TestUtils.loadModuleResources(getClass(), "/negative-scenario/duplicity/container-leaf.yang");
+            fail("SourceException should be thrown");
         } catch (final ReactorException e) {
             final String expected = "Error in module 'container-leaf': cannot add '(urn:simple.container" +
                     ".demo?revision=1970-01-01)foo'. Node name collision: '(urn:simple.container" +
@@ -189,13 +152,10 @@ public class YangParserNegativeTest {
     }
 
     @Test
-    public void testDuplicateTypedef() throws Exception {
-        final File yang = new File(getClass().getResource("/negative-scenario/duplicity/typedef.yang").toURI());
+    public void testDuplicateTypedef() throws IOException, YangSyntaxErrorException {
         try {
-            try (InputStream stream = new NamedFileInputStream(yang, yang.getPath())) {
-                TestUtils.loadModule(stream);
-                fail("SourceException should be thrown");
-            }
+            TestUtils.loadModuleResources(getClass(), "/negative-scenario/duplicity/typedef.yang");
+            fail("SourceException should be thrown");
         } catch (final ReactorException e) {
             assertTrue(e.getCause().getMessage().startsWith(
                 "Duplicate name for typedef (urn:simple.container.demo?revision=1970-01-01)int-ext [at"));
@@ -203,55 +163,42 @@ public class YangParserNegativeTest {
     }
 
     @Test
-    public void testDuplicityInAugmentTarget1() throws Exception {
-        final File yang1 = new File(getClass().getResource("/negative-scenario/duplicity/augment0.yang").toURI());
-        final File yang2 = new File(getClass().getResource("/negative-scenario/duplicity/augment1.yang").toURI());
-        try (InputStream stream1 = new NamedFileInputStream(yang1, yang1.getPath());
-            InputStream stream2 = new NamedFileInputStream(yang2, yang2.getPath())) {
-            TestUtils.loadModules(Arrays.asList(stream1, stream2));
-            testLog = output.toString();
-            assertTrue(testLog.contains("An augment cannot add node named 'id' because this name is already used in target"));
-        }
+    public void testDuplicityInAugmentTarget1() throws IOException, ReactorException, YangSyntaxErrorException {
+        TestUtils.loadModuleResources(getClass(),
+            "/negative-scenario/duplicity/augment0.yang",
+                "/negative-scenario/duplicity/augment1.yang");
+        testLog = output.toString();
+        assertTrue(testLog.contains("An augment cannot add node named 'id' because this name is already used in target"));
     }
 
     @Test
-    public void testDuplicityInAugmentTarget2() throws Exception {
-        final File yang1 = new File(getClass().getResource("/negative-scenario/duplicity/augment0.yang").toURI());
-        final File yang2 = new File(getClass().getResource("/negative-scenario/duplicity/augment2.yang").toURI());
-        try (InputStream stream1 = new NamedFileInputStream(yang1, yang1.getPath());
-             InputStream stream2 = new NamedFileInputStream(yang2, yang2.getPath())) {
-            TestUtils.loadModules(Arrays.asList(stream1, stream2));
-            testLog = output.toString();
-            assertTrue(testLog.contains("An augment cannot add node named 'delta' because this name is already used in target"));
-        }
+    public void testDuplicityInAugmentTarget2() throws IOException, ReactorException, YangSyntaxErrorException {
+        TestUtils.loadModuleResources(getClass(),
+            "/negative-scenario/duplicity/augment0.yang",
+                "/negative-scenario/duplicity/augment2.yang");
+        testLog = output.toString();
+        assertTrue(testLog.contains("An augment cannot add node named 'delta' because this name is already used in target"));
     }
 
     @Test
-    public void testMandatoryInAugment() throws Exception {
-        final File yang1 = new File(getClass().getResource("/negative-scenario/testfile8.yang").toURI());
-        final File yang2 = new File(getClass().getResource("/negative-scenario/testfile7.yang").toURI());
-        try (InputStream stream1 = new NamedFileInputStream(yang1, yang1.getPath());
-             InputStream stream2 = new NamedFileInputStream(yang2, yang2.getPath())) {
-            TestUtils.loadModules(Arrays.asList(stream1, stream2));
-            testLog = output.toString();
-            assertTrue(testLog.contains(
-                    "An augment cannot add node 'linkleaf' because it is mandatory and in module different than target"));
-        }
+    public void testMandatoryInAugment() throws IOException, ReactorException, YangSyntaxErrorException {
+        TestUtils.loadModuleResources(getClass(),
+            "/negative-scenario/testfile8.yang",
+                "/negative-scenario/testfile7.yang");
+        testLog = output.toString();
+        assertTrue(testLog.contains(
+            "An augment cannot add node 'linkleaf' because it is mandatory and in module different than target"));
     }
 
     @Test
-    public void testInvalidListKeyDefinition() throws Exception {
-        final File yang1 = new File(getClass().getResource("/negative-scenario/invalid-list-key-def.yang").toURI());
+    public void testInvalidListKeyDefinition() throws IOException, YangSyntaxErrorException {
         try {
-            try (InputStream stream1 = new NamedFileInputStream(yang1, yang1.getPath())) {
-                TestUtils.loadModule(stream1);
-                fail("InferenceException should be thrown");
-            }
+            TestUtils.loadModuleResources(getClass(), "/negative-scenario/invalid-list-key-def.yang");
+            fail("InferenceException should be thrown");
         } catch (final ReactorException e) {
-            final String expected = "Key 'rib-id' misses node 'rib-id' in list '(invalid:list:key:def?revision=1970-01-01)" +
-                    "application-map'";
+            final String expected = "Key 'rib-id' misses node 'rib-id' in list "
+                    + "'(invalid:list:key:def?revision=1970-01-01)application-map'";
             assertTrue(e.getCause().getMessage().startsWith(expected));
         }
     }
-
 }
index b3f301591d0bc473e062557ac4959f5c04b94eb6..07a7a8200fb4447bd92ba504b7256afe2139fc69 100644 (file)
@@ -22,6 +22,7 @@ import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
 import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
@@ -31,27 +32,29 @@ import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.MustDefinition;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.UsesNode;
 
 public class YangParserSimpleTest {
-    private final URI snNS = URI.create("urn:opendaylight:simple-nodes");
-    private Date snRev;
-    private final String snPref = "sn";
+    private static final QNameModule SN =
+            QNameModule.create(URI.create("urn:opendaylight:simple-nodes"), QName.parseRevision("2013-07-30"));
+    private static final QName SN_NODES = QName.create(SN, "nodes");
+    private static final SchemaPath SN_NODES_PATH = SchemaPath.create(true, SN_NODES);
 
-    private Set<Module> modules;
+    private SchemaContext context;
+    private Module testModule;
 
     @Before
     public void init() throws Exception {
-        snRev = SimpleDateFormatUtil.getRevisionFormat().parse("2013-07-30");
-        modules = TestUtils.loadModules(getClass().getResource("/simple-test").toURI());
+        context = TestUtils.loadModules(getClass().getResource("/simple-test").toURI());
+        testModule = TestUtils.findModule(context, "simple-nodes").get();
     }
 
     @Test
     public void testParseAnyXml() {
-        final Module testModule = TestUtils.findModule(modules, "simple-nodes");
         final AnyXmlSchemaNode data = (AnyXmlSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "data"));
         assertNotNull("'anyxml data not found'", data);
         assertFalse(data.equals(null));
@@ -59,10 +62,7 @@ public class YangParserSimpleTest {
                 "path=AbsoluteSchemaPath{path=[(urn:opendaylight:simple-nodes?revision=2013-07-30)data]}]", data.toString());
 
         // test SchemaNode args
-        final QName qname = data.getQName();
-        assertEquals("data", qname.getLocalName());
-        assertEquals(snNS, qname.getNamespace());
-        assertEquals(snRev, qname.getRevision());
+        assertEquals(QName.create(SN, "data"), data.getQName());
         assertEquals("anyxml desc", data.getDescription());
         assertEquals("data ref", data.getReference());
         assertEquals(Status.OBSOLETE, data.getStatus());
@@ -104,14 +104,11 @@ public class YangParserSimpleTest {
 
     @Test
     public void testParseContainer() throws ParseException {
-        final Module test = TestUtils.findModule(modules, "simple-nodes");
-
-        final ContainerSchemaNode nodes = (ContainerSchemaNode) test.getDataChildByName(QName.create(test.getQNameModule(), "nodes"));
+        final ContainerSchemaNode nodes = (ContainerSchemaNode) testModule
+                .getDataChildByName(QName.create(testModule.getQNameModule(), "nodes"));
         // test SchemaNode args
-        final QName expectedQName = QName.create(snNS, snRev, "nodes");
-        assertEquals(expectedQName, nodes.getQName());
-        final SchemaPath expectedPath = TestUtils.createPath(true, snNS, snRev, snPref, "nodes");
-        assertEquals(expectedPath, nodes.getPath());
+        assertEquals(SN_NODES, nodes.getQName());
+        assertEquals(SN_NODES_PATH, nodes.getPath());
         assertEquals("nodes collection", nodes.getDescription());
         assertEquals("nodes ref", nodes.getReference());
         assertEquals(Status.CURRENT, nodes.getStatus());
@@ -156,10 +153,9 @@ public class YangParserSimpleTest {
         final Set<TypeDefinition<?>> typedefs = nodes.getTypeDefinitions();
         assertEquals(1, typedefs.size());
         final TypeDefinition<?> nodesType = typedefs.iterator().next();
-        final QName typedefQName = QName.create(snNS, snRev, "nodes-type");
+        final QName typedefQName = QName.create(SN, "nodes-type");
         assertEquals(typedefQName, nodesType.getQName());
-        final SchemaPath nodesTypePath = TestUtils.createPath(true, snNS, snRev, snPref, "nodes", "nodes-type");
-        assertEquals(nodesTypePath, nodesType.getPath());
+        assertEquals(SN_NODES_PATH.createChild(QName.create(SN, "nodes-type")), nodesType.getPath());
         assertNull(nodesType.getDescription());
         assertNull(nodesType.getReference());
         assertEquals(Status.CURRENT, nodesType.getStatus());
@@ -168,19 +164,19 @@ public class YangParserSimpleTest {
         // child nodes
         // total size = 8: defined 6, inserted by uses 2
         assertEquals(8, nodes.getChildNodes().size());
-        final LeafListSchemaNode added = (LeafListSchemaNode)nodes.getDataChildByName(QName.create(test.getQNameModule(), "added"));
+        final LeafListSchemaNode added = (LeafListSchemaNode)nodes.getDataChildByName(QName.create(testModule.getQNameModule(), "added"));
         assertEquals(createPath("nodes", "added"), added.getPath());
         assertEquals(createPath("mytype"), added.getType().getPath());
 
-        final ListSchemaNode links = (ListSchemaNode) nodes.getDataChildByName(QName.create(test.getQNameModule(), "links"));
+        final ListSchemaNode links = (ListSchemaNode) nodes.getDataChildByName(QName.create(testModule.getQNameModule(), "links"));
         assertFalse(links.isUserOrdered());
 
         final Set<GroupingDefinition> groupings = nodes.getGroupings();
         assertEquals(1, groupings.size());
         final GroupingDefinition nodeGroup = groupings.iterator().next();
-        final QName groupQName = QName.create(snNS, snRev, "node-group");
+        final QName groupQName = QName.create(SN, "node-group");
         assertEquals(groupQName, nodeGroup.getQName());
-        final SchemaPath nodeGroupPath = TestUtils.createPath(true, snNS, snRev, snPref, "nodes", "node-group");
+        final SchemaPath nodeGroupPath = SN_NODES_PATH.createChild(groupQName);
         assertEquals(nodeGroupPath, nodeGroup.getPath());
 
         final Set<UsesNode> uses = nodes.getUses();
index 6f0aa2189deb7c2f5da08caf5cc5bf91f28246ee..855757d0276c58686be8df069ec6efcf53a87515 100644 (file)
@@ -12,14 +12,11 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
 
-import java.io.File;
 import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.text.DateFormat;
 import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -30,7 +27,7 @@ import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.YangConstants;
 import org.opendaylight.yangtools.yang.common.YangVersion;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
@@ -69,38 +66,33 @@ import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
-import org.opendaylight.yangtools.yang.parser.util.YangParseException;
 
 public class YangParserTest {
-    public static final String FS = File.separator;
-
-    private final URI fooNS = URI.create("urn:opendaylight.foo");
-    private final URI barNS = URI.create("urn:opendaylight.bar");
-    private final URI bazNS = URI.create("urn:opendaylight.baz");
-    private Date fooRev;
-    private Date barRev;
-    private Date bazRev;
-
-    private Set<Module> modules;
+    private static final QNameModule FOO = QNameModule.create(
+        URI.create("urn:opendaylight.foo"), QName.parseRevision("2013-02-27"));
+    private static final QNameModule BAR = QNameModule.create(
+        URI.create("urn:opendaylight.bar"), QName.parseRevision("2013-07-03"));
+    private static final QNameModule BAZ = QNameModule.create(
+        URI.create("urn:opendaylight.baz"), QName.parseRevision("2013-02-27"));
+
+    private SchemaContext context;
+    private Module foo;
+    private Module bar;
+    private Module baz;
 
     @Before
     public void init() throws Exception {
-        final DateFormat simpleDateFormat = SimpleDateFormatUtil.getRevisionFormat();
-        fooRev = simpleDateFormat.parse("2013-02-27");
-        barRev = simpleDateFormat.parse("2013-07-03");
-        bazRev = simpleDateFormat.parse("2013-02-27");
-
-        modules = TestUtils.loadModules(getClass().getResource("/model").toURI());
-        assertEquals(3, modules.size());
+        context = TestUtils.loadModules(getClass().getResource("/model").toURI());
+        foo = TestUtils.findModule(context, "foo").get();
+        bar = TestUtils.findModule(context, "bar").get();
+        baz = TestUtils.findModule(context, "baz").get();
     }
 
     @Test
     public void testHeaders() throws ParseException {
-        final Module foo = TestUtils.findModule(modules, "foo");
-
         assertEquals("foo", foo.getName());
         assertEquals(YangVersion.VERSION_1.toString(), foo.getYangVersion());
-        assertEquals(fooNS, foo.getNamespace());
+        assertEquals(FOO.getNamespace(), foo.getNamespace());
         assertEquals("foo", foo.getPrefix());
 
         final Set<ModuleImport> imports = foo.getImports();
@@ -108,11 +100,11 @@ public class YangParserTest {
 
         final ModuleImport import2 = TestUtils.findImport(imports, "br");
         assertEquals("bar", import2.getModuleName());
-        assertEquals(barRev, import2.getRevision());
+        assertEquals(BAR.getRevision(), import2.getRevision());
 
         final ModuleImport import3 = TestUtils.findImport(imports, "bz");
         assertEquals("baz", import3.getModuleName());
-        assertEquals(bazRev, import3.getRevision());
+        assertEquals(BAZ.getRevision(), import3.getRevision());
 
         assertEquals("opendaylight", foo.getOrganization());
         assertEquals("http://www.opendaylight.org/", foo.getContact());
@@ -123,20 +115,15 @@ public class YangParserTest {
 
     @Test
     public void testParseList() {
-        final Module bar = TestUtils.findModule(modules, "bar");
-        final URI expectedNamespace = URI.create("urn:opendaylight.bar");
-        final String expectedPrefix = "bar";
-
         final ContainerSchemaNode interfaces = (ContainerSchemaNode) bar.getDataChildByName(QName.create(
             bar.getQNameModule(), "interfaces"));
 
         final ListSchemaNode ifEntry = (ListSchemaNode) interfaces.getDataChildByName(QName.create(bar.getQNameModule(),
             "ifEntry"));
         // test SchemaNode args
-        final QName expectedQName = QName.create(expectedNamespace, barRev, "ifEntry");
-        assertEquals(expectedQName, ifEntry.getQName());
-        final SchemaPath expectedPath = TestUtils.createPath(true, expectedNamespace, barRev, expectedPrefix,
-            "interfaces", "ifEntry");
+        assertEquals(QName.create(BAR, "ifEntry"), ifEntry.getQName());
+
+        final SchemaPath expectedPath = TestUtils.createPath(true, BAR, "interfaces", "ifEntry");
         assertEquals(expectedPath, ifEntry.getPath());
         assertNull(ifEntry.getDescription());
         assertNull(ifEntry.getReference());
@@ -158,7 +145,7 @@ public class YangParserTest {
         assertEquals(2, availableAugmentations.size());
         // test ListSchemaNode args
         final List<QName> expectedKey = new ArrayList<>();
-        expectedKey.add(QName.create(expectedNamespace, barRev, "ifIndex"));
+        expectedKey.add(QName.create(BAR, "ifIndex"));
         assertEquals(expectedKey, ifEntry.getKeyDefinition());
         assertFalse(ifEntry.isUserOrdered());
         // test DataNodeContainer args
@@ -177,14 +164,10 @@ public class YangParserTest {
 
     @Test
     public void testTypedefRangesResolving() throws ParseException {
-        final Module foo = TestUtils.findModule(modules, "foo");
         final LeafSchemaNode int32Leaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(), "int32-leaf"));
 
         final IntegerTypeDefinition leafType = (IntegerTypeDefinition) int32Leaf.getType();
-        final QName leafTypeQName = leafType.getQName();
-        assertEquals("int32-ext2", leafTypeQName.getLocalName());
-        assertEquals(fooNS, leafTypeQName.getNamespace());
-        assertEquals(fooRev, leafTypeQName.getRevision());
+        assertEquals(QName.create(FOO, "int32-ext2"), leafType.getQName());
         assertEquals("mile", leafType.getUnits());
         assertEquals("11", leafType.getDefaultValue());
 
@@ -195,10 +178,7 @@ public class YangParserTest {
         assertEquals(20, range.getMax().intValue());
 
         final IntegerTypeDefinition baseType = leafType.getBaseType();
-        final QName baseTypeQName = baseType.getQName();
-        assertEquals("int32-ext2", baseTypeQName.getLocalName());
-        assertEquals(barNS, baseTypeQName.getNamespace());
-        assertEquals(barRev, baseTypeQName.getRevision());
+        assertEquals(QName.create(BAR, "int32-ext2"), baseType.getQName());
         assertEquals("mile", baseType.getUnits());
         assertEquals("11", baseType.getDefaultValue());
 
@@ -214,8 +194,7 @@ public class YangParserTest {
         final IntegerTypeDefinition base = baseType.getBaseType();
         final QName baseQName = base.getQName();
         assertEquals("int32-ext1", baseQName.getLocalName());
-        assertEquals(barNS, baseQName.getNamespace());
-        assertEquals(barRev, baseQName.getRevision());
+        assertEquals(BAR, baseQName.getModule());
         assertNull(base.getUnits());
         assertNull(base.getDefaultValue());
 
@@ -230,15 +209,13 @@ public class YangParserTest {
 
     @Test
     public void testTypedefPatternsResolving() {
-        final Module foo = TestUtils.findModule(modules, "foo");
         final LeafSchemaNode stringleaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(), "string-leaf"));
 
         assertTrue(stringleaf.getType() instanceof StringTypeDefinition);
         final StringTypeDefinition type = (StringTypeDefinition) stringleaf.getType();
         final QName typeQName = type.getQName();
         assertEquals("string-ext4", typeQName.getLocalName());
-        assertEquals(barNS, typeQName.getNamespace());
-        assertEquals(barRev, typeQName.getRevision());
+        assertEquals(BAR, typeQName.getModule());
         assertNull(type.getUnits());
         assertNull(type.getDefaultValue());
         List<PatternConstraint> patterns = type.getPatternConstraints();
@@ -250,8 +227,7 @@ public class YangParserTest {
         final StringTypeDefinition baseType1 = type.getBaseType();
         final QName baseType1QName = baseType1.getQName();
         assertEquals("string-ext3", baseType1QName.getLocalName());
-        assertEquals(barNS, baseType1QName.getNamespace());
-        assertEquals(barRev, baseType1QName.getRevision());
+        assertEquals(BAR, baseType1QName.getModule());
         assertNull(baseType1.getUnits());
         assertNull(baseType1.getDefaultValue());
         patterns = baseType1.getPatternConstraints();
@@ -263,8 +239,7 @@ public class YangParserTest {
         final StringTypeDefinition baseType2 = baseType1.getBaseType();
         final QName baseType2QName = baseType2.getQName();
         assertEquals("string-ext2", baseType2QName.getLocalName());
-        assertEquals(barNS, baseType2QName.getNamespace());
-        assertEquals(barRev, baseType2QName.getRevision());
+        assertEquals(BAR, baseType2QName.getModule());
         assertNull(baseType2.getUnits());
         assertNull(baseType2.getDefaultValue());
         assertTrue(baseType2.getPatternConstraints().isEmpty());
@@ -275,10 +250,7 @@ public class YangParserTest {
         assertEquals(10, length.getMax().intValue());
 
         final StringTypeDefinition baseType3 = baseType2.getBaseType();
-        final QName baseType3QName = baseType3.getQName();
-        assertEquals("string-ext1", baseType3QName.getLocalName());
-        assertEquals(barNS, baseType3QName.getNamespace());
-        assertEquals(barRev, baseType3QName.getRevision());
+        assertEquals(QName.create(BAR, "string-ext1"), baseType3.getQName());
         assertNull(baseType3.getUnits());
         assertNull(baseType3.getDefaultValue());
         patterns = baseType3.getPatternConstraints();
@@ -296,14 +268,10 @@ public class YangParserTest {
 
     @Test
     public void testTypedefInvalidPatternsResolving() {
-        final Module foo = TestUtils.findModule(modules, "foo");
         final LeafSchemaNode invalidPatternStringLeaf = (LeafSchemaNode) foo
                 .getDataChildByName(QName.create(foo.getQNameModule(), "invalid-pattern-string-leaf"));
         StringTypeDefinition type = (StringTypeDefinition) invalidPatternStringLeaf.getType();
-        QName typeQName = type.getQName();
-        assertEquals("invalid-string-pattern", typeQName.getLocalName());
-        assertEquals(barNS, typeQName.getNamespace());
-        assertEquals(barRev, typeQName.getRevision());
+        assertEquals(QName.create(BAR, "invalid-string-pattern"), type.getQName());
         assertNull(type.getUnits());
         assertNull(type.getDefaultValue());
         List<PatternConstraint> patterns = type.getPatternConstraints();
@@ -312,10 +280,8 @@ public class YangParserTest {
         final LeafSchemaNode invalidDirectStringPatternDefLeaf = (LeafSchemaNode) foo
                 .getDataChildByName(QName.create(foo.getQNameModule(), "invalid-direct-string-pattern-def-leaf"));
         type = (StringTypeDefinition) invalidDirectStringPatternDefLeaf.getType();
-        typeQName = type.getQName();
-        assertEquals("string", typeQName.getLocalName());
-        assertEquals(YangConstants.RFC6020_YANG_NAMESPACE, typeQName.getNamespace());
-        assertNull(typeQName.getRevision());
+
+        assertEquals(QName.create(YangConstants.RFC6020_YANG_MODULE, "string"), type.getQName());
         assertNull(type.getUnits());
         assertNull(type.getDefaultValue());
         patterns = type.getPatternConstraints();
@@ -324,10 +290,7 @@ public class YangParserTest {
         final LeafSchemaNode multiplePatternStringLeaf = (LeafSchemaNode) foo
                 .getDataChildByName(QName.create(foo.getQNameModule(), "multiple-pattern-string-leaf"));
         type = (StringTypeDefinition) multiplePatternStringLeaf.getType();
-        typeQName = type.getQName();
-        assertEquals("multiple-pattern-string", typeQName.getLocalName());
-        assertEquals(barNS, typeQName.getNamespace());
-        assertEquals(barRev, typeQName.getRevision());
+        assertEquals(QName.create(BAR, "multiple-pattern-string"), type.getQName());
         assertNull(type.getUnits());
         assertNull(type.getDefaultValue());
         patterns = type.getPatternConstraints();
@@ -340,10 +303,7 @@ public class YangParserTest {
         final LeafSchemaNode multiplePatternDirectStringDefLeaf = (LeafSchemaNode) foo
                 .getDataChildByName(QName.create(foo.getQNameModule(), "multiple-pattern-direct-string-def-leaf"));
         type = (StringTypeDefinition) multiplePatternDirectStringDefLeaf.getType();
-        typeQName = type.getQName();
-        assertEquals("string", typeQName.getLocalName());
-        assertEquals(fooNS, typeQName.getNamespace());
-        assertEquals(fooRev, typeQName.getRevision());
+        assertEquals(QName.create(FOO, "string"), type.getQName());
         assertNull(type.getUnits());
         assertNull(type.getDefaultValue());
         patterns = type.getPatternConstraints();
@@ -365,15 +325,10 @@ public class YangParserTest {
 
     @Test
     public void testTypedefLengthsResolving() {
-        final Module foo = TestUtils.findModule(modules, "foo");
-
         final LeafSchemaNode lengthLeaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(), "length-leaf"));
         final StringTypeDefinition type = (StringTypeDefinition) lengthLeaf.getType();
 
-        final QName typeQName = type.getQName();
-        assertEquals("string-ext2", typeQName.getLocalName());
-        assertEquals(fooNS, typeQName.getNamespace());
-        assertEquals(fooRev, typeQName.getRevision());
+        assertEquals(QName.create(FOO, "string-ext2"), type.getQName());
         assertNull(type.getUnits());
         assertNull(type.getDefaultValue());
         assertTrue(type.getPatternConstraints().isEmpty());
@@ -384,10 +339,7 @@ public class YangParserTest {
         assertEquals(10, length.getMax().intValue());
 
         final StringTypeDefinition baseType1 = type.getBaseType();
-        final QName baseType1QName = baseType1.getQName();
-        assertEquals("string-ext2", baseType1QName.getLocalName());
-        assertEquals(barNS, baseType1QName.getNamespace());
-        assertEquals(barRev, baseType1QName.getRevision());
+        assertEquals(QName.create(BAR, "string-ext2"), baseType1.getQName());
         assertNull(baseType1.getUnits());
         assertNull(baseType1.getDefaultValue());
         assertTrue(baseType1.getPatternConstraints().isEmpty());
@@ -398,10 +350,7 @@ public class YangParserTest {
         assertEquals(10, length.getMax().intValue());
 
         final StringTypeDefinition baseType2 = baseType1.getBaseType();
-        final QName baseType2QName = baseType2.getQName();
-        assertEquals("string-ext1", baseType2QName.getLocalName());
-        assertEquals(barNS, baseType2QName.getNamespace());
-        assertEquals(barRev, baseType2QName.getRevision());
+        assertEquals(QName.create(BAR, "string-ext1"), baseType2.getQName());
         assertNull(baseType2.getUnits());
         assertNull(baseType2.getDefaultValue());
         final List<PatternConstraint> patterns = baseType2.getPatternConstraints();
@@ -419,25 +368,18 @@ public class YangParserTest {
 
     @Test
     public void testTypedefDecimal1() {
-        final Module foo = TestUtils.findModule(modules, "foo");
         final LeafSchemaNode testleaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(), "decimal-leaf"));
 
         assertTrue(testleaf.getType() instanceof DecimalTypeDefinition);
         final DecimalTypeDefinition type = (DecimalTypeDefinition) testleaf.getType();
-        final QName typeQName = type.getQName();
-        assertEquals("my-decimal-type", typeQName.getLocalName());
-        assertEquals(barNS, typeQName.getNamespace());
-        assertEquals(barRev, typeQName.getRevision());
+        assertEquals(QName.create(BAR, "my-decimal-type"), type.getQName());
         assertNull(type.getUnits());
         assertNull(type.getDefaultValue());
         assertEquals(6, type.getFractionDigits().intValue());
         assertEquals(1, type.getRangeConstraints().size());
 
         final DecimalTypeDefinition typeBase = type.getBaseType();
-        final QName typeBaseQName = typeBase.getQName();
-        assertEquals("decimal64", typeBaseQName.getLocalName());
-        assertEquals(barNS, typeBaseQName.getNamespace());
-        assertEquals(barRev, typeBaseQName.getRevision());
+        assertEquals(QName.create(BAR, "decimal64"), typeBase.getQName());
         assertNull(typeBase.getUnits());
         assertNull(typeBase.getDefaultValue());
         assertEquals(6, typeBase.getFractionDigits().intValue());
@@ -448,15 +390,11 @@ public class YangParserTest {
 
     @Test
     public void testTypedefDecimal2() {
-        final Module foo = TestUtils.findModule(modules, "foo");
         final LeafSchemaNode testleaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(), "decimal-leaf2"));
 
         assertTrue(testleaf.getType() instanceof DecimalTypeDefinition);
         final DecimalTypeDefinition type = (DecimalTypeDefinition) testleaf.getType();
-        final QName typeQName = type.getQName();
-        assertEquals("my-decimal-type", typeQName.getLocalName());
-        assertEquals(barNS, typeQName.getNamespace());
-        assertEquals(barRev, typeQName.getRevision());
+        assertEquals(QName.create(BAR, "my-decimal-type"), type.getQName());
         assertNull(type.getUnits());
         assertNull(type.getDefaultValue());
         assertEquals(6, type.getFractionDigits().intValue());
@@ -468,23 +406,16 @@ public class YangParserTest {
 
     @Test
     public void testTypedefUnion() {
-        final Module foo = TestUtils.findModule(modules, "foo");
         final LeafSchemaNode unionleaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(), "union-leaf"));
 
         assertTrue(unionleaf.getType() instanceof UnionTypeDefinition);
         final UnionTypeDefinition type = (UnionTypeDefinition) unionleaf.getType();
-        final QName typeQName = type.getQName();
-        assertEquals("my-union-ext", typeQName.getLocalName());
-        assertEquals(barNS, typeQName.getNamespace());
-        assertEquals(barRev, typeQName.getRevision());
+        assertEquals(QName.create(BAR, "my-union-ext"), type.getQName());
         assertNull(type.getUnits());
         assertNull(type.getDefaultValue());
 
         final UnionTypeDefinition baseType = type.getBaseType();
-        final QName baseTypeQName = baseType.getQName();
-        assertEquals("my-union", baseTypeQName.getLocalName());
-        assertEquals(barNS, baseTypeQName.getNamespace());
-        assertEquals(barRev, baseTypeQName.getRevision());
+        assertEquals(QName.create(BAR, "my-union"), baseType.getQName());
         assertNull(baseType.getUnits());
         assertNull(baseType.getDefaultValue());
 
@@ -493,10 +424,7 @@ public class YangParserTest {
         assertEquals(2, unionTypes.size());
 
         final IntegerTypeDefinition unionType1 = (IntegerTypeDefinition) unionTypes.get(0);
-        final QName unionType1QName = baseType.getQName();
-        assertEquals("my-union", unionType1QName.getLocalName());
-        assertEquals(barNS, unionType1QName.getNamespace());
-        assertEquals(barRev, unionType1QName.getRevision());
+        assertEquals(QName.create(BAR, "my-union"), baseType.getQName());
         assertNull(unionType1.getUnits());
         assertNull(unionType1.getDefaultValue());
 
@@ -512,23 +440,16 @@ public class YangParserTest {
 
     @Test
     public void testNestedUnionResolving() {
-        final Module foo = TestUtils.findModule(modules, "foo");
         final LeafSchemaNode testleaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(), "custom-union-leaf"));
 
         assertTrue(testleaf.getType() instanceof UnionTypeDefinition);
         final UnionTypeDefinition type = (UnionTypeDefinition) testleaf.getType();
-        final QName testleafTypeQName = type.getQName();
-        assertEquals(bazNS, testleafTypeQName.getNamespace());
-        assertEquals(bazRev, testleafTypeQName.getRevision());
-        assertEquals("union1", testleafTypeQName.getLocalName());
+        assertEquals(QName.create(BAZ, "union1"), type.getQName());
         assertNull(type.getUnits());
         assertNull(type.getDefaultValue());
 
         final UnionTypeDefinition typeBase = type.getBaseType();
-        final QName typeBaseQName = typeBase.getQName();
-        assertEquals(bazNS, typeBaseQName.getNamespace());
-        assertEquals(bazRev, typeBaseQName.getRevision());
-        assertEquals("union2", typeBaseQName.getLocalName());
+        assertEquals(QName.create(BAZ, "union2"), typeBase.getQName());
         assertNull(typeBase.getUnits());
         assertNull(typeBase.getDefaultValue());
 
@@ -539,10 +460,7 @@ public class YangParserTest {
         assertTrue(unionTypes.get(1) instanceof UnionTypeDefinition);
 
         final UnionTypeDefinition unionType1 = (UnionTypeDefinition) unionTypes.get(1);
-        final QName uniontType1QName = unionType1.getQName();
-        assertEquals(barNS, uniontType1QName.getNamespace());
-        assertEquals(barRev, uniontType1QName.getRevision());
-        assertEquals("nested-union2", uniontType1QName.getLocalName());
+        assertEquals(QName.create(BAR, "nested-union2"), unionType1.getQName());
         assertNull(unionType1.getUnits());
         assertNull(unionType1.getDefaultValue());
 
@@ -553,19 +471,13 @@ public class YangParserTest {
         assertTrue(nestedUnion2Types.get(0) instanceof UnionTypeDefinition);
 
         final UnionTypeDefinition myUnionExt = (UnionTypeDefinition) nestedUnion2Types.get(0);
-        final QName myUnionExtQName = myUnionExt.getQName();
-        assertEquals(barNS, myUnionExtQName.getNamespace());
-        assertEquals(barRev, myUnionExtQName.getRevision());
-        assertEquals("my-union-ext", myUnionExtQName.getLocalName());
+        assertEquals(QName.create(BAR, "my-union-ext"), myUnionExt.getQName());
         assertNull(myUnionExt.getUnits());
         assertNull(myUnionExt.getDefaultValue());
 
 
         final UnionTypeDefinition myUnion = myUnionExt.getBaseType();
-        final QName myUnionQName = myUnion.getQName();
-        assertEquals(barNS, myUnionQName.getNamespace());
-        assertEquals(barRev, myUnionQName.getRevision());
-        assertEquals("my-union", myUnionQName.getLocalName());
+        assertEquals(QName.create(BAR, "my-union"), myUnion.getQName());
         assertNull(myUnion.getUnits());
         assertNull(myUnion.getDefaultValue());
 
@@ -576,10 +488,7 @@ public class YangParserTest {
         assertEquals(BaseTypes.int32Type(), myUnionBaseTypes.get(1));
 
         final IntegerTypeDefinition int16Ext = (IntegerTypeDefinition) myUnionBaseTypes.get(0);
-        final QName int16ExtQName = int16Ext.getQName();
-        assertEquals(barNS, int16ExtQName.getNamespace());
-        assertEquals(barRev, int16ExtQName.getRevision());
-        assertEquals("int16", int16ExtQName.getLocalName());
+        assertEquals(QName.create(BAR, "int16"), int16Ext.getQName());
         assertNull(int16Ext.getUnits());
         assertNull(int16Ext.getDefaultValue());
         final List<RangeConstraint> ranges = int16Ext.getRangeConstraints();
@@ -593,7 +502,6 @@ public class YangParserTest {
 
     @Test
     public void testChoice() {
-        final Module foo = TestUtils.findModule(modules, "foo");
         final ContainerSchemaNode transfer = (ContainerSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(), "transfer"));
         final ChoiceSchemaNode how = (ChoiceSchemaNode) transfer.getDataChildByName(QName.create(foo.getQNameModule(), "how"));
         final Set<ChoiceCaseNode> cases = how.getCases();
@@ -615,16 +523,14 @@ public class YangParserTest {
 
     @Test
     public void testDeviation() {
-        final Module foo = TestUtils.findModule(modules, "foo");
         final Set<Deviation> deviations = foo.getDeviations();
         assertEquals(1, deviations.size());
         final Deviation dev = deviations.iterator().next();
         assertEquals("system/user ref", dev.getReference());
 
-        final List<QName> path = new ArrayList<>();
-        path.add(QName.create(barNS, barRev, "interfaces"));
-        path.add(QName.create(barNS, barRev, "ifEntry"));
-        final SchemaPath expectedPath = SchemaPath.create(path, true);
+        final SchemaPath expectedPath = SchemaPath.create(true,
+            QName.create(BAR, "interfaces"),
+            QName.create(BAR, "ifEntry"));
 
         assertEquals(expectedPath, dev.getTargetPath());
         assertEquals(DeviateKind.ADD, dev.getDeviates().iterator().next().getDeviateType());
@@ -632,7 +538,6 @@ public class YangParserTest {
 
     @Test
     public void testUnknownNode() {
-        final Module baz = TestUtils.findModule(modules, "baz");
         final ContainerSchemaNode network = (ContainerSchemaNode) baz.getDataChildByName(QName.create(baz.getQNameModule(), "network"));
         final List<UnknownSchemaNode> unknownNodes = network.getUnknownSchemaNodes();
         assertEquals(1, unknownNodes.size());
@@ -643,14 +548,12 @@ public class YangParserTest {
 
     @Test
     public void testFeature() {
-        final Module baz = TestUtils.findModule(modules, "baz");
         final Set<FeatureDefinition> features = baz.getFeatures();
         assertEquals(1, features.size());
     }
 
     @Test
     public void testExtension() {
-        final Module baz = TestUtils.findModule(modules, "baz");
         final List<ExtensionDefinition> extensions = baz.getExtensionSchemaNodes();
         assertEquals(1, extensions.size());
         final ExtensionDefinition extension = extensions.get(0);
@@ -662,17 +565,13 @@ public class YangParserTest {
 
     @Test
     public void testNotification() {
-        final Module baz = TestUtils.findModule(modules, "baz");
-        final String expectedPrefix = "c";
-
         final Set<NotificationDefinition> notifications = baz.getNotifications();
         assertEquals(1, notifications.size());
 
         final NotificationDefinition notification = notifications.iterator().next();
         // test SchemaNode args
-        final QName expectedQName = QName.create(bazNS, bazRev, "event");
-        assertEquals(expectedQName, notification.getQName());
-        final SchemaPath expectedPath = TestUtils.createPath(true, bazNS, bazRev, expectedPrefix, "event");
+        assertEquals(QName.create(BAZ, "event"), notification.getQName());
+        final SchemaPath expectedPath = SchemaPath.create(true,  QName.create(BAZ, "event"));
         assertEquals(expectedPath, notification.getPath());
         assertNull(notification.getDescription());
         assertNull(notification.getReference());
@@ -692,8 +591,6 @@ public class YangParserTest {
 
     @Test
     public void testRpc() {
-        final Module baz = TestUtils.findModule(modules, "baz");
-
         final Set<RpcDefinition> rpcs = baz.getRpcs();
         assertEquals(1, rpcs.size());
 
@@ -704,16 +601,12 @@ public class YangParserTest {
 
     @Test
     public void testTypePath() throws ParseException {
-        final Module bar = TestUtils.findModule(modules, "bar");
         final Set<TypeDefinition<?>> types = bar.getTypeDefinitions();
 
         // int32-ext1
         final IntegerTypeDefinition int32ext1 = (IntegerTypeDefinition) TestUtils.findTypedef(types, "int32-ext1");
-        final QName int32TypedefQName = int32ext1.getQName();
-
-        assertEquals(barNS, int32TypedefQName.getNamespace());
-        assertEquals(barRev, int32TypedefQName.getRevision());
-        assertEquals("int32-ext1", int32TypedefQName.getLocalName());
+        final QName int32TypedefQName = QName.create(BAR, "int32-ext1");
+        assertEquals(int32TypedefQName, int32ext1.getQName());
 
         final SchemaPath typeSchemaPath = int32ext1.getPath();
         final Iterable<QName> typePath = typeSchemaPath.getPathFromRoot();
@@ -728,15 +621,13 @@ public class YangParserTest {
 
     @Test
     public void testTypePath2() throws ParseException {
-        final Module bar = TestUtils.findModule(modules, "bar");
         final Set<TypeDefinition<?>> types = bar.getTypeDefinitions();
 
         // my-decimal-type
         final DecimalTypeDefinition myDecType = (DecimalTypeDefinition) TestUtils.findTypedef(types, "my-decimal-type");
         final QName myDecTypeQName = myDecType.getQName();
 
-        assertEquals(barNS, myDecTypeQName.getNamespace());
-        assertEquals(barRev, myDecTypeQName.getRevision());
+        assertEquals(BAR, myDecTypeQName.getModule());
         assertEquals("my-decimal-type", myDecTypeQName.getLocalName());
 
         final SchemaPath typeSchemaPath = myDecType.getPath();
@@ -749,8 +640,7 @@ public class YangParserTest {
         final DecimalTypeDefinition dec64 = myDecType.getBaseType();
         final QName dec64QName = dec64.getQName();
 
-        assertEquals(barNS, dec64QName.getNamespace());
-        assertEquals(barRev, dec64QName.getRevision());
+        assertEquals(BAR, dec64QName.getModule());
         assertEquals("decimal64", dec64QName.getLocalName());
 
         final SchemaPath dec64SchemaPath = dec64.getPath();
@@ -791,8 +681,6 @@ public class YangParserTest {
 
     @Test
     public void testSubmodules() {
-        final Module foo = TestUtils.findModule(modules, "foo");
-
         final DataSchemaNode id = foo.getDataChildByName(QName.create(foo.getQNameModule(), "id"));
         assertNotNull(id);
         final DataSchemaNode subExt = foo.getDataChildByName(QName.create(foo.getQNameModule(), "sub-ext"));
@@ -808,14 +696,7 @@ public class YangParserTest {
     public void unknownStatementInSubmoduleHeaderTest() throws IOException, URISyntaxException, ReactorException {
         final StatementStreamSource yang1 = sourceForResource("/yang-grammar-test/revisions-extension.yang");
         final StatementStreamSource yang2 = sourceForResource("/yang-grammar-test/submodule-header-extension.yang");
-
-        try {
-            TestUtils.parseYangSources(yang1, yang2);
-        } catch (final YangParseException e) {
-            e.printStackTrace();
-            fail("YangParseException should not be thrown");
-        }
-
+        TestUtils.parseYangSources(yang1, yang2);
     }
 
     @Test
index 6fdd1ff4386f4cb732c4bb41d2a8638eb4986305..be8c883d0866d02653fe1532dfb28c6401687934 100644 (file)
@@ -373,10 +373,7 @@ public class YangParserWithContextTest {
         final StatementStreamSource test3 = sourceForResource("/context-augment-test/test3.yang");
 
         final SchemaContext context = TestUtils.parseYangSources(resource, test1, test2, test3);
-        final Set<Module> modules = context.getModules();
-        assertNotNull(modules);
-
-        final Module t4 = TestUtils.findModule(modules, "test4");
+        final Module t4 = TestUtils.findModule(context, "test4").get();
         final ContainerSchemaNode interfaces = (ContainerSchemaNode) t4.getDataChildByName(QName.create(
                 t4.getQNameModule(), "interfaces"));
         final ListSchemaNode ifEntry = (ListSchemaNode) interfaces.getDataChildByName(QName.create(t4.getQNameModule(),
index 902da6a3568493dbe70e48c154bd19d0b36f796a..ea7b976b75f3573f581f8718692eb44376804a20 100644 (file)
@@ -13,7 +13,7 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-import java.io.FileNotFoundException;
+import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import org.junit.Test;
@@ -22,20 +22,20 @@ import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
+import org.xml.sax.SAXException;
 
 public class YinOpenconfigVersionTest {
 
     @Test
-    public void basicTest() throws SourceException, FileNotFoundException, ReactorException, URISyntaxException {
+    public void basicTest() throws URISyntaxException, SAXException, IOException, ReactorException {
         SchemaContext context = StmtTestUtils.parseYinSources("/openconfig-version/yin-input/basic",
                 StatementParserMode.SEMVER_MODE);
         assertNotNull(context);
 
-        Module foo = context.findModuleByNamespace(new URI("foo")).iterator().next();
-        Module bar = context.findModuleByNamespace(new URI("bar")).iterator().next();
-        Module semVer = context.findModuleByNamespace(new URI("http://openconfig.net/yang/openconfig-ext"))
+        Module foo = context.findModuleByNamespace(URI.create("foo")).iterator().next();
+        Module bar = context.findModuleByNamespace(URI.create("bar")).iterator().next();
+        Module semVer = context.findModuleByNamespace(URI.create("http://openconfig.net/yang/openconfig-ext"))
                 .iterator().next();
 
         assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion());
@@ -44,13 +44,13 @@ public class YinOpenconfigVersionTest {
     }
 
     @Test
-    public void basicImportTest1() throws SourceException, FileNotFoundException, ReactorException, URISyntaxException {
+    public void basicImportTest1() throws URISyntaxException, SAXException, IOException, ReactorException {
         SchemaContext context = StmtTestUtils.parseYinSources("/openconfig-version/yin-input/basic-import",
                 StatementParserMode.SEMVER_MODE);
         assertNotNull(context);
 
-        Module foo = context.findModuleByNamespace(new URI("foo")).iterator().next();
-        Module semVer = context.findModuleByNamespace(new URI("http://openconfig.net/yang/openconfig-ext"))
+        Module foo = context.findModuleByNamespace(URI.create("foo")).iterator().next();
+        Module semVer = context.findModuleByNamespace(URI.create("http://openconfig.net/yang/openconfig-ext"))
                 .iterator().next();
 
         assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion());
@@ -60,8 +60,7 @@ public class YinOpenconfigVersionTest {
     }
 
     @Test
-    public void basicImportErrTest1() throws SourceException, FileNotFoundException, ReactorException,
-            URISyntaxException {
+    public void basicImportErrTest1() throws URISyntaxException, SAXException, IOException {
         try {
             StmtTestUtils.parseYinSources("/openconfig-version/yin-input/basic-import-invalid", StatementParserMode.SEMVER_MODE);
             fail("Test should fail due to invalid openconfig version");
index a1994cd76bcd2c67948dc983eb3b45c4ef2a4901..b10cf671a9376eb1d0d96005998f6d7bd159b48b 100644 (file)
@@ -11,6 +11,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
+import java.io.IOException;
 import java.net.URISyntaxException;
 import java.util.Iterator;
 import java.util.Set;
@@ -20,22 +21,24 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.stmt.TestUtils;
+import org.xml.sax.SAXException;
 
 public class YinFileAugmentStmtTest {
 
-    private Set<Module> modules;
+    private SchemaContext context;
 
     @Before
-    public void init() throws URISyntaxException, ReactorException {
-        modules = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
-        assertEquals(9, modules.size());
+    public void init() throws ReactorException, SAXException, IOException, URISyntaxException {
+        context = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
+        assertEquals(9, context.getModules().size());
     }
 
     @Test
     public void testAugment() {
-        final Module testModule = TestUtils.findModule(modules, "main-impl");
+        final Module testModule = TestUtils.findModule(context, "main-impl").get();
         assertNotNull(testModule);
 
         final Set<AugmentationSchema> augmentations = testModule.getAugmentations();
index 8a912acc0433ab6b4102d292414228f9a8d2557d..72065a976d622000ab07f8e7e1ece4e9f1a391ec 100644 (file)
@@ -12,9 +12,9 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
+import java.io.IOException;
 import java.net.URISyntaxException;
 import java.util.Iterator;
-import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -24,22 +24,24 @@ import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.stmt.TestUtils;
+import org.xml.sax.SAXException;
 
 public class YinFileChoiceStmtTest {
 
-    private Set<Module> modules;
+    private SchemaContext context;
 
     @Before
-    public void init() throws URISyntaxException, ReactorException {
-        modules = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
-        assertEquals(9, modules.size());
+    public void init() throws ReactorException, SAXException, IOException, URISyntaxException {
+        context = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
+        assertEquals(9, context.getModules().size());
     }
 
     @Test
     public void testChoiceAndCases() {
-        final Module testModule = TestUtils.findModule(modules, "config");
+        final Module testModule = TestUtils.findModule(context, "config").get();
         assertNotNull(testModule);
 
         final ContainerSchemaNode container = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(
index 99d68e23e98e25a33744a12b39c01cba36fd27bf..65018e331351e41df189fca0b39011105fdc9679 100644 (file)
@@ -11,30 +11,32 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 
+import java.io.IOException;
 import java.net.URISyntaxException;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
 import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.stmt.TestUtils;
+import org.xml.sax.SAXException;
 
 public class YinFileExtensionStmtTest {
 
-    private Set<Module> modules;
+    private SchemaContext context;
 
     @Before
-    public void init() throws URISyntaxException, ReactorException {
-        modules = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
-        assertEquals(9, modules.size());
+    public void init() throws ReactorException, SAXException, IOException, URISyntaxException {
+        context = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
+        assertEquals(9, context.getModules().size());
     }
 
     @Test
     public void testExtensions() {
-        Module testModule = TestUtils.findModule(modules, "config");
+        Module testModule = TestUtils.findModule(context, "config").get();
         assertNotNull(testModule);
 
         List<ExtensionDefinition> extensions = testModule.getExtensionSchemaNodes();
index d8236937610a2e8f38bbb2237564ec9085553477..b3c8ce95045e012e3495dda67a03f634328ac002 100644 (file)
@@ -13,6 +13,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertThat;
 
+import java.io.IOException;
 import java.net.URISyntaxException;
 import java.util.Iterator;
 import java.util.Set;
@@ -20,23 +21,25 @@ import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.model.api.FeatureDefinition;
 import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.stmt.TestUtils;
+import org.xml.sax.SAXException;
 
 public class YinFileFeatureStmtTest {
 
-    private Set<Module> modules;
+    private SchemaContext context;
 
     @Before
-    public void init() throws URISyntaxException, ReactorException {
-        modules = TestUtils.loadYinModules(getClass().getResource
-                ("/semantic-statement-parser/yin/feature-test/").toURI());
-        assertEquals(1, modules.size());
+    public void init() throws ReactorException, SAXException, IOException, URISyntaxException {
+        context = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/feature-test/")
+            .toURI());
+        assertEquals(1, context.getModules().size());
     }
 
     @Test
     public void testFeature() {
-        Module testModule = TestUtils.findModule(modules, "yang-with-features");
+        Module testModule = TestUtils.findModule(context, "yang-with-features").get();
         assertNotNull(testModule);
 
         Set<FeatureDefinition> features = testModule.getFeatures();
index 1fff202cf6206207b797fe08a9a7af82cd22d873..b4da6ca7de936a89123e0e1a46ac4ee0664f874e 100644 (file)
@@ -11,6 +11,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
+import java.io.IOException;
 import java.net.URISyntaxException;
 import java.util.Collection;
 import java.util.Iterator;
@@ -22,22 +23,24 @@ import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.stmt.TestUtils;
+import org.xml.sax.SAXException;
 
 public class YinFileGroupingStmtTest {
 
-    private Set<Module> modules;
+    private SchemaContext context;
 
     @Before
-    public void init() throws URISyntaxException, ReactorException {
-        modules = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
-        assertEquals(9, modules.size());
+    public void init() throws ReactorException, SAXException, IOException, URISyntaxException {
+        context = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
+        assertEquals(9, context.getModules().size());
     }
 
     @Test
     public void testGrouping() throws URISyntaxException {
-        final Module testModule = TestUtils.findModule(modules, "config");
+        final Module testModule = TestUtils.findModule(context, "config").get();
         assertNotNull(testModule);
 
         final Set<GroupingDefinition> groupings = testModule.getGroupings();
index d8231d403ee144ecdc49c34c72740133056dba40..47852d18ca4aafa4c3a6af56d3908f4b227078ae 100644 (file)
@@ -9,29 +9,31 @@ package org.opendaylight.yangtools.yang.stmt.yin;
 
 import static org.junit.Assert.assertEquals;
 
+import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.YangVersion;
 import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.stmt.TestUtils;
+import org.xml.sax.SAXException;
 
 public class YinFileHeaderStmtsTest {
 
-    private Set<Module> modules;
+    private SchemaContext modules;
 
     @Before
-    public void init() throws URISyntaxException, ReactorException {
+    public void init() throws URISyntaxException, ReactorException, SAXException, IOException {
         modules = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
-        assertEquals(9, modules.size());
+        assertEquals(9, modules.getModules().size());
     }
 
     @Test
     public void testYinFileHeader() throws URISyntaxException {
-        Module testModule = TestUtils.findModule(modules, "config");
+        Module testModule = TestUtils.findModule(modules, "config").get();
 
         assertEquals(YangVersion.VERSION_1.toString(), testModule.getYangVersion());
         assertEquals(new URI("urn:opendaylight:params:xml:ns:yang:controller:config"), testModule.getNamespace());
index 4d956a5bdc2eb0fc57ee8b69e675c58ec435c945..0c62ab50b3214794bc37d1f4e58b0507492df542 100644 (file)
@@ -14,6 +14,7 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertThat;
 
+import java.io.IOException;
 import java.net.URISyntaxException;
 import java.util.Iterator;
 import java.util.Set;
@@ -21,22 +22,24 @@ import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.stmt.TestUtils;
+import org.xml.sax.SAXException;
 
 public class YinFileIdentityStmtTest {
 
-    private Set<Module> modules;
+    private SchemaContext context;
 
     @Before
-    public void init() throws URISyntaxException, ReactorException {
-        modules = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
-        assertEquals(9, modules.size());
+    public void init() throws URISyntaxException, ReactorException, SAXException, IOException {
+        context = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
+        assertEquals(9, context.getModules().size());
     }
 
     @Test
     public void testIdentity() throws URISyntaxException {
-        Module testModule = TestUtils.findModule(modules, "config");
+        Module testModule = TestUtils.findModule(context, "config").get();
         assertNotNull(testModule);
 
         Set<IdentitySchemaNode> identities = testModule.getIdentities();
@@ -51,6 +54,5 @@ public class YinFileIdentityStmtTest {
         id = idIterator.next();
         assertThat(id.getQName().getLocalName(), anyOf(is("module-type"), is("service-type")));
         assertNull(id.getBaseIdentity());
-
     }
 }
index 50eba7c013744c147a9057bf3c21529589f5a510..98c0f72fd6ce0ea7b80897400d917b965e914613 100644 (file)
@@ -13,6 +13,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertThat;
 
+import java.io.IOException;
 import java.net.URISyntaxException;
 import java.text.ParseException;
 import java.util.Iterator;
@@ -21,23 +22,25 @@ import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.stmt.TestUtils;
+import org.xml.sax.SAXException;
 
 public class YinFileImportStmtTest {
 
-    private Set<Module> modules;
+    private SchemaContext context;
 
     @Before
-    public void init() throws URISyntaxException, ReactorException {
-        modules = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
-        assertEquals(9, modules.size());
+    public void init() throws URISyntaxException, ReactorException, SAXException, IOException {
+        context = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
+        assertEquals(9, context.getModules().size());
 
     }
 
     @Test
     public void testImport() throws ParseException {
-        Module testModule = TestUtils.findModule(modules, "ietf-netconf-monitoring");
+        Module testModule = TestUtils.findModule(context, "ietf-netconf-monitoring").get();
         assertNotNull(testModule);
 
         Set<ModuleImport> imports = testModule.getImports();
index 8e6624f8d3b23b0625d346713527fabf7c3e9895..a524a52efdc421a317fdb49fb4f4db1dae4a77f9 100644 (file)
@@ -10,30 +10,32 @@ package org.opendaylight.yangtools.yang.stmt.yin;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
+import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.Iterator;
-import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.stmt.TestUtils;
+import org.xml.sax.SAXException;
 
 public class YinFileIncludeStmtTest {
 
-    private Set<Module> modules;
+    private SchemaContext context;
 
     @Before
-    public void init() throws URISyntaxException, ReactorException {
-        modules = TestUtils.loadYinModules(getClass().getResource
+    public void init() throws URISyntaxException, ReactorException, SAXException, IOException {
+        context = TestUtils.loadYinModules(getClass().getResource
                 ("/semantic-statement-parser/yin/include-belongs-to-test").toURI());
-        assertEquals(1, modules.size());
+        assertEquals(1, context.getModules().size());
     }
 
     @Test
     public void testInclude() throws URISyntaxException {
-        Module parentModule = TestUtils.findModule(modules, "parent");
+        Module parentModule = TestUtils.findModule(context, "parent").get();
         assertNotNull(parentModule);
 
         assertEquals(1, parentModule.getSubmodules().size());
index d16136907653eddc8f1ac07ee98a400dde0073dc..b84ae68106c65cd15c26fcef7341f0ffe0cf366e 100644 (file)
@@ -11,30 +11,32 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 
+import java.io.IOException;
 import java.net.URISyntaxException;
-import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.stmt.TestUtils;
+import org.xml.sax.SAXException;
 
 public class YinFileLeafListStmtTest {
 
-    private Set<Module> modules;
+    private SchemaContext context;
 
     @Before
-    public void init() throws URISyntaxException, ReactorException {
-        modules = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
-        assertEquals(9, modules.size());
+    public void init() throws URISyntaxException, ReactorException, SAXException, IOException {
+        context = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
+        assertEquals(9, context.getModules().size());
     }
 
     @Test
     public void testLeafList() {
-        final Module testModule = TestUtils.findModule(modules, "ietf-netconf-monitoring");
+        final Module testModule = TestUtils.findModule(context, "ietf-netconf-monitoring").get();
         assertNotNull(testModule);
 
         ContainerSchemaNode container = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(
index 8dffff3c9ae9873fbf1b4e23348137338b994b9e..a7dd6380e1359fd1993b607a123c527cd7efeb6b 100644 (file)
@@ -11,11 +11,11 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
+import java.io.IOException;
 import java.net.URISyntaxException;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -24,25 +24,27 @@ import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.stmt.TestUtils;
+import org.xml.sax.SAXException;
 
 public class YinFileListStmtTest {
 
-    private Set<Module> modules;
+    private SchemaContext context;
 
     @Before
-    public void init() throws URISyntaxException, ReactorException {
-        modules = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
-        assertEquals(9, modules.size());
+    public void init() throws URISyntaxException, ReactorException, SAXException, IOException {
+        context = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
+        assertEquals(9, context.getModules().size());
     }
 
     @Test
-    public void testListAndLeaves() throws URISyntaxException {
-        final Module testModule = TestUtils.findModule(modules, "config");
+    public void testListAndLeaves() {
+        final Module testModule = TestUtils.findModule(context, "config").get();
         assertNotNull(testModule);
 
         final ContainerSchemaNode container = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(
index 29244eff26bffec7120fa00813e24679eff0600a..75a41b1cd5157e40f117eb8fa2a9e45f02def228 100644 (file)
@@ -10,27 +10,29 @@ package org.opendaylight.yangtools.yang.stmt.yin;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
+import java.io.IOException;
 import java.net.URISyntaxException;
-import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.stmt.TestUtils;
+import org.xml.sax.SAXException;
 
 public class YinFileMetaStmtsTest {
 
-    private Set<Module> modules;
+    private SchemaContext context;
 
     @Before
-    public void init() throws URISyntaxException, ReactorException {
-        modules = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
-        assertEquals(9, modules.size());
+    public void init() throws URISyntaxException, ReactorException, SAXException, IOException {
+        context = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
+        assertEquals(9, context.getModules().size());
     }
 
     @Test
     public void testMetaStatements() throws URISyntaxException {
-        Module testModule = TestUtils.findModule(modules, "ietf-netconf-monitoring");
+        Module testModule = TestUtils.findModule(context, "ietf-netconf-monitoring").get();
         assertNotNull(testModule);
 
         assertEquals("IETF NETCONF (Network Configuration) Working Group", testModule.getOrganization());
index c00cb6a4c95657934b036907e4b2970769196bae..45f111a2c6824d31a3a263f983304c5eb56df8fb 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.yangtools.yang.stmt.yin;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
+import java.io.IOException;
 import java.net.URISyntaxException;
 import java.util.Set;
 import org.junit.Before;
@@ -17,24 +18,24 @@ import org.junit.Test;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.stmt.TestUtils;
+import org.xml.sax.SAXException;
 
 public class YinFileRpcStmtTest {
 
-    private Set<Module> modules;
+    private SchemaContext context;
 
     @Before
-    public void init() throws URISyntaxException, ReactorException {
-        modules = TestUtils.loadYinModules(getClass().getResource
-                ("/semantic-statement-parser/yin/modules").toURI());
-        assertEquals(9, modules.size());
+    public void init() throws URISyntaxException, ReactorException, SAXException, IOException {
+        context = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
+        assertEquals(9, context.getModules().size());
     }
 
     @Test
     public void testRpc() {
-        Module testModule = TestUtils.findModule(modules, "ietf-netconf-monitoring");
-        assertNotNull(testModule);
+        Module testModule = TestUtils.findModule(context, "ietf-netconf-monitoring").get();
 
         Set<RpcDefinition> rpcs = testModule.getRpcs();
         assertEquals(1, rpcs.size());
index 86a3988c18e591da93cc07ee1b8ac36fe4df3b48..7d2cbe2e133434a2150ed4c2cd8bcc6e9ff57b1f 100644 (file)
@@ -12,20 +12,22 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import java.io.IOException;
 import java.net.URISyntaxException;
-import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.repo.api.YinTextSchemaSource;
+import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YinStatementStreamSource;
+import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YinTextToDomTransformer;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YinStatementSourceImpl;
 import org.opendaylight.yangtools.yang.stmt.TestUtils;
+import org.xml.sax.SAXException;
 
 public class YinFileStmtTest {
 
@@ -35,20 +37,26 @@ public class YinFileStmtTest {
     private static final StatementStreamSource INVALID_YIN_FILE = createSource("incorrect-foo.yin");
     private static final StatementStreamSource INVALID_YIN_FILE_2 = createSource("incorrect-bar.yin");
 
-    private Set<Module> modules;
+    private SchemaContext context;
 
     private static StatementStreamSource createSource(final String name) {
-        return new YinStatementSourceImpl("/semantic-statement-parser/yin/" + name, false);
+        try {
+            return YinStatementStreamSource.create(YinTextToDomTransformer.transformSource(
+                YinTextSchemaSource.forResource(YinFileStmtTest.class, "/semantic-statement-parser/yin/" + name)));
+        } catch (SAXException | IOException e) {
+            throw new IllegalArgumentException(e);
+        }
     }
 
     @Before
-    public void init() throws URISyntaxException, ReactorException {
-        modules = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
+    public void init() throws URISyntaxException, ReactorException, SAXException, IOException {
+        context = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
     }
 
     @Test
     public void readAndParseYinFileTestModel() throws SourceException, ReactorException {
         CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+
         addSources(reactor, YIN_FILE, EXT_FILE, EXT_USE_FILE);
         SchemaContext result = reactor.buildEffective();
         assertNotNull(result);
@@ -81,7 +89,7 @@ public class YinFileStmtTest {
 
     @Test
     public void testModulesSize() {
-        assertEquals(modules.size(), 9);
+        assertEquals(context.getModules().size(), 9);
     }
 
     private static void addSources(final CrossSourceStatementReactor.BuildAction reactor,  final
index 0b66a3d24dc92143c6d35a945c4a0fbc72f0abd5..e6be6abdd94e19323e9e5c059148f9266ddd71e8 100644 (file)
@@ -10,29 +10,32 @@ package org.opendaylight.yangtools.yang.stmt.yin;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
+import java.io.IOException;
 import java.net.URISyntaxException;
 import java.util.Iterator;
 import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.stmt.TestUtils;
+import org.xml.sax.SAXException;
 
 public class YinFileTypeDefStmtTest {
 
-    private Set<Module> modules;
+    private SchemaContext context;
 
     @Before
-    public void init() throws URISyntaxException, ReactorException {
-        modules = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
-        assertEquals(9, modules.size());
+    public void init() throws URISyntaxException, ReactorException, SAXException, IOException {
+        context = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
+        assertEquals(9, context.getModules().size());
     }
 
     @Test
-    public void testTypedef() throws URISyntaxException {
-        Module testModule = TestUtils.findModule(modules, "config");
+    public void testTypedef() {
+        Module testModule = TestUtils.findModule(context, "config").get();
         assertNotNull(testModule);
 
         Set<TypeDefinition<?>> typeDefs = testModule.getTypeDefinitions();
index 95f209f1ed50632e504a2706349e655acaf370aa..dc48bfb6d2bd4ff049dde227a20be55df7f9f11b 100644 (file)
@@ -11,6 +11,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
+import java.io.IOException;
 import java.net.URISyntaxException;
 import java.util.Iterator;
 import java.util.Set;
@@ -21,23 +22,25 @@ import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.UsesNode;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.stmt.TestUtils;
+import org.xml.sax.SAXException;
 
 public class YinFileUsesStmtTest {
 
-    private Set<Module> modules;
+    private SchemaContext context;
 
     @Before
-    public void init() throws URISyntaxException, ReactorException {
-        modules = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
-        assertEquals(9, modules.size());
+    public void init() throws URISyntaxException, ReactorException, SAXException, IOException {
+        context = TestUtils.loadYinModules(getClass().getResource("/semantic-statement-parser/yin/modules").toURI());
+        assertEquals(9, context.getModules().size());
     }
 
     @Test
     public void testUses() {
-        final Module testModule = TestUtils.findModule(modules, "main-impl");
+        final Module testModule = TestUtils.findModule(context, "main-impl").get();
         assertNotNull(testModule);
 
         final Set<AugmentationSchema> augmentations = testModule.getAugmentations();
index e5343e412b916ddfa6863289e45c12b09190d0cc..72b832e89ef76b15b80af5cdc9803e53c4537581 100644 (file)
@@ -9,11 +9,9 @@
 package org.opendaylight.yangtools.yang.test.util;
 
 import com.google.common.annotations.Beta;
-import com.google.common.base.Preconditions;
 import java.io.File;
 import java.io.FileFilter;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
+import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
@@ -21,16 +19,19 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
 import java.util.Set;
+import java.util.stream.Collectors;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.YangConstants;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
 import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
+import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YangStatementStreamSource;
 import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YinStatementStreamSource;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
-import org.opendaylight.yangtools.yang.parser.util.NamedFileInputStream;
 
 /**
  * Utility class which provides convenience methods for producing effective schema context based on the supplied
@@ -52,166 +53,73 @@ public final class YangParserTestUtils {
      * Creates a new effective schema context containing the specified YANG source. Statement parser mode is set to
      * default mode and all YANG features are supported.
      *
-     * @param yangSourcePath relative path to the YANG file to be parsed
+     * @param resource relative path to the YANG file to be parsed
      *
      * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in the parsed YANG source
-     * @throws FileNotFoundException if the specified file does not exist
-     * @throws URISyntaxException if the specified file does not exist
      */
-    public static SchemaContext parseYangSource(final String yangSourcePath) throws ReactorException,
-            FileNotFoundException, URISyntaxException {
-        return parseYangSource(yangSourcePath, StatementParserMode.DEFAULT_MODE);
+    public static SchemaContext parseYangResource(final String resource) {
+        return parseYangResource(resource, StatementParserMode.DEFAULT_MODE);
     }
 
     /**
-     * Creates a new effective schema context containing the specified YANG source. Statement parser mode is set to
-     * default mode.
-     *
-     * @param yangSourcePath relative path to the YANG file to be parsed
-     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
-     *                          model are resolved
+     * Creates a new effective schema context containing the specified YANG source. All YANG features are supported.
      *
+     * @param resource relative path to the YANG file to be parsed
+     * @param parserMode mode of statement parser
      * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in the parsed YANG source
-     * @throws FileNotFoundException if the specified file does not exist
-     * @throws URISyntaxException if the specified file does not exist
      */
-    public static SchemaContext parseYangSource(final String yangSourcePath, final Set<QName> supportedFeatures)
-            throws ReactorException, FileNotFoundException, URISyntaxException {
-        return parseYangSource(yangSourcePath, supportedFeatures, StatementParserMode.DEFAULT_MODE);
+    public static SchemaContext parseYangResource(final String resource, final StatementParserMode parserMode) {
+        return parseYangResource(resource, parserMode, null);
     }
 
     /**
-     * Creates a new effective schema context containing the specified YANG source. All YANG features are supported.
-     *
-     * @param yangSourcePath relative path to the YANG file to be parsed
-     * @param statementParserMode mode of statement parser
+     * Creates a new effective schema context containing the specified YANG source. Statement parser mode is set to
+     * default mode.
      *
+     * @param resource relative path to the YANG file to be parsed
+     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
+     *                          model are resolved
      * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in the parsed YANG source
-     * @throws FileNotFoundException if the specified file does not exist
-     * @throws URISyntaxException if the specified file does not exist
      */
-    public static SchemaContext parseYangSource(final String yangSourcePath,
-            final StatementParserMode statementParserMode) throws ReactorException, FileNotFoundException,
-            URISyntaxException {
-        return parseYangSource(yangSourcePath, null, statementParserMode);
+    public static SchemaContext parseYangResource(final String resource, final Set<QName> supportedFeatures) {
+        return parseYangResource(resource, StatementParserMode.DEFAULT_MODE, supportedFeatures);
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG source.
      *
-     * @param yangSourcePath relative path to the YANG file to be parsed
+     * @param resource relative path to the YANG file to be parsed
      * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
      *                          model are resolved
-     * @param statementParserMode mode of statement parser
-     *
+     * @param parserMode mode of statement parser
      * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in the parsed YANG source
-     * @throws FileNotFoundException if the specified file does not exist
-     * @throws URISyntaxException if the specified file does not exist
      */
-    public static SchemaContext parseYangSource(final String yangSourcePath, final Set<QName> supportedFeatures,
-            final StatementParserMode statementParserMode) throws ReactorException, FileNotFoundException,
-            URISyntaxException {
-        final URI sourcePath = YangParserTestUtils.class.getResource(yangSourcePath).toURI();
-        final File sourceFile = new File(sourcePath);
-        return parseYangSources(supportedFeatures, statementParserMode, sourceFile);
+    public static SchemaContext parseYangResource(final String resource, final StatementParserMode parserMode,
+            final Set<QName> supportedFeatures) {
+        final YangTextSchemaSource source = YangTextSchemaSource.forResource(YangParserTestUtils.class, resource);
+        return parseYangSources(parserMode, supportedFeatures, source);
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
      * default mode and all YANG features are supported.
      *
-     * @param sources YANG sources to be parsed
-     *
-     * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
-     *
-     * @deprecated Migration method only, do not use.
-     */
-    @Deprecated
-    public static SchemaContext parseYangSources(final YangStatementSourceImpl... sources) throws ReactorException {
-        return parseYangSources(StatementParserMode.DEFAULT_MODE, sources);
-    }
-
-    /**
-     * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
-     * default mode.
-     *
-     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
-     *                          models are resolved
-     * @param sources YANG sources to be parsed
-     *
-     * @return effective schema context
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
-     *
-     * @deprecated Migration method only, do not use.
-     */
-    @Deprecated
-    public static SchemaContext parseYangSources(final Set<QName> supportedFeatures,
-            final YangStatementSourceImpl... sources) throws ReactorException {
-        return parseYangSources(supportedFeatures, StatementParserMode.DEFAULT_MODE, sources);
-    }
-
-    /**
-     * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported.
-     *
-     * @param statementParserMode mode of statement parser
-     * @param sources YANG sources to be parsed
-     *
-     * @return effective schema context
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
-     *
-     * @deprecated Migration method only, do not use.
-     */
-    @Deprecated
-    public static SchemaContext parseYangSources(final StatementParserMode statementParserMode,
-            final YangStatementSourceImpl... sources) throws ReactorException {
-        return parseYangSources(null, statementParserMode, sources);
-    }
-
-    /**
-     * Creates a new effective schema context containing the specified YANG sources.
-     *
-     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
-     *                          models are resolved
-     * @param statementParserMode mode of statement parser
-     * @param sources YANG sources to be parsed
-     *
+     * @param files YANG files to be parsed
      * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
      */
-    public static SchemaContext parseYangSources(final Set<QName> supportedFeatures,
-            final StatementParserMode statementParserMode, final YangStatementSourceImpl... sources)
-                    throws ReactorException {
-        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(
-                statementParserMode, supportedFeatures);
-        reactor.addSources(sources);
-
-        return reactor.buildEffective();
+    public static SchemaContext parseYangFiles(final File... files) {
+        return parseYangFiles(Arrays.asList(files));
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
      * default mode and all YANG features are supported.
      *
-     * @param files YANG files to be parsed
-     *
+     * @param files collection of YANG files to be parsed
      * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
-     * @throws FileNotFoundException if one of the specified files does not exist
      */
-    public static SchemaContext parseYangSources(final File... files) throws ReactorException, FileNotFoundException {
-        return parseYangSources(StatementParserMode.DEFAULT_MODE, files);
+    public static SchemaContext parseYangFiles(final Collection<File> files) {
+        return parseYangFiles(StatementParserMode.DEFAULT_MODE, files);
     }
 
     /**
@@ -221,105 +129,36 @@ public final class YangParserTestUtils {
      * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
      *                          models are resolved
      * @param files YANG files to be parsed
-     *
      * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
-     * @throws FileNotFoundException if one of the specified files does not exist
      */
-    public static SchemaContext parseYangSources(final Set<QName> supportedFeatures, final File... files)
-            throws ReactorException, FileNotFoundException {
-        return parseYangSources(supportedFeatures, StatementParserMode.DEFAULT_MODE, files);
+    public static SchemaContext parseYangFiles(final Set<QName> supportedFeatures, final File... files) {
+        return parseYangFiles(supportedFeatures, Arrays.asList(files));
     }
 
-    /**
-     * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported.
-     *
-     * @param statementParserMode mode of statement parser
-     * @param files YANG files to be parsed
-     *
-     * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
-     * @throws FileNotFoundException if one of the specified files does not exist
-     */
-    public static SchemaContext parseYangSources(final StatementParserMode statementParserMode, final File... files)
-            throws ReactorException, FileNotFoundException {
-        return parseYangSources(null, statementParserMode, files);
+    public static SchemaContext parseYangFiles(final Set<QName> supportedFeatures, final Collection<File> files) {
+        return parseYangFiles(supportedFeatures, StatementParserMode.DEFAULT_MODE, files);
     }
 
     /**
-     * Creates a new effective schema context containing the specified YANG sources.
+     * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported.
      *
-     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
-     *                          models are resolved
-     * @param statementParserMode mode of statement parser
+     * @param parserMode mode of statement parser
      * @param files YANG files to be parsed
-     *
      * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
-     * @throws FileNotFoundException if one of the specified files does not exist
      */
-    public static SchemaContext parseYangSources(final Set<QName> supportedFeatures,
-            final StatementParserMode statementParserMode, final File... files) throws ReactorException,
-            FileNotFoundException {
-        final YangStatementSourceImpl[] sources = new YangStatementSourceImpl[files.length];
-        for (int i = 0; i < files.length; i++) {
-            sources[i] = new YangStatementSourceImpl(new NamedFileInputStream(files[i], files[i].getPath()));
-        }
-
-        return parseYangSources(supportedFeatures, statementParserMode, sources);
-    }
-
-    /**
-     * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
-     * default mode and all YANG features are supported.
-     *
-     * @param files collection of YANG files to be parsed
-     *
-     * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
-     * @throws FileNotFoundException if one of the specified files does not exist
-     */
-    public static SchemaContext parseYangSources(final Collection<File> files) throws ReactorException,
-            FileNotFoundException {
-        return parseYangSources(files, StatementParserMode.DEFAULT_MODE);
-    }
-
-    /**
-     * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
-     * default mode.
-     *
-     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
-     *                          models are resolved
-     * @param files collection of YANG files to be parsed
-     *
-     * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
-     * @throws FileNotFoundException if one of the specified files does not exist
-     */
-    public static SchemaContext parseYangSources(final Collection<File> files, final Set<QName> supportedFeatures)
-            throws ReactorException, FileNotFoundException {
-        return parseYangSources(files, supportedFeatures, StatementParserMode.DEFAULT_MODE);
+    public static SchemaContext parseYangFiles(final StatementParserMode parserMode, final File... files) {
+        return parseYangFiles(parserMode, Arrays.asList(files));
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported.
      *
-     * @param statementParserMode mode of statement parser
+     * @param parserMode mode of statement parser
      * @param files collection of YANG files to be parsed
-     *
      * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
-     * @throws FileNotFoundException if one of the specified files does not exist
      */
-    public static SchemaContext parseYangSources(final Collection<File> files,
-            final StatementParserMode statementParserMode) throws ReactorException, FileNotFoundException {
-        return parseYangSources(files, null, statementParserMode);
+    public static SchemaContext parseYangFiles(final StatementParserMode parserMode, final Collection<File> files) {
+        return parseYangFiles(null, parserMode, files);
     }
 
     /**
@@ -327,405 +166,179 @@ public final class YangParserTestUtils {
      *
      * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
      *                          models are resolved
-     * @param statementParserMode mode of statement parser
-     * @param files collection of YANG files to be parsed
-     *
-     * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
-     * @throws FileNotFoundException if one of the specified files does not exist
-     */
-    public static SchemaContext parseYangSources(final Collection<File> files, final Set<QName> supportedFeatures,
-            final StatementParserMode statementParserMode) throws ReactorException, FileNotFoundException {
-        return parseYangSources(supportedFeatures, statementParserMode, files.toArray(new File[files.size()]));
-    }
-
-    /**
-     * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
-     * default mode and all YANG features are supported.
-     *
-     * @param yangSourcesDirectoryPath relative path to the directory with YANG files to be parsed
-     *
-     * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
-     * @throws FileNotFoundException if the specified directory does not exist
-     * @throws URISyntaxException if the specified directory does not exist
-     */
-    public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath) throws ReactorException,
-            FileNotFoundException, URISyntaxException {
-        return parseYangSources(yangSourcesDirectoryPath, StatementParserMode.DEFAULT_MODE);
-    }
-
-    /**
-     * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
-     * default mode.
-     *
-     * @param yangSourcesDirectoryPath relative path to the directory with YANG files to be parsed
-     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
-     *                          models are resolved
-     *
-     * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
-     * @throws FileNotFoundException if the specified directory does not exist
-     * @throws URISyntaxException if the specified directory does not exist
-     */
-    public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath,
-            final Set<QName> supportedFeatures) throws ReactorException, FileNotFoundException,
-            URISyntaxException {
-        return parseYangSources(yangSourcesDirectoryPath, supportedFeatures, StatementParserMode.DEFAULT_MODE);
-    }
-
-    /**
-     * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported.
-     *
-     * @param yangSourcesDirectoryPath relative path to the directory with YANG files to be parsed
-     * @param statementParserMode mode of statement parser
-     *
+     * @param parserMode mode of statement parser
+     * @param files YANG files to be parsed
      * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
-     * @throws FileNotFoundException if the specified directory does not exist
-     * @throws URISyntaxException if the specified directory does not exist
      */
-    public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath,
-            final StatementParserMode statementParserMode) throws ReactorException, FileNotFoundException,
-            URISyntaxException {
-        return parseYangSources(yangSourcesDirectoryPath, null, statementParserMode);
+    public static SchemaContext parseYangFiles(final Set<QName> supportedFeatures,
+            final StatementParserMode parserMode, final File... files) {
+        return parseYangFiles(supportedFeatures, parserMode, Arrays.asList(files));
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources.
      *
-     * @param yangSourcesDirectoryPath relative path to the directory with YANG files to be parsed
      * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
      *                          models are resolved
-     * @param statementParserMode mode of statement parser
-     *
+     * @param parserMode mode of statement parser
+     * @param files YANG files to be parsed
      * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
-     * @throws FileNotFoundException if the specified directory does not exist
-     * @throws URISyntaxException if the specified directory does not exist
      */
-    public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath,
-            final Set<QName> supportedFeatures, final StatementParserMode statementParserMode)
-                    throws ReactorException, FileNotFoundException, URISyntaxException {
-        final URI directoryPath = YangParserTestUtils.class.getResource(yangSourcesDirectoryPath).toURI();
-        final File dir = new File(directoryPath);
-
-        return parseYangSources(supportedFeatures, statementParserMode, dir.listFiles(YANG_FILE_FILTER));
+    public static SchemaContext parseYangFiles(final Set<QName> supportedFeatures,
+            final StatementParserMode parserMode, final Collection<File> files) {
+        return parseYangSources(supportedFeatures, parserMode,
+            files.stream().map(YangTextSchemaSource::forFile).collect(Collectors.toList()));
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
      * default mode and all YANG features are supported.
      *
-     * @param yangDirs relative paths to the directories containing YANG files to be parsed
-     * @param yangFiles relative paths to the YANG files to be parsed
-     *
+     * @param resourcePath relative path to the directory with YANG files to be parsed
      * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
-     * @throws FileNotFoundException if one of the specified directories or files does not exist
-     * @throws URISyntaxException if one of the specified directories or files does not exist
      */
-    public static SchemaContext parseYangSources(final List<String> yangDirs, final List<String> yangFiles)
-            throws FileNotFoundException, ReactorException, URISyntaxException {
-        return parseYangSources(yangDirs, yangFiles, StatementParserMode.DEFAULT_MODE);
-    }
-
-    /**
-     * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
-     * default mode.
-     *
-     * @param yangDirs relative paths to the directories containing YANG files to be parsed
-     * @param yangFiles relative paths to the YANG files to be parsed
-     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
-     *                          models are resolved
-     *
-     * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
-     * @throws FileNotFoundException if one of the specified directories or files does not exist
-     * @throws URISyntaxException if one of the specified directories or files does not exist
-     */
-    public static SchemaContext parseYangSources(final List<String> yangDirs, final List<String> yangFiles,
-            final Set<QName> supportedFeatures) throws FileNotFoundException, ReactorException,
-            URISyntaxException {
-        return parseYangSources(yangDirs, yangFiles, supportedFeatures, StatementParserMode.DEFAULT_MODE);
+    public static SchemaContext parseYangResourceDirectory(final String resourcePath) {
+        return parseYangResourceDirectory(resourcePath, StatementParserMode.DEFAULT_MODE);
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported.
      *
-     * @param yangDirs relative paths to the directories containing YANG files to be parsed
-     * @param yangFiles relative paths to the YANG files to be parsed
-     * @param statementParserMode mode of statement parser
-     *
+     * @param resourcePath relative path to the directory with YANG files to be parsed
+     * @param parserMode mode of statement parser
      * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
-     * @throws FileNotFoundException if one of the specified directories or files does not exist
-     * @throws URISyntaxException if one of the specified directories or files does not exist
      */
-    public static SchemaContext parseYangSources(final List<String> yangDirs, final List<String> yangFiles,
-            final StatementParserMode statementParserMode) throws FileNotFoundException, ReactorException,
-            URISyntaxException {
-        return parseYangSources(yangDirs, yangFiles, null, statementParserMode);
-    }
-
-    /**
-     * Creates a new effective schema context containing the specified YANG sources.
-     *
-     * @param yangDirs relative paths to the directories containing YANG files to be parsed
-     * @param yangFiles relative paths to the YANG files to be parsed
-     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
-     *                          models are resolved
-     * @param statementParserMode mode of statement parser
-     *
-     * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
-     * @throws FileNotFoundException if one of the specified directories or files does not exist
-     * @throws URISyntaxException if one of the specified directories or files does not exist
-     */
-    public static SchemaContext parseYangSources(final List<String> yangDirs, final List<String> yangFiles,
-            final Set<QName> supportedFeatures, final StatementParserMode statementParserMode)
-            throws FileNotFoundException, ReactorException, URISyntaxException {
-        final List<File> allYangFiles = new ArrayList<>();
-        for (final String yangDir : yangDirs) {
-            allYangFiles.addAll(getYangFiles(yangDir));
-        }
-
-        for (final String yangFile : yangFiles) {
-            final URI filePath = YangParserTestUtils.class.getResource(yangFile).toURI();
-            allYangFiles.add(new File(filePath));
-        }
-
-        return parseYangSources(allYangFiles, supportedFeatures, statementParserMode);
-    }
-
-    /**
-     * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
-     * default mode and all YANG features are supported.
-     *
-     * @param filePaths relative paths to the YANG files to be parsed
-     *
-     * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
-     */
-    public static SchemaContext parseYangSources(final List<String> filePaths) throws ReactorException {
-        return parseYangSources(filePaths, StatementParserMode.DEFAULT_MODE);
+    public static SchemaContext parseYangResourceDirectory(final String resourcePath,
+            final StatementParserMode parserMode) {
+        return parseYangResourceDirectory(resourcePath, null, parserMode);
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
      * default mode.
      *
+     * @param resourcePath relative path to the directory with YANG files to be parsed
      * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
      *                          models are resolved
-     * @param filePaths relative paths to the YANG files to be parsed
-     *
-     * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
-     */
-    public static SchemaContext parseYangSources(final List<String> filePaths, final Set<QName> supportedFeatures)
-            throws ReactorException {
-        return parseYangSources(filePaths, supportedFeatures, StatementParserMode.DEFAULT_MODE);
-    }
-
-    /**
-     * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported.
-     *
-     * @param statementParserMode mode of statement parser
-     * @param filePaths relative paths to the YANG files to be parsed
-     *
      * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
      */
-    public static SchemaContext parseYangSources(final List<String> filePaths,
-            final StatementParserMode statementParserMode) throws ReactorException {
-        return parseYangSources(filePaths, (Set<QName>) null, statementParserMode);
+    public static SchemaContext parseYangResourceDirectory(final String resourcePath,
+            final Set<QName> supportedFeatures) {
+        return parseYangResourceDirectory(resourcePath, supportedFeatures, StatementParserMode.DEFAULT_MODE);
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources.
      *
+     * @param resourcePath relative path to the directory with YANG files to be parsed
      * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
      *                          models are resolved
-     * @param statementParserMode mode of statement parser
-     * @param filePaths relative paths to the YANG files to be parsed
-     *
+     * @param parserMode mode of statement parser
      * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
      */
-    public static SchemaContext parseYangSources(final List<String> filePaths,
-            final Set<QName> supportedFeatures, final StatementParserMode statementParserMode)
-                    throws ReactorException {
-        final YangStatementSourceImpl[] sources = new YangStatementSourceImpl[filePaths.size()];
-
-        for (int i = 0; i < filePaths.size(); i++) {
-            sources[i] = new YangStatementSourceImpl(YangParserTestUtils.class.getResourceAsStream(filePaths.get(i)));
+    public static SchemaContext parseYangResourceDirectory(final String resourcePath,
+            final Set<QName> supportedFeatures, final StatementParserMode parserMode) {
+        final URI directoryPath;
+        try {
+            directoryPath = YangParserTestUtils.class.getResource(resourcePath).toURI();
+        } catch (URISyntaxException e) {
+            throw new IllegalArgumentException("Failed to open resource " + resourcePath, e);
         }
-
-        return parseYangSources(supportedFeatures, statementParserMode, sources);
+        return parseYangFiles(supportedFeatures, parserMode, new File(directoryPath).listFiles(YANG_FILE_FILTER));
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
      * default mode and all YANG features are supported.
      *
-     * @param streams input streams containing YANG sources to be parsed
-     *
+     * @param clazz Resource lookup base
+     * @param resources Resource names to be looked up
      * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
      */
-    public static SchemaContext parseYangStreams(final List<InputStream> streams) throws ReactorException {
-        return parseYangStreams(streams, StatementParserMode.DEFAULT_MODE);
+    public static SchemaContext parseYangResources(final Class<?> clazz, final String... resources) {
+        final List<YangTextSchemaSource> sources = new ArrayList<>(resources.length);
+        for (final String r : resources) {
+            sources.add(YangTextSchemaSource.forResource(clazz, r));
+        }
+        return parseYangSources(null, StatementParserMode.DEFAULT_MODE, sources);
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
      * default mode.
      *
-     * @param streams input streams containing YANG sources to be parsed
+     * @param yangDirs relative paths to the directories containing YANG files to be parsed
+     * @param yangFiles relative paths to the YANG files to be parsed
      * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
      *                          models are resolved
-     *
      * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
      */
-    public static SchemaContext parseYangStreams(final List<InputStream> streams, final Set<QName> supportedFeatures)
-            throws ReactorException {
-        return parseYangStreams(streams, supportedFeatures, StatementParserMode.DEFAULT_MODE);
+    public static SchemaContext parseYangResources(final List<String> yangDirs, final List<String> yangFiles,
+            final Set<QName> supportedFeatures) {
+        return parseYangResources(yangDirs, yangFiles, supportedFeatures, StatementParserMode.DEFAULT_MODE);
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported.
      *
-     * @param streams input streams containing YANG sources to be parsed
+     * @param yangResourceDirs relative paths to the directories containing YANG files to be parsed
+     * @param yangResources relative paths to the YANG files to be parsed
      * @param statementParserMode mode of statement parser
-     *
      * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
      */
-    public static SchemaContext parseYangStreams(final List<InputStream> streams,
-            final StatementParserMode statementParserMode) throws ReactorException {
-        return parseYangStreams(streams, null, statementParserMode);
+    public static SchemaContext parseYangResources(final List<String> yangResourceDirs,
+            final List<String> yangResources, final StatementParserMode statementParserMode) {
+        return parseYangResources(yangResourceDirs, yangResources, null, statementParserMode);
     }
 
     /**
      * Creates a new effective schema context containing the specified YANG sources.
      *
+     * @param yangResourceDirs relative paths to the directories containing YANG files to be parsed
+     * @param yangResources relative paths to the YANG files to be parsed
      * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
      *                          models are resolved
      * @param statementParserMode mode of statement parser
-     * @param streams input streams containing YANG sources to be parsed
-     *
-     * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
-     */
-    public static SchemaContext parseYangStreams(final List<InputStream> streams, final Set<QName> supportedFeatures,
-            final StatementParserMode statementParserMode) throws ReactorException {
-        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(
-                statementParserMode, supportedFeatures);
-        return reactor.buildEffective(streams);
-    }
-
-    /**
-     * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
-     * default mode and all YANG features are supported.
-     *
-     * @param streams input streams containing YANG sources to be parsed
-     *
      * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
      */
-    public static SchemaContext parseYangStreams(final InputStream... streams) throws ReactorException {
-        return parseYangStreams(Arrays.asList(streams));
-    }
+    public static SchemaContext parseYangResources(final List<String> yangResourceDirs,
+            final List<String> yangResources, final Set<QName> supportedFeatures,
+            final StatementParserMode statementParserMode) {
+        final List<File> allYangFiles = new ArrayList<>();
+        for (final String yangDir : yangResourceDirs) {
+            allYangFiles.addAll(getYangFiles(yangDir));
+        }
 
-    /**
-     * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
-     * default mode.
-     *
-     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
-     *                          models are resolved
-     * @param streams input streams containing YANG sources to be parsed
-     *
-     * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
-     */
-    public static SchemaContext parseYangStreams(final Set<QName> supportedFeatures,
-            final InputStream... streams) throws ReactorException {
-        return parseYangStreams(Arrays.asList(streams), supportedFeatures);
-    }
+        for (final String yangFile : yangResources) {
+            try {
+                allYangFiles.add(new File(YangParserTestUtils.class.getResource(yangFile).toURI()));
+            } catch (URISyntaxException e) {
+                throw new IllegalArgumentException("Invalid resource " + yangFile, e);
+            }
+        }
 
-    /**
-     * Creates a new effective schema context containing the specified YANG sources. All YANG features are supported.
-     *
-     * @param statementParserMode mode of statement parser
-     * @param streams input streams containing YANG sources to be parsed
-     *
-     * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
-     */
-    public static SchemaContext parseYangStreams(final StatementParserMode statementParserMode,
-            final InputStream... streams) throws ReactorException {
-        return parseYangStreams(Arrays.asList(streams), statementParserMode);
+        return parseYangFiles(supportedFeatures, statementParserMode, allYangFiles);
     }
 
-    /**
-     * Creates a new effective schema context containing the specified YANG sources.
-     *
-     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
-     *                          models are resolved
-     * @param statementParserMode mode of statement parser
-     * @param streams input streams containing YANG sources to be parsed
-     *
-     * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
-     */
-    public static SchemaContext parseYangStreams(final Set<QName> supportedFeatures,
-            final StatementParserMode statementParserMode, final InputStream... streams) throws ReactorException {
-        return parseYangStreams(Arrays.asList(streams), supportedFeatures, statementParserMode);
+    public static SchemaContext parseYangSources(final StatementParserMode parserMode,
+            final Set<QName> supportedFeatures, final YangTextSchemaSource... sources) {
+        return parseYangSources(supportedFeatures, parserMode, Arrays.asList(sources));
     }
 
-    /**
-     * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
-     * default mode and all YANG features are supported.
-     *
-     * @param clazz Resource lookup base
-     * @param resources Resource names to be looked up
-     *
-     * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YANG sources
-     */
-    public static SchemaContext parseYangResources(final Class<?> clazz, final String... resources)
-            throws ReactorException {
-        final List<InputStream> streams = new ArrayList<>(resources.length);
-        for (final String r : resources) {
-            final InputStream is = clazz.getResourceAsStream(r);
-            Preconditions.checkArgument(is != null, "Resource %s not found", r);
-            streams.add(is);
+    public static SchemaContext parseYangSources(final Set<QName> supportedFeatures,
+            final StatementParserMode parserMode, final Collection<? extends YangTextSchemaSource> sources) {
+        final Collection<YangStatementStreamSource> streams = new ArrayList<>(sources.size());
+        for (YangTextSchemaSource source : sources) {
+            try {
+                streams.add(YangStatementStreamSource.create(source));
+            } catch (IOException e) {
+                throw new IllegalArgumentException("Failed to read source " + source, e);
+            } catch (YangSyntaxErrorException e) {
+                throw new IllegalArgumentException("Malformed source " + source, e);
+            }
         }
 
-        return parseYangStreams(streams);
+        return parseSources(supportedFeatures, parserMode, streams);
     }
 
     /**
@@ -733,12 +346,9 @@ public final class YangParserTestUtils {
      * default mode and all YANG features are supported.
      *
      * @param sources YIN sources to be parsed
-     *
      * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YIN sources
      */
-    public static SchemaContext parseYinSources(final YinStatementStreamSource... sources) throws ReactorException {
+    public static SchemaContext parseYinSources(final YinStatementStreamSource... sources) {
         return parseYinSources(StatementParserMode.DEFAULT_MODE, sources);
     }
 
@@ -755,7 +365,7 @@ public final class YangParserTestUtils {
      */
     public static SchemaContext parseYinSources(final Set<QName> supportedFeatures,
             final YinStatementStreamSource... sources) throws ReactorException {
-        return parseYinSources(supportedFeatures, StatementParserMode.DEFAULT_MODE, sources);
+        return parseSources(supportedFeatures, StatementParserMode.DEFAULT_MODE, sources);
     }
 
     /**
@@ -763,42 +373,61 @@ public final class YangParserTestUtils {
      *
      * @param statementParserMode mode of statement parser
      * @param sources YIN sources to be parsed
-     *
      * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YIN sources
      */
     public static SchemaContext parseYinSources(final StatementParserMode statementParserMode,
-            final YinStatementStreamSource... sources) throws ReactorException {
-        return parseYinSources(null, statementParserMode, sources);
+            final YinStatementStreamSource... sources) {
+        return parseSources(null, statementParserMode, sources);
+    }
+
+    /**
+     * Creates a new effective schema context containing the specified YANG sources.
+     *
+     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
+     *                          models are resolved
+     * @param parserMode mode of statement parser
+     * @param sources sources to be parsed
+     *
+     * @return effective schema context
+     */
+    public static SchemaContext parseSources(final Set<QName> supportedFeatures,
+            final StatementParserMode parserMode, final StatementStreamSource... sources) {
+        return parseSources(supportedFeatures, parserMode, Arrays.asList(sources));
     }
 
     /**
-     * Creates a new effective schema context containing the specified YIN sources.
+     * Creates a new effective schema context containing the specified YANG sources.
      *
-     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YIN
+     * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
      *                          models are resolved
      * @param statementParserMode mode of statement parser
-     * @param sources YIN sources to be parsed
+     * @param sources sources to be parsed
      *
      * @return effective schema context
-     *
-     * @throws ReactorException if there is an error in one of the parsed YIN sources
      */
-    public static SchemaContext parseYinSources(final Set<QName> supportedFeatures,
-            final StatementParserMode statementParserMode, final YinStatementStreamSource... sources)
-                    throws ReactorException {
+    public static SchemaContext parseSources(final Set<QName> supportedFeatures,
+            final StatementParserMode statementParserMode, final Collection<? extends StatementStreamSource> sources) {
         final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(
-                statementParserMode, supportedFeatures);
+                statementParserMode);
+        if (supportedFeatures != null) {
+            reactor.setSupportedFeatures(supportedFeatures);
+        }
         reactor.addSources(sources);
 
-        return reactor.buildEffective();
+        try {
+            return reactor.buildEffective();
+        } catch (ReactorException e) {
+            throw new IllegalStateException(e);
+        }
     }
 
-    private static Collection<File> getYangFiles(final String yangSourcesDirectoryPath) throws URISyntaxException {
-        final URI directoryPath = YangParserTestUtils.class.getResource(yangSourcesDirectoryPath).toURI();
-        final File dir = new File(directoryPath);
-
-        return Arrays.asList(dir.listFiles(YANG_FILE_FILTER));
+    private static Collection<File> getYangFiles(final String resourcePath) {
+        final URI directoryPath;
+        try {
+            directoryPath = YangParserTestUtils.class.getResource(resourcePath).toURI();
+        } catch (URISyntaxException e) {
+            throw new IllegalArgumentException("Failed to open resource directory " + resourcePath, e);
+        }
+        return Arrays.asList(new File(directoryPath).listFiles(YANG_FILE_FILTER));
     }
 }