diff --git a/extensions/kafka/runtime/pom.xml b/extensions/kafka/runtime/pom.xml index 15eb6035ab2b..54cbe10838a5 100644 --- a/extensions/kafka/runtime/pom.xml +++ b/extensions/kafka/runtime/pom.xml @@ -47,6 +47,11 @@ org.apache.camel camel-kafka + + io.quarkus + quarkus-junit5 + provided + diff --git a/extensions/kafka/runtime/src/main/java/org/apache/camel/quarkus/component/kafka/test/CamelQuarkusNativeImageLauncher.java b/extensions/kafka/runtime/src/main/java/org/apache/camel/quarkus/component/kafka/test/CamelQuarkusNativeImageLauncher.java new file mode 100644 index 000000000000..e513c2a2107d --- /dev/null +++ b/extensions/kafka/runtime/src/main/java/org/apache/camel/quarkus/component/kafka/test/CamelQuarkusNativeImageLauncher.java @@ -0,0 +1,26 @@ +package org.apache.camel.quarkus.component.kafka.test; + +import java.util.Collections; +import java.util.Optional; + +import io.quarkus.test.common.ArtifactLauncher.InitContext.DevServicesLaunchResult; +import io.quarkus.test.common.DefaultNativeImageLauncher; +import org.eclipse.microprofile.config.Config; +import org.eclipse.microprofile.config.ConfigProvider; + +public class CamelQuarkusNativeImageLauncher extends DefaultNativeImageLauncher { + + @Override + public void init(NativeImageInitContext initContext) { + super.init(initContext); + + Config config = ConfigProvider.getConfig(); + DevServicesLaunchResult result = initContext.getDevServicesLaunchResult(); + + String kafkaBootstrapServers = result.properties().get("kafka.bootstrap.servers"); + Optional camelKafkaBrokers = config.getOptionalValue("camel.component.kafka.brokers", String.class); + if (kafkaBootstrapServers != null && camelKafkaBrokers.isEmpty()) { + includeAsSysProps(Collections.singletonMap("camel.component.kafka.brokers", kafkaBootstrapServers)); + } + } +} diff --git a/extensions/kafka/runtime/src/main/resources/META-INF/services/io.quarkus.test.common.NativeImageLauncher b/extensions/kafka/runtime/src/main/resources/META-INF/services/io.quarkus.test.common.NativeImageLauncher new file mode 100644 index 000000000000..8a0e0737e427 --- /dev/null +++ b/extensions/kafka/runtime/src/main/resources/META-INF/services/io.quarkus.test.common.NativeImageLauncher @@ -0,0 +1 @@ +org.apache.camel.quarkus.component.kafka.test.CamelQuarkusNativeImageLauncher \ No newline at end of file