test/testlibrary/com/oracle/java/testlibrary/OutputAnalyzer.java
Print this page
rev 6890 : [mq]: coops
*** 72,214 ****
* Verify that the stdout and stderr contents of output buffer contains the string
*
* @param expectedString String that buffer should contain
* @throws RuntimeException If the string was not found
*/
! public void shouldContain(String expectedString) {
if (!stdout.contains(expectedString) && !stderr.contains(expectedString)) {
reportDiagnosticSummary();
throw new RuntimeException("'" + expectedString + "' missing from stdout/stderr \n");
}
}
/**
* Verify that the stdout contents of output buffer contains the string
*
* @param expectedString String that buffer should contain
* @throws RuntimeException If the string was not found
*/
! public void stdoutShouldContain(String expectedString) {
if (!stdout.contains(expectedString)) {
reportDiagnosticSummary();
throw new RuntimeException("'" + expectedString + "' missing from stdout \n");
}
}
/**
* Verify that the stderr contents of output buffer contains the string
*
* @param expectedString String that buffer should contain
* @throws RuntimeException If the string was not found
*/
! public void stderrShouldContain(String expectedString) {
if (!stderr.contains(expectedString)) {
reportDiagnosticSummary();
throw new RuntimeException("'" + expectedString + "' missing from stderr \n");
}
}
/**
* Verify that the stdout and stderr contents of output buffer does not contain the string
*
* @param expectedString String that the buffer should not contain
* @throws RuntimeException If the string was found
*/
! public void shouldNotContain(String notExpectedString) {
if (stdout.contains(notExpectedString)) {
reportDiagnosticSummary();
throw new RuntimeException("'" + notExpectedString + "' found in stdout \n");
}
if (stderr.contains(notExpectedString)) {
reportDiagnosticSummary();
throw new RuntimeException("'" + notExpectedString + "' found in stderr \n");
}
}
/**
* Verify that the stdout contents of output buffer does not contain the string
*
* @param expectedString String that the buffer should not contain
* @throws RuntimeException If the string was found
*/
! public void stdoutShouldNotContain(String notExpectedString) {
if (stdout.contains(notExpectedString)) {
reportDiagnosticSummary();
throw new RuntimeException("'" + notExpectedString + "' found in stdout \n");
}
}
/**
* Verify that the stderr contents of output buffer does not contain the string
*
* @param expectedString String that the buffer should not contain
* @throws RuntimeException If the string was found
*/
! public void stderrShouldNotContain(String notExpectedString) {
if (stderr.contains(notExpectedString)) {
reportDiagnosticSummary();
throw new RuntimeException("'" + notExpectedString + "' found in stderr \n");
}
}
/**
* Verify that the stdout and stderr contents of output buffer matches
* the pattern
*
* @param pattern
* @throws RuntimeException If the pattern was not found
*/
! public void shouldMatch(String pattern) {
Matcher stdoutMatcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout);
Matcher stderrMatcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
if (!stdoutMatcher.find() && !stderrMatcher.find()) {
reportDiagnosticSummary();
throw new RuntimeException("'" + pattern
+ "' missing from stdout/stderr \n");
}
}
/**
* Verify that the stdout contents of output buffer matches the
* pattern
*
* @param pattern
* @throws RuntimeException If the pattern was not found
*/
! public void stdoutShouldMatch(String pattern) {
Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout);
if (!matcher.find()) {
reportDiagnosticSummary();
throw new RuntimeException("'" + pattern
+ "' missing from stdout \n");
}
}
/**
* Verify that the stderr contents of output buffer matches the
* pattern
*
* @param pattern
* @throws RuntimeException If the pattern was not found
*/
! public void stderrShouldMatch(String pattern) {
Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
if (!matcher.find()) {
reportDiagnosticSummary();
throw new RuntimeException("'" + pattern
+ "' missing from stderr \n");
}
}
/**
* Verify that the stdout and stderr contents of output buffer does not
* match the pattern
*
* @param pattern
* @throws RuntimeException If the pattern was found
*/
! 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");
--- 72,223 ----
* Verify that the stdout and stderr contents of output buffer contains the string
*
* @param expectedString String that buffer should contain
* @throws RuntimeException If the string was not found
*/
! public OutputAnalyzer shouldContain(String expectedString) {
if (!stdout.contains(expectedString) && !stderr.contains(expectedString)) {
reportDiagnosticSummary();
throw new RuntimeException("'" + expectedString + "' missing from stdout/stderr \n");
}
+ return this;
}
/**
* Verify that the stdout contents of output buffer contains the string
*
* @param expectedString String that buffer should contain
* @throws RuntimeException If the string was not found
*/
! public OutputAnalyzer stdoutShouldContain(String expectedString) {
if (!stdout.contains(expectedString)) {
reportDiagnosticSummary();
throw new RuntimeException("'" + expectedString + "' missing from stdout \n");
}
+ return this;
}
/**
* Verify that the stderr contents of output buffer contains the string
*
* @param expectedString String that buffer should contain
* @throws RuntimeException If the string was not found
*/
! public OutputAnalyzer stderrShouldContain(String expectedString) {
if (!stderr.contains(expectedString)) {
reportDiagnosticSummary();
throw new RuntimeException("'" + expectedString + "' missing from stderr \n");
}
+ return this;
}
/**
* Verify that the stdout and stderr contents of output buffer does not contain the string
*
* @param expectedString String that the buffer should not contain
* @throws RuntimeException If the string was found
*/
! public OutputAnalyzer shouldNotContain(String notExpectedString) {
if (stdout.contains(notExpectedString)) {
reportDiagnosticSummary();
throw new RuntimeException("'" + notExpectedString + "' found in stdout \n");
}
if (stderr.contains(notExpectedString)) {
reportDiagnosticSummary();
throw new RuntimeException("'" + notExpectedString + "' found in stderr \n");
}
+ return this;
}
/**
* Verify that the stdout contents of output buffer does not contain the string
*
* @param expectedString String that the buffer should not contain
* @throws RuntimeException If the string was found
*/
! public OutputAnalyzer stdoutShouldNotContain(String notExpectedString) {
if (stdout.contains(notExpectedString)) {
reportDiagnosticSummary();
throw new RuntimeException("'" + notExpectedString + "' found in stdout \n");
}
+ return this;
}
/**
* Verify that the stderr contents of output buffer does not contain the string
*
* @param expectedString String that the buffer should not contain
* @throws RuntimeException If the string was found
*/
! public OutputAnalyzer stderrShouldNotContain(String notExpectedString) {
if (stderr.contains(notExpectedString)) {
reportDiagnosticSummary();
throw new RuntimeException("'" + notExpectedString + "' found in stderr \n");
}
+ return this;
}
/**
* Verify that the stdout and stderr contents of output buffer matches
* the pattern
*
* @param pattern
* @throws RuntimeException If the pattern was not found
*/
! public OutputAnalyzer shouldMatch(String pattern) {
Matcher stdoutMatcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout);
Matcher stderrMatcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
if (!stdoutMatcher.find() && !stderrMatcher.find()) {
reportDiagnosticSummary();
throw new RuntimeException("'" + pattern
+ "' missing from stdout/stderr \n");
}
+ return this;
}
/**
* Verify that the stdout contents of output buffer matches the
* pattern
*
* @param pattern
* @throws RuntimeException If the pattern was not found
*/
! public OutputAnalyzer stdoutShouldMatch(String pattern) {
Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout);
if (!matcher.find()) {
reportDiagnosticSummary();
throw new RuntimeException("'" + pattern
+ "' missing from stdout \n");
}
+ return this;
}
/**
* Verify that the stderr contents of output buffer matches the
* pattern
*
* @param pattern
* @throws RuntimeException If the pattern was not found
*/
! public OutputAnalyzer stderrShouldMatch(String pattern) {
Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
if (!matcher.find()) {
reportDiagnosticSummary();
throw new RuntimeException("'" + pattern
+ "' missing from stderr \n");
}
+ return this;
}
/**
* Verify that the stdout and stderr contents of output buffer does not
* match the pattern
*
* @param pattern
* @throws RuntimeException If the pattern was found
*/
! public OutputAnalyzer 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");
*** 217,258 ****
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
* pattern
*
* @param pattern
* @throws RuntimeException If the pattern was found
*/
! public void stdoutShouldNotMatch(String pattern) {
Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout);
if (matcher.find()) {
reportDiagnosticSummary();
throw new RuntimeException("'" + pattern
+ "' found in stdout \n");
}
}
/**
* Verify that the stderr contents of output buffer does not match the
* pattern
*
* @param pattern
* @throws RuntimeException If the pattern was found
*/
! public void stderrShouldNotMatch(String pattern) {
Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
if (matcher.find()) {
reportDiagnosticSummary();
throw new RuntimeException("'" + pattern
+ "' found in stderr \n");
}
}
/**
* Get the captured group of the first string matching the pattern.
* stderr is searched before stdout.
--- 226,270 ----
if (matcher.find()) {
reportDiagnosticSummary();
throw new RuntimeException("'" + pattern
+ "' found in stderr: '" + matcher.group() + "' \n");
}
+ return this;
}
/**
* Verify that the stdout contents of output buffer does not match the
* pattern
*
* @param pattern
* @throws RuntimeException If the pattern was found
*/
! public OutputAnalyzer stdoutShouldNotMatch(String pattern) {
Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout);
if (matcher.find()) {
reportDiagnosticSummary();
throw new RuntimeException("'" + pattern
+ "' found in stdout \n");
}
+ return this;
}
/**
* Verify that the stderr contents of output buffer does not match the
* pattern
*
* @param pattern
* @throws RuntimeException If the pattern was found
*/
! public OutputAnalyzer stderrShouldNotMatch(String pattern) {
Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
if (matcher.find()) {
reportDiagnosticSummary();
throw new RuntimeException("'" + pattern
+ "' found in stderr \n");
}
+ return this;
}
/**
* Get the captured group of the first string matching the pattern.
* stderr is searched before stdout.
*** 288,303 ****
* 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
*/
! public void shouldHaveExitValue(int expectedExitValue) {
if (getExitValue() != expectedExitValue) {
reportDiagnosticSummary();
throw new RuntimeException("Expected to get exit value of ["
+ expectedExitValue + "]\n");
}
}
/**
* Report summary that will help to diagnose the problem
--- 300,316 ----
* 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
*/
! public OutputAnalyzer shouldHaveExitValue(int expectedExitValue) {
if (getExitValue() != expectedExitValue) {
reportDiagnosticSummary();
throw new RuntimeException("Expected to get exit value of ["
+ expectedExitValue + "]\n");
}
+ return this;
}
/**
* Report summary that will help to diagnose the problem