Merge "Added getModifiedChild to DataTreeCandidateNode."
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / parser / impl / TestUtils.java
index ae6a9ea12717504750e0b080aa83b8366917c866..300ed776ffc10fff613dabc3ad7ae24341314ed5 100644 (file)
@@ -8,8 +8,8 @@
 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 +37,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 +62,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 +84,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 +105,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();
@@ -149,7 +148,7 @@ final class TestUtils {
     public static SchemaPath createPath(final boolean absolute, final URI namespace, final Date revision, final String prefix, final String... names) {
         List<QName> path = new ArrayList<>();
         for (String name : names) {
-            path.add(new QName(namespace, revision, prefix, name));
+            path.add(QName.create(namespace, revision, name));
         }
         return SchemaPath.create(path, absolute);
     }