9761ed8615a763df20ec6763defc69b55395a120
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / md / cluster / datastore / model / 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.cluster.datastore.model;
9
10 import java.io.InputStream;
11 import java.util.Collections;
12 import java.util.Set;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
15 import org.opendaylight.yangtools.yang.model.api.Module;
16 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
17 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
18
19 public class TestModel {
20
21   public static final QName TEST_QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13",
22           "test");
23
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 DESC_QNAME = QName.create(TEST_QNAME, "desc");
30   public static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value");
31   private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
32
33   public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_QNAME);
34   public static final YangInstanceIdentifier OUTER_LIST_PATH = YangInstanceIdentifier.builder(TEST_PATH).
35           node(OUTER_LIST_QNAME).build();
36   public static final YangInstanceIdentifier INNER_LIST_PATH = YangInstanceIdentifier.builder(TEST_PATH).
37           node(OUTER_LIST_QNAME).node(INNER_LIST_QNAME).build();
38   public static final QName TWO_QNAME = QName.create(TEST_QNAME,"two");
39   public static final QName THREE_QNAME = QName.create(TEST_QNAME,"three");
40
41
42   public static final InputStream getDatastoreTestInputStream() {
43     return getInputStream(DATASTORE_TEST_YANG);
44   }
45
46   private static InputStream getInputStream(final String resourceName) {
47     return TestModel.class.getResourceAsStream(DATASTORE_TEST_YANG);
48   }
49
50   public static SchemaContext createTestContext() {
51     YangParserImpl parser = new YangParserImpl();
52     Set<Module> modules = parser.parseYangModelsFromStreams(Collections.singletonList(getDatastoreTestInputStream()));
53     return parser.resolveSchemaContext(modules);
54   }
55 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.