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.sal.binding.generator.impl;
11 import org.junit.BeforeClass;
12 import org.junit.Test;
13 import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
14 import org.opendaylight.controller.sal.binding.model.api.Type;
15 import org.opendaylight.controller.yang.model.api.Module;
16 import org.opendaylight.controller.yang.model.api.SchemaContext;
17 import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
18 import org.opendaylight.controller.yang.parser.impl.YangParserImpl;
21 import java.util.ArrayList;
22 import java.util.List;
25 import static org.junit.Assert.assertNotNull;
26 import static org.junit.Assert.assertTrue;
28 public class ControllerTest {
30 private final static List<File> controllerModels = new ArrayList<>();
31 private final static String controllerModelsFolderPath = ControllerTest.class
32 .getResource("/controller-models").getPath();
35 public static void loadTestResources() {
36 final File ctrlFolder = new File(controllerModelsFolderPath);
38 for (final File fileEntry : ctrlFolder.listFiles()) {
39 if (fileEntry.isFile()) {
40 controllerModels.add(fileEntry);
46 public void controllerAugmentationTest() {
47 final YangModelParser parser = new YangParserImpl();
48 final Set<Module> modules = parser.parseYangModels(controllerModels);
49 final SchemaContext context = parser.resolveSchemaContext(modules);
51 assertNotNull(context);
52 final BindingGenerator bindingGen = new BindingGeneratorImpl();
53 final List<Type> genTypes = bindingGen.generateTypes(context);
55 assertNotNull(genTypes);
56 assertTrue(!genTypes.isEmpty());