Merge "Introduce Identifiables"
[yangtools.git] / code-generator / binding-generator-impl / src / test / java / org / opendaylight / yangtools / 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.yangtools.sal.binding.generator.impl;
9
10
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
13
14 import java.io.File;
15 import java.io.IOException;
16 import java.net.URISyntaxException;
17 import java.net.URL;
18 import java.util.ArrayList;
19 import java.util.List;
20 import org.junit.BeforeClass;
21 import org.junit.Test;
22 import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
23 import org.opendaylight.yangtools.sal.binding.model.api.Type;
24 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
25 import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
26 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
27
28 public class ControllerTest {
29
30     private final static List<File> controllerModels = new ArrayList<>();
31     private final static URL controllerModelsFolderPath = ControllerTest.class
32             .getResource("/controller-models");
33
34     @BeforeClass
35     public static void loadTestResources() throws URISyntaxException {
36         final File ctrlFolder = new File(controllerModelsFolderPath.toURI());
37
38         for (final File fileEntry : ctrlFolder.listFiles()) {
39             if (fileEntry.isFile()) {
40                 controllerModels.add(fileEntry);
41             }
42         }
43     }
44
45     @Test
46     public void controllerAugmentationTest() throws IOException {
47         final YangContextParser parser = new YangParserImpl();
48         final SchemaContext context = parser.parseFiles(controllerModels);
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 }