Get rid of old Yang Parser in Controller 45/39645/6
authorMartin Ciglan <mciglan@cisco.com>
Tue, 31 May 2016 12:46:39 +0000 (14:46 +0200)
committerTom Pantelis <tpanteli@brocade.com>
Fri, 3 Jun 2016 16:27:29 +0000 (16:27 +0000)
- Config part DONE
- MD-SAL part DONE
- bit of clean-up

Change-Id: I6bf4f8b81826d5ab61dd883fff3244f42d148375
Signed-off-by: Martin Ciglan <mciglan@cisco.com>
15 files changed:
opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/AbstractYangTest.java
opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/ModuleMXBeanEntryNameConflictTest.java
opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/unknownextension/UnknownExtensionTest.java
opendaylight/config/yang-jmx-generator/src/test/resources/org/opendaylight/controller/config/yangjmxgenerator/unknownextension/test-ifcWithUnknownExtension.yang
opendaylight/md-sal/benchmark-data-store/src/main/java/org/opendaylight/controller/md/sal/dom/store/benchmark/BenchmarkModel.java
opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/DOMRpcServiceTestBugfix560.java
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/util/TestModel.java
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/xml/codec/XmlUtilsTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/CompositeModel.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/SchemaContextHelper.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/TestModel.java
opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java
opendaylight/md-sal/sal-dom-xsql/src/test/java/org/opendaylight/xsql/test/XSQLTest.java
opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java
opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/AbstractRpcTest.java

index c62e1a7..fa99dea 100644 (file)
@@ -27,7 +27,8 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
 
 public abstract class AbstractYangTest {
     protected SchemaContext context;
 
 public abstract class AbstractYangTest {
     protected SchemaContext context;
@@ -56,13 +57,12 @@ public abstract class AbstractYangTest {
 
         yangISs.addAll(getConfigApiYangInputStreams());
 
 
         yangISs.addAll(getConfigApiYangInputStreams());
 
-        YangParserImpl parser = new YangParserImpl();
-        Set<Module> modulesToBuild = parser.parseYangModelsFromStreams(yangISs);
+        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        context = reactor.buildEffective(yangISs);
         // close ISs
         for (InputStream is : yangISs) {
             is.close();
         }
         // close ISs
         for (InputStream is : yangISs) {
             is.close();
         }
-        context = parser.resolveSchemaContext(modulesToBuild);
         namesToModules = YangModelSearchUtils.mapModulesByNames(context
                 .getModules());
         configModule = namesToModules.get(ConfigConstants.CONFIG_MODULE);
         namesToModules = YangModelSearchUtils.mapModulesByNames(context
                 .getModules());
         configModule = namesToModules.get(ConfigConstants.CONFIG_MODULE);
index 65f0f54..ed4437d 100644 (file)
@@ -18,7 +18,6 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.util.NameConflictException;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.util.NameConflictException;
@@ -26,7 +25,8 @@ import org.opendaylight.controller.config.yangjmxgenerator.plugin.util.YangModel
 import org.opendaylight.yangtools.sal.binding.yang.types.TypeProviderImpl;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.sal.binding.yang.types.TypeProviderImpl;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -120,13 +120,12 @@ public class ModuleMXBeanEntryNameConflictTest extends AbstractYangTest {
 
         yangISs.addAll(getConfigApiYangInputStreams());
 
 
         yangISs.addAll(getConfigApiYangInputStreams());
 
-        YangParserImpl parser = new YangParserImpl();
-        Set<Module> modulesToBuild = parser.parseYangModelsFromStreams(yangISs);
+        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        context = reactor.buildEffective(yangISs);
         // close ISs
         for (InputStream is : yangISs) {
             is.close();
         }
         // close ISs
         for (InputStream is : yangISs) {
             is.close();
         }
-        context = parser.resolveSchemaContext(modulesToBuild);
         namesToModules = YangModelSearchUtils.mapModulesByNames(context
                 .getModules());
         configModule = namesToModules.get(ConfigConstants.CONFIG_MODULE);
         namesToModules = YangModelSearchUtils.mapModulesByNames(context
                 .getModules());
         configModule = namesToModules.get(ConfigConstants.CONFIG_MODULE);
index 0bd2db8..3aee10b 100644 (file)
@@ -13,13 +13,12 @@ import static org.junit.Assert.fail;
 import com.google.common.collect.Lists;
 import java.io.InputStream;
 import java.util.List;
 import com.google.common.collect.Lists;
 import java.io.InputStream;
 import java.util.List;
-import java.util.Set;
 import org.junit.Test;
 import org.opendaylight.controller.config.yangjmxgenerator.ConfigConstants;
 import org.opendaylight.controller.config.yangjmxgenerator.ServiceInterfaceEntryTest;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.util.YangModelSearchUtils;
 import org.junit.Test;
 import org.opendaylight.controller.config.yangjmxgenerator.ConfigConstants;
 import org.opendaylight.controller.config.yangjmxgenerator.ServiceInterfaceEntryTest;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.util.YangModelSearchUtils;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
 
 public class UnknownExtensionTest extends ServiceInterfaceEntryTest {
 
 
 public class UnknownExtensionTest extends ServiceInterfaceEntryTest {
 
@@ -29,10 +28,8 @@ public class UnknownExtensionTest extends ServiceInterfaceEntryTest {
                 .getResourceAsStream("test-ifcWithUnknownExtension.yang"));
         yangISs.addAll(getConfigApiYangInputStreams());
         try {
                 .getResourceAsStream("test-ifcWithUnknownExtension.yang"));
         yangISs.addAll(getConfigApiYangInputStreams());
         try {
-            YangParserImpl parser = new YangParserImpl();
-            Set<Module> modulesToBuild = parser
-                    .parseYangModelsFromStreams(yangISs);
-            context = parser.resolveSchemaContext(modulesToBuild);
+            final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+            context = reactor.buildEffective(yangISs);
             namesToModules = YangModelSearchUtils.mapModulesByNames(context
                     .getModules());
             configModule = namesToModules.get(ConfigConstants.CONFIG_MODULE);
             namesToModules = YangModelSearchUtils.mapModulesByNames(context
                     .getModules());
             configModule = namesToModules.get(ConfigConstants.CONFIG_MODULE);
index 0aae571..e027177 100644 (file)
@@ -26,7 +26,7 @@ module config-threads {
              router between event producers and event consumers";
 
         base "config:service-type";
              router between event producers and event consumers";
 
         base "config:service-type";
-        config:java-class2 "com.google.common.eventbus.EventBus";
+        th:java-class2 "com.google.common.eventbus.EventBus";
     }
 
 }
     }
 
 }
index 024385b..c5f95f9 100644 (file)
@@ -9,13 +9,9 @@ package org.opendaylight.controller.md.sal.dom.store.benchmark;
 
 import java.io.InputStream;
 import java.util.Collections;
 
 import java.io.InputStream;
 import java.util.Collections;
-import java.util.Set;
-
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
 
 /**
  * Benchmark Model class loads the odl-datastore-test.yang model from resources.
 
 /**
  * Benchmark Model class loads the odl-datastore-test.yang model from resources.
@@ -36,20 +32,23 @@ public final class BenchmarkModel {
     private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
 
     public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_QNAME);
     private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
 
     public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_QNAME);
-    public static final YangInstanceIdentifier OUTER_LIST_PATH = YangInstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME).build();
-
-    public static final InputStream getDatastoreBenchmarkInputStream() {
-        return getInputStream(DATASTORE_TEST_YANG);
-    }
+    public static final YangInstanceIdentifier OUTER_LIST_PATH =
+            YangInstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME).build();
 
 
-    private static InputStream getInputStream(final String resourceName) {
-        return BenchmarkModel.class.getResourceAsStream(resourceName);
+    private static InputStream getInputStream() {
+        return BenchmarkModel.class.getResourceAsStream(DATASTORE_TEST_YANG);
     }
 
     public static SchemaContext createTestContext() {
     }
 
     public static SchemaContext createTestContext() {
-        YangParserImpl parser = new YangParserImpl();
-        Set<Module> modules = parser.parseYangModelsFromStreams(Collections.singletonList(
-            getDatastoreBenchmarkInputStream()));
-        return parser.resolveSchemaContext(modules);
+        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        final SchemaContext schemaContext;
+        final List<InputStream> streams = Collections.singletonList(getInputStream());
+
+        try {
+            schemaContext = reactor.buildEffective(streams);
+        } catch (ReactorException e) {
+            throw new RuntimeException("Unable to build schema context from " + streams, e);
+        }
+        return schemaContext;
     }
 }
     }
 }
index 0ec48a5..791c540 100644 (file)
@@ -10,13 +10,13 @@ package org.opendaylight.controller.sal.binding.test.connect.dom;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
+
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.MoreExecutors;
 import java.io.InputStream;
 import java.util.Collections;
 import java.util.List;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.MoreExecutors;
 import java.io.InputStream;
 import java.util.Collections;
 import java.util.List;
-import java.util.Set;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import org.junit.After;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import org.junit.After;
@@ -43,11 +43,10 @@ import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
 
 /**
  * Test case for reported bug 560
 
 /**
  * Test case for reported bug 560
@@ -89,16 +88,14 @@ public class DOMRpcServiceTestBugfix560 {
         bindingMountPointService = testContext.getBindingMountProviderService();
         assertNotNull(domMountPointService);
 
         bindingMountPointService = testContext.getBindingMountProviderService();
         assertNotNull(domMountPointService);
 
-        final YangContextParser parser = new YangParserImpl();
         final InputStream moduleStream = BindingReflections.getModuleInfo(
                 OpendaylightTestRpcServiceService.class)
                 .getModuleSourceStream();
 
         assertNotNull(moduleStream);
         final List<InputStream> rpcModels = Collections.singletonList(moduleStream);
         final InputStream moduleStream = BindingReflections.getModuleInfo(
                 OpendaylightTestRpcServiceService.class)
                 .getModuleSourceStream();
 
         assertNotNull(moduleStream);
         final List<InputStream> rpcModels = Collections.singletonList(moduleStream);
-        final Set<Module> modules = parser.parseYangModelsFromStreams(rpcModels);
-        final SchemaContext mountSchemaContext = parser.resolveSchemaContext(modules);
-        schemaContext = mountSchemaContext;
+        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        schemaContext = reactor.buildEffective(rpcModels);
     }
 
     private static org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier createBITllIdentifier(
     }
 
     private static org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier createBITllIdentifier(
@@ -118,8 +115,7 @@ public class DOMRpcServiceTestBugfix560 {
 
     @Test
     public void test() throws ExecutionException, InterruptedException {
 
     @Test
     public void test() throws ExecutionException, InterruptedException {
-        // FIXME: This is made to only make sure instance identifier codec
-        // for path is instantiated.
+        // FIXME: This is made to only make sure instance identifier codec for path is instantiated.
         domMountPointService
                 .createMountPoint(BI_MOUNT_ID).addService(DOMRpcService.class, new DOMRpcService() {
 
         domMountPointService
                 .createMountPoint(BI_MOUNT_ID).addService(DOMRpcService.class, new DOMRpcService() {
 
index 70bae6f..e1607c0 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.controller.cluster.datastore.util;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
+
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import java.io.InputStream;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import java.io.InputStream;
@@ -47,9 +48,10 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableCo
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetEntryNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapEntryNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetEntryNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapEntryNodeBuilder;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
+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;
 
 public class TestModel {
 
 
 public class TestModel {
 
@@ -148,7 +150,6 @@ public class TestModel {
     private static final String FIRST_GRAND_CHILD_NAME = "first grand child";
     private static final String SECOND_GRAND_CHILD_NAME = "second grand child";
 
     private static final String FIRST_GRAND_CHILD_NAME = "first grand child";
     private static final String SECOND_GRAND_CHILD_NAME = "second grand child";
 
-
     private static final MapEntryNode BAR_NODE = mapEntryBuilder(
             OUTER_LIST_QNAME, ID_QNAME, TWO_ID) //
             .withChild(mapNodeBuilder(INNER_LIST_QNAME) //
     private static final MapEntryNode BAR_NODE = mapEntryBuilder(
             OUTER_LIST_QNAME, ID_QNAME, TWO_ID) //
             .withChild(mapNodeBuilder(INNER_LIST_QNAME) //
@@ -179,18 +180,14 @@ public class TestModel {
         inputStreams.add(getDatastoreAugInputStream());
         inputStreams.add(getDatastoreTestNotificationInputStream());
 
         inputStreams.add(getDatastoreAugInputStream());
         inputStreams.add(getDatastoreTestNotificationInputStream());
 
-        YangParserImpl parser = new YangParserImpl();
-        Set<Module> modules = parser.parseYangModelsFromStreams(inputStreams);
-        return parser.resolveSchemaContext(modules);
+        return resolveSchemaContext(inputStreams);
     }
 
     public static SchemaContext createTestContextWithoutTestSchema() {
         List<InputStream> inputStreams = new ArrayList<>();
         inputStreams.add(getDatastoreTestNotificationInputStream());
 
     }
 
     public static SchemaContext createTestContextWithoutTestSchema() {
         List<InputStream> inputStreams = new ArrayList<>();
         inputStreams.add(getDatastoreTestNotificationInputStream());
 
-        YangParserImpl parser = new YangParserImpl();
-        Set<Module> modules = parser.parseYangModelsFromStreams(inputStreams);
-        return parser.resolveSchemaContext(modules);
+        return resolveSchemaContext(inputStreams);
     }
 
 
     }
 
 
@@ -199,11 +196,20 @@ public class TestModel {
         inputStreams.add(getDatastoreTestInputStream());
         inputStreams.add(getDatastoreTestNotificationInputStream());
 
         inputStreams.add(getDatastoreTestInputStream());
         inputStreams.add(getDatastoreTestNotificationInputStream());
 
-        YangParserImpl parser = new YangParserImpl();
-        Set<Module> modules = parser.parseYangModelsFromStreams(inputStreams);
-        return parser.resolveSchemaContext(modules);
+        return resolveSchemaContext(inputStreams);
     }
 
     }
 
+    private static SchemaContext resolveSchemaContext(List<InputStream> streams) {
+        final 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;
+    }
 
     /**
      * Returns a test document
 
     /**
      * Returns a test document
index 0b05f9e..b82f534 100644 (file)
@@ -12,12 +12,15 @@ import com.google.common.collect.Lists;
 import com.google.common.io.ByteSource;
 import java.io.IOException;
 import java.io.InputStream;
 import com.google.common.io.ByteSource;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.ArrayList;
 import javax.xml.parsers.DocumentBuilderFactory;
 import org.junit.Before;
 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 javax.xml.parsers.DocumentBuilderFactory;
 import org.junit.Before;
 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.impl.YangParserImpl;
+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;
 
 // FIXME : CompositeNode is not avaliable anymore so fix the test to use NormalizedNodeContainer ASAP
 public class XmlUtilsTest {
 
 // FIXME : CompositeNode is not avaliable anymore so fix the test to use NormalizedNodeContainer ASAP
 public class XmlUtilsTest {
@@ -33,7 +36,7 @@ public class XmlUtilsTest {
     BUILDERFACTORY = factory;
   }
 
     BUILDERFACTORY = factory;
   }
 
-  private SchemaContext schema;
+  private SchemaContext schemaContext;
   private RpcDefinition testRpc;
 
   public static final String XML_CONTENT = "<add-flow xmlns=\"urn:opendaylight:controller:rpc:test\"><input xmlns=\"urn:opendaylight:controller:rpc:test\">" +
   private RpcDefinition testRpc;
 
   public static final String XML_CONTENT = "<add-flow xmlns=\"urn:opendaylight:controller:rpc:test\"><input xmlns=\"urn:opendaylight:controller:rpc:test\">" +
@@ -49,8 +52,18 @@ public class XmlUtilsTest {
         return XmlUtilsTest.this.getClass().getResourceAsStream("rpcTest.yang");
       }
     };
         return XmlUtilsTest.this.getClass().getResourceAsStream("rpcTest.yang");
       }
     };
-    schema = new YangParserImpl().parseSources(Lists.newArrayList(byteSource));
-    final Module rpcTestModule = schema.getModules().iterator().next();
+
+    final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+    final ArrayList<ByteSource> sources = Lists.newArrayList(byteSource);
+
+    try {
+
+      schemaContext = reactor.buildEffective(sources);
+    } catch (ReactorException e) {
+      throw new RuntimeException("Unable to build schema context from " + sources, e);
+    }
+
+    final Module rpcTestModule = schemaContext.getModules().iterator().next();
     testRpc = rpcTestModule.getRpcs().iterator().next();
   }
 
     testRpc = rpcTestModule.getRpcs().iterator().next();
   }
 
index 0757c0c..fe2aed7 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.controller.md.cluster.datastore.model;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
+
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.HashSet;
@@ -33,9 +34,10 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContaine
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetEntryNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetEntryNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
+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;
 
 public class CompositeModel {
 
 
 public class CompositeModel {
 
@@ -213,7 +215,7 @@ public class CompositeModel {
   }
 
   private static InputStream getInputStream(final String resourceName) {
   }
 
   private static InputStream getInputStream(final String resourceName) {
-    return TestModel.class.getResourceAsStream(resourceName);
+    return CompositeModel.class.getResourceAsStream(resourceName);
   }
 
   public static SchemaContext createTestContext() {
   }
 
   public static SchemaContext createTestContext() {
@@ -222,9 +224,15 @@ public class CompositeModel {
     inputStreams.add(getDatastoreAugInputStream());
     inputStreams.add(getDatastoreTestNotificationInputStream());
 
     inputStreams.add(getDatastoreAugInputStream());
     inputStreams.add(getDatastoreTestNotificationInputStream());
 
-    YangParserImpl parser = new YangParserImpl();
-    Set<Module> modules = parser.parseYangModelsFromStreams(inputStreams);
-    return parser.resolveSchemaContext(modules);
+    final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+    final SchemaContext schemaContext;
+
+    try {
+      schemaContext = reactor.buildEffective(inputStreams);
+    } catch (ReactorException e) {
+        throw new RuntimeException("Unable to build schema context from " + inputStreams, e);
+    }
+    return schemaContext;
   }
 
   /**
   }
 
   /**
index 85e9893..2a3e621 100644 (file)
@@ -8,18 +8,19 @@
 
 package org.opendaylight.controller.md.cluster.datastore.model;
 
 
 package org.opendaylight.controller.md.cluster.datastore.model;
 
+import com.google.common.io.ByteSource;
 import com.google.common.io.Resources;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import com.google.common.io.Resources;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.MalformedURLException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
-import java.util.Set;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
+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;
 
 public class SchemaContextHelper {
 
 
 public class SchemaContextHelper {
 
@@ -28,7 +29,7 @@ public class SchemaContextHelper {
     public static final String CARS_YANG = "/cars.yang";
 
     public static InputStream getInputStream(final String yangFileName) {
     public static final String CARS_YANG = "/cars.yang";
 
     public static InputStream getInputStream(final String yangFileName) {
-        return TestModel.class.getResourceAsStream(yangFileName);
+        return SchemaContextHelper.class.getResourceAsStream(yangFileName);
     }
 
     public static SchemaContext full(){
     }
 
     public static SchemaContext full(){
@@ -36,24 +37,41 @@ public class SchemaContextHelper {
     }
 
     public static SchemaContext select(String... schemaFiles){
     }
 
     public static SchemaContext select(String... schemaFiles){
-        YangParserImpl parser = new YangParserImpl();
+        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        final SchemaContext schemaContext;
         List<InputStream> streams = new ArrayList<>();
 
         for(String schemaFile : schemaFiles){
             streams.add(getInputStream(schemaFile));
         }
 
         List<InputStream> streams = new ArrayList<>();
 
         for(String schemaFile : schemaFiles){
             streams.add(getInputStream(schemaFile));
         }
 
-        Set<Module> modules = parser.parseYangModelsFromStreams(streams);
-        return parser.resolveSchemaContext(modules);
+        try {
+            schemaContext = reactor.buildEffective(streams);
+        } catch (ReactorException e) {
+            throw new RuntimeException("Unable to build schema context from " + streams, e);
+        }
+
+        return schemaContext;
     }
 
     public static SchemaContext entityOwners() {
     }
 
     public static SchemaContext entityOwners() {
-        YangParserImpl parser = new YangParserImpl();
+        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        final SchemaContext schemaContext;
+        File file = null;
+
         try {
         try {
-            File file = new File("src/main/yang/entity-owners.yang");
-            return parser.parseSources(Arrays.asList(Resources.asByteSource(file.toURI().toURL())));
-        } catch (IOException | YangSyntaxErrorException e) {
-            throw new ExceptionInInitializerError(e);
+            file = new File("src/main/yang/entity-owners.yang");
+            final List<ByteSource> sources = Arrays.asList(Resources.asByteSource(file.toURI().toURL()));
+            try {
+                schemaContext = reactor.buildEffective(sources);
+            } catch (IOException e1) {
+                throw new ExceptionInInitializerError(e1);
+            } catch (ReactorException e2) {
+                throw new RuntimeException("Unable to build schema context from " + sources, e2);
+            }
+            return schemaContext;
+        } catch (MalformedURLException e3) {
+            throw new RuntimeException("Malformed URL detected in " + file, e3);
         }
     }
 }
         }
     }
 }
index 86c0f11..75bd9a0 100644 (file)
@@ -7,10 +7,11 @@
  */
 package org.opendaylight.controller.md.cluster.datastore.model;
 
  */
 package org.opendaylight.controller.md.cluster.datastore.model;
 
+import com.google.common.io.ByteSource;
 import com.google.common.io.Resources;
 import java.io.IOException;
 import com.google.common.io.Resources;
 import java.io.IOException;
-import java.io.InputStream;
 import java.util.Collections;
 import java.util.Collections;
+import java.util.Set;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
@@ -22,19 +23,20 @@ import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
+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;
 
 public class TestModel {
 
 
 public class TestModel {
 
-    public static final QName TEST_QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13",
-            "test");
+    public static final QName TEST_QNAME =
+            QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13", "test");
 
 
-    public static final QName TEST2_QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13",
-            "test2");
+    public static final QName TEST2_QNAME =
+            QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13", "test2");
 
 
-    public static final QName JUNK_QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:junk", "2014-03-13",
-            "junk");
+    public static final QName JUNK_QNAME =
+            QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:junk", "2014-03-13", "junk");
 
 
     public static final QName OUTER_LIST_QNAME = QName.create(TEST_QNAME, "outer-list");
 
 
     public static final QName OUTER_LIST_QNAME = QName.create(TEST_QNAME, "outer-list");
@@ -57,18 +59,20 @@ public class TestModel {
     public static final QName TWO_QNAME = QName.create(TEST_QNAME,"two");
     public static final QName THREE_QNAME = QName.create(TEST_QNAME,"three");
 
     public static final QName TWO_QNAME = QName.create(TEST_QNAME,"two");
     public static final QName THREE_QNAME = QName.create(TEST_QNAME,"three");
 
-
-    public static final InputStream getDatastoreTestInputStream() {
-        return TestModel.class.getResourceAsStream(DATASTORE_TEST_YANG);
-    }
-
     public static SchemaContext createTestContext() {
     public static SchemaContext createTestContext() {
-        YangParserImpl parser = new YangParserImpl();
+        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        final SchemaContext schemaContext;
+        final Set<ByteSource> sources = Collections.singleton(Resources.asByteSource(TestModel.class.getResource
+                (DATASTORE_TEST_YANG)));
+
         try {
         try {
-            return parser.parseSources(Collections.singleton(Resources.asByteSource(TestModel.class.getResource(DATASTORE_TEST_YANG))));
-        } catch (IOException | YangSyntaxErrorException e) {
-            throw new ExceptionInInitializerError(e);
+            schemaContext = reactor.buildEffective(sources);
+        } catch (IOException e1) {
+            throw new ExceptionInInitializerError(e1);
+        }  catch (ReactorException e2) {
+            throw new RuntimeException("Unable to build schema context from " + sources, e2);
         }
         }
+        return schemaContext;
     }
 
     public static DataContainerChild<?, ?> outerNode(int... ids) {
     }
 
     public static DataContainerChild<?, ?> outerNode(int... ids) {
index 09835ec..5013b46 100644 (file)
@@ -7,48 +7,50 @@
  */
 package org.opendaylight.controller.md.sal.dom.store.impl;
 
  */
 package org.opendaylight.controller.md.sal.dom.store.impl;
 
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.List;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
-
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.Set;
+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;
 
 public class TestModel {
 
 
 public class TestModel {
 
-    public static final QName TEST_QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13",
-            "test");
-    public static final QName TEST2_QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13",
-            "test2");
+    public static final QName TEST_QNAME =
+            QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13", "test");
+    public static final QName TEST2_QNAME =
+            QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13", "test2");
     public static final QName OUTER_LIST_QNAME = QName.create(TEST_QNAME, "outer-list");
     public static final QName INNER_LIST_QNAME = QName.create(TEST_QNAME, "inner-list");
     public static final QName OUTER_CHOICE_QNAME = QName.create(TEST_QNAME, "outer-choice");
     public static final QName ID_QNAME = QName.create(TEST_QNAME, "id");
     public static final QName NAME_QNAME = QName.create(TEST_QNAME, "name");
     public static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value");
     public static final QName OUTER_LIST_QNAME = QName.create(TEST_QNAME, "outer-list");
     public static final QName INNER_LIST_QNAME = QName.create(TEST_QNAME, "inner-list");
     public static final QName OUTER_CHOICE_QNAME = QName.create(TEST_QNAME, "outer-choice");
     public static final QName ID_QNAME = QName.create(TEST_QNAME, "id");
     public static final QName NAME_QNAME = QName.create(TEST_QNAME, "name");
     public static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value");
-    private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
-
-    public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_QNAME);
-    public static final YangInstanceIdentifier TEST2_PATH = YangInstanceIdentifier.of(TEST2_QNAME);
-    public static final YangInstanceIdentifier OUTER_LIST_PATH = YangInstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME).build();
     public static final QName TWO_QNAME = QName.create(TEST_QNAME,"two");
     public static final QName THREE_QNAME = QName.create(TEST_QNAME,"three");
     public static final QName TWO_QNAME = QName.create(TEST_QNAME,"two");
     public static final QName THREE_QNAME = QName.create(TEST_QNAME,"three");
+    public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_QNAME);
+    public static final YangInstanceIdentifier TEST2_PATH = YangInstanceIdentifier.of(TEST2_QNAME);
+    public static final YangInstanceIdentifier OUTER_LIST_PATH =
+            YangInstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME).build();
+    private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
 
 
-
-    public static final InputStream getDatastoreTestInputStream() {
-        return getInputStream(DATASTORE_TEST_YANG);
-    }
-
-    private static InputStream getInputStream(final String resourceName) {
+    private static InputStream getInputStream() {
         return TestModel.class.getResourceAsStream(DATASTORE_TEST_YANG);
     }
 
     public static SchemaContext createTestContext() {
         return TestModel.class.getResourceAsStream(DATASTORE_TEST_YANG);
     }
 
     public static SchemaContext createTestContext() {
-        YangParserImpl parser = new YangParserImpl();
-        Set<Module> modules = parser.parseYangModelsFromStreams(Collections.singletonList(getDatastoreTestInputStream()));
-        return parser.resolveSchemaContext(modules);
+        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        final SchemaContext schemaContext;
+        final List<InputStream> streams = Collections.singletonList(getInputStream());
+
+        try {
+            schemaContext = reactor.buildEffective(streams);
+        } catch (ReactorException e) {
+            throw new RuntimeException("Unable to build schema context from " + streams, e);
+        }
+        return schemaContext;
     }
 }
     }
 }
index b7238ab..d96769b 100644 (file)
@@ -11,8 +11,7 @@ package org.opendaylight.xsql.test;
 import java.io.InputStream;
 import java.sql.SQLException;
 import java.util.Collections;
 import java.io.InputStream;
 import java.sql.SQLException;
 import java.util.Collections;
-import java.util.Set;
-
+import java.util.List;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -21,9 +20,10 @@ import org.opendaylight.controller.md.sal.dom.xsql.XSQLAdapter;
 import org.opendaylight.controller.md.sal.dom.xsql.XSQLBluePrint;
 import org.opendaylight.controller.md.sal.dom.xsql.jdbc.JDBCResultSet;
 import org.opendaylight.controller.md.sal.dom.xsql.jdbc.JDBCServer;
 import org.opendaylight.controller.md.sal.dom.xsql.XSQLBluePrint;
 import org.opendaylight.controller.md.sal.dom.xsql.jdbc.JDBCResultSet;
 import org.opendaylight.controller.md.sal.dom.xsql.jdbc.JDBCServer;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
+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;
 
 public class XSQLTest {
     private static final String DATASTORE_TEST_YANG = "/sal-persisted-dom-test.yang";
 
 public class XSQLTest {
     private static final String DATASTORE_TEST_YANG = "/sal-persisted-dom-test.yang";
@@ -187,17 +187,20 @@ public class XSQLTest {
         System.out.println(str);
     }
 
         System.out.println(str);
     }
 
-    public static final InputStream getDatastoreTestInputStream() {
-        return getInputStream(DATASTORE_TEST_YANG);
-    }
-
-    private static InputStream getInputStream(final String resourceName) {
+    private static InputStream getInputStream() {
         return XSQLTest.class.getResourceAsStream(DATASTORE_TEST_YANG);
     }
 
     public static SchemaContext createTestContext() {
         return XSQLTest.class.getResourceAsStream(DATASTORE_TEST_YANG);
     }
 
     public static SchemaContext createTestContext() {
-        YangParserImpl parser = new YangParserImpl();
-        Set<Module> modules = parser.parseYangModelsFromStreams(Collections.singletonList(getDatastoreTestInputStream()));
-        return parser.resolveSchemaContext(modules);
+        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        final SchemaContext schemaContext;
+        final List<InputStream> streams = Collections.singletonList(getInputStream());
+
+        try {
+            schemaContext = reactor.buildEffective(streams);
+        } catch (ReactorException e) {
+            throw new RuntimeException("Unable to build schema context from " + streams, e);
+        }
+        return schemaContext;
     }
 }
     }
 }
index 66e71a3..247f4b2 100644 (file)
@@ -7,45 +7,47 @@
  */
 package org.opendaylight.controller.md.sal.dom.store.impl;
 
  */
 package org.opendaylight.controller.md.sal.dom.store.impl;
 
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.List;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
-
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.Set;
+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;
 
 public class TestModel {
 
 
 public class TestModel {
 
-    public static final QName TEST_QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13",
-        "test");
+    public static final QName TEST_QNAME =
+            QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13", "test");
     public static final QName OUTER_LIST_QNAME = QName.create(TEST_QNAME, "outer-list");
     public static final QName INNER_LIST_QNAME = QName.create(TEST_QNAME, "inner-list");
     public static final QName OUTER_CHOICE_QNAME = QName.create(TEST_QNAME, "outer-choice");
     public static final QName ID_QNAME = QName.create(TEST_QNAME, "id");
     public static final QName NAME_QNAME = QName.create(TEST_QNAME, "name");
     public static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value");
     public static final QName OUTER_LIST_QNAME = QName.create(TEST_QNAME, "outer-list");
     public static final QName INNER_LIST_QNAME = QName.create(TEST_QNAME, "inner-list");
     public static final QName OUTER_CHOICE_QNAME = QName.create(TEST_QNAME, "outer-choice");
     public static final QName ID_QNAME = QName.create(TEST_QNAME, "id");
     public static final QName NAME_QNAME = QName.create(TEST_QNAME, "name");
     public static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value");
-    private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
-
-    public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_QNAME);
-    public static final YangInstanceIdentifier OUTER_LIST_PATH = YangInstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME).build();
     public static final QName TWO_QNAME = QName.create(TEST_QNAME, "two");
     public static final QName THREE_QNAME = QName.create(TEST_QNAME, "three");
     public static final QName TWO_QNAME = QName.create(TEST_QNAME, "two");
     public static final QName THREE_QNAME = QName.create(TEST_QNAME, "three");
+    public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_QNAME);
+    public static final YangInstanceIdentifier OUTER_LIST_PATH =
+            YangInstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME).build();
+    private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
 
 
-
-    public static final InputStream getDatastoreTestInputStream() {
-        return getInputStream(DATASTORE_TEST_YANG);
-    }
-
-    private static InputStream getInputStream(final String resourceName) {
+    private static InputStream getInputStream() {
         return TestModel.class.getResourceAsStream(DATASTORE_TEST_YANG);
     }
 
     public static SchemaContext createTestContext() {
         return TestModel.class.getResourceAsStream(DATASTORE_TEST_YANG);
     }
 
     public static SchemaContext createTestContext() {
-        YangParserImpl parser = new YangParserImpl();
-        Set<Module> modules = parser.parseYangModelsFromStreams(Collections.singletonList(getDatastoreTestInputStream()));
-        return parser.resolveSchemaContext(modules);
+        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        final SchemaContext schemaContext;
+        final List<InputStream> streams = Collections.singletonList(getInputStream());
+
+        try {
+            schemaContext = reactor.buildEffective(streams);
+        } catch (ReactorException e) {
+            throw new RuntimeException("Unable to build schema context from " + streams, e);
+        }
+        return schemaContext;
     }
 }
     }
 }
index f88b0c6..3c8cb65 100644 (file)
@@ -16,9 +16,12 @@ import static org.junit.Assert.assertTrue;
 import akka.actor.ActorRef;
 import akka.actor.ActorSystem;
 import akka.testkit.JavaTestKit;
 import akka.actor.ActorRef;
 import akka.actor.ActorSystem;
 import akka.testkit.JavaTestKit;
-import java.io.File;
+import com.google.common.collect.Lists;
+import com.google.common.io.ByteSource;
+import java.io.IOException;
+import java.io.InputStream;
 import java.net.URI;
 import java.net.URI;
-import java.util.Arrays;
+import java.util.ArrayList;
 import java.util.Collection;
 import org.junit.AfterClass;
 import org.junit.Before;
 import java.util.Collection;
 import org.junit.AfterClass;
 import org.junit.Before;
@@ -40,7 +43,9 @@ import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
+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;
 
 /**
  * Base class for RPC tests.
 
 /**
  * Base class for RPC tests.
@@ -95,9 +100,22 @@ public class AbstractRpcTest {
     }
 
     @Before
     }
 
     @Before
-    public void setUp() {
-        schemaContext = new YangParserImpl().parseFiles(Arrays.asList(
-                new File(RpcBrokerTest.class.getResource("/test-rpc.yang").getPath())));
+    public void setUp() throws Exception {
+        final ByteSource byteSource = new ByteSource() {
+            @Override
+            public InputStream openStream() throws IOException {
+                return AbstractRpcTest.this.getClass().getResourceAsStream("/test-rpc.yang");
+            }
+        };
+
+        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        final ArrayList<ByteSource> sources = Lists.newArrayList(byteSource);
+
+        try {
+            schemaContext = reactor.buildEffective(sources);
+        } catch (ReactorException e) {
+            throw new RuntimeException("Unable to build schema context from " + sources, e);
+        }
 
         domRpcService1 = Mockito.mock(DOMRpcService.class);
         domRpcService2 = Mockito.mock(DOMRpcService.class);
 
         domRpcService1 = Mockito.mock(DOMRpcService.class);
         domRpcService2 = Mockito.mock(DOMRpcService.class);
@@ -108,7 +126,6 @@ public class AbstractRpcTest {
         remoteRpcImpl1 = new RemoteRpcImplementation(rpcRegistry1Probe.getRef(), config1);
         remoteRpcImpl2 = new RemoteRpcImplementation(rpcRegistry2Probe.getRef(), config2);
 
         remoteRpcImpl1 = new RemoteRpcImplementation(rpcRegistry1Probe.getRef(), config1);
         remoteRpcImpl2 = new RemoteRpcImplementation(rpcRegistry2Probe.getRef(), config2);
 
-
     }
 
     static void assertRpcErrorEquals(final RpcError rpcError, final ErrorSeverity severity,
     }
 
     static void assertRpcErrorEquals(final RpcError rpcError, final ErrorSeverity severity,

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.