Merge "Bug 7432 - eliminate use of yang-parser-impl internals"
authorTomas Cere <tcere@cisco.com>
Tue, 10 Jan 2017 12:36:37 +0000 (12:36 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 10 Jan 2017 12:36:37 +0000 (12:36 +0000)
netconf/tools/netconf-cli/pom.xml
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/commands/CommandDispatcher.java
netconf/tools/netconf-cli/src/test/java/org/opendaylight/netconf/cli/NetconfCliTest.java

index 4cec9bbf37f42d00732f88df2920489e433e25fe..f797ca76bf1f986254a44fa0c27c762664ca2350 100644 (file)
       <groupId>org.opendaylight.yangtools</groupId>
       <artifactId>yang-common</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.yangtools</groupId>
+      <artifactId>yang-test-util</artifactId>
+      <scope>compile</scope>
+    </dependency>
     <dependency>
       <groupId>${project.groupId}</groupId>
       <artifactId>netconf-client</artifactId>
index 81c791f39711e7d2eec4827091d30bb6e98228ab..077a8a8b44ae6b947c65970887c166ab0049b5fb 100644 (file)
@@ -33,8 +33,7 @@ import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 /**
  * The registry of available commands local + remote. Created from schema contexts.
@@ -165,11 +164,9 @@ public class CommandDispatcher {
 
     public static SchemaContext parseSchema(final Collection<String> yangPath) {
         final List<InputStream> streams = loadYangs(yangPath);
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
-                .newBuild();
         final SchemaContext schemaContext;
         try {
-            schemaContext = reactor.buildEffective(streams);
+            schemaContext = YangParserTestUtils.parseYangStreams(streams);
         } catch (ReactorException e) {
             throw new RuntimeException("Unable to build schema context from " + streams, e);
         }
index 5baf205751df5fc8e3de00d2aef8266c2546ff1b..67d1a519adfc6012157bbb8e868965c94aeb0d18 100644 (file)
@@ -12,10 +12,8 @@ import static org.opendaylight.netconf.cli.io.IOUtil.PROMPT_SUFIX;
 
 import java.io.File;
 import java.io.FileNotFoundException;
-import java.io.IOException;
 import java.io.InputStream;
 import java.net.URI;
-import java.net.URISyntaxException;
 import java.util.ArrayDeque;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -25,20 +23,15 @@ import java.util.List;
 import java.util.Map;
 import org.junit.Ignore;
 import org.junit.Test;
-import org.opendaylight.netconf.cli.reader.ReadingException;
-import org.opendaylight.netconf.cli.writer.WriteException;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 @Ignore
 public class NetconfCliTest {
 
-    private static SchemaContext loadSchemaContext(final String resourceDirectory) throws IOException,
-            URISyntaxException {
+    private static SchemaContext loadSchemaContext(final String resourceDirectory) throws Exception {
         final URI uri = NetconfCliTest.class.getResource(resourceDirectory).toURI();
         final File testDir = new File(uri);
         final String[] fileList = testDir.list();
@@ -49,23 +42,11 @@ public class NetconfCliTest {
         for (final String fileName : fileList) {
             NetconfCliTest.class.getResourceAsStream(fileName);
         }
-        return parseYangStreams(streams);
-    }
-
-    private static SchemaContext parseYangStreams(final List<InputStream> streams) {
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
-                .newBuild();
-        final SchemaContext schemaContext;
-        try {
-            schemaContext = reactor.buildEffective(streams);
-        } catch (ReactorException e) {
-            throw new RuntimeException("Unable to build schema context from " + streams, e);
-        }
-        return schemaContext;
+        return YangParserTestUtils.parseYangStreams(streams);
     }
 
     @Test
-    public void cliTest() throws ReadingException, IOException, WriteException, URISyntaxException {
+    public void cliTest() throws Exception {
 
         final SchemaContext schemaContext = loadSchemaContext("/schema-context");
         assertNotNull(schemaContext);