diff options
Diffstat (limited to 'validation')
-rw-r--r-- | validation/pom.xml | 38 | ||||
-rw-r--r-- | validation/src/test/java/org/onap/cli/validation/OnapCliMainTest.java | 76 |
2 files changed, 114 insertions, 0 deletions
diff --git a/validation/pom.xml b/validation/pom.xml index adeb49b8..dc42e2f7 100644 --- a/validation/pom.xml +++ b/validation/pom.xml @@ -37,5 +37,43 @@ <version>4.11</version> <scope>test</scope> </dependency> + <dependency> + <groupId>org.onap.cli</groupId> + <artifactId>cli-main</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.cli</groupId> + <artifactId>cli-plugins-msb</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.cli</groupId> + <artifactId>cli-plugins-sdc</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.cli</groupId> + <artifactId>cli-plugins-aai</artifactId> + <version>${project.version}</version> + </dependency> </dependencies> +<!-- <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>2.9</version> + <configuration> + <useManifestOnlyJar>false</useManifestOnlyJar> + <useSystemClassLoader>false</useSystemClassLoader> + <additionalClasspathElements> + <additionalClasspathElement> + ${project.build.directory}/../../deployment/zip/target/deployunzip/lib/*.jar + </additionalClasspathElement> + </additionalClasspathElements> + </configuration> + </plugin> + </plugins> + </build> --> </project> diff --git a/validation/src/test/java/org/onap/cli/validation/OnapCliMainTest.java b/validation/src/test/java/org/onap/cli/validation/OnapCliMainTest.java new file mode 100644 index 00000000..f89e265d --- /dev/null +++ b/validation/src/test/java/org/onap/cli/validation/OnapCliMainTest.java @@ -0,0 +1,76 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.cli.validation; + +import java.io.IOException; +import java.util.Map; +import java.util.Set; + +import org.aspectj.lang.annotation.After; +import org.junit.Test; +import org.onap.cli.fw.OnapCommandRegistrar; +import org.onap.cli.fw.error.OnapCommandException; +import org.onap.cli.fw.utils.ExternalSchema; +import org.onap.cli.fw.utils.OnapCommandUtils; +import org.onap.cli.main.OnapCli; + +public class OnapCliMainTest { + + OnapCli cli = null; + + /** + * Clean up. + */ + @After(value = "") + public void cleanup() { + if (this.cli != null) { + if (cli.getExitCode() != 0) { + // Fail test case + } + } + } + + private void handle(String[] args) { + cli = new OnapCli(args); + cli.handle(); + } + + @Test + public void validateCommands() throws IOException, OnapCommandException { + OnapCommandRegistrar.getRegistrar().setEnabledProductVersion("cli-1.0"); + for (ExternalSchema sch : OnapCommandRegistrar.getRegistrar().listCommandInfo()) { + System.out.println( + "************************* validate '" + sch.getCmdName() + "' *******************************"); + this.handle(new String[] { "schema-validate", "-l", sch.getSchemaName(), "-i"}); + } + } + + @Test + public void commandHelpTest() throws OnapCommandException { + for (String version: OnapCommandRegistrar.getRegistrar().getAvailableProductVersions()) { + OnapCommandRegistrar.getRegistrar().setEnabledProductVersion(version); + for (ExternalSchema sch : OnapCommandRegistrar.getRegistrar().listCommandInfo()) { + if (sch.getCmdVersion().equals(version)) { + System.out.println( + "************************* help '" + sch.getCmdName() + "' *******************************"); + this.handle(new String[] { sch.getCmdName(), "-h"}); + } + } + } + } + + } |