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.io.IOException;
16 import java.net.URISyntaxException;
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;
28 public class ControllerTest {
30 private final static List<File> controllerModels = new ArrayList<>();
31 private final static URL controllerModelsFolderPath = ControllerTest.class
32 .getResource("/controller-models");
35 public static void loadTestResources() throws URISyntaxException {
36 final File ctrlFolder = new File(controllerModelsFolderPath.toURI());
38 for (final File fileEntry : ctrlFolder.listFiles()) {
39 if (fileEntry.isFile()) {
40 controllerModels.add(fileEntry);
46 public void controllerAugmentationTest() throws IOException {
47 final YangContextParser parser = new YangParserImpl();
48 final SchemaContext context = parser.parseFiles(controllerModels);
50 assertNotNull(context);
51 final BindingGenerator bindingGen = new BindingGeneratorImpl();
52 final List<Type> genTypes = bindingGen.generateTypes(context);
54 assertNotNull(genTypes);
55 assertTrue(!genTypes.isEmpty());