-
- private static final DocumentBuilderFactory BUILDERFACTORY;
-
- static {
- final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
- factory.setCoalescing(true);
- factory.setIgnoringElementContentWhitespace(true);
- factory.setIgnoringComments(true);
- BUILDERFACTORY = factory;
- }
-
- private SchemaContext schema;
- private RpcDefinition testRpc;
-
- public static final String XML_CONTENT = "<add-flow xmlns=\"urn:opendaylight:controller:rpc:test\"><input xmlns=\"urn:opendaylight:controller:rpc:test\">" +
- "<id>flowid</id>" +
- "<flow xmlns:ltha=\"urn:opendaylight:controller:rpc:test\">/ltha:node/ltha:node1[ltha:id='3@java.lang.Short']</flow>" +
- "</input></add-flow>";
-
- @Before
- public void setUp() throws Exception {
- final ByteSource byteSource = new ByteSource() {
- @Override
- public InputStream openStream() throws IOException {
- return XmlUtilsTest.this.getClass().getResourceAsStream("rpcTest.yang");
- }
- };
- schema = new YangParserImpl().parseSources(Lists.newArrayList(byteSource));
- final Module rpcTestModule = schema.getModules().iterator().next();
- testRpc = rpcTestModule.getRpcs().iterator().next();
- }
-
+ public static final String XML_CONTENT = "<add-flow xmlns=\"urn:opendaylight:controller:rpc:test\">"
+ + "<input xmlns=\"urn:opendaylight:controller:rpc:test\"><id>flowid</id>"
+ + "<flow xmlns:ltha=\"urn:opendaylight:controller:rpc:test\">/ltha:node/ltha:node1"
+ + "[ltha:id='3@java.lang.Short']</flow></input></add-flow>";
+
+ private SchemaContext schemaContext;
+
+ @Before
+ public void setUp() throws Exception {
+ final ByteSource byteSource = new ByteSource() {
+ @Override
+ public InputStream openStream() throws IOException {
+ return XmlUtilsTest.this.getClass().getResourceAsStream("rpcTest.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);
+ }
+
+ final Module rpcTestModule = schemaContext.getModules().iterator().next();
+ rpcTestModule.getRpcs().iterator().next();
+ }