This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 204f71d3d394 CAMEL-26325: camel-jbang - Export should resolve the 
delegate endpoint of a webhook: endpoint (#29726)
204f71d3d394 is described below

commit 204f71d3d39457f464d43f2dcc2849761e04c434
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Nov 12 19:28:41 2026 +0100

    CAMEL-26325: camel-jbang - Export should resolve the delegate endpoint of a 
webhook: endpoint (#29726)
    
    camel export now adds the component of the delegate endpoint of a webhook:
    endpoint, e.g. camel-telegram for webhook:telegram:bots. During export every
    endpoint is a stub, so WebhookEndpoint never created its delegate.
    DownloadEndpointStrategy resolves the delegate of a stubbed webhook: 
endpoint,
    as it does for master: (CAMEL-25186) and zookeeper-master: (CAMEL-26116).
    camel run is not affected.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 .../camel/dsl/jbang/core/commands/ExportTest.java  | 30 ++++++++++++++++++++++
 .../src/test/resources/webhook-route.yaml          | 24 +++++++++++++++++
 .../main/download/DownloadEndpointStrategy.java    | 15 +++++++++++
 3 files changed, 69 insertions(+)

diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportTest.java
 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportTest.java
index 2b43ee65d795..aa0d73df9422 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportTest.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportTest.java
@@ -871,6 +871,36 @@ class ExportTest {
         }
     }
 
+    @ParameterizedTest
+    @MethodSource("runtimeProvider")
+    public void shouldExportWebhookDelegate(RuntimeType rt) throws Exception {
+        LOG.info("shouldExportWebhookDelegate {}", rt);
+        Export command = createCommand(rt, new String[] { 
"src/test/resources/webhook-route.yaml" },
+                "--gav=examples:route:1.0.0", "--dir=" + workingDir, 
"--quiet");
+        int exit = command.doCall();
+
+        Assertions.assertEquals(0, exit);
+        Model model = readMavenModel();
+
+        // the delegate component of the webhook endpoint must be exported as 
well (CAMEL-26325)
+        if (rt == RuntimeType.main) {
+            Assertions.assertTrue(containsDependency(model.getDependencies(), 
"org.apache.camel", "camel-webhook", null));
+            Assertions.assertTrue(containsDependency(model.getDependencies(), 
"org.apache.camel", "camel-telegram", null));
+        } else if (rt == RuntimeType.springBoot) {
+            Assertions.assertTrue(
+                    containsDependency(model.getDependencies(), 
"org.apache.camel.springboot", "camel-webhook-starter",
+                            null));
+            Assertions.assertTrue(
+                    containsDependency(model.getDependencies(), 
"org.apache.camel.springboot", "camel-telegram-starter",
+                            null));
+        } else if (rt == RuntimeType.quarkus) {
+            // camel-quarkus has no webhook extension
+            Assertions.assertTrue(
+                    containsDependency(model.getDependencies(), 
"org.apache.camel.quarkus", "camel-quarkus-telegram",
+                            null));
+        }
+    }
+
     @ParameterizedTest
     @MethodSource("runtimeProvider")
     public void shouldExportCircuitBreaker(RuntimeType rt) throws Exception {
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/test/resources/webhook-route.yaml 
b/dsl/camel-jbang/camel-jbang-core/src/test/resources/webhook-route.yaml
new file mode 100644
index 000000000000..8b30c3e74b2f
--- /dev/null
+++ b/dsl/camel-jbang/camel-jbang-core/src/test/resources/webhook-route.yaml
@@ -0,0 +1,24 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+- route:
+    from:
+      uri: webhook:telegram:bots
+      parameters:
+        authorizationToken: "{{token}}"
+      steps:
+        - log: "${body}"
diff --git 
a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/DownloadEndpointStrategy.java
 
b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/DownloadEndpointStrategy.java
index bb2c13b672ab..f9c553de003c 100644
--- 
a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/DownloadEndpointStrategy.java
+++ 
b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/DownloadEndpointStrategy.java
@@ -55,6 +55,12 @@ public class DownloadEndpointStrategy implements 
EndpointStrategy {
             if (delegateUri != null) {
                 camelContext.getEndpoint(delegateUri);
             }
+        } else if (export && "webhook".equals(scheme) && endpoint instanceof 
StubEndpoint) {
+            // a stubbed webhook endpoint does not create its delegate 
endpoint, so resolve it here (CAMEL-26325)
+            String delegateUri = extractWebhookDelegateUri(uri);
+            if (delegateUri != null) {
+                camelContext.getEndpoint(delegateUri);
+            }
         }
         return endpoint;
     }
@@ -70,6 +76,15 @@ public class DownloadEndpointStrategy implements 
EndpointStrategy {
         return delegateUri;
     }
 
+    // extracts the delegate uri the same way as WebhookComponent (the 
remaining part, with the query parameters)
+    private static String extractWebhookDelegateUri(String uri) {
+        String delegateUri = 
FileUtil.stripLeadingSeparator(StringHelper.after(uri, ":"));
+        if (ObjectHelper.isEmpty(StringHelper.before(delegateUri, "?", 
delegateUri))) {
+            return null;
+        }
+        return delegateUri;
+    }
+
     private static String extractName(String uri) {
         uri = StringHelper.before(uri, "?", uri);
         int count = StringHelper.countChar(uri, ':');

Reply via email to