< prev index next >

test/jdk/sun/tools/jps/TestJpsSanity.java

Print this page
rev 48074 : 8189102: All tools should support -?, -h and --help
Reviewed-by: kvn, jjg, weijun, alanb, rfield, ksrini
   1 /*
   2  * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


  67         } finally {
  68             LingeredApp.stopApp(app);
  69         }
  70     }
  71 
  72     private static void testJpsLongPkg() throws Exception {
  73         LingeredApp app = null;
  74         try {
  75             app = LingeredApp.startApp();
  76             OutputAnalyzer output = JpsHelper.jps("-l");
  77             output.shouldMatch("^[0-9]+ jdk\\.test\\.lib\\.apps\\.LingeredApp$");
  78         } finally {
  79             LingeredApp.stopApp(app);
  80         }
  81     }
  82 
  83     private static void testJpsUsage() throws Exception {
  84         OutputAnalyzer output = JpsHelper.jps("-?");
  85         JpsHelper.verifyOutputAgainstFile(output);
  86 
  87         output = JpsHelper.jps("-help");



  88         JpsHelper.verifyOutputAgainstFile(output);
  89     }
  90 
  91     private static void testJpsVersion() throws Exception {
  92         OutputAnalyzer output = JpsHelper.jps("-version");
  93         Asserts.assertNotEquals(output.getExitValue(), 0, "Exit code shouldn't be 0");
  94         Asserts.assertFalse(output.getStderr().isEmpty(), "Error output should not be empty");
  95         output.shouldContain("illegal argument: -version");
  96     }
  97 
  98     private static void testJpsUnknownHost() throws Exception {
  99         String invalidHostName = "Oja781nh2ev7vcvbajdg-Sda1-C.invalid";
 100         OutputAnalyzer output = JpsHelper.jps(invalidHostName);
 101         Asserts.assertNotEquals(output.getExitValue(), 0, "Exit code shouldn't be 0");
 102         Asserts.assertFalse(output.getStderr().isEmpty(), "Error output should not be empty");
 103         output.shouldMatch(".*(RMI Registry not available at|Unknown host\\:) " + invalidHostName + ".*");
 104     }
 105 
 106 }
   1 /*
   2  * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


  67         } finally {
  68             LingeredApp.stopApp(app);
  69         }
  70     }
  71 
  72     private static void testJpsLongPkg() throws Exception {
  73         LingeredApp app = null;
  74         try {
  75             app = LingeredApp.startApp();
  76             OutputAnalyzer output = JpsHelper.jps("-l");
  77             output.shouldMatch("^[0-9]+ jdk\\.test\\.lib\\.apps\\.LingeredApp$");
  78         } finally {
  79             LingeredApp.stopApp(app);
  80         }
  81     }
  82 
  83     private static void testJpsUsage() throws Exception {
  84         OutputAnalyzer output = JpsHelper.jps("-?");
  85         JpsHelper.verifyOutputAgainstFile(output);
  86 
  87         output = JpsHelper.jps("-h");
  88         JpsHelper.verifyOutputAgainstFile(output);
  89 
  90         output = JpsHelper.jps("--help");
  91         JpsHelper.verifyOutputAgainstFile(output);
  92     }
  93 
  94     private static void testJpsVersion() throws Exception {
  95         OutputAnalyzer output = JpsHelper.jps("-version");
  96         Asserts.assertNotEquals(output.getExitValue(), 0, "Exit code shouldn't be 0");
  97         Asserts.assertFalse(output.getStderr().isEmpty(), "Error output should not be empty");
  98         output.shouldContain("illegal argument: -version");
  99     }
 100 
 101     private static void testJpsUnknownHost() throws Exception {
 102         String invalidHostName = "Oja781nh2ev7vcvbajdg-Sda1-C.invalid";
 103         OutputAnalyzer output = JpsHelper.jps(invalidHostName);
 104         Asserts.assertNotEquals(output.getExitValue(), 0, "Exit code shouldn't be 0");
 105         Asserts.assertFalse(output.getStderr().isEmpty(), "Error output should not be empty");
 106         output.shouldMatch(".*(RMI Registry not available at|Unknown host\\:) " + invalidHostName + ".*");
 107     }
 108 
 109 }
< prev index next >