Skip to content

Commit

Permalink
Use random port for DevTools tests
Browse files Browse the repository at this point in the history
Change the `RemoteApplicationLauncher` to use a random port and also
protect against an NPE if the launch fails.
  • Loading branch information
philwebb committed Oct 30, 2018
1 parent 9ea5c58 commit 4630c22
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ public void launchApplication() throws Exception {

@After
public void stopApplication() throws InterruptedException {
this.launchedApplication.stop();
if (this.launchedApplication != null) {
this.launchedApplication.stop();
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ public LaunchedApplication launchApplication(JvmLauncher javaLauncher)
throws Exception {
LaunchedJvm applicationJvm = javaLauncher.launch("app",
createApplicationClassPath(), "com.example.DevToolsTestApplication",
"--server.port=12345", "--spring.devtools.remote.secret=secret");
awaitServerPort(applicationJvm.getStandardOut());
"--server.port=0", "--spring.devtools.remote.secret=secret");
int port = awaitServerPort(applicationJvm.getStandardOut());
LaunchedJvm remoteSpringApplicationJvm = javaLauncher.launch(
"remote-spring-application", createRemoteSpringApplicationClassPath(),
RemoteSpringApplication.class.getName(),
"--spring.devtools.remote.secret=secret", "http://localhost:12345");
"--spring.devtools.remote.secret=secret", "http://localhost:" + port);
awaitRemoteSpringApplication(remoteSpringApplicationJvm.getStandardOut());
return new LaunchedApplication(new File("target/remote"),
applicationJvm.getStandardOut(), applicationJvm.getStandardError(),
Expand Down

0 comments on commit 4630c22

Please sign in to comment.