|
|
@ -21,7 +21,6 @@ import java.io.IOException;
|
|
|
|
import java.nio.file.Files;
|
|
|
|
import java.nio.file.Files;
|
|
|
|
import java.nio.file.Path;
|
|
|
|
import java.nio.file.Path;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collections;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
@ -134,10 +133,8 @@ public class ApplicationRunner extends DefaultTask {
|
|
|
|
private void awaitLogging(Process process) {
|
|
|
|
private void awaitLogging(Process process) {
|
|
|
|
long end = System.currentTimeMillis() + 30000;
|
|
|
|
long end = System.currentTimeMillis() + 30000;
|
|
|
|
String expectedLogging = this.expectedLogging.get();
|
|
|
|
String expectedLogging = this.expectedLogging.get();
|
|
|
|
List<String> outputLines = Collections.emptyList();
|
|
|
|
|
|
|
|
while (System.currentTimeMillis() < end) {
|
|
|
|
while (System.currentTimeMillis() < end) {
|
|
|
|
outputLines = outputLines();
|
|
|
|
for (String line : outputLines()) {
|
|
|
|
for (String line : outputLines) {
|
|
|
|
|
|
|
|
if (line.contains(expectedLogging)) {
|
|
|
|
if (line.contains(expectedLogging)) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -146,10 +143,7 @@ public class ApplicationRunner extends DefaultTask {
|
|
|
|
throw new IllegalStateException("Process exited before '" + expectedLogging + "' was logged");
|
|
|
|
throw new IllegalStateException("Process exited before '" + expectedLogging + "' was logged");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
StringBuilder message = new StringBuilder(
|
|
|
|
throw new IllegalStateException("'" + expectedLogging + "' was not logged within 30 seconds");
|
|
|
|
"After 30 seconds '" + expectedLogging + "' had not be logged in the following output:\n\n");
|
|
|
|
|
|
|
|
outputLines.forEach((line) -> message.append(line).append("\n"));
|
|
|
|
|
|
|
|
throw new IllegalStateException(message.toString());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private List<String> outputLines() {
|
|
|
|
private List<String> outputLines() {
|
|
|
@ -177,8 +171,8 @@ public class ApplicationRunner extends DefaultTask {
|
|
|
|
private List<String> normalize(List<String> lines) {
|
|
|
|
private List<String> normalize(List<String> lines) {
|
|
|
|
List<String> normalizedLines = lines;
|
|
|
|
List<String> normalizedLines = lines;
|
|
|
|
Map<String, String> normalizations = new HashMap<>(this.normalizations);
|
|
|
|
Map<String, String> normalizations = new HashMap<>(this.normalizations);
|
|
|
|
normalizations.put("(Starting .* using Java .* on ).*( with PID [\\d]+ \\().*( started by ).*( in ).*(\\))",
|
|
|
|
normalizations.put("(Starting .* using Java .* with PID [\\d]+ \\().*( started by ).*( in ).*(\\))",
|
|
|
|
"$1myhost$2" + this.applicationJar.get() + "$3myuser$4/opt/apps/$5");
|
|
|
|
"$1" + this.applicationJar.get() + "$2myuser$3/opt/apps/$4");
|
|
|
|
for (Entry<String, String> normalization : normalizations.entrySet()) {
|
|
|
|
for (Entry<String, String> normalization : normalizations.entrySet()) {
|
|
|
|
Pattern pattern = Pattern.compile(normalization.getKey());
|
|
|
|
Pattern pattern = Pattern.compile(normalization.getKey());
|
|
|
|
normalizedLines = normalize(normalizedLines, pattern, normalization.getValue());
|
|
|
|
normalizedLines = normalize(normalizedLines, pattern, normalization.getValue());
|
|
|
|