Fix CDS unit test failures
[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 com.google.common.io.Resources;
11 import java.io.IOException;
12 import java.io.InputStream;
13 import java.util.Collections;
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.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
25     public static final QName TEST2_QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13",
26             "test2");
27
28     public static final QName JUNK_QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:junk", "2014-03-13",
29             "junk");
30
31
32     public static final QName OUTER_LIST_QNAME = QName.create(TEST_QNAME, "outer-list");
33     public static final QName INNER_LIST_QNAME = QName.create(TEST_QNAME, "inner-list");
34     public static final QName OUTER_CHOICE_QNAME = QName.create(TEST_QNAME, "outer-choice");
35     public static final QName ID_QNAME = QName.create(TEST_QNAME, "id");
36     public static final QName NAME_QNAME = QName.create(TEST_QNAME, "name");
37     public static final QName DESC_QNAME = QName.create(TEST_QNAME, "desc");
38     private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
39
40     public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_QNAME);
41     public static final YangInstanceIdentifier TEST2_PATH = YangInstanceIdentifier.of(TEST2_QNAME);
42     public static final YangInstanceIdentifier JUNK_PATH = YangInstanceIdentifier.of(JUNK_QNAME);
43     public static final YangInstanceIdentifier OUTER_LIST_PATH = YangInstanceIdentifier.builder(TEST_PATH).
44             node(OUTER_LIST_QNAME).build();
45     public static final YangInstanceIdentifier INNER_LIST_PATH = YangInstanceIdentifier.builder(TEST_PATH).
46             node(OUTER_LIST_QNAME).node(INNER_LIST_QNAME).build();
47     public static final QName TWO_QNAME = QName.create(TEST_QNAME,"two");
48     public static final QName THREE_QNAME = QName.create(TEST_QNAME,"three");
49
50
51     public static final InputStream getDatastoreTestInputStream() {
52         return TestModel.class.getResourceAsStream(DATASTORE_TEST_YANG);
53     }
54
55     public static SchemaContext createTestContext() {
56         YangParserImpl parser = new YangParserImpl();
57         try {
58             return parser.parseSources(Collections.singleton(Resources.asByteSource(TestModel.class.getResource(DATASTORE_TEST_YANG))));
59         } catch (IOException | YangSyntaxErrorException e) {
60             throw new ExceptionInInitializerError(e);
61         }
62     }
63 }