Bug 7159: Add yang-test-util artifact 29/49129/2
authorIgor Foltin <ifoltin@cisco.com>
Thu, 8 Dec 2016 07:46:22 +0000 (08:46 +0100)
committerIgor Foltin <ifoltin@cisco.com>
Fri, 9 Dec 2016 08:48:30 +0000 (09:48 +0100)
This patch introduces a new artifact called yang-test-util which
provides a utility class with convenience methods for producing
effective schema context based on the supplied yang/yin sources
or paths to these sources.

Converted all places to use these helper methods

Change-Id: I49cb3f0df8bdbcf562f68bf600e8e4dd49cfe4f2
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
70 files changed:
common/artifacts/pom.xml
yang-validation-tool/pom.xml
yang-validation-tool/src/main/java/org/opendaylight/yangtools/yang/validation/tool/Main.java
yang-validation-tool/src/main/java/org/opendaylight/yangtools/yang/validation/tool/TestUtils.java [deleted file]
yang/pom.xml
yang/yang-data-codec-gson/pom.xml
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/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/TestUtils.java
yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/YangModeledAnyXmlSupportTest.java
yang/yang-data-codec-xml/pom.xml
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/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/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/pom.xml
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/TestUtils.java [deleted file]
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/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/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/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/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/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/pom.xml
yang/yang-data-jaxen/src/test/java/org/opendaylight/yangtools/yang/data/jaxen/JaxenTest.java
yang/yang-data-jaxen/src/test/java/org/opendaylight/yangtools/yang/data/jaxen/TestUtils.java
yang/yang-maven-plugin/pom.xml
yang/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/YangToSourcesProcessor.java
yang/yang-maven-plugin/src/test/java/org/opendaylight/yangtools/yang2sources/plugin/UtilTest.java
yang/yang-model-export/pom.xml
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/SchemaContextEmitterTest.java
yang/yang-model-export/src/test/java/org/opendaylight/yangtools/yang/model/export/test/StmtTestUtils.java [deleted file]
yang/yang-system-test/pom.xml
yang/yang-system-test/src/main/java/org/opendaylight/yangtools/yang/parser/system/test/Main.java
yang/yang-system-test/src/main/java/org/opendaylight/yangtools/yang/parser/system/test/YangParserUtils.java [deleted file]
yang/yang-test-util/pom.xml [new file with mode: 0644]
yang/yang-test-util/src/main/java/org/opendaylight/yangtools/yang/test/util/YangParserTestUtils.java [new file with mode: 0644]

index d9d64f7d9d54ab1913b85b999053591402de10a2..fdfa06544e9e16f3063dc9711a5c5e8bb27b1287 100644 (file)
                 <artifactId>yang-parser-impl</artifactId>
                 <version>${project.version}</version>
             </dependency>
+            <dependency>
+                <groupId>org.opendaylight.yangtools</groupId>
+                <artifactId>yang-test-util</artifactId>
+                <version>${project.version}</version>
+                <scope>test</scope>
+            </dependency>
             <dependency>
                 <groupId>org.opendaylight.yangtools</groupId>
                 <artifactId>yang-maven-plugin</artifactId>
index c651f65482e022e6ad5349d23349b8a8661cf8c7..9c263c9f2275ee6604d6f55271875541238c8509 100644 (file)
@@ -36,7 +36,8 @@
     <dependencies>
         <dependency>
             <groupId>org.opendaylight.yangtools</groupId>
-            <artifactId>yang-parser-impl</artifactId>
+            <artifactId>yang-test-util</artifactId>
+            <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>net.sourceforge.argparse4j</groupId>
index c3a48843bc21cbfc2e7592ba4c461b7f0820a0e9..5eab866e83d9bf135810a3ccce916d3429c8d0c4 100644 (file)
@@ -10,6 +10,7 @@ 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;
 
@@ -27,7 +28,7 @@ public final class Main {
             final File[] yangModels = params.getYangSourceDir().listFiles();
 
             try {
-                TestUtils.parseYangSources(Arrays.asList(yangModels));
+                YangParserTestUtils.parseYangSources(Arrays.asList(yangModels));
             } catch (Exception e) {
                 LOG.error("Yang files could not be parsed.", e);
             }
diff --git a/yang-validation-tool/src/main/java/org/opendaylight/yangtools/yang/validation/tool/TestUtils.java b/yang-validation-tool/src/main/java/org/opendaylight/yangtools/yang/validation/tool/TestUtils.java
deleted file mode 100644 (file)
index 50931e1..0000000
+++ /dev/null
@@ -1,55 +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.validation.tool;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.util.Collection;
-
-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.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;
-
-public class TestUtils {
-
-    private TestUtils() {
-        throw new UnsupportedOperationException("Utility class");
-    }
-
-    public static SchemaContext parseYangSources(StatementStreamSource... sources) throws SourceException,
-            ReactorException {
-
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        reactor.addSources(sources);
-
-        return reactor.buildEffective();
-    }
-
-    public static SchemaContext parseYangSources(File... files) throws SourceException, ReactorException,
-            FileNotFoundException {
-
-        StatementStreamSource[] sources = new StatementStreamSource[files.length];
-
-        for (int i = 0; i < files.length; i++) {
-            sources[i] = new YangStatementSourceImpl(new FileInputStream(files[i]));
-        }
-
-        return parseYangSources(sources);
-    }
-
-    public static SchemaContext parseYangSources(Collection<File> files) throws SourceException, ReactorException,
-            FileNotFoundException {
-        return parseYangSources(files.toArray(new File[files.size()]));
-    }
-}
index 6e28450651cf97e416d30fd00363ade92b63d8f0..e52383c526c3a6b1a18462b373d0a98596b8f3bf 100644 (file)
@@ -40,6 +40,7 @@
         <module>yang-model-export</module>
         <module>yang-data-jaxen</module>
         <module>yang-system-test</module>
+        <module>yang-test-util</module>
     </modules>
     <build>
         <plugins>
index 9f2b78241eab58aab11dfbca27430f9b2d02ce65..7763d390e0ac9841b06ea9f95dc1cbfd5703e6b1 100644 (file)
             <artifactId>yang-parser-impl</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-test-util</artifactId>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
index 7fc8f04fb4395e83528b90f09322f78bc40a15bb..1cc22e3ca76b59dcbf84a06a3f91954e12cf42df 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.yangtools.yang.data.codec.gson;
 
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
-import static org.opendaylight.yangtools.yang.data.codec.gson.TestUtils.loadModules;
 import static org.opendaylight.yangtools.yang.data.codec.gson.TestUtils.loadTextFile;
 
 import com.google.gson.JsonElement;
@@ -39,6 +38,7 @@ 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;
 import org.w3c.dom.Text;
@@ -54,7 +54,7 @@ public class AnyXmlSupportTest {
 
     @BeforeClass
     public static void setup() throws IOException, URISyntaxException, ReactorException {
-        schemaContext = loadModules("/complexjson/yang");
+        schemaContext = YangParserTestUtils.parseYangSources("/complexjson/yang");
     }
 
     @Test
index b95f5cc7363b80afcbac372fc80546002c7a9d4e..273238c2cf114be655092c3f1ad10c414d7f2025 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.yangtools.yang.data.codec.gson;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
-import static org.opendaylight.yangtools.yang.data.codec.gson.TestUtils.loadModules;
 import static org.opendaylight.yangtools.yang.data.codec.gson.TestUtils.loadTextFile;
 
 import com.google.common.base.Optional;
@@ -32,6 +31,7 @@ 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.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class Bug4501Test {
 
@@ -39,7 +39,7 @@ public class Bug4501Test {
 
     @BeforeClass
     public static void initialization() throws IOException, URISyntaxException, ReactorException {
-        schemaContext = loadModules("/bug-4501/yang");
+        schemaContext = YangParserTestUtils.parseYangSources("/bug-4501/yang");
     }
 
     @Test
index 2a3a1d5a221e5852af66014bb8ba16a95ade4bb5..32ac33c24891097052824e4bc0bcc34611af06a9 100644 (file)
@@ -30,13 +30,14 @@ 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 = TestUtils.parseYangSources(sourceDir.listFiles());
+        SchemaContext context = YangParserTestUtils.parseYangSources(sourceDir.listFiles());
         assertNotNull(context);
 
         verifyNormalizedNodeResult(context);
@@ -95,7 +96,7 @@ public class Bug4969Test {
     @Test
     public void newParserLeafRefTest2() throws SourceException, ReactorException, URISyntaxException, IOException {
         File sourceDir = new File(Bug4969Test.class.getResource("/leafref/yang").toURI());
-        SchemaContext context = TestUtils.parseYangSources(sourceDir.listFiles());
+        SchemaContext context = YangParserTestUtils.parseYangSources(sourceDir.listFiles());
         assertNotNull(context);
 
         parseJsonToNormalizedNodes(context);
index a765cdef2fb38a470a4de396cb7ec3bca54c9706..116080fab1022635d964b7d9b34228fadfa1dbbd 100644 (file)
@@ -38,6 +38,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class Bug5446Test {
 
@@ -53,8 +54,8 @@ public class Bug5446Test {
         rootQName = QName.create(fooModuleQName, "root");
         ipAddressQName = QName.create(fooModuleQName, "ip-address");
 
-        schemaContext = TestUtils.parseYangSources(new File(Bug5446Test.class.getResource("/bug5446/yang/foo.yang")
-                .toURI()));
+        schemaContext = YangParserTestUtils.parseYangSources(
+                new File(Bug5446Test.class.getResource("/bug5446/yang/foo.yang").toURI()));
     }
 
     @Test
index 342e89911ac05ea6472b1358dc48e36db331182b..bbc0a07b6f32bbe51e94316ee45b966ef53c34d8 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.yangtools.yang.data.codec.gson;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
-import static org.opendaylight.yangtools.yang.data.codec.gson.TestUtils.loadModules;
 import static org.opendaylight.yangtools.yang.data.codec.gson.TestUtils.loadTextFile;
 
 import com.google.common.base.Optional;
@@ -30,13 +29,14 @@ 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.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 = loadModules("/bug-6112/yang");
+        schemaContext = YangParserTestUtils.parseYangSources("/bug-6112/yang");
     }
 
     private NormalizedNode<?, ?> readJson(final String jsonPath) throws IOException, URISyntaxException {
index 96bb518cbd337e6a5e96afa04282cd6e38f0a5f4..5ab681dc290ed29a6282ebf4edf2bb9ce7f17d00 100644 (file)
@@ -11,7 +11,6 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-import static org.opendaylight.yangtools.yang.data.codec.gson.TestUtils.loadModules;
 import static org.opendaylight.yangtools.yang.data.codec.gson.TestUtils.loadTextFile;
 import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.augmentationBuilder;
 import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.choiceBuilder;
@@ -35,6 +34,7 @@ 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;
 
 /**
  *
@@ -48,7 +48,7 @@ public class JsonStreamToNormalizedNodeTest {
 
     @BeforeClass
     public static void initialization() throws IOException, URISyntaxException, ReactorException {
-        schemaContext = loadModules("/complexjson/yang");
+        schemaContext = YangParserTestUtils.parseYangSources("/complexjson/yang");
     }
 
     @Test
index dd866c4b2fe9b54721cf959adbebc0abe32f317b..6777a4b05e5650487bc1bd30ad36607d58932721 100644 (file)
@@ -13,7 +13,6 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.opendaylight.yangtools.yang.data.codec.gson.TestUtils.childArray;
 import static org.opendaylight.yangtools.yang.data.codec.gson.TestUtils.childPrimitive;
-import static org.opendaylight.yangtools.yang.data.codec.gson.TestUtils.loadModules;
 import static org.opendaylight.yangtools.yang.data.codec.gson.TestUtils.resolveCont1;
 import com.google.common.collect.Sets;
 import com.google.gson.JsonArray;
@@ -40,6 +39,7 @@ 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;
 
 /**
  * Each test tests whether json output obtained after transformation contains is corect. The transformation takes
@@ -59,7 +59,7 @@ public class NormalizedNodeToJsonStreamTest {
 
     @BeforeClass
     public static void initialization() throws IOException, URISyntaxException, ReactorException {
-        schemaContext = loadModules("/complexjson/yang");
+        schemaContext = YangParserTestUtils.parseYangSources("/complexjson/yang");
     }
 
     @Test
index 28db132ffe37df5cbd974574404676c7eb5ed135..7af0cb752a8ea2f41b0e956d2c40a516c797e387 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.yangtools.yang.data.codec.gson;
 
-import static org.opendaylight.yangtools.yang.data.codec.gson.TestUtils.loadModules;
 import static org.opendaylight.yangtools.yang.data.codec.gson.TestUtils.loadTextFile;
 
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
@@ -31,6 +30,7 @@ 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.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -41,7 +41,7 @@ public class StreamToNormalizedNodeTest {
 
     @BeforeClass
     public static void initialization() throws IOException, URISyntaxException, ReactorException {
-        schemaContext = loadModules("/complexjson/yang");
+        schemaContext = YangParserTestUtils.parseYangSources("/complexjson/yang");
         streamAsString = loadTextFile(new File(StreamToNormalizedNodeTest.class.getResource(
                 "/complexjson/complex-json.json").toURI()));
     }
index e9105db7b93f8e7f243ad5e35d6ec52c6f2781c2..b98566e140562b5242734fe64691669286189a3c 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.yangtools.yang.data.codec.gson;
 
 import static org.junit.Assert.assertTrue;
+
 import com.google.gson.JsonArray;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
@@ -15,80 +16,15 @@ import com.google.gson.JsonParser;
 import com.google.gson.JsonPrimitive;
 import java.io.BufferedReader;
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
 import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.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.YangStatementSourceImpl;
 
 public class TestUtils {
 
     private TestUtils() {
     }
 
-    static SchemaContext loadModules(final String resourceDirectory) throws IOException, URISyntaxException,
-            ReactorException {
-        URI path = StreamToNormalizedNodeTest.class.getResource(resourceDirectory).toURI();
-        final File testDir = new File(path);
-        final String[] fileList = testDir.list();
-        final List<File> testFiles = new ArrayList<>();
-        if (fileList == null) {
-            throw new FileNotFoundException(resourceDirectory);
-        }
-        for (String fileName : fileList) {
-            if (!new File(testDir, fileName).isDirectory()) {
-                testFiles.add(new File(testDir, fileName));
-            }
-        }
-        return parseYangSources(testFiles);
-    }
-
-    public static SchemaContext parseYangSources(StatementStreamSource... sources)
-            throws SourceException, ReactorException {
-
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
-                .newBuild();
-        reactor.addSources(sources);
-
-        return reactor.buildEffective();
-    }
-
-    public static SchemaContext parseYangSources(File... files) throws SourceException, ReactorException, FileNotFoundException {
-
-        StatementStreamSource[] sources = new StatementStreamSource[files.length];
-
-        for (int i = 0; i<files.length; i++) {
-            sources[i] = new YangStatementSourceImpl(new FileInputStream(files[i]));
-        }
-
-        return parseYangSources(sources);
-    }
-
-    public static SchemaContext parseYangSources(Collection<File> files) throws SourceException, ReactorException, FileNotFoundException {
-        return parseYangSources(files.toArray(new File[files.size()]));
-    }
-
-
-    public static SchemaContext parseYangStreams(List<InputStream> streams)
-            throws SourceException, ReactorException {
-
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
-                .newBuild();
-        return reactor.buildEffective(streams);
-    }
-
     static String loadTextFile(final File file) throws IOException {
         FileReader fileReader = new FileReader(file);
         BufferedReader bufReader = new BufferedReader(fileReader);
index fc93965366673737df96e0c91683dec708b38a5f..889a9bfe6cb8c45263b9e74720c8ec945957fce0 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.yangtools.yang.data.codec.gson;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
-import static org.opendaylight.yangtools.yang.data.codec.gson.TestUtils.loadModules;
 import static org.opendaylight.yangtools.yang.data.codec.gson.TestUtils.loadTextFile;
 
 import com.google.gson.JsonElement;
@@ -42,6 +41,7 @@ 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.xml.sax.SAXException;
 
 public class YangModeledAnyXmlSupportTest {
@@ -52,7 +52,7 @@ public class YangModeledAnyXmlSupportTest {
     @BeforeClass
     public static void init() throws IOException, URISyntaxException, ReactorException, SAXException,
             XMLStreamException, ParserConfigurationException {
-        schemaContext = loadModules("/yang-modeled-anyxml/yang");
+        schemaContext = YangParserTestUtils.parseYangSources("/yang-modeled-anyxml/yang");
 
         final InputStream resourceAsStream = YangModeledAnyXmlSupportTest.class.getResourceAsStream(
                 "/yang-modeled-anyxml/xml/baz.xml");
index ec4ba7431ff8c48fa3269f8f50dfa527ce71f96a..a497624eb3dc622fdadff55b44466b64daba194e 100644 (file)
             <artifactId>yang-parser-impl</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-test-util</artifactId>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
index b6ffc06dfb7be98194d88abb703976dd24779bbf..3db72a8cbc7df3f83972ab2a624de031d856e264 100644 (file)
@@ -32,9 +32,8 @@ 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.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.test.util.YangParserTestUtils;
 
 public class Bug5396Test {
 
@@ -45,10 +44,7 @@ public class Bug5396Test {
     public void Init() throws Exception {
         fooModuleQName = QNameModule.create(new URI("foo"), SimpleDateFormatUtil.getRevisionFormat().parse("2016-03-22"));
 
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        reactor.addSource(new YangStatementSourceImpl("/bug5396/yang/foo.yang", false));
-
-        schemaContext = reactor.buildEffective();
+        schemaContext = YangParserTestUtils.parseYangSources(new YangStatementSourceImpl("/bug5396/yang/foo.yang", false));
     }
 
     @Test
index 5838a44eba80a6c11798ed976efc9a665a94b8e0..e51888885ba638d4a2ae4f77cd193a229a7b815c 100644 (file)
@@ -46,9 +46,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWrit
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-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.test.util.YangParserTestUtils;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 import org.xml.sax.SAXException;
@@ -79,10 +78,7 @@ public class Bug5446Test extends XMLTestCase {
         rootQName = QName.create(fooModuleQName, "root");
         ipAddressQName = QName.create(fooModuleQName, "ip-address");
 
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        reactor.addSource(new YangStatementSourceImpl("/bug5446/yang/foo.yang", false));
-
-        schemaContext = reactor.buildEffective();
+        schemaContext = YangParserTestUtils.parseYangSources(new YangStatementSourceImpl("/bug5446/yang/foo.yang", false));
     }
 
     @Test
index 07ca9443e6bc14e545031ee77d2a711aca544fa9..dff1e6dff0a59b5cadf3bca373f9eec4625d8e58 100644 (file)
@@ -77,9 +77,8 @@ 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.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.test.util.YangParserTestUtils;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 import org.xml.sax.SAXException;
@@ -271,9 +270,7 @@ public class NormalizedNodeXmlTranslationTest {
     private final String xmlPath;
 
     private SchemaContext parseTestSchema(final String yangPath) throws ReactorException {
-        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        reactor.addSource(new YangStatementSourceImpl(yangPath, false));
-        return reactor.buildEffective();
+        return YangParserTestUtils.parseYangSources(new YangStatementSourceImpl(yangPath, false));
     }
 
     @Test
index 1e0e68dfbe9e91b47fe6dccd8d46ce63dc48c22f..6b2ecc48741adb41d7a20d0c352c0a52f06fdd62 100644 (file)
@@ -58,9 +58,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWrit
 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.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.test.util.YangParserTestUtils;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 import org.xml.sax.SAXException;
@@ -124,10 +123,7 @@ public class NormalizedNodesToXmlTest {
     @Test
     public void testNormalizedNodeToXmlSerialization() throws ReactorException, XMLStreamException, IOException,
             SAXException {
-        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        reactor.addSource(new YangStatementSourceImpl("/baz.yang", false));
-
-        final SchemaContext schemaContext = reactor.buildEffective();
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangSources(new YangStatementSourceImpl("/baz.yang", false));
 
         final Document doc = loadDocument("/baz.xml");
 
index 3f04e985f83e3eb4d489b26abddc3301768a4d37..da670a9bff0345a9bfc4f51276869129cf3bc694 100644 (file)
@@ -45,9 +45,8 @@ import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
 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.test.util.YangParserTestUtils;
 import org.w3c.dom.Document;
 
 public class XmlStreamUtilsTest {
@@ -59,10 +58,7 @@ public class XmlStreamUtilsTest {
 
     @BeforeClass
     public static void initialize() throws URISyntaxException, FileNotFoundException, ReactorException {
-        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        reactor.addSource(new YangStatementSourceImpl("/leafref-test.yang", false));
-
-        schemaContext = reactor.buildEffective();
+        schemaContext = YangParserTestUtils.parseYangSources(new YangStatementSourceImpl("/leafref-test.yang", false));
         assertNotNull(schemaContext);
         assertEquals(1, schemaContext.getModules().size());
         leafRefModule = schemaContext.getModules().iterator().next();
index e6be618dd392dea8df4a796fb339f7bbef71464e..9776bc49e51d0ea2692c6224131a6dd6826168b3 100644 (file)
@@ -47,9 +47,8 @@ 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.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.test.util.YangParserTestUtils;
 import org.xml.sax.SAXException;
 
 public class XmlToNormalizedNodesTest {
@@ -111,10 +110,7 @@ public class XmlToNormalizedNodesTest {
     @Test
     public void testComplexXmlParsing() throws IOException, URISyntaxException, ReactorException, XMLStreamException,
             ParserConfigurationException, SAXException {
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        reactor.addSource(new YangStatementSourceImpl("/baz.yang", false));
-
-        SchemaContext schemaContext = reactor.buildEffective();
+        SchemaContext schemaContext = YangParserTestUtils.parseYangSources(new YangStatementSourceImpl("/baz.yang", false));
 
         final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/baz.xml");
 
@@ -142,10 +138,7 @@ public class XmlToNormalizedNodesTest {
     @Test
     public void testSimpleXmlParsing() throws IOException, URISyntaxException, ReactorException, XMLStreamException,
             ParserConfigurationException, SAXException {
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        reactor.addSource(new YangStatementSourceImpl("/foo.yang", false));
-
-        SchemaContext schemaContext = reactor.buildEffective();
+        SchemaContext schemaContext = YangParserTestUtils.parseYangSources(new YangStatementSourceImpl("/foo.yang", false));
 
         final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/foo.xml");
 
@@ -165,10 +158,7 @@ public class XmlToNormalizedNodesTest {
     @Test
     public void shouldFailOnDuplicateLeaf() throws ReactorException, XMLStreamException, IOException,
             ParserConfigurationException, SAXException, URISyntaxException {
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        reactor.addSource(new YangStatementSourceImpl("/foo.yang", false));
-
-        SchemaContext schemaContext = reactor.buildEffective();
+        SchemaContext schemaContext = YangParserTestUtils.parseYangSources(new YangStatementSourceImpl("/foo.yang", false));
 
         final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/invalid-foo.xml");
 
@@ -191,10 +181,7 @@ public class XmlToNormalizedNodesTest {
     @Test
     public void shouldFailOnDuplicateAnyXml() throws ReactorException, XMLStreamException, IOException,
             ParserConfigurationException, SAXException, URISyntaxException {
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        reactor.addSource(new YangStatementSourceImpl("/foo.yang", false));
-
-        SchemaContext schemaContext = reactor.buildEffective();
+        SchemaContext schemaContext = YangParserTestUtils.parseYangSources(new YangStatementSourceImpl("/foo.yang", false));
 
         final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/invalid-foo-2.xml");
 
@@ -216,10 +203,7 @@ public class XmlToNormalizedNodesTest {
     @Test
     public void shouldFailOnDuplicateContainer() throws ReactorException, XMLStreamException, IOException,
             ParserConfigurationException, SAXException, URISyntaxException {
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        reactor.addSource(new YangStatementSourceImpl("/foo.yang", false));
-
-        SchemaContext schemaContext = reactor.buildEffective();
+        SchemaContext schemaContext = YangParserTestUtils.parseYangSources(new YangStatementSourceImpl("/foo.yang", false));
 
         final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/invalid-foo-3.xml");
 
@@ -241,10 +225,7 @@ public class XmlToNormalizedNodesTest {
     @Test
     public void shouldFailOnUnterminatedLeafElement() throws ReactorException, XMLStreamException, IOException,
             ParserConfigurationException, SAXException, URISyntaxException {
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        reactor.addSource(new YangStatementSourceImpl("/baz.yang", false));
-
-        SchemaContext schemaContext = reactor.buildEffective();
+        SchemaContext schemaContext = YangParserTestUtils.parseYangSources(new YangStatementSourceImpl("/baz.yang", false));
 
         final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/invalid-baz.xml");
 
@@ -267,10 +248,7 @@ public class XmlToNormalizedNodesTest {
     @Test
     public void shouldFailOnUnterminatedLeafElement2() throws ReactorException, XMLStreamException, IOException,
             ParserConfigurationException, SAXException, URISyntaxException {
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        reactor.addSource(new YangStatementSourceImpl("/baz.yang", false));
-
-        SchemaContext schemaContext = reactor.buildEffective();
+        SchemaContext schemaContext = YangParserTestUtils.parseYangSources(new YangStatementSourceImpl("/baz.yang", false));
 
         final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/invalid-baz-2.xml");
 
@@ -293,10 +271,7 @@ public class XmlToNormalizedNodesTest {
     @Test
     public void shouldFailOnUnterminatedContainerElement() throws ReactorException, XMLStreamException, IOException,
             ParserConfigurationException, SAXException, URISyntaxException {
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        reactor.addSource(new YangStatementSourceImpl("/baz.yang", false));
-
-        SchemaContext schemaContext = reactor.buildEffective();
+        SchemaContext schemaContext = YangParserTestUtils.parseYangSources(new YangStatementSourceImpl("/baz.yang", false));
 
         final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/invalid-baz-4.xml");
 
@@ -319,10 +294,7 @@ public class XmlToNormalizedNodesTest {
     @Test
     public void shouldFailOnUnexistingContainerElement() throws ReactorException, XMLStreamException, IOException,
             ParserConfigurationException, SAXException, URISyntaxException {
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        reactor.addSource(new YangStatementSourceImpl("/baz.yang", false));
-
-        SchemaContext schemaContext = reactor.buildEffective();
+        SchemaContext schemaContext = YangParserTestUtils.parseYangSources(new YangStatementSourceImpl("/baz.yang", false));
 
         final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/invalid-baz-3.xml");
 
index aae76bf455fdf2a41e42481b537b9af1c42947f4..1aa608eefe24faac5f6183679af2974b23a7a1bc 100644 (file)
@@ -43,9 +43,7 @@ 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.api.YangModeledAnyXmlSchemaNode;
-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.test.util.YangParserTestUtils;
 
 public class YangModeledAnyXMLDeserializationTest {
 
@@ -77,12 +75,7 @@ public class YangModeledAnyXMLDeserializationTest {
         myLeaf2 = QName.create(fooModuleQName, "my-leaf-2");
         myAnyXMLDataFoo = QName.create(fooModuleQName, "my-anyxml-data");
 
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        reactor.addSources(new YangStatementSourceImpl("/anyxml-support/yang/foo.yang", false),
-                new YangStatementSourceImpl("/anyxml-support/yang/bar.yang", false),
-                new YangStatementSourceImpl("/anyxml-support/yang/yang-ext.yang", false));
-
-        schemaContext = reactor.buildEffective();
+        schemaContext = YangParserTestUtils.parseYangSources("/anyxml-support/yang");
     }
 
     @Test
index 32a43aa8a60e1b5b91488f34efa9e19a14e1e289..49a9c72f08da9d3cd657ad20977e34220dc87cda 100644 (file)
@@ -51,9 +51,7 @@ 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.util.SchemaContextUtil;
-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.test.util.YangParserTestUtils;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 import org.xml.sax.SAXException;
@@ -82,10 +80,7 @@ public class YangModeledAnyXMLSerializationTest extends XMLTestCase {
         myContainer2QName = QName.create(bazModuleQName, "my-container-2");
         myAnyXMLDataBaz = QName.create(bazModuleQName, "my-anyxml-data");
 
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        reactor.addSources(new YangStatementSourceImpl("/anyxml-support/serialization/baz.yang", false),
-                new YangStatementSourceImpl("/anyxml-support/serialization/yang-ext.yang", false));
-        schemaContext = reactor.buildEffective();
+        schemaContext = YangParserTestUtils.parseYangSources("/anyxml-support/serialization");
     }
 
     @Test
index f20d8504c99493dbb3444627d92bc827e81ed859..58f8b520f9e84ee4212cd5e439deaa75fdb13fef 100644 (file)
             <artifactId>yang-parser-impl</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>yang-test-util</artifactId>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>commons-lang</groupId>
             <artifactId>commons-lang</artifactId>
diff --git a/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/TestUtils.java b/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/TestUtils.java
deleted file mode 100644 (file)
index a09f17d..0000000
+++ /dev/null
@@ -1,64 +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.data.impl;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.List;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.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.YangStatementSourceImpl;
-
-public class TestUtils {
-
-    private TestUtils() {
-        throw new UnsupportedOperationException("Utility class");
-    }
-
-    public static SchemaContext parseYangSources(StatementStreamSource... sources) throws SourceException,
-            ReactorException {
-
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        reactor.addSources(sources);
-
-        return reactor.buildEffective();
-    }
-
-    public static SchemaContext parseYangSources(File... files) throws SourceException, ReactorException,
-            FileNotFoundException {
-
-        StatementStreamSource[] sources = new StatementStreamSource[files.length];
-
-        for (int i = 0; i < files.length; i++) {
-            sources[i] = new YangStatementSourceImpl(new FileInputStream(files[i]));
-        }
-
-        return parseYangSources(sources);
-    }
-
-    public static SchemaContext parseYangSources(Collection<File> files) throws SourceException, ReactorException,
-            FileNotFoundException {
-        return parseYangSources(files.toArray(new File[files.size()]));
-    }
-
-    public static SchemaContext parseYangStreams(List<InputStream> streams)
-            throws SourceException, ReactorException {
-
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
-                .newBuild();
-        return reactor.buildEffective(streams);
-    }
-}
index b432d96f4ff9f4416c5afe1619098065fc6867b8..8cfc79f2920c08a92ea80358e275e0aa06ba571c 100644 (file)
@@ -24,13 +24,13 @@ import javax.xml.parsers.ParserConfigurationException;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.impl.TestUtils;
 import org.opendaylight.yangtools.yang.data.impl.schema.transform.dom.DomUtils;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 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.test.util.YangParserTestUtils;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.xml.sax.SAXException;
@@ -61,7 +61,7 @@ public class Bug2964Test {
     @Before
     public void setUp() throws Exception {
         final File leafRefTestYang = new File(getClass().getResource("/leafref-test.yang").toURI());
-        schema = TestUtils.parseYangSources(leafRefTestYang);
+        schema = YangParserTestUtils.parseYangSources(leafRefTestYang);
     }
 
     public static Document readXmlToDocument(final String xmlContent) throws SAXException, IOException {
index 935947f9f6187de022b5ee3d75dff06f986ba222..4bf8e35875cb0dfd40befda640fac54c1df8fcf3 100644 (file)
@@ -19,9 +19,9 @@ import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.impl.TestUtils;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
@@ -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 = TestUtils.parseYangSources(rpcTestYang);
+        this.schemaContext = YangParserTestUtils.parseYangSources(rpcTestYang);
 
         final YangInstanceIdentifier.NodeIdentifier container = new YangInstanceIdentifier.NodeIdentifier(
                 QName.create(InstanceIdentifierForXmlCodecTest.NS, InstanceIdentifierForXmlCodecTest.REVISION, "cont"));
index 0324bb45ae6c7f0dadc0fa4a8bfb909da124a90d..72c6246f0a29f08d228ce44b213228bba62c36ee 100644 (file)
@@ -33,7 +33,6 @@ import org.opendaylight.yangtools.yang.data.api.ModifyAction;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.impl.TestUtils;
 import org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodec;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
@@ -43,6 +42,7 @@ import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.xml.sax.SAXException;
@@ -80,7 +80,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 = TestUtils.parseYangSources(rpcTestYang1, rpcTestYang2);
+        this.schema = YangParserTestUtils.parseYangSources(rpcTestYang1, rpcTestYang2);
     }
 
     public static Document readXmlToDocument(final String xmlContent) throws SAXException, IOException {
index 06e5764f13b8edc036e044466f7d7b1160e2c350..32965e2dcc4b651fccbf9ac2f78e8c02d2c68996 100644 (file)
@@ -35,7 +35,6 @@ import org.junit.Ignore;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.data.impl.TestUtils;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
@@ -47,6 +46,7 @@ import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.w3c.dom.Document;
 
 public class XmlStreamUtilsTest {
@@ -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 = TestUtils.parseYangSources(file);
+        schemaContext = YangParserTestUtils.parseYangSources(file);
         assertNotNull(schemaContext);
         assertEquals(1, schemaContext.getModules().size());
         leafRefModule = schemaContext.getModules().iterator().next();
index cfbd0fd35d3540b0d9d932e7ccd43e61907f04ce..3528902bea878299652dd2f2e71fcd7df18adb79 100644 (file)
@@ -21,7 +21,6 @@ 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.data.impl.TestUtils;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
@@ -29,6 +28,7 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
 import org.opendaylight.yangtools.yang.data.api.codec.StringCodec;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -40,7 +40,7 @@ public class StringPatternCheckingCodecTest {
 
     @Test
     public void testStringPatternCheckingCodec() throws ReactorException, ParseException, URISyntaxException {
-        SchemaContext schemaContext = TestUtils.parseYangSources(TEST_MODULE);
+        SchemaContext schemaContext = YangParserTestUtils.parseYangSources(TEST_MODULE);
         assertNotNull(schemaContext);
 
         QNameModule testModuleQName = QNameModule.create(new URI("string-pattern-checking-codec-test"),
index e9e08bf39820ab40cde3e45bc59adab31e40cba6..ac6a35f389394fa6154ac2c8041dfec6e5ec92b7 100644 (file)
@@ -36,7 +36,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
-import org.opendaylight.yangtools.yang.data.impl.TestUtils;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefContext;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefDataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefValidatation;
@@ -53,6 +52,7 @@ 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;
 
@@ -122,7 +122,7 @@ public class DataTreeCandidateValidatorTest {
                 .toURI());
         final File resourceDir = resourceFile.getParentFile();
 
-        context = TestUtils.parseYangSources(Arrays.asList(resourceDir
+        context = YangParserTestUtils.parseYangSources(Arrays.asList(resourceDir
                 .listFiles()));
 
         final Set<Module> modules = context.getModules();
index 60d47246dff0440eeb56c46cdc7862d4a251f267..9f0f0b31365b28c50540c3d65b9d71086b074aa3 100644 (file)
@@ -30,7 +30,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
-import org.opendaylight.yangtools.yang.data.impl.TestUtils;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefContext;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefDataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefValidatation;
@@ -44,6 +43,7 @@ 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;
 
@@ -159,7 +159,7 @@ public class DataTreeCandidateValidatorTest2 {
                 "/leafref-validation/leafref-validation2.yang").toURI());
         final File resourceDir = resourceFile.getParentFile();
 
-        context = TestUtils.parseYangSources(Arrays.asList(resourceDir.listFiles()));
+        context = YangParserTestUtils.parseYangSources(Arrays.asList(resourceDir.listFiles()));
 
         final Set<Module> modules = context.getModules();
         for (final Module module : modules) {
index 82906f25681cf5d12287f8c47c399f7e2c29b8db..7aca4447d257485a2de33d6f91ce5cd261de3722 100644 (file)
@@ -30,7 +30,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
-import org.opendaylight.yangtools.yang.data.impl.TestUtils;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefContext;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefDataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefValidatation;
@@ -44,6 +43,7 @@ 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;
 
@@ -206,7 +206,7 @@ public class DataTreeCandidateValidatorTest3 {
                 "/leafref-validation/leafref-validation3.yang").toURI());
         final File resourceDir = resourceFile.getParentFile();
 
-        context = TestUtils.parseYangSources(Arrays.asList(resourceDir.listFiles()));
+        context = YangParserTestUtils.parseYangSources(Arrays.asList(resourceDir.listFiles()));
 
         final Set<Module> modules = context.getModules();
         for (final Module module : modules) {
index 097fa671f5d8a7e0fa700bc36f69851d69caa531..35c3bc44933d7b74c4942954110323923f17f603 100644 (file)
@@ -20,7 +20,6 @@ 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.data.impl.TestUtils;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefContext;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefContextUtils;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
@@ -28,6 +27,7 @@ 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 {
 
@@ -44,7 +44,7 @@ public class LeafRefContextTest {
 
         final File resourceDir = resourceFile.getParentFile();
 
-        context = TestUtils.parseYangSources(Arrays.asList(resourceDir.listFiles()));
+        context = YangParserTestUtils.parseYangSources(Arrays.asList(resourceDir.listFiles()));
 
         final Set<Module> modules = context.getModules();
         for (final Module module : modules) {
index c377a68e915ffa636bc7ae9a726d0f033caafc5d..9fb1add6bcab5dd66405194b2a34d960cefaae20 100644 (file)
@@ -23,7 +23,6 @@ import org.junit.Ignore;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.data.impl.TestUtils;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefContext;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefContextUtils;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
@@ -31,6 +30,7 @@ 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 {
 
@@ -47,7 +47,7 @@ public class LeafRefContextTreeBuilderTest {
                 "/leafref-context-test/correct-modules/leafref-test.yang").toURI());
         final File resourceDir = resourceFile.getParentFile();
 
-        context = TestUtils.parseYangSources(Arrays.asList(resourceDir.listFiles()));
+        context = YangParserTestUtils.parseYangSources(Arrays.asList(resourceDir.listFiles()));
 
         final Set<Module> modules = context.getModules();
         for (final Module module : modules) {
@@ -244,7 +244,7 @@ public class LeafRefContextTreeBuilderTest {
                 "/leafref-context-test/incorrect-modules/leafref-test.yang").toURI());
         final File resourceDir = resourceFile.getParentFile();
 
-        final SchemaContext context = TestUtils.parseYangSources(Arrays.asList(resourceDir.listFiles()));
+        final SchemaContext context = YangParserTestUtils.parseYangSources(Arrays.asList(resourceDir.listFiles()));
 
         LeafRefContext.create(context);
 
index 3fe28f79320373a155cb88de1b60a82874e05536..0c2c6e8c5081a92e1971a2ca5ba85fc63d31d8b3 100644 (file)
@@ -34,7 +34,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.OrderedLeafSetNode;
 import org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode;
-import org.opendaylight.yangtools.yang.data.impl.TestUtils;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.ListNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableAugmentationNodeBuilder;
@@ -64,6 +63,7 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.YangModeledAnyXmlSchemaNode;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ContainerEffectiveStatementImpl;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class BuilderTest {
     private static final QName ROOT_CONTAINER = QName.create("test.namespace.builder.test", "2016-01-01", "root-container");
@@ -92,7 +92,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 = TestUtils.parseYangSources(leafRefTestYang);
+        final SchemaContext schema = YangParserTestUtils.parseYangSources(leafRefTestYang);
         final Module module = schema.getModules().iterator().next();
         final DataSchemaNode root = module.getDataChildByName(ROOT_CONTAINER);
         list = (ListSchemaNode)((ContainerEffectiveStatementImpl) root).getDataChildByName(LIST_MAIN);
index d25c7d0f1dece9f219b0c4323a684b8ef13245f7..c362d44d3bdac7a774b0388b9dd2761eabd48acc 100644 (file)
@@ -25,9 +25,9 @@ import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
 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.data.impl.TestUtils;
 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 InstanceIdToNodesTest {
 
@@ -55,7 +55,7 @@ public class InstanceIdToNodesTest {
 
     static SchemaContext createTestContext() throws URISyntaxException, FileNotFoundException, ReactorException {
         final File resourceFile = new File(InstanceIdToNodesTest.class.getResource("/filter-test.yang").toURI());
-        return TestUtils.parseYangSources(resourceFile);
+        return YangParserTestUtils.parseYangSources(resourceFile);
     }
 
     @BeforeClass
index f11763ac8c05d1c7b09688feb4a5d8b565051fb4..5f373d1f6cfa5beeef948c9c66e69c5e8650f3c1 100644 (file)
@@ -30,7 +30,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
-import org.opendaylight.yangtools.yang.data.impl.TestUtils;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableChoiceNodeSchemaAwareBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapNodeSchemaAwareBuilder;
@@ -45,6 +44,7 @@ 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;
 
 public class NormalizedDataBuilderTest {
 
@@ -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 = TestUtils.parseYangSources(resourceFile);
+        schema = YangParserTestUtils.parseYangSources(resourceFile);
         containerNode = (ContainerSchemaNode) getSchemaNode(schema, "test", "container");
     }
 
index 1922cfa02b5af2dc38724e227f48d7416f107f76..88407f0d7f2935e6c95ea42411b8eec5e5173a62 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.yangtools.yang.data.impl.schema;
 
 import java.io.FileNotFoundException;
-import java.io.InputStream;
 import java.io.StringWriter;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
@@ -31,9 +30,7 @@ import org.opendaylight.yangtools.yang.data.impl.codec.xml.XMLStreamNormalizedNo
 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.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.test.util.YangParserTestUtils;
 
 public class SchemaOrderedNormalizedNodeWriterTest {
 
@@ -157,12 +154,7 @@ public class SchemaOrderedNormalizedNodeWriterTest {
     }
 
     private SchemaContext getSchemaContext(final String filePath) throws URISyntaxException, ReactorException, FileNotFoundException {
-        final InputStream resourceStream = getClass().getResourceAsStream(filePath);
-        final YangStatementSourceImpl source = new YangStatementSourceImpl(resourceStream);
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
-                .newBuild();
-        reactor.addSources(source);
-        return reactor.buildEffective();
+        return YangParserTestUtils.parseYangSource(filePath);
     }
 
     private static YangInstanceIdentifier.NodeIdentifier getNodeIdentifier(final String ns, final String name) {
index ef63edcc858919841b9bf26fd769d8ff783f4d49..c52f8e8c7a2032b33225462d7beee7a1438fa0f6 100644 (file)
@@ -15,7 +15,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode;
-import org.opendaylight.yangtools.yang.data.impl.TestUtils;
 import org.opendaylight.yangtools.yang.data.impl.schema.transform.ToNormalizedNodeParser;
 import org.opendaylight.yangtools.yang.data.impl.schema.transform.dom.DomUtils;
 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
@@ -23,6 +22,7 @@ import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.w3c.dom.Element;
 
 public class DomToNormalizedNodeParserFactoryTest {
@@ -31,7 +31,7 @@ public class DomToNormalizedNodeParserFactoryTest {
     public void testFactoryInstantiation() throws ReactorException {
         YangStatementSourceImpl foo = new YangStatementSourceImpl("/foo.yang", false);
 
-        SchemaContext schemaContext = TestUtils.parseYangSources(foo);
+        SchemaContext schemaContext = YangParserTestUtils.parseYangSources(foo);
 
         DomToNormalizedNodeParserFactory factory = DomToNormalizedNodeParserFactory.getInstance(
                 DomUtils.defaultValueCodecProvider(), schemaContext,
index 103adb2aa58c422fd88f76475ec8208c22f1aec3..ce7cb06befd77aaf08137ab3f723bb29bba3dc8f 100644 (file)
@@ -33,10 +33,10 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgum
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
-import org.opendaylight.yangtools.yang.data.impl.TestUtils;
 import org.opendaylight.yangtools.yang.data.impl.schema.transform.dom.DomUtils;
 import org.opendaylight.yangtools.yang.data.impl.schema.transform.dom.parser.DomToNormalizedNodeParserFactory;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.w3c.dom.Document;
 import org.xml.sax.SAXException;
 
@@ -64,7 +64,7 @@ public class Bug5396 {
         fooModuleQName = QNameModule.create(new URI("foo"), SimpleDateFormatUtil.getRevisionFormat()
                 .parse("2016-03-22"));
         root = QName.create(fooModuleQName, "root");
-        schemaContext = TestUtils
+        schemaContext = YangParserTestUtils
                 .parseYangSources(new File(getClass().getResource("/bug5396/yang/foo.yang").toURI()));
     }
 
index 79dbab92450abb6911ca95eb2a5709cf8bc453ec..0fb0511cb94c9bfef69e82961bac71183548effc 100644 (file)
@@ -43,12 +43,12 @@ import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
-import org.opendaylight.yangtools.yang.data.impl.TestUtils;
 import org.opendaylight.yangtools.yang.data.impl.codec.xml.XMLStreamNormalizedNodeStreamWriter;
 import org.opendaylight.yangtools.yang.data.impl.codec.xml.XmlDocumentUtils;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 import org.xml.sax.SAXException;
@@ -79,7 +79,7 @@ public class Bug5446Test extends XMLTestCase {
         rootQName = QName.create(fooModuleQName, "root");
         ipAddressQName = QName.create(fooModuleQName, "ip-address");
 
-        schemaContext = TestUtils.parseYangSources(new File(getClass().getResource("/bug5446/yang/foo.yang").toURI()));
+        schemaContext = YangParserTestUtils.parseYangSources(new File(getClass().getResource("/bug5446/yang/foo.yang").toURI()));
     }
 
     @Test
index 0950a1ab1250fb863da7acbe2c11bd90350bd434..a3a29fbce3b12d3715d14d765222c3646d73ac20 100644 (file)
@@ -24,7 +24,6 @@ import javax.xml.transform.stream.StreamResult;
 import org.mockito.Mockito;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.impl.TestUtils;
 import org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodec;
 import org.opendaylight.yangtools.yang.data.impl.codec.xml.XmlCodecProvider;
 import org.opendaylight.yangtools.yang.data.impl.codec.xml.XmlDocumentUtils;
@@ -32,8 +31,8 @@ import org.opendaylight.yangtools.yang.data.impl.schema.transform.base.serialize
 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.parser.spi.source.StatementStreamSource;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -49,8 +48,8 @@ public class DomSerializerTestUtils {
     }
 
     public static SchemaContext getSchemaContext() throws ReactorException, IOException, YangSyntaxErrorException {
-        final StatementStreamSource source = new YangStatementSourceImpl("/dom-serializer-test/serializer-test.yang", false);
-        final SchemaContext schemaContext = TestUtils.parseYangSources(source);
+        final YangStatementSourceImpl source = new YangStatementSourceImpl("/dom-serializer-test/serializer-test.yang", false);
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangSources(source);
 
         assertNotNull("Schema context must not be null.", schemaContext);
         return schemaContext;
index 7d3be418b0cb356eeb7b669d534dca47694c830c..b90d4bbb9298f2a50f688014d4413af698362402 100644 (file)
@@ -58,7 +58,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
-import org.opendaylight.yangtools.yang.data.impl.TestUtils;
 import org.opendaylight.yangtools.yang.data.impl.codec.xml.XMLStreamNormalizedNodeStreamWriter;
 import org.opendaylight.yangtools.yang.data.impl.codec.xml.XmlDocumentUtils;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
@@ -73,6 +72,7 @@ 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;
 import org.w3c.dom.Document;
@@ -266,7 +266,7 @@ public class NormalizedNodeXmlTranslationTest {
     private final String xmlPath;
 
     SchemaContext parseTestSchema(final String... yangPath) throws ReactorException {
-        return TestUtils.parseYangStreams(getTestYangs(yangPath));
+        return YangParserTestUtils.parseYangStreams(getTestYangs(yangPath));
     }
 
     List<InputStream> getTestYangs(final String... yangPaths) {
index e4eb6237f71a1e095293b76576c3fd2e05cc7f68..63452250c1429cacf7502ba721a9f9c02cfe416b 100644 (file)
@@ -13,7 +13,6 @@ import static org.junit.Assert.assertTrue;
 
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
-import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URI;
@@ -36,7 +35,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
 import org.opendaylight.yangtools.yang.data.api.schema.YangModeledAnyXmlNode;
-import org.opendaylight.yangtools.yang.data.impl.TestUtils;
 import org.opendaylight.yangtools.yang.data.impl.schema.transform.dom.DomUtils;
 import org.opendaylight.yangtools.yang.data.impl.schema.transform.dom.parser.DomToNormalizedNodeParserFactory;
 import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
@@ -47,6 +45,7 @@ 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.api.YangModeledAnyXmlSchemaNode;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.w3c.dom.Document;
 import org.xml.sax.SAXException;
 
@@ -92,8 +91,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 = TestUtils.parseYangSources(new File(getClass().getResource("/anyxml-support/yang/foo.yang")
-                .toURI()), new File(getClass().getResource("/anyxml-support/yang/bar.yang").toURI()), new File(getClass().getResource("/anyxml-support/yang/yang-ext.yang").toURI()));
+        schemaContext = YangParserTestUtils.parseYangSources("/anyxml-support/yang");
     }
 
     @Test
index c51c845de9354cc0de6fe0f665703fd19c4faaba..308f32c0be6b20041542f20471ec3a89136ae839 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.yangtools.yang.data.impl.schema.transform.dom.serialize
 
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
-import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.StringWriter;
@@ -43,7 +42,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.YangModeledAnyXmlNode;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
-import org.opendaylight.yangtools.yang.data.impl.TestUtils;
 import org.opendaylight.yangtools.yang.data.impl.codec.xml.XMLStreamNormalizedNodeStreamWriter;
 import org.opendaylight.yangtools.yang.data.impl.codec.xml.XmlDocumentUtils;
 import org.opendaylight.yangtools.yang.data.impl.schema.transform.dom.DomUtils;
@@ -54,6 +52,7 @@ 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.util.SchemaContextUtil;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 import org.xml.sax.SAXException;
@@ -86,9 +85,7 @@ public class YangModeledAnyXMLSerializationTest extends XMLTestCase {
         myContainer2QName = QName.create(bazModuleQName, "my-container-2");
         myAnyXMLDataBaz = QName.create(bazModuleQName, "my-anyxml-data");
 
-        schemaContext = TestUtils.parseYangSources(
-                new File(getClass().getResource("/anyxml-support/serialization/baz.yang").toURI()), new File(getClass()
-                        .getResource("/anyxml-support/serialization/yang-ext.yang").toURI()));
+        schemaContext = YangParserTestUtils.parseYangSources("/anyxml-support/serialization");
     }
 
     @Test
index f0dc617e286b1d5c745ca915711c8a822dde62c4..1177d49897fd68cd0f12e01ed34d049df0fadf83 100644 (file)
@@ -25,11 +25,11 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
-import org.opendaylight.yangtools.yang.data.impl.TestUtils;
 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.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class Bug2690Test {
     private static final String ODL_DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
@@ -53,7 +53,7 @@ public class Bug2690Test {
     }
 
     public static SchemaContext createTestContext() throws ReactorException {
-        return TestUtils.parseYangStreams(Collections.singletonList(getDatastoreTestInputStream()));
+        return YangParserTestUtils.parseYangStreams(Collections.singletonList(getDatastoreTestInputStream()));
     }
 
     @Test
index 8d36915d111ec70a1f6747a9a9c66f001fec693e..4801cb79de9263b28a48a44610e0515a61c5b253 100644 (file)
@@ -26,12 +26,12 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
-import org.opendaylight.yangtools.yang.data.impl.TestUtils;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class Bug4295Test {
 
@@ -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 = TestUtils.parseYangSources(resourceFile);
+        context = YangParserTestUtils.parseYangSources(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 9c999da6d205c1215ebd2f5d60cb0d58523892b8..84173e44739cb0dc7fb62fee2d32aab28d221167 100644 (file)
@@ -40,9 +40,8 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMa
 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.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.test.util.YangParserTestUtils;
 
 public class Bug4454Test {
     private static final YangStatementSourceImpl source = new YangStatementSourceImpl("/bug-4454-test.yang", false);
@@ -122,10 +121,7 @@ public class Bug4454Test {
     }
 
     public static SchemaContext createTestContext() throws IOException, YangSyntaxErrorException, ReactorException {
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        reactor.addSources(source);
-
-        return reactor.buildEffective();
+        return YangParserTestUtils.parseYangSources(source);
     }
 
     @Test
index 404be92bfe0f4b6d53761ff35b9c11ea561391c0..244fda31c5b30a9c9b836d10827a58a72810adc0 100644 (file)
@@ -32,7 +32,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
-import org.opendaylight.yangtools.yang.data.impl.TestUtils;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetEntryNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder;
@@ -40,6 +39,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUn
 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;
 
@@ -99,7 +99,7 @@ public class ListConstraintsValidation {
     }
 
     public static SchemaContext createTestContext() throws ReactorException {
-        return TestUtils.parseYangStreams(Collections.singletonList(getDatastoreTestInputStream()));
+        return YangParserTestUtils.parseYangStreams(Collections.singletonList(getDatastoreTestInputStream()));
     }
 
     @Test
index b12c054788e2faea48555daba013b51eddc75e8e..b6bf61b7b260b5afd4b9d65ef95e0f0c44ab92d2 100644 (file)
@@ -34,9 +34,9 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
-import org.opendaylight.yangtools.yang.data.impl.TestUtils;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -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 = TestUtils.parseYangSources(resourceFile);
+        context = YangParserTestUtils.parseYangSources(resourceFile);
         testModule = QNameModule.create(new URI("ordered-list-modification-test"),
                 SimpleDateFormatUtil.getRevisionFormat().parse("1970-01-01"));
         parentContainer = QName.create(testModule, "parent-container");
index 790ac93225765de599801c56d41aaf4afe326d75..669f46cbcc5ac1bf2edfe66432f6798798e3354d 100644 (file)
@@ -13,9 +13,9 @@ import java.util.Collections;
 
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.impl.TestUtils;
 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 {
 
@@ -44,11 +44,11 @@ public class TestModel {
     }
 
     public static SchemaContext createTestContext() throws ReactorException {
-        return TestUtils.parseYangStreams(Arrays.asList(getDatastoreTestInputStream()));
+        return YangParserTestUtils.parseYangStreams(Arrays.asList(getDatastoreTestInputStream()));
     }
 
     public static SchemaContext createTestContext(String resourcePath) throws ReactorException {
         InputStream yangStream = TestModel.class.getResourceAsStream(resourcePath);
-        return TestUtils.parseYangStreams(Collections.singletonList(yangStream));
+        return YangParserTestUtils.parseYangStreams(Collections.singletonList(yangStream));
     }
 }
index c7805a794eba1d81928d8fd4c299ce85aee72712..232ce65f0c6a88ce61322601a11965572a793352 100644 (file)
             <artifactId>yang-parser-impl</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>yang-test-util</artifactId>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>com.google.guava</groupId>
             <artifactId>guava</artifactId>
index be8ba083f66f2ac8ff6d1b5e81a81160319da522..b2c5284e1150bcc8e5defd75bd787cbde66c0656 100644 (file)
@@ -48,6 +48,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.xpath.XPathSchemaContext;
 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;
 
 public class JaxenTest {
     private ConverterNamespaceContext convertNctx;
@@ -216,7 +217,7 @@ public class JaxenTest {
     }
 
     private SchemaContext createSchemaContext() throws IOException, URISyntaxException, ReactorException {
-        return TestUtils.loadModules("/test/documentTest");
+        return YangParserTestUtils.parseYangSources("/test/documentTest");
     }
 
     private static NormalizedNode<?, ?> createNormalizedNodes() {
index 0f675cea623a9e8309fc0e8baa8153743ab9080d..798dbeab42bb3e6dbbbc4faa027f150e72cfb67f 100644 (file)
@@ -12,27 +12,11 @@ import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.ma
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
-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.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;
 
 final class TestUtils {
 
@@ -55,48 +39,6 @@ final class TestUtils {
     private TestUtils() {
     }
 
-    static SchemaContext loadModules(final String resourceDirectory) throws IOException, URISyntaxException,
-            ReactorException {
-        URI path = TestUtils.class.getResource(resourceDirectory).toURI();
-        final File testDir = new File(path);
-        final String[] fileList = testDir.list();
-        final List<File> testFiles = new ArrayList<>();
-        if (fileList == null) {
-            throw new FileNotFoundException(resourceDirectory);
-        }
-        for (String fileName : fileList) {
-            if (!new File(testDir, fileName).isDirectory()) {
-                testFiles.add(new File(testDir, fileName));
-            }
-        }
-        return parseYangSources(testFiles);
-    }
-
-    public static SchemaContext parseYangSources(StatementStreamSource... sources)
-            throws SourceException, ReactorException {
-
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
-                .newBuild();
-        reactor.addSources(sources);
-
-        return reactor.buildEffective();
-    }
-
-    public static SchemaContext parseYangSources(File... files) throws SourceException, ReactorException, FileNotFoundException {
-
-        StatementStreamSource[] sources = new StatementStreamSource[files.length];
-
-        for (int i = 0; i<files.length; i++) {
-            sources[i] = new YangStatementSourceImpl(new FileInputStream(files[i]));
-        }
-
-        return parseYangSources(sources);
-    }
-
-    public static SchemaContext parseYangSources(Collection<File> files) throws SourceException, ReactorException, FileNotFoundException {
-        return parseYangSources(files.toArray(new File[files.size()]));
-    }
-
     /**
      * Returns a test document
      *
index 56c798b73b3e0e68f47dd3b980f4e31db3493c1e..9fb5440da3fc3928d0eb69d5344b8cbb4ae492ea 100644 (file)
             <groupId>${project.groupId}</groupId>
             <artifactId>yang-parser-impl</artifactId>
         </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>yang-test-util</artifactId>
+            <scope>compile</scope>
+        </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>yang-maven-plugin-spi</artifactId>
index 8ad0e463353a784fccfad75e7f8938420daf4dc7..604fab0d13a0c0505bf25b8910237bd09d8f28c7 100644 (file)
@@ -30,9 +30,8 @@ import org.apache.maven.project.MavenProject;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.repo.YangTextSchemaContextResolver;
-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.NamedFileInputStream;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.opendaylight.yangtools.yang2sources.plugin.ConfigArg.CodeGeneratorArg;
 import org.opendaylight.yangtools.yang2sources.plugin.Util.ContextHolder;
 import org.opendaylight.yangtools.yang2sources.plugin.Util.YangsInZipsResult;
@@ -119,7 +118,6 @@ class YangToSourcesProcessor {
     }
 
     private ContextHolder processYang() throws MojoExecutionException {
-        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
         SchemaContext resolveSchemaContext;
         List<Closeable> closeables = new ArrayList<>();
         LOG.info("{} Inspecting {}", LOG_PREFIX, yangFilesRootDir);
@@ -187,7 +185,7 @@ class YangToSourcesProcessor {
                     closeables.addAll(yangStreams);
                 }
 
-                resolveSchemaContext = reactor.buildEffective(all);
+                resolveSchemaContext = YangParserTestUtils.parseYangStreams(all);
 
                 Set<Module> parsedAllYangModules = resolveSchemaContext.getModules();
                 projectYangModules = new HashSet<>();
index 846f7a750011f2c5357b44c6d8c65624e0aa9e7e..db443dcbd24a1c65293870c1c6dabe4fdfa0c8f3 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.yangtools.yang2sources.plugin;
 import java.io.BufferedInputStream;
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.net.URL;
@@ -41,12 +40,7 @@ import org.mockito.Mockito;
 import org.mockito.runners.MockitoJUnitRunner;
 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.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.YangStatementSourceImpl;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.opendaylight.yangtools.yang2sources.plugin.Util.ContextHolder;
 import org.opendaylight.yangtools.yang2sources.plugin.Util.YangsInZipsResult;
 
@@ -145,7 +139,7 @@ public class UtilTest {
     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 = parseYangSources(testYang1, testYang2);
+        final SchemaContext context = YangParserTestUtils.parseYangSources(testYang1, testYang2);
         final Set<Module> yangModules = new HashSet<>();
         final Util.ContextHolder cxH = new ContextHolder(context, yangModules);
         Assert.assertEquals(context, cxH.getContext());
@@ -232,19 +226,4 @@ public class UtilTest {
             }
         }
     }
-
-    private SchemaContext parseYangSources(final File... files)
-            throws SourceException, ReactorException, FileNotFoundException {
-
-        final StatementStreamSource[] sources = new StatementStreamSource[files.length];
-
-        for (int i = 0; i < files.length; i++) {
-            sources[i] = new YangStatementSourceImpl(new FileInputStream(files[i]));
-        }
-
-        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        reactor.addSources(sources);
-
-        return reactor.buildEffective();
-    }
 }
index edb0c627aba7d219f228190b3cf28c999ab9dea3..f680f9a31910512737c8f376a34910555c00323e 100644 (file)
             <artifactId>yang-parser-impl</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>yang-test-util</artifactId>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>org.mockito</groupId>
             <artifactId>mockito-core</artifactId>
index a3d5a6c34b7da59b598103ac426126b101f4623b..72514b4e5a300cd4067e183938ece57e834c173c 100644 (file)
@@ -15,11 +15,12 @@ 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.export.YinExportUtils;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class Bug4504Test {
     @Test
     public void test() throws Exception {
-        SchemaContext schema = StmtTestUtils.parseYangSources("/bugs/bug4504");
+        SchemaContext schema = YangParserTestUtils.parseYangSources("/bugs/bug4504");
         assertNotNull(schema);
         final File outDir = new File("target/bug4504-export");
         outDir.mkdirs();
index 0d0d9d1bb43473bce2d1368419c3a45188aed0c1..39e4eeba861a3e2c6823f7f85e8e955acc9bfcac 100644 (file)
@@ -18,11 +18,12 @@ 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.export.YinExportUtils;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class Bug5531Test {
     @Test
     public void test() throws Exception {
-        SchemaContext schema = StmtTestUtils.parseYangSources("/bugs/bug5531");
+        SchemaContext schema = YangParserTestUtils.parseYangSources("/bugs/bug5531");
 
         assertNotNull(schema);
         assertNotNull(schema.getModules());
index 1216b706b4e2553f838d78e2e8bc4982878d2178..f94f8dea4fcdf8178aeb0b641e3fae97f5a8b148 100644 (file)
@@ -40,6 +40,7 @@ import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.export.YinExportUtils;
 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;
 import org.xml.sax.SAXException;
@@ -49,7 +50,7 @@ public class SchemaContextEmitterTest {
     @Test
     public void testSchemaContextEmitter() throws ReactorException, IOException, URISyntaxException,
             XMLStreamException, SAXException {
-        final SchemaContext schemaContext = StmtTestUtils.parseYangSources("/schema-context-emitter-test");
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangSources("/schema-context-emitter-test");
         assertNotNull(schemaContext);
         assertEquals(1, schemaContext.getModules().size());
 
diff --git a/yang/yang-model-export/src/test/java/org/opendaylight/yangtools/yang/model/export/test/StmtTestUtils.java b/yang/yang-model-export/src/test/java/org/opendaylight/yangtools/yang/model/export/test/StmtTestUtils.java
deleted file mode 100644 (file)
index 1231e78..0000000
+++ /dev/null
@@ -1,62 +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.model.export.test;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileNotFoundException;
-import java.net.URISyntaxException;
-import java.net.URL;
-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.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;
-
-final class StmtTestUtils {
-
-    final static FileFilter YANG_FILE_FILTER = file -> {
-        String name = file.getName().toLowerCase();
-        return name.endsWith(".yang") && file.isFile();
-    };
-
-    private StmtTestUtils() {
-        throw new UnsupportedOperationException("Utility class");
-    }
-
-    static SchemaContext parseYangSources(StatementStreamSource... sources) throws SourceException, ReactorException {
-
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        reactor.addSources(sources);
-
-        return reactor.buildEffective();
-    }
-
-    static SchemaContext parseYangSources(File... files) throws SourceException, ReactorException,
-            FileNotFoundException {
-        StatementStreamSource[] sources = new StatementStreamSource[files.length];
-
-        for (int i = 0; i < files.length; i++) {
-            sources[i] = new YangStatementSourceImpl(new NamedFileInputStream(files[i], files[i].getPath()));
-        }
-
-        return parseYangSources(sources);
-    }
-
-    static SchemaContext parseYangSources(String yangSourcesDirectoryPath) throws SourceException, ReactorException,
-            FileNotFoundException, URISyntaxException {
-        URL resourceDir = StmtTestUtils.class.getResource(yangSourcesDirectoryPath);
-        File testSourcesDir = new File(resourceDir.toURI());
-
-        return parseYangSources(testSourcesDir.listFiles(YANG_FILE_FILTER));
-    }
-}
index 31ffd28c46ad4a65e4e740d23c15fc7cac132d95..fa8ea6bd8f4fc9e0af1604090fd19bd3aa8a9fcf 100644 (file)
@@ -21,7 +21,7 @@
     <dependencies>
         <dependency>
             <groupId>${project.groupId}</groupId>
-            <artifactId>yang-parser-impl</artifactId>
+            <artifactId>yang-test-util</artifactId>
             <version>${project.version}</version>
         </dependency>
         <dependency>
index cab46b9cf3898038eedcfbfcdf2469e38d87ade7..537a1f8d1a3a6ee8f80e5671f3a3e801e7888459 100644 (file)
@@ -8,8 +8,6 @@
 package org.opendaylight.yangtools.yang.parser.system.test;
 
 import com.google.common.base.Stopwatch;
-import java.io.FileNotFoundException;
-import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -28,8 +26,7 @@ import org.apache.commons.cli.ParseException;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.repo.api.IfFeaturePredicates;
-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;
 
 /**
  * Main class of Yang parser system test.
@@ -78,8 +75,7 @@ public class Main {
         return options;
     }
 
-    public static void main(final String[] args) throws SourceException, FileNotFoundException, ReactorException,
-            URISyntaxException {
+    public static void main(final String[] args) {
 
         final HelpFormatter formatter = new HelpFormatter();
         final Options options = createOptions();
@@ -117,7 +113,7 @@ public class Main {
         final Stopwatch stopWatch = Stopwatch.createStarted();
 
         try {
-            context = YangParserUtils.parseYangSources(yangDirs, yangFiles, isFeatureSupported);
+            context = YangParserTestUtils.parseYangSources(yangDirs, yangFiles, isFeatureSupported);
         } catch (final Exception e) {
             LOG.log(Level.SEVERE, "Failed to create SchemaContext.", e);
             System.exit(1);
diff --git a/yang/yang-system-test/src/main/java/org/opendaylight/yangtools/yang/parser/system/test/YangParserUtils.java b/yang/yang-system-test/src/main/java/org/opendaylight/yangtools/yang/parser/system/test/YangParserUtils.java
deleted file mode 100644 (file)
index 4deac82..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (c) 2016 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.system.test;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileNotFoundException;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.function.Predicate;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.repo.api.IfFeaturePredicates;
-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.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.stmt.rfc6020.YinStatementSourceImpl;
-import org.opendaylight.yangtools.yang.parser.util.NamedFileInputStream;
-
-public class YangParserUtils {
-
-    final public static FileFilter YANG_FILE_FILTER = new FileFilter() {
-        @Override
-        public boolean accept(final File file) {
-            final String name = file.getName().toLowerCase();
-            return name.endsWith(".yang") && file.isFile();
-        }
-    };
-
-    final public static FileFilter YIN_FILE_FILTER = new FileFilter() {
-        @Override
-        public boolean accept(final File file) {
-            final String name = file.getName().toLowerCase();
-            return name.endsWith(".xml") && file.isFile();
-        }
-    };
-
-    private YangParserUtils() {
-        new UnsupportedOperationException("Utility class");
-    }
-
-    public static void addSources(final CrossSourceStatementReactor.BuildAction reactor,
-            final YangStatementSourceImpl... sources) {
-        for (final YangStatementSourceImpl source : sources) {
-            reactor.addSource(source);
-        }
-    }
-
-    public static SchemaContext parseYangSources(final StatementStreamSource... sources) throws SourceException,
-            ReactorException {
-        return parseYangSources(IfFeaturePredicates.ALL_FEATURES, StatementParserMode.DEFAULT_MODE, sources);
-    }
-
-    public static SchemaContext parseYangSources(final Predicate<QName> isFeatureSupported,
-            final StatementParserMode statementParserMode, final StatementStreamSource... sources)
-            throws SourceException, ReactorException {
-
-        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(
-                statementParserMode, isFeatureSupported);
-        reactor.addSources(sources);
-
-        return reactor.buildEffective();
-    }
-
-    public static SchemaContext parseYangSources(final File... files) throws SourceException, ReactorException,
-            FileNotFoundException {
-        return parseYangSources(IfFeaturePredicates.ALL_FEATURES, StatementParserMode.DEFAULT_MODE, files);
-    }
-
-    public static SchemaContext parseYangSources(final Predicate<QName> isFeatureSupported,
-            final StatementParserMode statementParserMode, final File... files) throws SourceException,
-            ReactorException, FileNotFoundException {
-
-        final StatementStreamSource[] sources = new StatementStreamSource[files.length];
-
-        for (int i = 0; i < files.length; i++) {
-            sources[i] = new YangStatementSourceImpl(new NamedFileInputStream(files[i], files[i].getPath()));
-        }
-
-        return parseYangSources(isFeatureSupported, statementParserMode, sources);
-    }
-
-    public static SchemaContext parseYangSources(final Collection<File> files, final Predicate<QName> isFeatureSupported)
-            throws SourceException, ReactorException, FileNotFoundException {
-        return parseYangSources(files, StatementParserMode.DEFAULT_MODE, isFeatureSupported);
-    }
-
-    public static SchemaContext parseYangSources(final Collection<File> files,
-            final StatementParserMode statementParserMode, final Predicate<QName> isFeatureSupported)
-            throws SourceException, ReactorException, FileNotFoundException {
-        return parseYangSources(isFeatureSupported, statementParserMode, files.toArray(new File[files.size()]));
-    }
-
-    public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath) throws SourceException,
-            ReactorException, FileNotFoundException, URISyntaxException {
-        return parseYangSources(yangSourcesDirectoryPath, StatementParserMode.DEFAULT_MODE);
-    }
-
-    public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath,
-            final StatementParserMode statementParserMode) throws SourceException, ReactorException,
-            FileNotFoundException, URISyntaxException {
-        final File testSourcesDir = new File(yangSourcesDirectoryPath);
-        return parseYangSources(IfFeaturePredicates.ALL_FEATURES, statementParserMode,
-                testSourcesDir.listFiles(YANG_FILE_FILTER));
-    }
-
-    public static SchemaContext parseYinSources(final String yinSourcesDirectoryPath,
-            final StatementParserMode statementParserMode) throws SourceException, ReactorException,
-            FileNotFoundException, URISyntaxException {
-
-        final File testSourcesDir = new File(yinSourcesDirectoryPath);
-        return parseYinSources(statementParserMode, testSourcesDir.listFiles(YIN_FILE_FILTER));
-    }
-
-    public static SchemaContext parseYinSources(final StatementParserMode statementParserMode, final File... files)
-            throws SourceException, ReactorException, FileNotFoundException {
-
-        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()));
-        }
-
-        return parseYinSources(statementParserMode, sources);
-    }
-
-    public static SchemaContext parseYinSources(final StatementParserMode statementParserMode,
-            final StatementStreamSource... sources) throws SourceException, ReactorException {
-
-        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
-                .newBuild(statementParserMode);
-        reactor.addSources(sources);
-
-        return reactor.buildEffective();
-    }
-
-    public static SchemaContext parseYangSources(final List<String> yangDirs, final List<String> yangFiles,
-            final Predicate<QName> isFeatureSupported) throws SourceException, FileNotFoundException, ReactorException {
-        final List<File> allYangFiles = new ArrayList<>();
-        for (final String yangDir : yangDirs) {
-            allYangFiles.addAll(getYangFiles(yangDir));
-        }
-
-        for (final String yangFile : yangFiles) {
-            allYangFiles.add(new File(yangFile));
-        }
-
-        return parseYangSources(allYangFiles, isFeatureSupported);
-    }
-
-    public static Collection<File> getYangFiles(final String yangSourcesDirectoryPath) {
-        final File testSourcesDir = new File(yangSourcesDirectoryPath);
-        return Arrays.asList(testSourcesDir.listFiles(YANG_FILE_FILTER));
-    }
-}
diff --git a/yang/yang-test-util/pom.xml b/yang/yang-test-util/pom.xml
new file mode 100644 (file)
index 0000000..5abcb92
--- /dev/null
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+ Copyright (c) 2016 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
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <parent>
+        <groupId>org.opendaylight.odlparent</groupId>
+        <artifactId>bundle-parent</artifactId>
+        <version>1.8.0-SNAPSHOT</version>
+        <relativePath/>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.opendaylight.yangtools</groupId>
+    <artifactId>yang-test-util</artifactId>
+    <version>1.1.0-SNAPSHOT</version>
+    <packaging>bundle</packaging>
+    <name>${project.artifactId}</name>
+    <description>${project.artifactId}</description>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.opendaylight.yangtools</groupId>
+                <artifactId>yangtools-artifacts</artifactId>
+                <version>1.1.0-SNAPSHOT</version>
+                <scope>import</scope>
+                <type>pom</type>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-parser-impl</artifactId>
+        </dependency>
+    </dependencies>
+
+    <!--
+      Maven Site Configuration
+
+      The following configuration is necessary for maven-site-plugin to
+      correctly identify the correct deployment path for OpenDaylight Maven
+      sites.
+  -->
+    <url>${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/</url>
+
+    <distributionManagement>
+        <site>
+            <id>opendaylight-site</id>
+            <url>${nexus.site.url}/${project.artifactId}/</url>
+        </site>
+    </distributionManagement>
+
+</project>
\ No newline at end of file
diff --git a/yang/yang-test-util/src/main/java/org/opendaylight/yangtools/yang/test/util/YangParserTestUtils.java b/yang/yang-test-util/src/main/java/org/opendaylight/yangtools/yang/test/util/YangParserTestUtils.java
new file mode 100644 (file)
index 0000000..04c7379
--- /dev/null
@@ -0,0 +1,682 @@
+/*
+ * Copyright (c) 2016 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.test.util;
+
+import com.google.common.annotations.Beta;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.function.Predicate;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.repo.api.IfFeaturePredicates;
+import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
+import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YinStatementStreamSource;
+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.NamedFileInputStream;
+
+/**
+ * Utility class which provides convenience methods for producing effective schema context based on the supplied
+ * yang/yin sources or paths to these sources
+ */
+@Beta
+public final class YangParserTestUtils {
+
+    private static final FileFilter YANG_FILE_FILTER = file -> {
+        final String name = file.getName().toLowerCase();
+        return name.endsWith(".yang") && file.isFile();
+    };
+
+    private YangParserTestUtils() {
+        throw new UnsupportedOperationException("Utility class should not be instantiated.");
+    }
+
+    /**
+     * 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
+     */
+    public static SchemaContext parseYangSources(final YangStatementSourceImpl... sources) throws ReactorException {
+        return parseYangSources(IfFeaturePredicates.ALL_FEATURES, StatementParserMode.DEFAULT_MODE, sources);
+    }
+
+    /**
+     * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
+     * default mode.
+     *
+     * @param isFeatureSupported predicate 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
+     */
+    public static SchemaContext parseYangSources(final Predicate<QName> isFeatureSupported,
+            final YangStatementSourceImpl... sources) throws ReactorException {
+        return parseYangSources(isFeatureSupported, 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
+     */
+    public static SchemaContext parseYangSources(final StatementParserMode statementParserMode,
+            final YangStatementSourceImpl... sources) throws ReactorException {
+        return parseYangSources(IfFeaturePredicates.ALL_FEATURES, statementParserMode, sources);
+    }
+
+    /**
+     * Creates a new effective schema context containing the specified YANG sources.
+     *
+     * @param isFeatureSupported predicate 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
+     *
+     * @return effective schema context
+     *
+     * @throws ReactorException if there is an error in one of the parsed YANG sources
+     */
+    public static SchemaContext parseYangSources(final Predicate<QName> isFeatureSupported,
+            final StatementParserMode statementParserMode, final YangStatementSourceImpl... sources) throws ReactorException {
+        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(
+                statementParserMode, isFeatureSupported);
+        reactor.addSources(sources);
+
+        return reactor.buildEffective();
+    }
+
+    /**
+     * 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
+     *
+     * @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(IfFeaturePredicates.ALL_FEATURES, StatementParserMode.DEFAULT_MODE, files);
+    }
+
+    /**
+     * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
+     * default mode.
+     *
+     * @param isFeatureSupported predicate 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 Predicate<QName> isFeatureSupported, final File... files)
+            throws ReactorException, FileNotFoundException {
+        return parseYangSources(isFeatureSupported, StatementParserMode.DEFAULT_MODE, 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(IfFeaturePredicates.ALL_FEATURES, statementParserMode, files);
+    }
+
+    /**
+     * Creates a new effective schema context containing the specified YANG sources.
+     *
+     * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG models are resolved
+     * @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 Predicate<QName> isFeatureSupported,
+            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(isFeatureSupported, 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, IfFeaturePredicates.ALL_FEATURES, StatementParserMode.DEFAULT_MODE);
+    }
+
+    /**
+     * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
+     * default mode.
+     *
+     * @param isFeatureSupported predicate 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 Predicate<QName> isFeatureSupported)
+            throws ReactorException, FileNotFoundException {
+        return parseYangSources(files, isFeatureSupported, 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 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, IfFeaturePredicates.ALL_FEATURES, statementParserMode);
+    }
+
+    /**
+     * Creates a new effective schema context containing the specified YANG sources.
+     *
+     * @param isFeatureSupported predicate 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 Predicate<QName> isFeatureSupported,
+            final StatementParserMode statementParserMode) throws ReactorException, FileNotFoundException {
+        return parseYangSources(isFeatureSupported, 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, IfFeaturePredicates.ALL_FEATURES, 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 isFeatureSupported predicate 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 Predicate<QName> isFeatureSupported) throws ReactorException, FileNotFoundException, URISyntaxException {
+        return parseYangSources(yangSourcesDirectoryPath, isFeatureSupported, 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
+     *
+     * @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, IfFeaturePredicates.ALL_FEATURES, statementParserMode);
+    }
+
+    /**
+     * 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 isFeatureSupported predicate 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 the specified directory does not exist
+     * @throws URISyntaxException if the specified directory does not exist
+     */
+    public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath,
+            final Predicate<QName> isFeatureSupported, final StatementParserMode statementParserMode) throws ReactorException,
+            FileNotFoundException, URISyntaxException {
+        final URI directoryPath = YangParserTestUtils.class.getResource(yangSourcesDirectoryPath).toURI();
+        final File dir = new File(directoryPath);
+
+        return parseYangSources(isFeatureSupported, statementParserMode, dir.listFiles(YANG_FILE_FILTER));
+    }
+
+    /**
+     * 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
+     *
+     * @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, IfFeaturePredicates.ALL_FEATURES, 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 isFeatureSupported predicate 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 Predicate<QName> isFeatureSupported)
+            throws ReactorException, FileNotFoundException, URISyntaxException {
+        return parseYangSource(yangSourcePath, isFeatureSupported, StatementParserMode.DEFAULT_MODE);
+    }
+
+    /**
+     * 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
+     *
+     * @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, IfFeaturePredicates.ALL_FEATURES, statementParserMode);
+    }
+
+    /**
+     * Creates a new effective schema context containing the specified YANG source.
+     *
+     * @param yangSourcePath relative path to the YANG file to be parsed
+     * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YANG model are resolved
+     * @param statementParserMode 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 Predicate<QName> isFeatureSupported,
+            final StatementParserMode statementParserMode) throws ReactorException, FileNotFoundException, URISyntaxException {
+        final URI sourcePath = YangParserTestUtils.class.getResource(yangSourcePath).toURI();
+        final File sourceFile = new File(sourcePath);
+        return parseYangSources(isFeatureSupported, statementParserMode, sourceFile);
+    }
+
+    /**
+     * 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
+     *
+     * @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, IfFeaturePredicates.ALL_FEATURES, 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 isFeatureSupported predicate 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 Predicate<QName> isFeatureSupported) throws FileNotFoundException, ReactorException, URISyntaxException {
+        return parseYangSources(yangDirs, yangFiles, isFeatureSupported, 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
+     *
+     * @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, IfFeaturePredicates.ALL_FEATURES, 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 isFeatureSupported predicate 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 Predicate<QName> isFeatureSupported, 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, isFeatureSupported, statementParserMode);
+    }
+
+    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));
+    }
+
+    /**
+     * 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, IfFeaturePredicates.ALL_FEATURES, StatementParserMode.DEFAULT_MODE);
+    }
+
+    /**
+     * Creates a new effective schema context containing the specified YANG sources. Statement parser mode is set to
+     * default mode.
+     *
+     * @param isFeatureSupported predicate 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 Predicate<QName> isFeatureSupported)
+            throws ReactorException {
+        return parseYangSources(filePaths, isFeatureSupported, 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, IfFeaturePredicates.ALL_FEATURES, statementParserMode);
+    }
+
+    /**
+     * Creates a new effective schema context containing the specified YANG sources.
+     *
+     * @param isFeatureSupported predicate 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
+     *
+     * @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 Predicate<QName> isFeatureSupported,
+            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)));
+        }
+
+        return parseYangSources(isFeatureSupported, 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 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) throws ReactorException {
+        return parseYangStreams(streams, IfFeaturePredicates.ALL_FEATURES, StatementParserMode.DEFAULT_MODE);
+    }
+
+    /**
+     * 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 isFeatureSupported predicate 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 Predicate<QName> isFeatureSupported)
+            throws ReactorException {
+        return parseYangStreams(streams, isFeatureSupported, 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 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, IfFeaturePredicates.ALL_FEATURES, statementParserMode);
+    }
+
+    /**
+     * Creates a new effective schema context containing the specified YANG sources.
+     *
+     * @param isFeatureSupported predicate 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 Predicate<QName> isFeatureSupported,
+            final StatementParserMode statementParserMode) throws ReactorException {
+        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(
+                statementParserMode, isFeatureSupported);
+        return reactor.buildEffective(streams);
+    }
+
+    /**
+     * Creates a new effective schema context containing the specified YIN sources. Statement parser mode is set to
+     * 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 {
+        return parseYinSources(IfFeaturePredicates.ALL_FEATURES, StatementParserMode.DEFAULT_MODE, sources);
+    }
+
+    /**
+     * Creates a new effective schema context containing the specified YIN sources. Statement parser mode is set to
+     * default mode.
+     *
+     * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YIN models are resolved
+     * @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 Predicate<QName> isFeatureSupported,
+            final YinStatementStreamSource... sources) throws ReactorException {
+        return parseYinSources(isFeatureSupported, StatementParserMode.DEFAULT_MODE, sources);
+    }
+
+    /**
+     * Creates a new effective schema context containing the specified YIN sources. All YANG features are supported.
+     *
+     * @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(IfFeaturePredicates.ALL_FEATURES, statementParserMode, sources);
+    }
+
+    /**
+     * Creates a new effective schema context containing the specified YIN sources.
+     *
+     * @param isFeatureSupported predicate based on which all if-feature statements in the parsed YIN models are resolved
+     * @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 Predicate<QName> isFeatureSupported,
+            final StatementParserMode statementParserMode, final YinStatementStreamSource... sources) throws ReactorException {
+        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(
+                statementParserMode, isFeatureSupported);
+        reactor.addSources(sources);
+
+        return reactor.buildEffective();
+    }
+}