<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>
<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>
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;
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);
}
+++ /dev/null
-/*
- * 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()]));
- }
-}
<module>yang-model-export</module>
<module>yang-data-jaxen</module>
<module>yang-system-test</module>
+ <module>yang-test-util</module>
</modules>
<build>
<plugins>
<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>
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;
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;
@BeforeClass
public static void setup() throws IOException, URISyntaxException, ReactorException {
- schemaContext = loadModules("/complexjson/yang");
+ schemaContext = YangParserTestUtils.parseYangSources("/complexjson/yang");
}
@Test
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;
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 {
@BeforeClass
public static void initialization() throws IOException, URISyntaxException, ReactorException {
- schemaContext = loadModules("/bug-4501/yang");
+ schemaContext = YangParserTestUtils.parseYangSources("/bug-4501/yang");
}
@Test
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);
@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);
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 {
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
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;
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 {
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;
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;
/**
*
@BeforeClass
public static void initialization() throws IOException, URISyntaxException, ReactorException {
- schemaContext = loadModules("/complexjson/yang");
+ schemaContext = YangParserTestUtils.parseYangSources("/complexjson/yang");
}
@Test
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;
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
@BeforeClass
public static void initialization() throws IOException, URISyntaxException, ReactorException {
- schemaContext = loadModules("/complexjson/yang");
+ schemaContext = YangParserTestUtils.parseYangSources("/complexjson/yang");
}
@Test
*/
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;
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;
@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()));
}
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;
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);
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;
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 {
@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");
<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>
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 {
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
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;
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
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;
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
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;
@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");
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 {
@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();
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 {
@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");
@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");
@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");
@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");
@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");
@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");
@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");
@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");
@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");
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 {
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
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;
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
<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>
+++ /dev/null
-/*
- * 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);
- }
-}
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;
@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 {
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;
@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"));
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;
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;
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 {
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;
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 {
@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();
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;
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;
@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"),
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;
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;
.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();
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;
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;
"/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) {
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;
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;
"/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) {
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;
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 {
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) {
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;
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 {
"/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) {
"/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);
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;
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");
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);
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 {
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
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;
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 {
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");
}
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;
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 {
}
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) {
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;
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 {
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,
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;
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()));
}
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;
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
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;
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;
}
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;
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;
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;
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) {
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;
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;
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;
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
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;
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;
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;
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
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";
}
public static SchemaContext createTestContext() throws ReactorException {
- return TestUtils.parseYangStreams(Collections.singletonList(getDatastoreTestInputStream()));
+ return YangParserTestUtils.parseYangStreams(Collections.singletonList(getDatastoreTestInputStream()));
}
@Test
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 {
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");
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);
}
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
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;
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;
}
public static SchemaContext createTestContext() throws ReactorException {
- return TestUtils.parseYangStreams(Collections.singletonList(getDatastoreTestInputStream()));
+ return YangParserTestUtils.parseYangStreams(Collections.singletonList(getDatastoreTestInputStream()));
}
@Test
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;
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");
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 {
}
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));
}
}
<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>
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;
}
private SchemaContext createSchemaContext() throws IOException, URISyntaxException, ReactorException {
- return TestUtils.loadModules("/test/documentTest");
+ return YangParserTestUtils.parseYangSources("/test/documentTest");
}
private static NormalizedNode<?, ?> createNormalizedNodes() {
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 {
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
*
<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>
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;
}
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);
closeables.addAll(yangStreams);
}
- resolveSchemaContext = reactor.buildEffective(all);
+ resolveSchemaContext = YangParserTestUtils.parseYangStreams(all);
Set<Module> parsedAllYangModules = resolveSchemaContext.getModules();
projectYangModules = new HashSet<>();
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;
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;
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());
}
}
}
-
- 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();
- }
}
<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>
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();
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());
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;
@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());
+++ /dev/null
-/*
- * 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));
- }
-}
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>yang-parser-impl</artifactId>
+ <artifactId>yang-test-util</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
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;
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.
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();
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);
+++ /dev/null
-/*
- * 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));
- }
-}
--- /dev/null
+<?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
--- /dev/null
+/*
+ * 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();
+ }
+}