Merge "OF plugin classes must have a strict dependency on Connection Service"
[controller.git] / opendaylight / sal / yang-prototype / code-generator / binding-generator-impl / src / test / java / org / opendaylight / controller / sal / binding / generator / impl / ControllerTest.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.sal.binding.generator.impl;
9
10
11 import static org.junit.Assert.*;
12
13 import java.io.File;
14 import java.util.ArrayList;
15 import java.util.List;
16 import java.util.Set;
17
18 import org.junit.BeforeClass;
19 import org.junit.Test;
20 import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
21 import org.opendaylight.controller.sal.binding.model.api.Type;
22 import org.opendaylight.yangtools.yang.model.api.Module;
23 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
24 import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
25 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
26
27 public class ControllerTest {
28
29     private final static List<File> controllerModels = new ArrayList<>();
30     private final static String controllerModelsFolderPath = ControllerTest.class
31             .getResource("/controller-models").getPath();
32
33     @BeforeClass
34     public static void loadTestResources() {
35         final File ctrlFolder = new File(controllerModelsFolderPath);
36
37         for (final File fileEntry : ctrlFolder.listFiles()) {
38             if (fileEntry.isFile()) {
39                 controllerModels.add(fileEntry);
40             }
41         }
42     }
43
44     @Test
45     public void controllerAugmentationTest() {
46         final YangModelParser parser = new YangParserImpl();
47         final Set<Module> modules = parser.parseYangModels(controllerModels);
48         final SchemaContext context = parser.resolveSchemaContext(modules);
49
50         assertNotNull(context);
51         final BindingGenerator bindingGen = new BindingGeneratorImpl();
52         final List<Type> genTypes = bindingGen.generateTypes(context);
53
54         assertNotNull(genTypes);
55         assertTrue(!genTypes.isEmpty());
56     }
57 }