Browse Source

Improve diagnostics in DevTools integration tests

See gh-10454
pull/10447/merge
Andy Wilkinson 8 years ago
parent
commit
b152b98f84
  1. 6
      spring-boot-integration-tests/spring-boot-devtools-tests/src/test/java/org/springframework/boot/devtools/tests/DevToolsIntegrationTests.java
  2. 15
      spring-boot-integration-tests/spring-boot-devtools-tests/src/test/java/org/springframework/boot/devtools/tests/JvmLauncher.java
  3. 10
      spring-boot-integration-tests/spring-boot-devtools-tests/src/test/java/org/springframework/boot/devtools/tests/LaunchedApplication.java
  4. 2
      spring-boot-integration-tests/spring-boot-devtools-tests/src/test/java/org/springframework/boot/devtools/tests/LocalApplicationLauncher.java
  5. 4
      spring-boot-integration-tests/spring-boot-devtools-tests/src/test/java/org/springframework/boot/devtools/tests/RemoteApplicationLauncher.java

6
spring-boot-integration-tests/spring-boot-devtools-tests/src/test/java/org/springframework/boot/devtools/tests/DevToolsIntegrationTests.java

@ -142,9 +142,11 @@ public class DevToolsIntegrationTests { @@ -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);
}

15
spring-boot-integration-tests/spring-boot-devtools-tests/src/test/java/org/springframework/boot/devtools/tests/JvmLauncher.java

@ -49,10 +49,10 @@ class JvmLauncher implements TestRule { @@ -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 { @@ -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 { @@ -74,6 +77,10 @@ class JvmLauncher implements TestRule {
return this.standardOut;
}
File getStandardError() {
return this.standardError;
}
}
}

10
spring-boot-integration-tests/spring-boot-devtools-tests/src/test/java/org/springframework/boot/devtools/tests/LaunchedApplication.java

@ -29,11 +29,15 @@ class LaunchedApplication { @@ -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 { @@ -48,6 +52,10 @@ class LaunchedApplication {
return this.standardOut;
}
File getStandardError() {
return this.standardError;
}
File getClassesDirectory() {
return this.classesDirectory;
}

2
spring-boot-integration-tests/spring-boot-devtools-tests/src/test/java/org/springframework/boot/devtools/tests/LocalApplicationLauncher.java

@ -37,7 +37,7 @@ public class LocalApplicationLauncher implements ApplicationLauncher { @@ -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 {

4
spring-boot-integration-tests/spring-boot-devtools-tests/src/test/java/org/springframework/boot/devtools/tests/RemoteApplicationLauncher.java

@ -48,8 +48,8 @@ abstract class RemoteApplicationLauncher implements ApplicationLauncher { @@ -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…
Cancel
Save