test/testlibrary/com/oracle/java/testlibrary/OutputAnalyzer.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
hsx-gc Cdiff test/testlibrary/com/oracle/java/testlibrary/OutputAnalyzer.java
test/testlibrary/com/oracle/java/testlibrary/OutputAnalyzer.java
Print this page
*** 209,225 ****
public void shouldNotMatch(String pattern) {
Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout);
if (matcher.find()) {
reportDiagnosticSummary();
throw new RuntimeException("'" + pattern
! + "' found in stdout \n");
}
matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
if (matcher.find()) {
reportDiagnosticSummary();
throw new RuntimeException("'" + pattern
! + "' found in stderr \n");
}
}
/**
* Verify that the stdout contents of output buffer does not match the
--- 209,225 ----
public void shouldNotMatch(String pattern) {
Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout);
if (matcher.find()) {
reportDiagnosticSummary();
throw new RuntimeException("'" + pattern
! + "' found in stdout: '" + matcher.group() + "' \n");
}
matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
if (matcher.find()) {
reportDiagnosticSummary();
throw new RuntimeException("'" + pattern
! + "' found in stderr: '" + matcher.group() + "' \n");
}
}
/**
* Verify that the stdout contents of output buffer does not match the
*** 252,261 ****
--- 252,292 ----
+ "' found in stderr \n");
}
}
/**
+ * Get the captured group of the first string matching the pattern.
+ * stderr is searched before stdout.
+ *
+ * @param pattern The multi-line pattern to match
+ * @param group The group to capture
+ * @return The matched string or null if no match was found
+ */
+ public String firstMatch(String pattern, int group) {
+ Matcher stderrMatcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
+ Matcher stdoutMatcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout);
+ if (stderrMatcher.find()) {
+ return stderrMatcher.group(group);
+ }
+ if (stdoutMatcher.find()) {
+ return stdoutMatcher.group(group);
+ }
+ return null;
+ }
+
+ /**
+ * Get the first string matching the pattern.
+ * stderr is searched before stdout.
+ *
+ * @param pattern The multi-line pattern to match
+ * @return The matched string or null if no match was found
+ */
+ public String firstMatch(String pattern) {
+ return firstMatch(pattern, 0);
+ }
+
+ /**
* Verify the exit value of the process
*
* @param expectedExitValue Expected exit value from process
* @throws RuntimeException If the exit value from the process did not match the expected value
*/
test/testlibrary/com/oracle/java/testlibrary/OutputAnalyzer.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File