2 * Copyright (c) 2014 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.sal.restconf.impl.test;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
13 import java.io.FileNotFoundException;
15 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
16 import org.opendaylight.yangtools.yang.model.api.Module;
18 public abstract class YangAndXmlAndDataSchemaLoader {
20 protected static Set<Module> modules;
21 protected static DataSchemaNode dataSchemaNode;
22 protected static String searchedModuleName;
23 protected static String searchedDataSchemaName;
24 protected static String schemaNodePath;
26 protected static void dataLoad(final String yangPath) throws FileNotFoundException {
27 dataLoad(yangPath, 1, null, null);
30 protected static void dataLoad(final String yangPath, final int modulesNumber, final String moduleName,
31 final String dataSchemaName) throws FileNotFoundException {
32 modules = TestUtils.loadSchemaContext(yangPath).getModules();
33 assertEquals(modulesNumber, modules.size());
34 final Module module = TestUtils.resolveModule(moduleName, modules);
35 searchedModuleName = module == null ? "" : module.getName();
36 assertNotNull(module);
37 dataSchemaNode = TestUtils.resolveDataSchemaNode(dataSchemaName, module);
38 searchedDataSchemaName = dataSchemaNode == null ? "" : dataSchemaNode.getQName().getLocalName();
39 assertNotNull(dataSchemaNode);
40 schemaNodePath = searchedModuleName + ":" + searchedDataSchemaName;