From eb899b4e82df65ed77079236622e6f6a95f22c69 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Wed, 18 Oct 2023 09:53:36 +0200 Subject: [PATCH] Add a test for Python service startup failure --- src/test/java/org/apposed/appose/ApposeTest.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/java/org/apposed/appose/ApposeTest.java b/src/test/java/org/apposed/appose/ApposeTest.java index 9d4b47d..5770cc4 100644 --- a/src/test/java/org/apposed/appose/ApposeTest.java +++ b/src/test/java/org/apposed/appose/ApposeTest.java @@ -32,6 +32,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.fail; import java.io.IOException; import java.util.ArrayList; @@ -85,6 +86,21 @@ public void testPython() throws IOException, InterruptedException { } } + @Test + public void testServiceStartupFailure() throws IOException { + Environment env = Appose.base("no-pythons-to-be-found-here").build(); + try (Service service = env.python()) { + fail("Python worker process started successfully!?"); + } + catch (IllegalArgumentException exc) { + assertEquals( + "No executables found amongst candidates: " + + "[python, python.exe, bin/python, bin/python.exe]", + exc.getMessage() + ); + } + } + public void executeAndAssert(Service service, String script) throws InterruptedException, IOException {