blob: 4deeb7b50f1f678f00868121954dcb6dda8acdce [file] [log] [blame]
Gaurav Agrawal983470e2016-06-02 11:23:03 +05301/*
2 * Copyright 2016-present Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.yangutils.ietfyang;
18
19import org.apache.maven.plugin.MojoExecutionException;
20import org.junit.Test;
Gaurav Agrawal983470e2016-06-02 11:23:03 +053021import org.onosproject.yangutils.parser.exceptions.ParserException;
Gaurav Agrawal983470e2016-06-02 11:23:03 +053022import org.onosproject.yangutils.plugin.manager.YangUtilManager;
Bharat saraswale50edca2016-08-05 01:58:25 +053023import org.onosproject.yangutils.utils.io.YangPluginConfig;
Bharat saraswal0663aff2016-10-18 23:16:14 +053024import org.onosproject.yangutils.utils.io.impl.YangFileScanner;
Gaurav Agrawal983470e2016-06-02 11:23:03 +053025
Bharat saraswal0663aff2016-10-18 23:16:14 +053026import java.io.File;
27import java.io.IOException;
28
29import static org.onosproject.yangutils.utils.io.YangPluginConfig.compileCode;
Gaurav Agrawal983470e2016-06-02 11:23:03 +053030import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
31
32/**
33 * Test cases for testing IETF YANG files.
34 */
35public class IetfYangFileTest {
36
Gaurav Agrawal983470e2016-06-02 11:23:03 +053037 private final YangUtilManager utilManager = new YangUtilManager();
Gaurav Agrawal983470e2016-06-02 11:23:03 +053038
39 /**
40 * Checks hierarchical intra with inter file type linking.
41 * Reference: https://datatracker.ietf.org/doc/draft-zha-l3sm-l3vpn-onos-deployment
42 */
43 @Test
44 public void l3vpnserviceyang()
45 throws IOException, ParserException, MojoExecutionException {
46
Bharat saraswal0663aff2016-10-18 23:16:14 +053047 String dir = "target/ietfyang/l3vpnservice/";
48 deleteDirectory(dir);
Gaurav Agrawal983470e2016-06-02 11:23:03 +053049 String searchDir = "src/test/resources/ietfyang/l3vpnservice";
50 utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
51 utilManager.parseYangFileInfoSet();
52 utilManager.resolveDependenciesUsingLinker();
53
Gaurav Agrawal983470e2016-06-02 11:23:03 +053054 YangPluginConfig yangPluginConfig = new YangPluginConfig();
Bharat saraswal0663aff2016-10-18 23:16:14 +053055 yangPluginConfig.setCodeGenDir(dir);
Gaurav Agrawal983470e2016-06-02 11:23:03 +053056
Bharat saraswal039f59c2016-07-14 21:57:13 +053057 utilManager.translateToJava(yangPluginConfig);
Bharat saraswal0663aff2016-10-18 23:16:14 +053058 String dir1 = System.getProperty("user.dir") + File.separator + dir;
59 compileCode(dir1);
60 deleteDirectory("target/ietfyang/");
Gaurav Agrawal983470e2016-06-02 11:23:03 +053061 }
62
63}