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;
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 {
}
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();
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();
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();