*/
package org.opendaylight.controller.md.sal.dom.store.impl;
-import com.google.common.io.ByteSource;
-import com.google.common.io.Resources;
import java.io.IOException;
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.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.spi.source.SourceException;
-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;
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");
- 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");
-
- // private static ByteSource getInputStream() {
- // return Resources.asByteSource(TestModel.class.getResource(DATASTORE_TEST_YANG));
- // }
-
- private static InputStream getInputStream() {
- return TestModel.class.getResourceAsStream(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();
+ private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
public static SchemaContext createTestContext() throws IOException, YangSyntaxErrorException, ReactorException {
- //YangParserImpl parser = new YangParserImpl();
- //return parser.parseSources(Collections.singletonList(getInputStream()));
- return parseYangStreams(Collections.singletonList(getInputStream()));
+ return YangParserTestUtils.parseYangStreams(Collections.singletonList(getInputStream()));
}
- private static SchemaContext parseYangStreams(List<InputStream> streams)
- throws SourceException, ReactorException {
-
- CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
- .newBuild();
- return reactor.buildEffective(streams);
+ private static InputStream getInputStream() {
+ return TestModel.class.getResourceAsStream(DATASTORE_TEST_YANG);
}
}