author | jbachorik |
Thu, 03 Dec 2015 12:00:37 +0100 | |
changeset 34597 | e5f2344c6fab |
permissions | -rw-r--r-- |
34597
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
1 |
/* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
2 |
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
4 |
* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
8 |
* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
13 |
* accompanied this code). |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
14 |
* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
18 |
* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
21 |
* questions. |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
22 |
*/ |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
23 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
24 |
package jdk.test.lib.process; |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
25 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
26 |
import java.io.IOException; |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
27 |
import java.util.Arrays; |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
28 |
import java.util.List; |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
29 |
import java.util.regex.Matcher; |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
30 |
import java.util.regex.Pattern; |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
31 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
32 |
public final class OutputAnalyzer { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
33 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
34 |
private final String stdout; |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
35 |
private final String stderr; |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
36 |
private final int exitValue; |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
37 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
38 |
/** |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
39 |
* Create an OutputAnalyzer, a utility class for verifying output and exit |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
40 |
* value from a Process |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
41 |
* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
42 |
* @param process Process to analyze |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
43 |
* @throws IOException If an I/O error occurs. |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
44 |
*/ |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
45 |
public OutputAnalyzer(Process process) throws IOException { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
46 |
OutputBuffer output = ProcessTools.getOutput(process); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
47 |
exitValue = process.exitValue(); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
48 |
this.stdout = output.getStdout(); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
49 |
this.stderr = output.getStderr(); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
50 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
51 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
52 |
/** |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
53 |
* Create an OutputAnalyzer, a utility class for verifying output |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
54 |
* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
55 |
* @param buf String buffer to analyze |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
56 |
*/ |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
57 |
public OutputAnalyzer(String buf) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
58 |
this(buf, buf); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
59 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
60 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
61 |
/** |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
62 |
* Create an OutputAnalyzer, a utility class for verifying output |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
63 |
* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
64 |
* @param stdout stdout buffer to analyze |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
65 |
* @param stderr stderr buffer to analyze |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
66 |
*/ |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
67 |
public OutputAnalyzer(String stdout, String stderr) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
68 |
this.stdout = stdout; |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
69 |
this.stderr = stderr; |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
70 |
exitValue = -1; |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
71 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
72 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
73 |
/** |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
74 |
* Verify that the stdout contents of output buffer is empty |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
75 |
* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
76 |
* @throws RuntimeException |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
77 |
* If stdout was not empty |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
78 |
*/ |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
79 |
public void stdoutShouldBeEmpty() { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
80 |
if (!getStdout().isEmpty()) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
81 |
reportDiagnosticSummary(); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
82 |
throw new RuntimeException("stdout was not empty"); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
83 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
84 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
85 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
86 |
/** |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
87 |
* Verify that the stderr contents of output buffer is empty |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
88 |
* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
89 |
* @throws RuntimeException |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
90 |
* If stderr was not empty |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
91 |
*/ |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
92 |
public void stderrShouldBeEmpty() { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
93 |
if (!getStderr().isEmpty()) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
94 |
reportDiagnosticSummary(); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
95 |
throw new RuntimeException("stderr was not empty"); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
96 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
97 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
98 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
99 |
/** |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
100 |
* Verify that the stdout contents of output buffer is not empty |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
101 |
* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
102 |
* @throws RuntimeException |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
103 |
* If stdout was empty |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
104 |
*/ |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
105 |
public void stdoutShouldNotBeEmpty() { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
106 |
if (getStdout().isEmpty()) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
107 |
reportDiagnosticSummary(); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
108 |
throw new RuntimeException("stdout was empty"); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
109 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
110 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
111 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
112 |
/** |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
113 |
* Verify that the stderr contents of output buffer is not empty |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
114 |
* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
115 |
* @throws RuntimeException |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
116 |
* If stderr was empty |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
117 |
*/ |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
118 |
public void stderrShouldNotBeEmpty() { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
119 |
if (getStderr().isEmpty()) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
120 |
reportDiagnosticSummary(); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
121 |
throw new RuntimeException("stderr was empty"); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
122 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
123 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
124 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
125 |
/** |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
126 |
* Verify that the stdout and stderr contents of output buffer contains the string |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
127 |
* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
128 |
* @param expectedString String that buffer should contain |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
129 |
* @throws RuntimeException If the string was not found |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
130 |
*/ |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
131 |
public OutputAnalyzer shouldContain(String expectedString) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
132 |
if (!stdout.contains(expectedString) && !stderr.contains(expectedString)) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
133 |
reportDiagnosticSummary(); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
134 |
throw new RuntimeException("'" + expectedString + "' missing from stdout/stderr \n"); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
135 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
136 |
return this; |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
137 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
138 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
139 |
/** |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
140 |
* Verify that the stdout contents of output buffer contains the string |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
141 |
* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
142 |
* @param expectedString String that buffer should contain |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
143 |
* @throws RuntimeException If the string was not found |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
144 |
*/ |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
145 |
public OutputAnalyzer stdoutShouldContain(String expectedString) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
146 |
if (!stdout.contains(expectedString)) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
147 |
reportDiagnosticSummary(); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
148 |
throw new RuntimeException("'" + expectedString + "' missing from stdout \n"); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
149 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
150 |
return this; |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
151 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
152 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
153 |
/** |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
154 |
* Verify that the stderr contents of output buffer contains the string |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
155 |
* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
156 |
* @param expectedString String that buffer should contain |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
157 |
* @throws RuntimeException If the string was not found |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
158 |
*/ |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
159 |
public OutputAnalyzer stderrShouldContain(String expectedString) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
160 |
if (!stderr.contains(expectedString)) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
161 |
reportDiagnosticSummary(); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
162 |
throw new RuntimeException("'" + expectedString + "' missing from stderr \n"); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
163 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
164 |
return this; |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
165 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
166 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
167 |
/** |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
168 |
* Verify that the stdout and stderr contents of output buffer does not contain the string |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
169 |
* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
170 |
* @param expectedString String that the buffer should not contain |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
171 |
* @throws RuntimeException If the string was found |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
172 |
*/ |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
173 |
public OutputAnalyzer shouldNotContain(String notExpectedString) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
174 |
if (stdout.contains(notExpectedString)) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
175 |
reportDiagnosticSummary(); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
176 |
throw new RuntimeException("'" + notExpectedString + "' found in stdout \n"); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
177 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
178 |
if (stderr.contains(notExpectedString)) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
179 |
reportDiagnosticSummary(); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
180 |
throw new RuntimeException("'" + notExpectedString + "' found in stderr \n"); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
181 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
182 |
return this; |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
183 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
184 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
185 |
/** |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
186 |
* Verify that the stdout contents of output buffer does not contain the string |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
187 |
* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
188 |
* @param expectedString String that the buffer should not contain |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
189 |
* @throws RuntimeException If the string was found |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
190 |
*/ |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
191 |
public OutputAnalyzer stdoutShouldNotContain(String notExpectedString) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
192 |
if (stdout.contains(notExpectedString)) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
193 |
reportDiagnosticSummary(); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
194 |
throw new RuntimeException("'" + notExpectedString + "' found in stdout \n"); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
195 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
196 |
return this; |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
197 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
198 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
199 |
/** |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
200 |
* Verify that the stderr contents of output buffer does not contain the string |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
201 |
* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
202 |
* @param expectedString String that the buffer should not contain |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
203 |
* @throws RuntimeException If the string was found |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
204 |
*/ |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
205 |
public OutputAnalyzer stderrShouldNotContain(String notExpectedString) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
206 |
if (stderr.contains(notExpectedString)) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
207 |
reportDiagnosticSummary(); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
208 |
throw new RuntimeException("'" + notExpectedString + "' found in stderr \n"); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
209 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
210 |
return this; |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
211 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
212 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
213 |
/** |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
214 |
* Verify that the stdout and stderr contents of output buffer matches |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
215 |
* the pattern |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
216 |
* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
217 |
* @param pattern |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
218 |
* @throws RuntimeException If the pattern was not found |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
219 |
*/ |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
220 |
public OutputAnalyzer shouldMatch(String pattern) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
221 |
Matcher stdoutMatcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
222 |
Matcher stderrMatcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
223 |
if (!stdoutMatcher.find() && !stderrMatcher.find()) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
224 |
reportDiagnosticSummary(); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
225 |
throw new RuntimeException("'" + pattern |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
226 |
+ "' missing from stdout/stderr \n"); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
227 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
228 |
return this; |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
229 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
230 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
231 |
/** |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
232 |
* Verify that the stdout contents of output buffer matches the |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
233 |
* pattern |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
234 |
* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
235 |
* @param pattern |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
236 |
* @throws RuntimeException If the pattern was not found |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
237 |
*/ |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
238 |
public OutputAnalyzer stdoutShouldMatch(String pattern) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
239 |
Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
240 |
if (!matcher.find()) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
241 |
reportDiagnosticSummary(); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
242 |
throw new RuntimeException("'" + pattern |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
243 |
+ "' missing from stdout \n"); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
244 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
245 |
return this; |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
246 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
247 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
248 |
/** |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
249 |
* Verify that the stderr contents of output buffer matches the |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
250 |
* pattern |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
251 |
* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
252 |
* @param pattern |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
253 |
* @throws RuntimeException If the pattern was not found |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
254 |
*/ |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
255 |
public OutputAnalyzer stderrShouldMatch(String pattern) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
256 |
Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
257 |
if (!matcher.find()) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
258 |
reportDiagnosticSummary(); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
259 |
throw new RuntimeException("'" + pattern |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
260 |
+ "' missing from stderr \n"); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
261 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
262 |
return this; |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
263 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
264 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
265 |
/** |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
266 |
* Verify that the stdout and stderr contents of output buffer does not |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
267 |
* match the pattern |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
268 |
* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
269 |
* @param pattern |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
270 |
* @throws RuntimeException If the pattern was found |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
271 |
*/ |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
272 |
public OutputAnalyzer shouldNotMatch(String pattern) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
273 |
Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
274 |
if (matcher.find()) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
275 |
reportDiagnosticSummary(); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
276 |
throw new RuntimeException("'" + pattern |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
277 |
+ "' found in stdout: '" + matcher.group() + "' \n"); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
278 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
279 |
matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
280 |
if (matcher.find()) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
281 |
reportDiagnosticSummary(); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
282 |
throw new RuntimeException("'" + pattern |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
283 |
+ "' found in stderr: '" + matcher.group() + "' \n"); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
284 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
285 |
return this; |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
286 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
287 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
288 |
/** |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
289 |
* Verify that the stdout contents of output buffer does not match the |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
290 |
* pattern |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
291 |
* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
292 |
* @param pattern |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
293 |
* @throws RuntimeException If the pattern was found |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
294 |
*/ |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
295 |
public OutputAnalyzer stdoutShouldNotMatch(String pattern) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
296 |
Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
297 |
if (matcher.find()) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
298 |
reportDiagnosticSummary(); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
299 |
throw new RuntimeException("'" + pattern |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
300 |
+ "' found in stdout \n"); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
301 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
302 |
return this; |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
303 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
304 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
305 |
/** |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
306 |
* Verify that the stderr contents of output buffer does not match the |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
307 |
* pattern |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
308 |
* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
309 |
* @param pattern |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
310 |
* @throws RuntimeException If the pattern was found |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
311 |
*/ |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
312 |
public OutputAnalyzer stderrShouldNotMatch(String pattern) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
313 |
Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
314 |
if (matcher.find()) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
315 |
reportDiagnosticSummary(); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
316 |
throw new RuntimeException("'" + pattern |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
317 |
+ "' found in stderr \n"); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
318 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
319 |
return this; |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
320 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
321 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
322 |
/** |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
323 |
* Get the captured group of the first string matching the pattern. |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
324 |
* stderr is searched before stdout. |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
325 |
* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
326 |
* @param pattern The multi-line pattern to match |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
327 |
* @param group The group to capture |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
328 |
* @return The matched string or null if no match was found |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
329 |
*/ |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
330 |
public String firstMatch(String pattern, int group) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
331 |
Matcher stderrMatcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
332 |
Matcher stdoutMatcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
333 |
if (stderrMatcher.find()) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
334 |
return stderrMatcher.group(group); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
335 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
336 |
if (stdoutMatcher.find()) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
337 |
return stdoutMatcher.group(group); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
338 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
339 |
return null; |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
340 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
341 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
342 |
/** |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
343 |
* Get the first string matching the pattern. |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
344 |
* stderr is searched before stdout. |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
345 |
* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
346 |
* @param pattern The multi-line pattern to match |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
347 |
* @return The matched string or null if no match was found |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
348 |
*/ |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
349 |
public String firstMatch(String pattern) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
350 |
return firstMatch(pattern, 0); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
351 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
352 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
353 |
/** |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
354 |
* Verify the exit value of the process |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
355 |
* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
356 |
* @param expectedExitValue Expected exit value from process |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
357 |
* @throws RuntimeException If the exit value from the process did not match the expected value |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
358 |
*/ |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
359 |
public OutputAnalyzer shouldHaveExitValue(int expectedExitValue) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
360 |
if (getExitValue() != expectedExitValue) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
361 |
reportDiagnosticSummary(); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
362 |
throw new RuntimeException("Expected to get exit value of [" |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
363 |
+ expectedExitValue + "]\n"); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
364 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
365 |
return this; |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
366 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
367 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
368 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
369 |
/** |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
370 |
* Report summary that will help to diagnose the problem |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
371 |
* Currently includes: |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
372 |
* - standard input produced by the process under test |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
373 |
* - standard output |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
374 |
* - exit code |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
375 |
* Note: the command line is printed by the ProcessTools |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
376 |
*/ |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
377 |
private void reportDiagnosticSummary() { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
378 |
String msg = |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
379 |
" stdout: [" + stdout + "];\n" + |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
380 |
" stderr: [" + stderr + "]\n" + |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
381 |
" exitValue = " + getExitValue() + "\n"; |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
382 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
383 |
System.err.println(msg); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
384 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
385 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
386 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
387 |
/** |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
388 |
* Get the contents of the output buffer (stdout and stderr) |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
389 |
* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
390 |
* @return Content of the output buffer |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
391 |
*/ |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
392 |
public String getOutput() { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
393 |
return stdout + stderr; |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
394 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
395 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
396 |
/** |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
397 |
* Get the contents of the stdout buffer |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
398 |
* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
399 |
* @return Content of the stdout buffer |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
400 |
*/ |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
401 |
public String getStdout() { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
402 |
return stdout; |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
403 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
404 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
405 |
/** |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
406 |
* Get the contents of the stderr buffer |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
407 |
* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
408 |
* @return Content of the stderr buffer |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
409 |
*/ |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
410 |
public String getStderr() { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
411 |
return stderr; |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
412 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
413 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
414 |
/** |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
415 |
* Get the process exit value |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
416 |
* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
417 |
* @return Process exit value |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
418 |
*/ |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
419 |
public int getExitValue() { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
420 |
return exitValue; |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
421 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
422 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
423 |
/** |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
424 |
* Get the contents of the output buffer (stdout and stderr) as list of strings. |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
425 |
* Output will be split by newlines. |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
426 |
* |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
427 |
* @return Contents of the output buffer as list of strings |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
428 |
*/ |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
429 |
public List<String> asLines() { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
430 |
return asLines(getOutput()); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
431 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
432 |
|
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
433 |
private List<String> asLines(String buffer) { |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
434 |
return Arrays.asList(buffer.split("(\\r\\n|\\n|\\r)")); |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
435 |
} |
e5f2344c6fab
8141526: Allow to collect stdout/stderr from the FinalizationRunner even before the process returns
jbachorik
parents:
diff
changeset
|
436 |
} |