2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.md.sal.dom.store.benchmark;
10 import java.io.InputStream;
11 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.Module;
17 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
18 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
21 * Benchmark Model class loads the odl-datastore-test.yang model from resources.
23 * This class serves as facilitator class which holds several references to initialized yang model as static final
26 * @author Lukas Sedlak <lsedlak@cisco.com>
28 public final class BenchmarkModel {
30 public static final QName TEST_QNAME = QName
31 .create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13","test");
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 ID_QNAME = QName.create(TEST_QNAME, "id");
35 public static final QName NAME_QNAME = QName.create(TEST_QNAME, "name");
36 private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
38 public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_QNAME);
39 public static final YangInstanceIdentifier OUTER_LIST_PATH = YangInstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME).build();
41 public static final InputStream getDatastoreBenchmarkInputStream() {
42 return getInputStream(DATASTORE_TEST_YANG);
45 private static InputStream getInputStream(final String resourceName) {
46 return BenchmarkModel.class.getResourceAsStream(resourceName);
49 public static SchemaContext createTestContext() {
50 YangParserImpl parser = new YangParserImpl();
51 Set<Module> modules = parser.parseYangModelsFromStreams(Collections.singletonList(
52 getDatastoreBenchmarkInputStream()));
53 return parser.resolveSchemaContext(modules);