diff --git a/integration-tests/main-command-mode/src/test/java/org/apache/camel/quarkus/main/cmd/it/CommandModeTest.java b/integration-tests/main-command-mode/src/test/java/org/apache/camel/quarkus/main/cmd/it/CommandModeTest.java index 3cc8a2bb9d0e..4145cea89791 100644 --- a/integration-tests/main-command-mode/src/test/java/org/apache/camel/quarkus/main/cmd/it/CommandModeTest.java +++ b/integration-tests/main-command-mode/src/test/java/org/apache/camel/quarkus/main/cmd/it/CommandModeTest.java @@ -17,6 +17,7 @@ package org.apache.camel.quarkus.main.cmd.it; import java.io.IOException; +import java.util.Map; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -91,4 +92,25 @@ void testMainStopsAfterMaxSeconds() throws IOException, InterruptedException, Ex Assertions.fail("The process should not take so long as camel.main.duration-max-seconds is set"); } } + + @Test + void startupCondition() throws Exception { + String[] jvmArgs = new String[] { + "-Dcamel.startupcondition.enabled=true", + "-Dcamel.startupcondition.environment-variable-exists=CAMEL_SPECIES", + "-Dcamel.startupcondition.timeout=100", + "-Dcamel.main.duration-max-seconds=1" + }; + + // Launch the process without the expected environment variable + ProcessResult startupConditionNotMetResult = new QuarkusProcessExecutor(jvmArgs).execute(); + assertThat(startupConditionNotMetResult.getExitValue()).isEqualTo(1); + + // Try again with the environment variable set + Map environment = Map.of("CAMEL_SPECIES", "Dromedary"); + QuarkusProcessExecutor executor = new QuarkusProcessExecutor(customizer -> customizer.environment(environment), + jvmArgs); + ProcessResult startupConditionMetResult = executor.execute(); + assertThat(startupConditionMetResult.getExitValue()).isEqualTo(0); + } }