Merge "Bug 499: Initial implementation of data tree modifications"
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / test / java / org / opendaylight / controller / md / sal / dom / store / impl / TestModel.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.md.sal.dom.store.impl;
9
10 import java.io.InputStream;
11 import java.util.Collections;
12 import java.util.Set;
13
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
16 import org.opendaylight.yangtools.yang.model.api.Module;
17 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
18 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
19
20 public class TestModel {
21
22     public static final QName TEST_QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13",
23             "test");
24     public static final QName OUTER_LIST_QNAME = QName.create(TEST_QNAME, "outer-list");
25     public static final QName INNER_LIST_QNAME = QName.create(TEST_QNAME, "inner-list");
26     public static final QName OUTER_CHOICE_QNAME = QName.create(TEST_QNAME, "outer-choice");
27     public static final QName ID_QNAME = QName.create(TEST_QNAME, "id");
28     public static final QName NAME_QNAME = QName.create(TEST_QNAME, "name");
29     public static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value");
30     private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
31
32     public static final InstanceIdentifier TEST_PATH = InstanceIdentifier.of(TEST_QNAME);
33     public static final InstanceIdentifier OUTER_LIST_PATH = InstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME).build();
34
35
36     public static final InputStream getDatastoreTestInputStream() {
37         return getInputStream(DATASTORE_TEST_YANG);
38     }
39
40     private static InputStream getInputStream(final String resourceName) {
41         return TestModel.class.getResourceAsStream(DATASTORE_TEST_YANG);
42     }
43
44     public static SchemaContext createTestContext() {
45         YangParserImpl parser = new YangParserImpl();
46         Set<Module> modules = parser.parseYangModelsFromStreams(Collections.singletonList(getDatastoreTestInputStream()));
47         return parser.resolveSchemaContext(modules);
48     }
49 }