X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cadi%2Faaf%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Faaf%2Fcadi%2Fcm%2Ftest%2FJU_CmAgent.java;fp=cadi%2Faaf%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Faaf%2Fcadi%2Fcm%2Ftest%2FJU_CmAgent.java;h=34ccf57bbdca0bade7adf0106ceab5af889d30cc;hb=a7fb5826abbf912a01230f5f5c09a8683d743f9c;hp=0000000000000000000000000000000000000000;hpb=2fe00d05bfd7b35413d8f744ca523906b2488827;p=aaf%2Fauthz.git diff --git a/cadi/aaf/src/test/java/org/onap/aaf/cadi/cm/test/JU_CmAgent.java b/cadi/aaf/src/test/java/org/onap/aaf/cadi/cm/test/JU_CmAgent.java new file mode 100644 index 00000000..34ccf57b --- /dev/null +++ b/cadi/aaf/src/test/java/org/onap/aaf/cadi/cm/test/JU_CmAgent.java @@ -0,0 +1,123 @@ +/******************************************************************************* + * ============LICENSE_START==================================================== + * * org.onap.aaf + * * =========================================================================== + * * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * * =========================================================================== + * * 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. + * * ============LICENSE_END==================================================== + * * + * * + ******************************************************************************/ + +package org.onap.aaf.cadi.cm.test; + +import java.io.ByteArrayInputStream; +import java.io.File; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.aaf.cadi.cm.CmAgent; + +public class JU_CmAgent { + + private static final String resourceDirString = "src/test/resources"; + private static final String aafDir = resourceDirString + "/aaf"; + + private ByteArrayInputStream inStream; + + @Before + public void setup() { + System.setProperty("user.home", aafDir); + + // Simulate user input + inStream = new ByteArrayInputStream("test\nhttp://example.com\nhttp://example.com".getBytes()); + System.setIn(inStream); + } + + @After + public void tearDown() { + recursiveDelete(new File(aafDir)); + } + + @Test + public void test() { + String[] args; + args = new String[] { + "-login", + "-noexit", + }; + CmAgent.main(args); + + inStream.reset(); + args = new String[] { + "noexit=true", + }; + CmAgent.main(args); + + inStream.reset(); + args = new String[] { + "place", + }; + CmAgent.main(args); + + inStream.reset(); + args = new String[] { + "create" + }; + CmAgent.main(args); + + inStream.reset(); + args = new String[] { + "read" + }; + CmAgent.main(args); + + inStream.reset(); + args = new String[] { + "copy" + }; + CmAgent.main(args); + + inStream.reset(); + args = new String[] { + "update" + }; + CmAgent.main(args); + + inStream.reset(); + args = new String[] { + "delete" + }; + CmAgent.main(args); + + inStream.reset(); + args = new String[] { + "showpass" + }; + CmAgent.main(args); + + } + + private void recursiveDelete(File file) { + for (File f : file.listFiles()) { + if (f.isDirectory()) { + recursiveDelete(f); + } + f.delete(); + } + file.delete(); + } + +}