a5a1d935e5076843d477e24f8be19c1db43d915f
[yangtools.git] / benchmarks / src / main / java / org / opendaylight / yangtools / yang / data / impl / tree / BenchmarkModel.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.yangtools.yang.data.impl.tree;
9
10 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
11 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
12
13 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
14 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
15 import java.io.InputStream;
16 import java.util.Collections;
17 import org.opendaylight.yangtools.yang.common.QName;
18 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
19 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
20
21 /**
22  * @author Lukas Sedlak <lsedlak@cisco.com>
23  */
24 public class BenchmarkModel {
25
26     public static final QName TEST_QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13",
27         "test");
28     public static final QName OUTER_LIST_QNAME = QName.create(TEST_QNAME, "outer-list");
29     public static final QName INNER_LIST_QNAME = QName.create(TEST_QNAME, "inner-list");
30     public static final QName OUTER_CHOICE_QNAME = QName.create(TEST_QNAME, "outer-choice");
31     public static final QName ID_QNAME = QName.create(TEST_QNAME, "id");
32     public static final QName NAME_QNAME = QName.create(TEST_QNAME, "name");
33     public static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value");
34     private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
35
36     public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_QNAME);
37     public static final YangInstanceIdentifier OUTER_LIST_PATH = YangInstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME).build();
38
39     public static final InputStream getDatastoreBenchmarkInputStream() {
40         return getInputStream(DATASTORE_TEST_YANG);
41     }
42
43     private static InputStream getInputStream(final String resourceName) {
44         return BenchmarkModel.class.getResourceAsStream(resourceName);
45     }
46
47     public static SchemaContext createTestContext() throws SourceException, ReactorException {
48         CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
49         SchemaContext schemaContext = reactor.buildEffective(Collections.singletonList(
50             getDatastoreBenchmarkInputStream()));
51
52         return schemaContext;
53     }
54
55 }