Improve diagnostics in DevTools integration tests
See gh-10454
This commit is contained in:
parent
5cf48a29a5
commit
b152b98f84
|
|
@ -142,9 +142,11 @@ public class DevToolsIntegrationTests {
|
|||
if (System.currentTimeMillis() > end) {
|
||||
throw new IllegalStateException(String.format(
|
||||
"server.port file was not written within 30 seconds. "
|
||||
+ "Application output:%n%s",
|
||||
+ "Application output:%n%s%s",
|
||||
FileCopyUtils.copyToString(new FileReader(
|
||||
this.launchedApplication.getStandardOut()))));
|
||||
this.launchedApplication.getStandardOut())),
|
||||
FileCopyUtils.copyToString(new FileReader(
|
||||
this.launchedApplication.getStandardError()))));
|
||||
}
|
||||
Thread.sleep(100);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,10 +49,10 @@ class JvmLauncher implements TestRule {
|
|||
.asList(System.getProperty("java.home") + "/bin/java", "-cp", classpath));
|
||||
command.addAll(Arrays.asList(args));
|
||||
File standardOut = new File(this.outputDirectory, name + ".out");
|
||||
File standardError = new File(this.outputDirectory, name + ".err");
|
||||
Process process = new ProcessBuilder(command.toArray(new String[command.size()]))
|
||||
.redirectError(new File(this.outputDirectory, name + ".err"))
|
||||
.redirectOutput(standardOut).start();
|
||||
return new LaunchedJvm(process, standardOut);
|
||||
.redirectError(standardError).redirectOutput(standardOut).start();
|
||||
return new LaunchedJvm(process, standardOut, standardError);
|
||||
}
|
||||
|
||||
static class LaunchedJvm {
|
||||
|
|
@ -61,9 +61,12 @@ class JvmLauncher implements TestRule {
|
|||
|
||||
private final File standardOut;
|
||||
|
||||
LaunchedJvm(Process process, File standardOut) {
|
||||
private final File standardError;
|
||||
|
||||
LaunchedJvm(Process process, File standardOut, File standardError) {
|
||||
this.process = process;
|
||||
this.standardOut = standardOut;
|
||||
this.standardError = standardError;
|
||||
}
|
||||
|
||||
Process getProcess() {
|
||||
|
|
@ -74,6 +77,10 @@ class JvmLauncher implements TestRule {
|
|||
return this.standardOut;
|
||||
}
|
||||
|
||||
File getStandardError() {
|
||||
return this.standardError;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,11 +29,15 @@ class LaunchedApplication {
|
|||
|
||||
private final File standardOut;
|
||||
|
||||
private final File standardError;
|
||||
|
||||
private final Process[] processes;
|
||||
|
||||
LaunchedApplication(File classesDirectory, File standardOut, Process... processes) {
|
||||
LaunchedApplication(File classesDirectory, File standardOut, File standardError,
|
||||
Process... processes) {
|
||||
this.classesDirectory = classesDirectory;
|
||||
this.standardOut = standardOut;
|
||||
this.standardError = standardError;
|
||||
this.processes = processes;
|
||||
}
|
||||
|
||||
|
|
@ -48,6 +52,10 @@ class LaunchedApplication {
|
|||
return this.standardOut;
|
||||
}
|
||||
|
||||
File getStandardError() {
|
||||
return this.standardError;
|
||||
}
|
||||
|
||||
File getClassesDirectory() {
|
||||
return this.classesDirectory;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public class LocalApplicationLauncher implements ApplicationLauncher {
|
|||
LaunchedJvm jvm = jvmLauncher.launch("local", createApplicationClassPath(),
|
||||
"com.example.DevToolsTestApplication", "--server.port=0");
|
||||
return new LaunchedApplication(new File("target/app"), jvm.getStandardOut(),
|
||||
jvm.getProcess());
|
||||
jvm.getStandardError(), jvm.getProcess());
|
||||
}
|
||||
|
||||
protected String createApplicationClassPath() throws Exception {
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ abstract class RemoteApplicationLauncher implements ApplicationLauncher {
|
|||
"--spring.devtools.remote.secret=secret", "http://localhost:12345");
|
||||
awaitRemoteSpringApplication(remoteSpringApplicationJvm.getStandardOut());
|
||||
return new LaunchedApplication(new File("target/remote"),
|
||||
applicationJvm.getStandardOut(), applicationJvm.getProcess(),
|
||||
remoteSpringApplicationJvm.getProcess());
|
||||
applicationJvm.getStandardOut(), applicationJvm.getStandardError(),
|
||||
applicationJvm.getProcess(), remoteSpringApplicationJvm.getProcess());
|
||||
}
|
||||
|
||||
protected abstract String createApplicationClassPath() throws Exception;
|
||||
|
|
|
|||
Loading…
Reference in New Issue