Use random port for DevTools tests
Change the `RemoteApplicationLauncher` to use a random port and also protect against an NPE if the launch fails.
This commit is contained in:
parent
9ea5c58e38
commit
4630c2292f
|
|
@ -80,7 +80,9 @@ public class DevToolsIntegrationTests {
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void stopApplication() throws InterruptedException {
|
public void stopApplication() throws InterruptedException {
|
||||||
this.launchedApplication.stop();
|
if (this.launchedApplication != null) {
|
||||||
|
this.launchedApplication.stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -40,12 +40,12 @@ abstract class RemoteApplicationLauncher implements ApplicationLauncher {
|
||||||
throws Exception {
|
throws Exception {
|
||||||
LaunchedJvm applicationJvm = javaLauncher.launch("app",
|
LaunchedJvm applicationJvm = javaLauncher.launch("app",
|
||||||
createApplicationClassPath(), "com.example.DevToolsTestApplication",
|
createApplicationClassPath(), "com.example.DevToolsTestApplication",
|
||||||
"--server.port=12345", "--spring.devtools.remote.secret=secret");
|
"--server.port=0", "--spring.devtools.remote.secret=secret");
|
||||||
awaitServerPort(applicationJvm.getStandardOut());
|
int port = awaitServerPort(applicationJvm.getStandardOut());
|
||||||
LaunchedJvm remoteSpringApplicationJvm = javaLauncher.launch(
|
LaunchedJvm remoteSpringApplicationJvm = javaLauncher.launch(
|
||||||
"remote-spring-application", createRemoteSpringApplicationClassPath(),
|
"remote-spring-application", createRemoteSpringApplicationClassPath(),
|
||||||
RemoteSpringApplication.class.getName(),
|
RemoteSpringApplication.class.getName(),
|
||||||
"--spring.devtools.remote.secret=secret", "http://localhost:12345");
|
"--spring.devtools.remote.secret=secret", "http://localhost:" + port);
|
||||||
awaitRemoteSpringApplication(remoteSpringApplicationJvm.getStandardOut());
|
awaitRemoteSpringApplication(remoteSpringApplicationJvm.getStandardOut());
|
||||||
return new LaunchedApplication(new File("target/remote"),
|
return new LaunchedApplication(new File("target/remote"),
|
||||||
applicationJvm.getStandardOut(), applicationJvm.getStandardError(),
|
applicationJvm.getStandardOut(), applicationJvm.getStandardError(),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue