X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=yang%2Fyang-data-codec-gson%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fdata%2Fcodec%2Fgson%2FTestUtils.java;h=b98566e140562b5242734fe64691669286189a3c;hb=21b3fb1ea12d1e28115f6c216bbbfd9c80b2216f;hp=e9105db7b93f8e7f243ad5e35d6ec52c6f2781c2;hpb=c24d6e2f39acbb11e22b5676bb7481ed52bec461;p=yangtools.git diff --git a/yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/TestUtils.java b/yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/TestUtils.java index e9105db7b9..b98566e140 100644 --- a/yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/TestUtils.java +++ b/yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/TestUtils.java @@ -8,6 +8,7 @@ package org.opendaylight.yangtools.yang.data.codec.gson; import static org.junit.Assert.assertTrue; + import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -15,80 +16,15 @@ import com.google.gson.JsonParser; import com.google.gson.JsonPrimitive; import java.io.BufferedReader; import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; -import java.io.InputStream; -import java.net.URI; import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; -import org.opendaylight.yangtools.yang.parser.spi.source.SourceException; -import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource; -import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor; -import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline; -import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl; public class TestUtils { private TestUtils() { } - static SchemaContext loadModules(final String resourceDirectory) throws IOException, URISyntaxException, - ReactorException { - URI path = StreamToNormalizedNodeTest.class.getResource(resourceDirectory).toURI(); - final File testDir = new File(path); - final String[] fileList = testDir.list(); - final List 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) throws SourceException, ReactorException, FileNotFoundException { - return parseYangSources(files.toArray(new File[files.size()])); - } - - - public static SchemaContext parseYangStreams(List 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);