Skip to content

Commit

Permalink
Add test for StartupCondition
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesnetherton committed Dec 4, 2024
1 parent 182539b commit b330132
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String, String> environment = Map.of("CAMEL_SPECIES", "Dromedary");
QuarkusProcessExecutor executor = new QuarkusProcessExecutor(customizer -> customizer.environment(environment),
jvmArgs);
ProcessResult startupConditionMetResult = executor.execute();
assertThat(startupConditionMetResult.getExitValue()).isEqualTo(0);
}
}

0 comments on commit b330132

Please sign in to comment.