Degrade DataNodeContainer.getChildNodes() from Set to Collection
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / parser / impl / TestUtils.java
index ae6a9ea12717504750e0b080aa83b8366917c866..8fd6c1896dc640b324acc54dedd1f232a7e2bc34 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.yangtools.yang.parser.impl;
 import static org.junit.Assert.assertEquals;
 
 import com.google.common.io.ByteSource;
+import com.google.common.io.ByteStreams;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
@@ -37,8 +38,8 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
 import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
+import org.opendaylight.yangtools.yang.parser.builder.impl.BuilderUtils;
 import org.opendaylight.yangtools.yang.parser.util.NamedByteArrayInputStream;
-import org.opendaylight.yangtools.yang.parser.util.ParserUtils;
 
 final class TestUtils {
 
@@ -62,7 +63,7 @@ final class TestUtils {
     }
 
     public static Set<Module> loadModules(final List<InputStream> input) throws IOException, YangSyntaxErrorException {
-        Collection<ByteSource> sources = ParserUtils.streamsToByteSources(input);
+        Collection<ByteSource> sources = BuilderUtils.streamsToByteSources(input);
         final YangContextParser parser = new YangParserImpl();
         SchemaContext ctx = parser.parseSources(sources);
         return ctx.getModules();
@@ -84,12 +85,11 @@ final class TestUtils {
     public static Module loadModuleWithContext(final String name, final InputStream stream, final SchemaContext context)
             throws IOException, YangSyntaxErrorException {
         final YangContextParser parser = new YangParserImpl();
-        ByteSource source = new ByteSource() {
-            @Override
-            public InputStream openStream() throws IOException {
-                return NamedByteArrayInputStream.create(stream);
-            }
-        };
+
+        final byte[] streamContent = ByteStreams.toByteArray(stream);
+
+        ByteSource source = ByteStreams.asByteSource(streamContent);
+
         final Collection<ByteSource> sources = Collections.singletonList(source);
         SchemaContext ctx = parser.parseSources(sources, context);
         final Set<Module> modules = ctx.getModules();
@@ -106,7 +106,7 @@ final class TestUtils {
 
     public static Set<Module> loadModulesWithContext(final Collection<InputStream> input, final SchemaContext context)
             throws IOException, YangSyntaxErrorException {
-        Collection<ByteSource> sources = ParserUtils.streamsToByteSources(input);
+        Collection<ByteSource> sources = BuilderUtils.streamsToByteSources(input);
         final YangContextParser parser = new YangParserImpl();
         SchemaContext ctx = parser.parseSources(sources, context);
         final Set<Module> modules = ctx.getModules();