2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.md.sal.dom.store.impl;
10 import java.io.IOException;
11 import java.io.InputStream;
12 import java.util.Collections;
13 import java.util.List;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
16 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
17 import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
19 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
20 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
21 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
23 public class TestModel {
25 public static final QName TEST_QNAME =
26 QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13", "test");
27 public static final QName OUTER_LIST_QNAME = QName.create(TEST_QNAME, "outer-list");
28 public static final QName INNER_LIST_QNAME = QName.create(TEST_QNAME, "inner-list");
29 public static final QName OUTER_CHOICE_QNAME = QName.create(TEST_QNAME, "outer-choice");
30 public static final QName ID_QNAME = QName.create(TEST_QNAME, "id");
31 public static final QName NAME_QNAME = QName.create(TEST_QNAME, "name");
32 public static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value");
33 public static final QName TWO_QNAME = QName.create(TEST_QNAME, "two");
34 public static final QName THREE_QNAME = QName.create(TEST_QNAME, "three");
35 public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_QNAME);
36 public static final YangInstanceIdentifier OUTER_LIST_PATH =
37 YangInstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME).build();
38 private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
40 public static SchemaContext createTestContext() throws IOException, YangSyntaxErrorException, ReactorException {
41 return parseYangStreams(Collections.singletonList(getInputStream()));
44 private static InputStream getInputStream() {
45 return TestModel.class.getResourceAsStream(DATASTORE_TEST_YANG);
48 private static SchemaContext parseYangStreams(List<InputStream> streams)
49 throws SourceException, ReactorException {
51 CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
53 return reactor.buildEffective(streams);