package org.opendaylight.yangtools.yang.stmt.retest;
import static org.junit.Assert.assertEquals;
-
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.net.URI;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YinStatementSourceImpl;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveSchemaContext;
+import org.opendaylight.yangtools.yang.parser.util.NamedFileInputStream;
import org.opendaylight.yangtools.yang.stmt.test.StmtTestUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public final class TestUtils {
+ private static final Logger LOG = LoggerFactory.getLogger(TestUtils.class);
private TestUtils() {
}
File[] files = new File(resourceDirectory).listFiles();
for (File file : files) {
- addSources(reactor, new YangStatementSourceImpl(file.getPath(),
- true));
+ if (file.getName().endsWith(".yang")) {
+ addSources(reactor, new YangStatementSourceImpl(file.getPath(), true));
+ } else {
+ LOG.info("Ignoring non-yang file {}", file);
+ }
}
EffectiveSchemaContext ctx = reactor.buildEffective();
}
private static void addSources(
- CrossSourceStatementReactor.BuildAction reactor,
- YangStatementSourceImpl... sources) {
+ final CrossSourceStatementReactor.BuildAction reactor,
+ final YangStatementSourceImpl... sources) {
for (YangStatementSourceImpl source : sources) {
reactor.addSource(source);
}
}
public static SchemaContext parseYangSources(
- StatementStreamSource... sources) throws SourceException,
+ final StatementStreamSource... sources) throws SourceException,
ReactorException {
CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
return reactor.buildEffective();
}
- public static SchemaContext parseYangSources(File... files)
+ public static SchemaContext parseYangSources(final 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]));
+ sources[i] = new YangStatementSourceImpl(new NamedFileInputStream(files[i], files[i].getPath()));
}
return parseYangSources(sources);
}
- public static SchemaContext parseYangSources(Collection<File> files)
+ public static SchemaContext parseYangSources(final Collection<File> files)
throws SourceException, ReactorException, FileNotFoundException {
return parseYangSources(files.toArray(new File[files.size()]));
}
- public static SchemaContext parseYangSources(String yangSourcesDirectoryPath)
+ public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath)
throws SourceException, ReactorException, FileNotFoundException,
URISyntaxException {
return parseYangSources(testSourcesDir.listFiles());
}
- public static SchemaContext parseYangSource(String yangSourceFilePath)
+ public static SchemaContext parseYangSource(final String yangSourceFilePath)
throws SourceException, ReactorException, FileNotFoundException,
URISyntaxException {
return parseYangSources(testSourcesFile);
}
- private static void addYinSources(CrossSourceStatementReactor.BuildAction reactor, YinStatementSourceImpl...
- sources) {
+ private static void addYinSources(final CrossSourceStatementReactor.BuildAction reactor,
+ final YinStatementSourceImpl... sources) {
for (YinStatementSourceImpl source : sources) {
reactor.addSource(source);
}