|
|
|
@ -59,13 +59,6 @@ public class DevToolsIntegrationTests { |
|
|
|
@Rule |
|
|
|
@Rule |
|
|
|
public JvmLauncher javaLauncher = new JvmLauncher(); |
|
|
|
public JvmLauncher javaLauncher = new JvmLauncher(); |
|
|
|
|
|
|
|
|
|
|
|
@Parameters(name = "{0}") |
|
|
|
|
|
|
|
public static Object[] parameters() { |
|
|
|
|
|
|
|
return new Object[] { new Object[] { new LocalApplicationLauncher() }, |
|
|
|
|
|
|
|
new Object[] { new ExplodedRemoteApplicationLauncher() }, |
|
|
|
|
|
|
|
new Object[] { new JarFileRemoteApplicationLauncher() } }; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public DevToolsIntegrationTests(ApplicationLauncher applicationLauncher) { |
|
|
|
public DevToolsIntegrationTests(ApplicationLauncher applicationLauncher) { |
|
|
|
this.applicationLauncher = applicationLauncher; |
|
|
|
this.applicationLauncher = applicationLauncher; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -93,20 +86,23 @@ public class DevToolsIntegrationTests { |
|
|
|
.isEqualTo(HttpStatus.NOT_FOUND); |
|
|
|
.isEqualTo(HttpStatus.NOT_FOUND); |
|
|
|
controller("com.example.ControllerOne").withRequestMapping("one") |
|
|
|
controller("com.example.ControllerOne").withRequestMapping("one") |
|
|
|
.withRequestMapping("two").build(); |
|
|
|
.withRequestMapping("two").build(); |
|
|
|
|
|
|
|
urlBase = "http://localhost:" + awaitServerPort(); |
|
|
|
assertThat(template.getForObject(urlBase + "/one", String.class)) |
|
|
|
assertThat(template.getForObject(urlBase + "/one", String.class)) |
|
|
|
.isEqualTo("one"); |
|
|
|
.isEqualTo("one"); |
|
|
|
assertThat(template.getForObject("http://localhost:" + awaitServerPort() + "/two", |
|
|
|
assertThat(template.getForObject(urlBase + "/two", String.class)) |
|
|
|
String.class)).isEqualTo("two"); |
|
|
|
.isEqualTo("two"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void removeARequestMappingFromAnExistingController() throws Exception { |
|
|
|
public void removeARequestMappingFromAnExistingController() throws Exception { |
|
|
|
TestRestTemplate template = new TestRestTemplate(); |
|
|
|
TestRestTemplate template = new TestRestTemplate(); |
|
|
|
assertThat(template.getForObject("http://localhost:" + awaitServerPort() + "/one", |
|
|
|
String urlBase = "http://localhost:" + awaitServerPort(); |
|
|
|
String.class)).isEqualTo("one"); |
|
|
|
assertThat(template.getForObject(urlBase + "/one", String.class)) |
|
|
|
|
|
|
|
.isEqualTo("one"); |
|
|
|
controller("com.example.ControllerOne").build(); |
|
|
|
controller("com.example.ControllerOne").build(); |
|
|
|
assertThat(template.getForEntity("http://localhost:" + awaitServerPort() + "/one", |
|
|
|
urlBase = "http://localhost:" + awaitServerPort(); |
|
|
|
String.class).getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); |
|
|
|
assertThat(template.getForEntity(urlBase + "/one", String.class).getStatusCode()) |
|
|
|
|
|
|
|
.isEqualTo(HttpStatus.NOT_FOUND); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
@ -118,10 +114,11 @@ public class DevToolsIntegrationTests { |
|
|
|
assertThat(template.getForEntity(urlBase + "/two", String.class).getStatusCode()) |
|
|
|
assertThat(template.getForEntity(urlBase + "/two", String.class).getStatusCode()) |
|
|
|
.isEqualTo(HttpStatus.NOT_FOUND); |
|
|
|
.isEqualTo(HttpStatus.NOT_FOUND); |
|
|
|
controller("com.example.ControllerTwo").withRequestMapping("two").build(); |
|
|
|
controller("com.example.ControllerTwo").withRequestMapping("two").build(); |
|
|
|
|
|
|
|
urlBase = "http://localhost:" + awaitServerPort(); |
|
|
|
assertThat(template.getForObject(urlBase + "/one", String.class)) |
|
|
|
assertThat(template.getForObject(urlBase + "/one", String.class)) |
|
|
|
.isEqualTo("one"); |
|
|
|
.isEqualTo("one"); |
|
|
|
assertThat(template.getForObject("http://localhost:" + awaitServerPort() + "/two", |
|
|
|
assertThat(template.getForObject(urlBase + "/two", String.class)) |
|
|
|
String.class)).isEqualTo("two"); |
|
|
|
.isEqualTo("two"); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -134,15 +131,16 @@ public class DevToolsIntegrationTests { |
|
|
|
assertThat(template.getForEntity(urlBase + "/two", String.class).getStatusCode()) |
|
|
|
assertThat(template.getForEntity(urlBase + "/two", String.class).getStatusCode()) |
|
|
|
.isEqualTo(HttpStatus.NOT_FOUND); |
|
|
|
.isEqualTo(HttpStatus.NOT_FOUND); |
|
|
|
controller("com.example.ControllerTwo").withRequestMapping("two").build(); |
|
|
|
controller("com.example.ControllerTwo").withRequestMapping("two").build(); |
|
|
|
|
|
|
|
urlBase = "http://localhost:" + awaitServerPort(); |
|
|
|
assertThat(template.getForObject(urlBase + "/one", String.class)) |
|
|
|
assertThat(template.getForObject(urlBase + "/one", String.class)) |
|
|
|
.isEqualTo("one"); |
|
|
|
.isEqualTo("one"); |
|
|
|
assertThat(template.getForObject("http://localhost:" + awaitServerPort() + "/two", |
|
|
|
assertThat(template.getForObject(urlBase + "/two", String.class)) |
|
|
|
String.class)).isEqualTo("two"); |
|
|
|
.isEqualTo("two"); |
|
|
|
controller("com.example.ControllerTwo").withRequestMapping("two") |
|
|
|
controller("com.example.ControllerTwo").withRequestMapping("two") |
|
|
|
.withRequestMapping("three").build(); |
|
|
|
.withRequestMapping("three").build(); |
|
|
|
assertThat(template.getForObject( |
|
|
|
urlBase = "http://localhost:" + awaitServerPort(); |
|
|
|
"http://localhost:" + awaitServerPort() + "/three", String.class)) |
|
|
|
assertThat(template.getForObject(urlBase + "/three", String.class)) |
|
|
|
.isEqualTo("three"); |
|
|
|
.isEqualTo("three"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
@ -155,32 +153,33 @@ public class DevToolsIntegrationTests { |
|
|
|
assertThat(template.getForEntity(urlBase + "/two", String.class).getStatusCode()) |
|
|
|
assertThat(template.getForEntity(urlBase + "/two", String.class).getStatusCode()) |
|
|
|
.isEqualTo(HttpStatus.NOT_FOUND); |
|
|
|
.isEqualTo(HttpStatus.NOT_FOUND); |
|
|
|
controller("com.example.ControllerTwo").withRequestMapping("two").build(); |
|
|
|
controller("com.example.ControllerTwo").withRequestMapping("two").build(); |
|
|
|
|
|
|
|
urlBase = "http://localhost:" + awaitServerPort(); |
|
|
|
assertThat(template.getForObject(urlBase + "/one", String.class)) |
|
|
|
assertThat(template.getForObject(urlBase + "/one", String.class)) |
|
|
|
.isEqualTo("one"); |
|
|
|
.isEqualTo("one"); |
|
|
|
assertThat(template.getForObject("http://localhost:" + awaitServerPort() + "/two", |
|
|
|
assertThat(template.getForObject(urlBase + "/two", String.class)) |
|
|
|
String.class)).isEqualTo("two"); |
|
|
|
.isEqualTo("two"); |
|
|
|
controller("com.example.ControllerOne").withRequestMapping("one") |
|
|
|
controller("com.example.ControllerOne").withRequestMapping("one") |
|
|
|
.withRequestMapping("three").build(); |
|
|
|
.withRequestMapping("three").build(); |
|
|
|
int port = awaitServerPort(); |
|
|
|
urlBase = "http://localhost:" + awaitServerPort(); |
|
|
|
assertThat( |
|
|
|
assertThat(template.getForObject(urlBase + "/one", String.class)) |
|
|
|
template.getForObject("http://localhost:" + port + "/one", String.class)) |
|
|
|
.isEqualTo("one"); |
|
|
|
.isEqualTo("one"); |
|
|
|
assertThat(template.getForObject(urlBase + "/two", String.class)) |
|
|
|
assertThat( |
|
|
|
.isEqualTo("two"); |
|
|
|
template.getForObject("http://localhost:" + port + "/two", String.class)) |
|
|
|
assertThat(template.getForObject(urlBase + "/three", String.class)) |
|
|
|
.isEqualTo("two"); |
|
|
|
.isEqualTo("three"); |
|
|
|
assertThat(template.getForObject("http://localhost:" + port + "/three", |
|
|
|
|
|
|
|
String.class)).isEqualTo("three"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void deleteAController() throws Exception { |
|
|
|
public void deleteAController() throws Exception { |
|
|
|
TestRestTemplate template = new TestRestTemplate(); |
|
|
|
TestRestTemplate template = new TestRestTemplate(); |
|
|
|
assertThat(template.getForObject("http://localhost:" + awaitServerPort() + "/one", |
|
|
|
String urlBase = "http://localhost:" + awaitServerPort(); |
|
|
|
String.class)).isEqualTo("one"); |
|
|
|
assertThat(template.getForObject(urlBase + "/one", String.class)) |
|
|
|
|
|
|
|
.isEqualTo("one"); |
|
|
|
assertThat(new File(this.launchedApplication.getClassesDirectory(), |
|
|
|
assertThat(new File(this.launchedApplication.getClassesDirectory(), |
|
|
|
"com/example/ControllerOne.class").delete()).isTrue(); |
|
|
|
"com/example/ControllerOne.class").delete()).isTrue(); |
|
|
|
assertThat(template.getForEntity("http://localhost:" + awaitServerPort() + "/one", |
|
|
|
urlBase = "http://localhost:" + awaitServerPort(); |
|
|
|
String.class).getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); |
|
|
|
assertThat(template.getForEntity(urlBase + "/one", String.class).getStatusCode()) |
|
|
|
|
|
|
|
.isEqualTo(HttpStatus.NOT_FOUND); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -193,18 +192,20 @@ public class DevToolsIntegrationTests { |
|
|
|
assertThat(template.getForEntity(urlBase + "/two", String.class).getStatusCode()) |
|
|
|
assertThat(template.getForEntity(urlBase + "/two", String.class).getStatusCode()) |
|
|
|
.isEqualTo(HttpStatus.NOT_FOUND); |
|
|
|
.isEqualTo(HttpStatus.NOT_FOUND); |
|
|
|
controller("com.example.ControllerTwo").withRequestMapping("two").build(); |
|
|
|
controller("com.example.ControllerTwo").withRequestMapping("two").build(); |
|
|
|
|
|
|
|
urlBase = "http://localhost:" + awaitServerPort(); |
|
|
|
assertThat(template.getForObject(urlBase + "/one", String.class)) |
|
|
|
assertThat(template.getForObject(urlBase + "/one", String.class)) |
|
|
|
.isEqualTo("one"); |
|
|
|
.isEqualTo("one"); |
|
|
|
assertThat(template.getForObject("http://localhost:" + awaitServerPort() + "/two", |
|
|
|
assertThat(template.getForObject(urlBase + "/two", String.class)) |
|
|
|
String.class)).isEqualTo("two"); |
|
|
|
.isEqualTo("two"); |
|
|
|
assertThat(new File(this.launchedApplication.getClassesDirectory(), |
|
|
|
assertThat(new File(this.launchedApplication.getClassesDirectory(), |
|
|
|
"com/example/ControllerTwo.class").delete()).isTrue(); |
|
|
|
"com/example/ControllerTwo.class").delete()).isTrue(); |
|
|
|
assertThat(template.getForEntity("http://localhost:" + awaitServerPort() + "/two", |
|
|
|
urlBase = "http://localhost:" + awaitServerPort(); |
|
|
|
String.class).getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); |
|
|
|
assertThat(template.getForEntity(urlBase + "/two", String.class).getStatusCode()) |
|
|
|
|
|
|
|
.isEqualTo(HttpStatus.NOT_FOUND); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private int awaitServerPort() throws Exception { |
|
|
|
private int awaitServerPort() throws Exception { |
|
|
|
long end = System.currentTimeMillis() + 30000; |
|
|
|
long end = System.currentTimeMillis() + 40000; |
|
|
|
while (this.serverPortFile.length() == 0) { |
|
|
|
while (this.serverPortFile.length() == 0) { |
|
|
|
System.out.println("Getting server port " + this.serverPortFile.length()); |
|
|
|
System.out.println("Getting server port " + this.serverPortFile.length()); |
|
|
|
if (System.currentTimeMillis() > end) { |
|
|
|
if (System.currentTimeMillis() > end) { |
|
|
|
@ -222,6 +223,8 @@ public class DevToolsIntegrationTests { |
|
|
|
int port = Integer.valueOf(FileCopyUtils.copyToString(portReader)); |
|
|
|
int port = Integer.valueOf(FileCopyUtils.copyToString(portReader)); |
|
|
|
this.serverPortFile.delete(); |
|
|
|
this.serverPortFile.delete(); |
|
|
|
System.out.println("Got port " + port); |
|
|
|
System.out.println("Got port " + port); |
|
|
|
|
|
|
|
this.launchedApplication.restartRemote(port); |
|
|
|
|
|
|
|
Thread.sleep(1000); |
|
|
|
return port; |
|
|
|
return port; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -230,6 +233,13 @@ public class DevToolsIntegrationTests { |
|
|
|
this.launchedApplication.getClassesDirectory()); |
|
|
|
this.launchedApplication.getClassesDirectory()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Parameters(name = "{0}") |
|
|
|
|
|
|
|
public static Object[] parameters() { |
|
|
|
|
|
|
|
return new Object[] { new Object[] { new LocalApplicationLauncher() }, |
|
|
|
|
|
|
|
new Object[] { new ExplodedRemoteApplicationLauncher() }, |
|
|
|
|
|
|
|
new Object[] { new JarFileRemoteApplicationLauncher() } }; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static final class ControllerBuilder { |
|
|
|
private static final class ControllerBuilder { |
|
|
|
|
|
|
|
|
|
|
|
private final List<String> mappings = new ArrayList<>(); |
|
|
|
private final List<String> mappings = new ArrayList<>(); |
|
|
|
|