X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fmd-sal%2Fsal-dom-xsql%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fxsql%2Ftest%2FXSQLTest.java;h=d96769bad8bfa12f637ae98906699c5293578922;hb=f781598707f0810491cb571f835ee49772e00e83;hp=e3f5fbb81018f9a915b37bca39d401ad96b0ca29;hpb=2801b4929e60938cdac4c84dff6422e24e93d11d;p=controller.git diff --git a/opendaylight/md-sal/sal-dom-xsql/src/test/java/org/opendaylight/xsql/test/XSQLTest.java b/opendaylight/md-sal/sal-dom-xsql/src/test/java/org/opendaylight/xsql/test/XSQLTest.java index e3f5fbb810..d96769bad8 100644 --- a/opendaylight/md-sal/sal-dom-xsql/src/test/java/org/opendaylight/xsql/test/XSQLTest.java +++ b/opendaylight/md-sal/sal-dom-xsql/src/test/java/org/opendaylight/xsql/test/XSQLTest.java @@ -1,10 +1,17 @@ +/* + * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + package org.opendaylight.xsql.test; 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; @@ -13,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.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.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"; @@ -179,17 +187,20 @@ public class XSQLTest { 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() { - YangParserImpl parser = new YangParserImpl(); - Set modules = parser.parseYangModelsFromStreams(Collections.singletonList(getDatastoreTestInputStream())); - return parser.resolveSchemaContext(modules); + final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); + final SchemaContext schemaContext; + final List 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; } }