Fix benchmark compilation and runtime
[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 java.io.IOException;
11 import org.opendaylight.yangtools.yang.common.QName;
12 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
13 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
14 import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
15 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
16 import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YangStatementStreamSource;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
18 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
19 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
20
21 /**
22  * @author Lukas Sedlak <lsedlak@cisco.com>
23  */
24 public class BenchmarkModel {
25
26     public static final QName TEST_QNAME =
27             QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13", "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
35     public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_QNAME);
36     public static final YangInstanceIdentifier OUTER_LIST_PATH = YangInstanceIdentifier.builder(TEST_PATH)
37             .node(OUTER_LIST_QNAME).build();
38
39     public static SchemaContext createTestContext() {
40         CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
41         try {
42             reactor.addSource(YangStatementStreamSource.create(
43                 YangTextSchemaSource.forResource("/odl-datastore-test.yang")));
44             return reactor.buildEffective();
45         } catch (IOException | YangSyntaxErrorException | ReactorException e) {
46             throw new IllegalStateException(e);
47         }
48     }
49 }