blob: e34613dfe47bf20c6cc602a8cab6e5e59529663d [file] [log] [blame]
Gaurav Agrawal56527662016-04-20 15:49:17 +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
Gaurav Agrawalc5f63272016-06-16 13:09:53 +053017package org.onosproject.yangutils.plugin.manager;
Gaurav Agrawal56527662016-04-20 15:49:17 +053018
19import java.io.IOException;
Vinod Kumar Se4b9b0c2016-04-30 21:09:15 +053020
Gaurav Agrawal56527662016-04-20 15:49:17 +053021import org.junit.Test;
22import org.onosproject.yangutils.datamodel.YangNode;
23import org.onosproject.yangutils.parser.exceptions.ParserException;
24import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
Gaurav Agrawal8a5af142016-06-15 13:58:01 +053025import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
Gaurav Agrawal56527662016-04-20 15:49:17 +053026
27import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode;
VinodKumarS-Huaweicb3a1f52016-05-10 17:58:57 +053028import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
Gaurav Agrawal56527662016-04-20 15:49:17 +053029
30/**
31 * Unit tests for rpc translator.
32 */
33public final class RpcTranslatorTest {
34
35 private final YangUtilsParserManager manager = new YangUtilsParserManager();
36
37 /**
38 * Checks rpc translation should not result in any exception.
39 */
40 @Test
Vinod Kumar Se4b9b0c2016-04-30 21:09:15 +053041 public void processRpcTranslator()
42 throws IOException, ParserException {
Gaurav Agrawal56527662016-04-20 15:49:17 +053043
Gaurav Agrawal56527662016-04-20 15:49:17 +053044 YangNode node = manager.getDataModel("src/test/resources/RpcTranslator.yang");
45
46 YangPluginConfig yangPluginConfig = new YangPluginConfig();
Bharat saraswal991f6882016-06-17 12:16:25 +053047 yangPluginConfig.setCodeGenDir("target/RpcTestGenFile/");
Gaurav Agrawal56527662016-04-20 15:49:17 +053048
Bharat saraswal33dfa012016-05-17 19:59:16 +053049 generateJavaCode(node, yangPluginConfig);
Gaurav Agrawal56527662016-04-20 15:49:17 +053050
Bharat saraswal991f6882016-06-17 12:16:25 +053051 deleteDirectory("target/RpcTestGenFile/");
Gaurav Agrawal56527662016-04-20 15:49:17 +053052 }
53 // TODO enhance the test cases, after having a framework of translator test.
54}