Gaurav Agrawal | 983470e | 2016-06-02 11:23:03 +0530 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package org.onosproject.yangutils.ietfyang; |
| 18 | |
| 19 | import org.apache.maven.plugin.MojoExecutionException; |
| 20 | import org.junit.Test; |
Gaurav Agrawal | 983470e | 2016-06-02 11:23:03 +0530 | [diff] [blame] | 21 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
Gaurav Agrawal | 983470e | 2016-06-02 11:23:03 +0530 | [diff] [blame] | 22 | import org.onosproject.yangutils.plugin.manager.YangUtilManager; |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 23 | import org.onosproject.yangutils.utils.io.YangPluginConfig; |
Bharat saraswal | 0663aff | 2016-10-18 23:16:14 +0530 | [diff] [blame] | 24 | import org.onosproject.yangutils.utils.io.impl.YangFileScanner; |
Gaurav Agrawal | 983470e | 2016-06-02 11:23:03 +0530 | [diff] [blame] | 25 | |
Bharat saraswal | 0663aff | 2016-10-18 23:16:14 +0530 | [diff] [blame] | 26 | import java.io.File; |
| 27 | import java.io.IOException; |
| 28 | |
| 29 | import static org.onosproject.yangutils.utils.io.YangPluginConfig.compileCode; |
Gaurav Agrawal | 983470e | 2016-06-02 11:23:03 +0530 | [diff] [blame] | 30 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory; |
| 31 | |
| 32 | /** |
| 33 | * Test cases for testing IETF YANG files. |
| 34 | */ |
| 35 | public class IetfYangFileTest { |
| 36 | |
Gaurav Agrawal | 983470e | 2016-06-02 11:23:03 +0530 | [diff] [blame] | 37 | private final YangUtilManager utilManager = new YangUtilManager(); |
Gaurav Agrawal | 983470e | 2016-06-02 11:23:03 +0530 | [diff] [blame] | 38 | |
| 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 saraswal | 0663aff | 2016-10-18 23:16:14 +0530 | [diff] [blame] | 47 | String dir = "target/ietfyang/l3vpnservice/"; |
| 48 | deleteDirectory(dir); |
Gaurav Agrawal | 983470e | 2016-06-02 11:23:03 +0530 | [diff] [blame] | 49 | String searchDir = "src/test/resources/ietfyang/l3vpnservice"; |
| 50 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir)); |
| 51 | utilManager.parseYangFileInfoSet(); |
| 52 | utilManager.resolveDependenciesUsingLinker(); |
| 53 | |
Gaurav Agrawal | 983470e | 2016-06-02 11:23:03 +0530 | [diff] [blame] | 54 | YangPluginConfig yangPluginConfig = new YangPluginConfig(); |
Bharat saraswal | 0663aff | 2016-10-18 23:16:14 +0530 | [diff] [blame] | 55 | yangPluginConfig.setCodeGenDir(dir); |
Gaurav Agrawal | 983470e | 2016-06-02 11:23:03 +0530 | [diff] [blame] | 56 | |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 57 | utilManager.translateToJava(yangPluginConfig); |
Bharat saraswal | 0663aff | 2016-10-18 23:16:14 +0530 | [diff] [blame] | 58 | String dir1 = System.getProperty("user.dir") + File.separator + dir; |
| 59 | compileCode(dir1); |
| 60 | deleteDirectory("target/ietfyang/"); |
Gaurav Agrawal | 983470e | 2016-06-02 11:23:03 +0530 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | } |