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.yangtools.sal.binding.generator.impl;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
15 import java.net.URISyntaxException;
17 import java.util.ArrayList;
18 import java.util.List;
21 import org.junit.BeforeClass;
22 import org.junit.Test;
23 import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
24 import org.opendaylight.yangtools.sal.binding.model.api.Type;
25 import org.opendaylight.yangtools.yang.model.api.Module;
26 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
27 import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
28 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
30 public class ControllerTest {
32 private final static List<File> controllerModels = new ArrayList<>();
33 private final static URL controllerModelsFolderPath = ControllerTest.class
34 .getResource("/controller-models");
37 public static void loadTestResources() throws URISyntaxException {
38 final File ctrlFolder = new File(controllerModelsFolderPath.toURI());
40 for (final File fileEntry : ctrlFolder.listFiles()) {
41 if (fileEntry.isFile()) {
42 controllerModels.add(fileEntry);
48 public void controllerAugmentationTest() {
49 final YangModelParser parser = new YangParserImpl();
50 final Set<Module> modules = parser.parseYangModels(controllerModels);
51 final SchemaContext context = parser.resolveSchemaContext(modules);
53 assertNotNull(context);
54 final BindingGenerator bindingGen = new BindingGeneratorImpl();
55 final List<Type> genTypes = bindingGen.generateTypes(context);
57 assertNotNull(genTypes);
58 assertTrue(!genTypes.isEmpty());