Skip to content

Commit b152b98

Browse files
committed
Improve diagnostics in DevTools integration tests
See gh-10454
1 parent 5cf48a2 commit b152b98

File tree

5 files changed

+27
-10
lines changed

5 files changed

+27
-10
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,11 @@ private int awaitServerPort() throws Exception {
142142
if (System.currentTimeMillis() > end) {
143143
throw new IllegalStateException(String.format(
144144
"server.port file was not written within 30 seconds. "
145-
+ "Application output:%n%s",
145+
+ "Application output:%n%s%s",
146146
FileCopyUtils.copyToString(new FileReader(
147-
this.launchedApplication.getStandardOut()))));
147+
this.launchedApplication.getStandardOut())),
148+
FileCopyUtils.copyToString(new FileReader(
149+
this.launchedApplication.getStandardError()))));
148150
}
149151
Thread.sleep(100);
150152
}

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ LaunchedJvm launch(String name, String classpath, String... args) throws IOExcep
4949
.asList(System.getProperty("java.home") + "/bin/java", "-cp", classpath));
5050
command.addAll(Arrays.asList(args));
5151
File standardOut = new File(this.outputDirectory, name + ".out");
52+
File standardError = new File(this.outputDirectory, name + ".err");
5253
Process process = new ProcessBuilder(command.toArray(new String[command.size()]))
53-
.redirectError(new File(this.outputDirectory, name + ".err"))
54-
.redirectOutput(standardOut).start();
55-
return new LaunchedJvm(process, standardOut);
54+
.redirectError(standardError).redirectOutput(standardOut).start();
55+
return new LaunchedJvm(process, standardOut, standardError);
5656
}
5757

5858
static class LaunchedJvm {
@@ -61,9 +61,12 @@ static class LaunchedJvm {
6161

6262
private final File standardOut;
6363

64-
LaunchedJvm(Process process, File standardOut) {
64+
private final File standardError;
65+
66+
LaunchedJvm(Process process, File standardOut, File standardError) {
6567
this.process = process;
6668
this.standardOut = standardOut;
69+
this.standardError = standardError;
6770
}
6871

6972
Process getProcess() {
@@ -74,6 +77,10 @@ File getStandardOut() {
7477
return this.standardOut;
7578
}
7679

80+
File getStandardError() {
81+
return this.standardError;
82+
}
83+
7784
}
7885

7986
}

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,15 @@ class LaunchedApplication {
2929

3030
private final File standardOut;
3131

32+
private final File standardError;
33+
3234
private final Process[] processes;
3335

34-
LaunchedApplication(File classesDirectory, File standardOut, Process... processes) {
36+
LaunchedApplication(File classesDirectory, File standardOut, File standardError,
37+
Process... processes) {
3538
this.classesDirectory = classesDirectory;
3639
this.standardOut = standardOut;
40+
this.standardError = standardError;
3741
this.processes = processes;
3842
}
3943

@@ -48,6 +52,10 @@ File getStandardOut() {
4852
return this.standardOut;
4953
}
5054

55+
File getStandardError() {
56+
return this.standardError;
57+
}
58+
5159
File getClassesDirectory() {
5260
return this.classesDirectory;
5361
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public LaunchedApplication launchApplication(JvmLauncher jvmLauncher)
3737
LaunchedJvm jvm = jvmLauncher.launch("local", createApplicationClassPath(),
3838
"com.example.DevToolsTestApplication", "--server.port=0");
3939
return new LaunchedApplication(new File("target/app"), jvm.getStandardOut(),
40-
jvm.getProcess());
40+
jvm.getStandardError(), jvm.getProcess());
4141
}
4242

4343
protected String createApplicationClassPath() throws Exception {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public LaunchedApplication launchApplication(JvmLauncher javaLauncher)
4848
"--spring.devtools.remote.secret=secret", "http://localhost:12345");
4949
awaitRemoteSpringApplication(remoteSpringApplicationJvm.getStandardOut());
5050
return new LaunchedApplication(new File("target/remote"),
51-
applicationJvm.getStandardOut(), applicationJvm.getProcess(),
52-
remoteSpringApplicationJvm.getProcess());
51+
applicationJvm.getStandardOut(), applicationJvm.getStandardError(),
52+
applicationJvm.getProcess(), remoteSpringApplicationJvm.getProcess());
5353
}
5454

5555
protected abstract String createApplicationClassPath() throws Exception;

0 commit comments

Comments
 (0)