Migrate to MD-SAL APIs
[controller.git] / opendaylight / md-sal / benchmark-data-store / src / main / java / org / opendaylight / controller / md / sal / dom / store / benchmark / BenchmarkModel.java
index 024385b2a9380c13d385dca39204e36818aa649b..20e107402a2e674e44c958f239adadabfb266855 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -7,15 +7,10 @@
  */
 package org.opendaylight.controller.md.sal.dom.store.benchmark;
 
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.Set;
-
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 /**
  * Benchmark Model class loads the odl-datastore-test.yang model from resources.
@@ -23,7 +18,7 @@ import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
  * This class serves as facilitator class which holds several references to initialized yang model as static final
  * members.
  *
- * @author Lukas Sedlak <lsedlak@cisco.com>
+ * @author Lukas Sedlak
  */
 public final class BenchmarkModel {
 
@@ -34,22 +29,14 @@ public final class BenchmarkModel {
     public static final QName ID_QNAME = QName.create(TEST_QNAME, "id");
     public static final QName NAME_QNAME = QName.create(TEST_QNAME, "name");
     private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
-
     public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_QNAME);
-    public static final YangInstanceIdentifier OUTER_LIST_PATH = YangInstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME).build();
-
-    public static final InputStream getDatastoreBenchmarkInputStream() {
-        return getInputStream(DATASTORE_TEST_YANG);
-    }
+    public static final YangInstanceIdentifier OUTER_LIST_PATH =
+            YangInstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME).build();
 
-    private static InputStream getInputStream(final String resourceName) {
-        return BenchmarkModel.class.getResourceAsStream(resourceName);
+    private BenchmarkModel() {
     }
 
     public static SchemaContext createTestContext() {
-        YangParserImpl parser = new YangParserImpl();
-        Set<Module> modules = parser.parseYangModelsFromStreams(Collections.singletonList(
-            getDatastoreBenchmarkInputStream()));
-        return parser.resolveSchemaContext(modules);
+        return YangParserTestUtils.parseYangResources(BenchmarkModel.class, DATASTORE_TEST_YANG);
     }
 }