8163272: jhsdb jinfo cannot show system properties
authorysuenaga
Mon, 08 Aug 2016 21:59:33 +0900
changeset 40397 67060ef26d11
parent 40396 4cf85a8b24e4
child 40398 2be90ca0e54e
child 40463 8a2083c5e2b1
8163272: jhsdb jinfo cannot show system properties Reviewed-by: dholmes, dsamersoff
jdk/test/sun/tools/jhsdb/BasicLauncherTest.java
--- a/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java	Fri Aug 05 09:58:09 2016 -0700
+++ b/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java	Mon Aug 08 21:59:33 2016 +0900
@@ -40,6 +40,7 @@
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Arrays;
+import java.util.Optional;
 import jdk.testlibrary.JDKToolLauncher;
 import jdk.testlibrary.Utils;
 import jdk.testlibrary.OutputAnalyzer;
@@ -111,7 +112,8 @@
      * @param vmArgs  - vm and java arguments to launch test app
      * @return exit code of tool
      */
-    public static void launch(String expectedMessage, List<String> toolArgs)
+    public static void launch(String expectedMessage,
+                 Optional<String> unexpectedMessage, List<String> toolArgs)
         throws IOException {
 
         System.out.println("Starting LingeredApp");
@@ -131,6 +133,7 @@
             processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT);
             OutputAnalyzer output = ProcessTools.executeProcess(processBuilder);;
             output.shouldContain(expectedMessage);
+            unexpectedMessage.ifPresent(output::shouldNotContain);
             output.shouldHaveExitValue(0);
 
         } catch (Exception ex) {
@@ -140,13 +143,16 @@
         }
     }
 
-    public static void launch(String expectedMessage, String... toolArgs)
+    public static void launch(String expectedMessage,
+                              String unexpectedMessage, String... toolArgs)
         throws IOException {
 
-        launch(expectedMessage, Arrays.asList(toolArgs));
+        launch(expectedMessage, Optional.ofNullable(unexpectedMessage),
+                                                       Arrays.asList(toolArgs));
     }
 
-    public static void launchNotOSX(String expectedMessage, String... toolArgs)
+    public static void launchNotOSX(String expectedMessage,
+                              String unexpectedMessage, String... toolArgs)
         throws IOException {
 
         if (Platform.isOSX()) {
@@ -154,6 +160,8 @@
             System.out.println("This test is not expected to work on OS X. Skipping");
             return;
         }
+
+        launch(expectedMessage, unexpectedMessage, toolArgs);
     }
 
     public static void testHeapDump() throws IOException {
@@ -164,7 +172,7 @@
         }
         dump.deleteOnExit();
 
-        launch("heap written to", "jmap",
+        launch("heap written to", null, "jmap",
                "--binaryheap", "--dumpfile=" + dump.getAbsolutePath());
 
         assertTrue(dump.exists() && dump.isFile(),
@@ -182,11 +190,12 @@
 
         launchCLHSDB();
 
-        launch("compiler detected", "jmap", "--clstats");
-        launchNotOSX("No deadlocks found", "jstack");
-        launch("compiler detected", "jmap");
-        launch("Java System Properties", "jinfo");
-        launch("java.threads", "jsnap");
+        launch("compiler detected", null, "jmap", "--clstats");
+        launchNotOSX("No deadlocks found", null, "jstack");
+        launch("compiler detected", null, "jmap");
+        launch("Java System Properties",
+               "System Properties info not available", "jinfo");
+        launch("java.threads", null, "jsnap");
 
         testHeapDump();