8071566: Improve testing for multi-version JAR file maker tool
authoranazarov
Wed, 18 Jan 2017 20:36:15 +0300
changeset 43172 8c1bd20e4f45
parent 43171 61b58ba86188
child 43173 5212680a318b
8071566: Improve testing for multi-version JAR file maker tool Reviewed-by: chegar
test/lib/jdk/test/lib/process/OutputAnalyzer.java
--- a/test/lib/jdk/test/lib/process/OutputAnalyzer.java	Wed Jan 18 09:35:03 2017 +0000
+++ b/test/lib/jdk/test/lib/process/OutputAnalyzer.java	Wed Jan 18 20:36:15 2017 +0300
@@ -183,6 +183,23 @@
   }
 
   /**
+   * Verify that the stdout and stderr contents of output buffer does not contain the string
+   *
+   * @throws RuntimeException If the string was found
+   */
+  public OutputAnalyzer shouldBeEmpty() {
+    if (!stdout.isEmpty()) {
+        reportDiagnosticSummary();
+        throw new RuntimeException("stdout was not empty");
+    }
+    if (!stderr.isEmpty()) {
+        reportDiagnosticSummary();
+        throw new RuntimeException("stderr was not empty");
+    }
+    return this;
+  }
+
+  /**
    * Verify that the stdout contents of output buffer does not contain the string
    *
    * @param expectedString String that the buffer should not contain
@@ -365,6 +382,21 @@
       return this;
   }
 
+  /**
+   * Verify the exit value of the process
+   *
+   * @param notExpectedExitValue Unexpected exit value from process
+   * @throws RuntimeException If the exit value from the process did match the expected value
+   */
+  public OutputAnalyzer shouldNotHaveExitValue(int notExpectedExitValue) {
+      if (getExitValue() == notExpectedExitValue) {
+          reportDiagnosticSummary();
+          throw new RuntimeException("Unexpected to get exit value of ["
+                  + notExpectedExitValue + "]\n");
+      }
+      return this;
+  }
+
 
   /**
    * Report summary that will help to diagnose the problem