mirror of
https://github.com/ethauvin/bld.git
synced 2025-04-25 08:17:11 -07:00
Make sure previous executors are closed cleanly
This commit is contained in:
parent
77ceceb122
commit
3eb5795cf2
2 changed files with 50 additions and 43 deletions
|
@ -283,17 +283,19 @@ public class TestCreateRife2Operation {
|
|||
/myapp/src/test/resources""").matcher(FileUtils.generateDirectoryListing(tmp)).matches());
|
||||
|
||||
var run_operation = new RunOperation().fromProject(create_operation.project());
|
||||
var executor = Executors.newSingleThreadScheduledExecutor();
|
||||
var checked_url = new URL("http://localhost:8080");
|
||||
var check_result = new StringBuilder();
|
||||
executor.schedule(() -> {
|
||||
try {
|
||||
check_result.append(FileUtils.readString(checked_url));
|
||||
} catch (FileUtilsErrorException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}, 1, TimeUnit.SECONDS);
|
||||
executor.schedule(() -> run_operation.process().destroy(), 2, TimeUnit.SECONDS);
|
||||
StringBuilder check_result;
|
||||
try (var executor = Executors.newSingleThreadScheduledExecutor()) {
|
||||
var checked_url = new URL("http://localhost:8080");
|
||||
check_result = new StringBuilder();
|
||||
executor.schedule(() -> {
|
||||
try {
|
||||
check_result.append(FileUtils.readString(checked_url));
|
||||
} catch (FileUtilsErrorException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}, 1, TimeUnit.SECONDS);
|
||||
executor.schedule(() -> run_operation.process().destroy(), 2, TimeUnit.SECONDS);
|
||||
}
|
||||
assertThrows(ExitStatusException.class, run_operation::execute);
|
||||
|
||||
assertTrue(check_result.toString().contains("<p>Hello World Myapp</p>"));
|
||||
|
@ -533,17 +535,19 @@ public class TestCreateRife2Operation {
|
|||
/myapp/src/test/resources""").matcher(FileUtils.generateDirectoryListing(tmp)).matches());
|
||||
|
||||
var run_operation = new RunOperation().fromProject(create_operation.project());
|
||||
var executor = Executors.newSingleThreadScheduledExecutor();
|
||||
var checked_url = new URL("http://localhost:8080");
|
||||
var check_result = new StringBuilder();
|
||||
executor.schedule(() -> {
|
||||
try {
|
||||
check_result.append(FileUtils.readString(checked_url));
|
||||
} catch (FileUtilsErrorException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}, 1, TimeUnit.SECONDS);
|
||||
executor.schedule(() -> run_operation.process().destroy(), 2, TimeUnit.SECONDS);
|
||||
StringBuilder check_result;
|
||||
try (var executor = Executors.newSingleThreadScheduledExecutor()) {
|
||||
var checked_url = new URL("http://localhost:8080");
|
||||
check_result = new StringBuilder();
|
||||
executor.schedule(() -> {
|
||||
try {
|
||||
check_result.append(FileUtils.readString(checked_url));
|
||||
} catch (FileUtilsErrorException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}, 1, TimeUnit.SECONDS);
|
||||
executor.schedule(() -> run_operation.process().destroy(), 2, TimeUnit.SECONDS);
|
||||
}
|
||||
assertThrows(ExitStatusException.class, run_operation::execute);
|
||||
|
||||
assertTrue(check_result.toString().contains("<p>Hello World Myapp</p>"), check_result.toString());
|
||||
|
@ -699,17 +703,19 @@ public class TestCreateRife2Operation {
|
|||
/myapp/src/test/resources""").matcher(FileUtils.generateDirectoryListing(tmp)).matches());
|
||||
|
||||
var run_operation = new RunOperation().fromProject(create_operation.project());
|
||||
var executor = Executors.newSingleThreadScheduledExecutor();
|
||||
var checked_url = new URL("http://localhost:8080");
|
||||
var check_result = new StringBuilder();
|
||||
executor.schedule(() -> {
|
||||
try {
|
||||
check_result.append(FileUtils.readString(checked_url));
|
||||
} catch (FileUtilsErrorException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}, 1, TimeUnit.SECONDS);
|
||||
executor.schedule(() -> run_operation.process().destroy(), 2, TimeUnit.SECONDS);
|
||||
StringBuilder check_result;
|
||||
try (var executor = Executors.newSingleThreadScheduledExecutor()) {
|
||||
var checked_url = new URL("http://localhost:8080");
|
||||
check_result = new StringBuilder();
|
||||
executor.schedule(() -> {
|
||||
try {
|
||||
check_result.append(FileUtils.readString(checked_url));
|
||||
} catch (FileUtilsErrorException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}, 1, TimeUnit.SECONDS);
|
||||
executor.schedule(() -> run_operation.process().destroy(), 2, TimeUnit.SECONDS);
|
||||
}
|
||||
assertThrows(ExitStatusException.class, run_operation::execute);
|
||||
|
||||
assertTrue(check_result.toString().contains("<p>Hello World Myapp</p>"));
|
||||
|
|
|
@ -162,16 +162,17 @@ public class TestUberJarOperation {
|
|||
var run_operation = new RunOperation()
|
||||
.javaOptions(List.of("-jar"))
|
||||
.mainClass(uberjar_file.getAbsolutePath());
|
||||
var executor = Executors.newSingleThreadScheduledExecutor();
|
||||
var checked_url = new URL("http://localhost:8080");
|
||||
executor.schedule(() -> {
|
||||
try {
|
||||
check_result.append(FileUtils.readString(checked_url));
|
||||
} catch (FileUtilsErrorException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}, 1, TimeUnit.SECONDS);
|
||||
executor.schedule(() -> run_operation.process().destroy(), 2, TimeUnit.SECONDS);
|
||||
try (var executor = Executors.newSingleThreadScheduledExecutor()) {
|
||||
var checked_url = new URL("http://localhost:8080");
|
||||
executor.schedule(() -> {
|
||||
try {
|
||||
check_result.append(FileUtils.readString(checked_url));
|
||||
} catch (FileUtilsErrorException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}, 1, TimeUnit.SECONDS);
|
||||
executor.schedule(() -> run_operation.process().destroy(), 2, TimeUnit.SECONDS);
|
||||
}
|
||||
assertThrows(ExitStatusException.class, run_operation::execute);
|
||||
|
||||
assertTrue(check_result.toString().contains("<p>Hello World App</p>"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue