Fix a bug in the CmAgent JUnit 61/48361/1
authorIanHowell <ian.howell@att.com>
Mon, 21 May 2018 19:17:56 +0000 (14:17 -0500)
committerIanHowell <ian.howell@att.com>
Mon, 21 May 2018 19:17:59 +0000 (14:17 -0500)
Issue-ID: AAF-223
Change-Id: Ida4ae9c3ae644c137a576beebe94c9083939aab5
Signed-off-by: IanHowell <ian.howell@att.com>
cadi/aaf/src/main/java/org/onap/aaf/cadi/cm/CmAgent.java
cadi/aaf/src/test/java/org/onap/aaf/cadi/cm/test/JU_CmAgent.java

index f900a1f..bcc156c 100644 (file)
@@ -79,9 +79,12 @@ public class CmAgent {
        private static ErrMessage errMsg;
        private static Map<String,PlaceArtifact> placeArtifact;
        private static RosettaEnv env;
+       
+       private static boolean doExit;
 
        public static void main(String[] args) {
                int exitCode = 0;
+               doExit = true;
                try {
                        AAFSSO aafsso = new AAFSSO(args);
                        if(aafsso.loginOnly()) {
@@ -93,7 +96,9 @@ public class CmAgent {
                                env = new RosettaEnv(access.getProperties());
                                Deque<String> cmds = new ArrayDeque<String>();
                                for(String p : args) {
-                                       if(p.indexOf('=')<0) {
+                                       if("-noexit".equalsIgnoreCase(p)) {
+                                               doExit = false;
+                                       } else if(p.indexOf('=') < 0) {
                                                cmds.add(p);
                                        }
                                }
@@ -110,7 +115,9 @@ public class CmAgent {
                                        System.out.println("   showpass <mechID> [<machine>]");
                                        System.out.println("   check    <mechID> [<machine>]");
                                        System.out.println("   genkeypair");
-                                       System.exit(1);
+                                       if (doExit) {
+                                               System.exit(1);
+                                       }
                                }
                                
                                TIMEOUT = Integer.parseInt(env.getProperty(Config.AAF_CONN_TIMEOUT, "5000"));
@@ -183,7 +190,7 @@ public class CmAgent {
                } catch (Exception e) {
                        e.printStackTrace();
                }
-               if(exitCode!=0) {
+               if(exitCode != 0 && doExit) {
                        System.exit(exitCode);
                }
        }
index 34ccf57..fbeb360 100644 (file)
@@ -56,54 +56,61 @@ public class JU_CmAgent {
                String[] args;
                args = new String[] {
                                "-login",
-                               "-noexit",
+                               "-noExit",
                };
                CmAgent.main(args);
 
                inStream.reset();
                args = new String[] {
-                               "noexit=true",
+                               "-noExit",
                };
                CmAgent.main(args);
 
                inStream.reset();
                args = new String[] {
                                "place",
+                               "-noExit",
                };
                CmAgent.main(args);
 
                inStream.reset();
                args = new String[] {
+                               "-noExit",
                                "create"
                };
                CmAgent.main(args);
 
                inStream.reset();
                args = new String[] {
+                               "-noExit",
                                "read"
                };
                CmAgent.main(args);
 
                inStream.reset();
                args = new String[] {
+                               "-noExit",
                                "copy"
                };
                CmAgent.main(args);
 
                inStream.reset();
                args = new String[] {
+                               "-noExit",
                                "update"
                };
                CmAgent.main(args);
 
                inStream.reset();
                args = new String[] {
+                               "-noExit",
                                "delete"
                };
                CmAgent.main(args);
 
                inStream.reset();
                args = new String[] {
+                               "-noExit",
                                "showpass"
                };
                CmAgent.main(args);