From 0994f184f2f4e784270ad427598b1eee4545a740 Mon Sep 17 00:00:00 2001 From: Geert Bevin Date: Sat, 30 Sep 2023 19:17:11 -0400 Subject: [PATCH] Backing out previous change since it only works on JDK 19 --- .../operations/TestCreateRife2Operation.java | 72 +++++++++---------- .../bld/operations/TestUberJarOperation.java | 21 +++--- 2 files changed, 43 insertions(+), 50 deletions(-) diff --git a/src/test/java/rife/bld/operations/TestCreateRife2Operation.java b/src/test/java/rife/bld/operations/TestCreateRife2Operation.java index 3b4e0af..6aad8cd 100644 --- a/src/test/java/rife/bld/operations/TestCreateRife2Operation.java +++ b/src/test/java/rife/bld/operations/TestCreateRife2Operation.java @@ -283,19 +283,17 @@ public class TestCreateRife2Operation { /myapp/src/test/resources""").matcher(FileUtils.generateDirectoryListing(tmp)).matches()); var run_operation = new RunOperation().fromProject(create_operation.project()); - 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); - } + 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); assertThrows(ExitStatusException.class, run_operation::execute); assertTrue(check_result.toString().contains("

Hello World Myapp

")); @@ -535,19 +533,17 @@ public class TestCreateRife2Operation { /myapp/src/test/resources""").matcher(FileUtils.generateDirectoryListing(tmp)).matches()); var run_operation = new RunOperation().fromProject(create_operation.project()); - 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); - } + 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); assertThrows(ExitStatusException.class, run_operation::execute); assertTrue(check_result.toString().contains("

Hello World Myapp

"), check_result.toString()); @@ -703,19 +699,17 @@ public class TestCreateRife2Operation { /myapp/src/test/resources""").matcher(FileUtils.generateDirectoryListing(tmp)).matches()); var run_operation = new RunOperation().fromProject(create_operation.project()); - 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); - } + 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); assertThrows(ExitStatusException.class, run_operation::execute); assertTrue(check_result.toString().contains("

Hello World Myapp

")); diff --git a/src/test/java/rife/bld/operations/TestUberJarOperation.java b/src/test/java/rife/bld/operations/TestUberJarOperation.java index d2e087e..1a022a0 100644 --- a/src/test/java/rife/bld/operations/TestUberJarOperation.java +++ b/src/test/java/rife/bld/operations/TestUberJarOperation.java @@ -162,17 +162,16 @@ public class TestUberJarOperation { var run_operation = new RunOperation() .javaOptions(List.of("-jar")) .mainClass(uberjar_file.getAbsolutePath()); - 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); - } + 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("

Hello World App

"));