Get rid of old Yang Parser in Controller
[controller.git] / opendaylight / md-sal / benchmark-data-store / src / main / java / org / opendaylight / controller / md / sal / dom / store / benchmark / BenchmarkModel.java
1 /*
2  * Copyright (c) 2013 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.benchmark;
9
10 import java.io.InputStream;
11 import java.util.Collections;
12 import org.opendaylight.yangtools.yang.common.QName;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
14 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
15
16 /**
17  * Benchmark Model class loads the odl-datastore-test.yang model from resources.
18  * <br>
19  * This class serves as facilitator class which holds several references to initialized yang model as static final
20  * members.
21  *
22  * @author Lukas Sedlak <lsedlak@cisco.com>
23  */
24 public final class BenchmarkModel {
25
26     public static final QName TEST_QNAME = QName
27         .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 ID_QNAME = QName.create(TEST_QNAME, "id");
31     public static final QName NAME_QNAME = QName.create(TEST_QNAME, "name");
32     private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
33
34     public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_QNAME);
35     public static final YangInstanceIdentifier OUTER_LIST_PATH =
36             YangInstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME).build();
37
38     private static InputStream getInputStream() {
39         return BenchmarkModel.class.getResourceAsStream(DATASTORE_TEST_YANG);
40     }
41
42     public static SchemaContext createTestContext() {
43         final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
44         final SchemaContext schemaContext;
45         final List<InputStream> streams = Collections.singletonList(getInputStream());
46
47         try {
48             schemaContext = reactor.buildEffective(streams);
49         } catch (ReactorException e) {
50             throw new RuntimeException("Unable to build schema context from " + streams, e);
51         }
52         return schemaContext;
53     }
54 }

©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.