You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ff...@apache.org on 2022/03/11 22:56:47 UTC

[camel-spring-boot] branch main updated: [CAMEL-17777]add tests in camel-webhook-starter (#463)

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

ffang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git


The following commit(s) were added to refs/heads/main by this push:
     new c9edbbb  [CAMEL-17777]add tests in camel-webhook-starter (#463)
c9edbbb is described below

commit c9edbbbe2bc2150ff632ab9a4d6afe7a3227c0a8
Author: Freeman(Yue) Fang <fr...@gmail.com>
AuthorDate: Fri Mar 11 17:56:44 2022 -0500

    [CAMEL-17777]add tests in camel-webhook-starter (#463)
    
    (cherry picked from commit e79c618cbb3e109308c4f3f990a951d942f95fb6)
---
 components-starter/camel-webhook-starter/pom.xml   |  26 ++++
 .../webhook/springboot/TestComponent.java          |  49 +++++++
 .../component/webhook/springboot/TestEndpoint.java | 163 +++++++++++++++++++++
 .../webhook/springboot/WebhookBasePathTest.java    | 163 +++++++++++++++++++++
 .../webhook/springboot/WebhookHttpBindingTest.java | 128 ++++++++++++++++
 .../webhook/springboot/WebhookMultiRouteTest.java  | 121 +++++++++++++++
 .../webhook/springboot/WebhookPathTest.java        | 141 ++++++++++++++++++
 .../webhook/springboot/WebhookUriEncodingTest.java | 117 +++++++++++++++
 8 files changed, 908 insertions(+)

diff --git a/components-starter/camel-webhook-starter/pom.xml b/components-starter/camel-webhook-starter/pom.xml
index 06d2f01..624e42b 100644
--- a/components-starter/camel-webhook-starter/pom.xml
+++ b/components-starter/camel-webhook-starter/pom.xml
@@ -39,6 +39,32 @@
       <artifactId>camel-webhook</artifactId>
       <version>${camel-version}</version>
     </dependency>
+    <!-- Test dependencies -->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-test-junit5</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.awaitility</groupId>
+      <artifactId>awaitility</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-netty-http</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.assertj</groupId>
+      <artifactId>assertj-core</artifactId>
+      <scope>test</scope>
+    </dependency>
     <!--START OF GENERATED CODE-->
     <dependency>
       <groupId>org.apache.camel.springboot</groupId>
diff --git a/components-starter/camel-webhook-starter/src/test/java/org/apache/camel/component/webhook/springboot/TestComponent.java b/components-starter/camel-webhook-starter/src/test/java/org/apache/camel/component/webhook/springboot/TestComponent.java
new file mode 100644
index 0000000..93a9c4f
--- /dev/null
+++ b/components-starter/camel-webhook-starter/src/test/java/org/apache/camel/component/webhook/springboot/TestComponent.java
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+package org.apache.camel.component.webhook.springboot;
+
+import java.util.Map;
+import java.util.function.Consumer;
+
+import org.apache.camel.support.DefaultComponent;
+
+public class TestComponent extends DefaultComponent {
+
+    private TestEndpoint endpoint;
+
+    private Consumer<TestEndpoint> customizer;
+
+    public TestComponent() {
+    }
+
+    public TestComponent(Consumer<TestEndpoint> customizer) {
+        this.customizer = customizer;
+    }
+
+    @Override
+    protected TestEndpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+        if (this.endpoint == null) {
+            this.endpoint = new TestEndpoint(uri, this);
+            if (this.customizer != null) {
+                this.customizer.accept(this.endpoint);
+            }
+        }
+
+        return this.endpoint;
+    }
+
+}
diff --git a/components-starter/camel-webhook-starter/src/test/java/org/apache/camel/component/webhook/springboot/TestEndpoint.java b/components-starter/camel-webhook-starter/src/test/java/org/apache/camel/component/webhook/springboot/TestEndpoint.java
new file mode 100644
index 0000000..1c50da5
--- /dev/null
+++ b/components-starter/camel-webhook-starter/src/test/java/org/apache/camel/component/webhook/springboot/TestEndpoint.java
@@ -0,0 +1,163 @@
+/*
+ * 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.
+ */
+package org.apache.camel.component.webhook.springboot;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.function.Function;
+import java.util.function.Supplier;
+
+import org.apache.camel.Component;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.component.webhook.WebhookCapableEndpoint;
+import org.apache.camel.component.webhook.WebhookConfiguration;
+import org.apache.camel.support.DefaultEndpoint;
+
+/**
+ * A test endpoint for testing webhook capabilities
+ */
+public class TestEndpoint extends DefaultEndpoint implements WebhookCapableEndpoint {
+
+    private static final List<String> DEFAULT_METHOD = Collections.unmodifiableList(Collections.singletonList("POST"));
+
+    private Function<Processor, Processor> webhookHandler;
+
+    private Runnable register;
+
+    private Runnable unregister;
+
+    private Supplier<List<String>> methods;
+
+    private Supplier<Producer> producer;
+
+    private Function<Processor, Consumer> consumer;
+
+    private WebhookConfiguration webhookConfiguration;
+
+    private boolean singleton;
+
+    /**
+     * For query parameter testing 1
+     */
+    private String foo;
+
+    /**
+     * For query parameter testing 2
+     */
+    private String bar;
+
+    public TestEndpoint(String endpointUri, Component component) {
+        super(endpointUri, component);
+    }
+
+    @Override
+    public Processor createWebhookHandler(Processor next) {
+        if (this.webhookHandler != null) {
+            return this.webhookHandler.apply(next);
+        }
+        return next;
+    }
+
+    @Override
+    public void registerWebhook() {
+        if (this.register != null) {
+            this.register.run();
+        }
+    }
+
+    @Override
+    public void unregisterWebhook() {
+        if (this.unregister != null) {
+            this.unregister.run();
+        }
+    }
+
+    @Override
+    public void setWebhookConfiguration(WebhookConfiguration webhookConfiguration) {
+        this.webhookConfiguration = webhookConfiguration;
+    }
+
+    public WebhookConfiguration getWebhookConfiguration() {
+        return webhookConfiguration;
+    }
+
+    @Override
+    public List<String> getWebhookMethods() {
+        return this.methods != null ? this.methods.get() : DEFAULT_METHOD;
+    }
+
+    @Override
+    public Producer createProducer() throws Exception {
+        return this.producer != null ? this.producer.get() : null;
+    }
+
+    @Override
+    public Consumer createConsumer(Processor processor) throws Exception {
+        return this.consumer != null ? this.consumer.apply(processor) : null;
+    }
+
+    @Override
+    public boolean isSingleton() {
+        return singleton;
+    }
+
+    public void setSingleton(boolean singleton) {
+        this.singleton = singleton;
+    }
+
+    public void setWebhookHandler(Function<Processor, Processor> webhookHandler) {
+        this.webhookHandler = webhookHandler;
+    }
+
+    public void setRegisterWebhook(Runnable register) {
+        this.register = register;
+    }
+
+    public void setUnregisterWebhook(Runnable unregister) {
+        this.unregister = unregister;
+    }
+
+    public void setWebhookMethods(Supplier<List<String>> methods) {
+        this.methods = methods;
+    }
+
+    public void setWebhookProducer(Supplier<Producer> producer) {
+        this.producer = producer;
+    }
+
+    public void setConsumer(Function<Processor, Consumer> consumer) {
+        this.consumer = consumer;
+    }
+
+    public String getFoo() {
+        return foo;
+    }
+
+    public void setFoo(String foo) {
+        this.foo = foo;
+    }
+
+    public String getBar() {
+        return bar;
+    }
+
+    public void setBar(String bar) {
+        this.bar = bar;
+    }
+}
diff --git a/components-starter/camel-webhook-starter/src/test/java/org/apache/camel/component/webhook/springboot/WebhookBasePathTest.java b/components-starter/camel-webhook-starter/src/test/java/org/apache/camel/component/webhook/springboot/WebhookBasePathTest.java
new file mode 100644
index 0000000..e8c03b3
--- /dev/null
+++ b/components-starter/camel-webhook-starter/src/test/java/org/apache/camel/component/webhook/springboot/WebhookBasePathTest.java
@@ -0,0 +1,163 @@
+/*
+ * 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.
+ */
+package org.apache.camel.component.webhook.springboot;
+
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.webhook.WebhookComponent;
+import org.apache.camel.component.webhook.WebhookConfiguration;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.spring.boot.CamelContextConfiguration;
+
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.AvailablePortFinder;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+    classes = {
+        CamelAutoConfiguration.class,
+        WebhookBasePathTest.class,
+        WebhookBasePathTest.TestConfiguration.class
+    }
+)
+public class WebhookBasePathTest {
+    
+    private static int port;
+
+   
+    @Autowired
+    ProducerTemplate template;
+
+    @EndpointInject("mock:authors")
+    MockEndpoint mock;
+    
+    @BeforeAll
+    public static void initPort() {
+        port = AvailablePortFinder.getNextAvailable();
+    }
+    
+    @Bean
+    CamelContextConfiguration contextConfiguration() {
+        return new CamelContextConfiguration() {
+            @Override
+            public void beforeApplicationStart(CamelContext context) {
+                WebhookComponent comp = (WebhookComponent) context.getComponent("webhook");
+                comp.getConfiguration().setWebhookBasePath("/base");
+            }
+            @Override
+            public void afterApplicationStart(CamelContext camelContext) {
+                //do nothing here
+            }
+
+        };
+    }
+
+    
+    @Bean("wb-delegate-component")
+    private TestComponent getTestComponent() {
+        return new TestComponent(endpoint -> {
+            endpoint.setWebhookHandler(proc -> ex -> {
+                ex.getMessage().setBody("webhook");
+                proc.process(ex);
+            });
+        });
+    }
+
+    @Test
+    public void testComponentPath() {
+        String result = template.requestBody("netty-http:http://localhost:" + port + "/base/uri0", "", String.class);
+        assertEquals("msg: webhook", result);
+    }
+
+    @Test
+    public void testUriPath() {
+        String result = template.requestBody("netty-http:http://localhost:" + port + "/base/uri", "", String.class);
+        assertEquals("uri: webhook", result);
+    }
+
+    @Test
+    public void testAutoPath() {
+        String result = template.requestBody("netty-http:http://localhost:" + port + "/base"
+                                             + WebhookConfiguration.computeDefaultPath("wb-delegate://auto"),
+                "", String.class);
+        assertEquals("auto: webhook", result);
+    }
+
+    @Test
+    public void testRootPathError() {
+        assertThrows(CamelExecutionException.class,
+                () -> template.requestBody("netty-http:http://localhost:" + port, "", String.class));
+    }
+
+    @Test
+    public void testRootBasePathError() {
+        assertThrows(CamelExecutionException.class,
+                () -> template.requestBody("netty-http:http://localhost:" + port + "/base/", "", String.class));
+    }
+
+        
+
+    // *************************************
+    // Config
+    // *************************************
+
+    @Configuration
+    public static class TestConfiguration {
+
+        @Bean
+        public RouteBuilder routeBuilder() {
+            return new RouteBuilder() {
+                @Override
+                public void configure() throws Exception {
+
+                    restConfiguration()
+                            .host("0.0.0.0")
+                            .port(port);
+
+                    from("webhook:wb-delegate://xx?webhookPath=uri0")
+                            .transform(body().prepend("msg: "));
+
+                    from("webhook:wb-delegate://xx?webhookPath=/uri")
+                            .transform(body().prepend("uri: "));
+
+                    from("webhook:wb-delegate://auto")
+                            .transform(body().prepend("auto: "));
+
+                }
+            };
+        }
+    }
+}
diff --git a/components-starter/camel-webhook-starter/src/test/java/org/apache/camel/component/webhook/springboot/WebhookHttpBindingTest.java b/components-starter/camel-webhook-starter/src/test/java/org/apache/camel/component/webhook/springboot/WebhookHttpBindingTest.java
new file mode 100644
index 0000000..d5819fa
--- /dev/null
+++ b/components-starter/camel-webhook-starter/src/test/java/org/apache/camel/component/webhook/springboot/WebhookHttpBindingTest.java
@@ -0,0 +1,128 @@
+/*
+ * 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.
+ */
+package org.apache.camel.component.webhook.springboot;
+
+
+import java.util.Arrays;
+
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.webhook.WebhookConfiguration;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.AvailablePortFinder;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+    classes = {
+        CamelAutoConfiguration.class,
+        WebhookHttpBindingTest.class,
+        WebhookHttpBindingTest.TestConfiguration.class
+    }
+)
+public class WebhookHttpBindingTest {
+    
+    private static int port;
+
+   
+    @Autowired
+    ProducerTemplate template;
+
+    @EndpointInject("mock:authors")
+    MockEndpoint mock;
+    
+    @BeforeAll
+    public static void initPort() {
+        port = AvailablePortFinder.getNextAvailable();
+    }
+    
+    @Bean("wb-delegate-component")
+    private TestComponent getTestComponent() {
+        return new TestComponent(endpoint -> {
+            endpoint.setWebhookHandler(proc -> ex -> {
+                ex.getMessage().setBody("webhook");
+                proc.process(ex);
+            });
+            endpoint.setWebhookMethods(() -> Arrays.asList("POST", "PUT"));
+        });
+    }
+
+    @Test
+    public void testWrapper() {
+        String result = template.requestBody("netty-http:http://localhost:" + port
+                                             + WebhookConfiguration.computeDefaultPath("wb-delegate://xx"),
+                "", String.class);
+        assertEquals("msg: webhook", result);
+
+        result = template.requestBodyAndHeader("netty-http:http://localhost:" + port
+                                               + WebhookConfiguration.computeDefaultPath("wb-delegate://xx"),
+                "", Exchange.HTTP_METHOD, "PUT", String.class);
+        assertEquals("msg: webhook", result);
+    }
+
+    @Test
+    public void testGetError() {
+        assertThrows(CamelExecutionException.class,
+                () -> template.requestBodyAndHeader("netty-http:http://localhost:" + port, "",
+                        Exchange.HTTP_METHOD, "GET", String.class));
+    }
+
+        
+
+    // *************************************
+    // Config
+    // *************************************
+
+    @Configuration
+    public static class TestConfiguration {
+
+        @Bean
+        public RouteBuilder routeBuilder() {
+            return new RouteBuilder() {
+                @Override
+                public void configure() throws Exception {
+
+                    restConfiguration()
+                            .host("0.0.0.0")
+                            .port(port);
+
+                    from("webhook:wb-delegate://xx")
+                            .transform(body().prepend("msg: "));
+
+                }
+            };
+        }
+    }
+}
diff --git a/components-starter/camel-webhook-starter/src/test/java/org/apache/camel/component/webhook/springboot/WebhookMultiRouteTest.java b/components-starter/camel-webhook-starter/src/test/java/org/apache/camel/component/webhook/springboot/WebhookMultiRouteTest.java
new file mode 100644
index 0000000..29d7f0c
--- /dev/null
+++ b/components-starter/camel-webhook-starter/src/test/java/org/apache/camel/component/webhook/springboot/WebhookMultiRouteTest.java
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ */
+package org.apache.camel.component.webhook.springboot;
+
+
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+import org.apache.camel.component.webhook.WebhookConfiguration;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.AvailablePortFinder;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+    classes = {
+        CamelAutoConfiguration.class,
+        WebhookMultiRouteTest.class,
+        WebhookMultiRouteTest.TestConfiguration.class
+    }
+)
+public class WebhookMultiRouteTest {
+    
+    private static int port;
+
+   
+    @Autowired
+    ProducerTemplate template;
+
+    @EndpointInject("mock:authors")
+    MockEndpoint mock;
+    
+    @BeforeAll
+    public static void initPort() {
+        port = AvailablePortFinder.getNextAvailable();
+    }
+    
+    
+    @Bean("wb-delegate-component")
+    private TestComponent getTestComponent() {
+        return new TestComponent(endpoint -> {
+            endpoint.setWebhookHandler(proc -> ex -> {
+                ex.getMessage().setBody("webhook");
+                proc.process(ex);
+            });
+        });
+    }
+
+    @Test
+    public void testMultiRoute() {
+        String result = template.requestBody("netty-http:http://localhost:" + port
+                                             + WebhookConfiguration.computeDefaultPath("wb-delegate://yy"),
+                "", String.class);
+        assertEquals("uri: webhook", result);
+
+        result = template.requestBody("netty-http:http://localhost:" + port
+                                      + WebhookConfiguration.computeDefaultPath("wb-delegate://xx"),
+                "", String.class);
+        assertEquals("msg: webhook", result);
+    }
+
+        
+
+    // *************************************
+    // Config
+    // *************************************
+
+    @Configuration
+    public static class TestConfiguration {
+
+        @Bean
+        public RouteBuilder routeBuilder() {
+            return new RouteBuilder() {
+                @Override
+                public void configure() throws Exception {
+
+                    restConfiguration()
+                            .host("0.0.0.0")
+                            .port(port);
+
+                    from("webhook:wb-delegate://yy")
+                            .transform(body().prepend("uri: "));
+
+                    from("webhook:wb-delegate://xx")
+                            .transform(body().prepend("msg: "));
+
+                }
+            };
+        }
+    }
+}
diff --git a/components-starter/camel-webhook-starter/src/test/java/org/apache/camel/component/webhook/springboot/WebhookPathTest.java b/components-starter/camel-webhook-starter/src/test/java/org/apache/camel/component/webhook/springboot/WebhookPathTest.java
new file mode 100644
index 0000000..85b20a0
--- /dev/null
+++ b/components-starter/camel-webhook-starter/src/test/java/org/apache/camel/component/webhook/springboot/WebhookPathTest.java
@@ -0,0 +1,141 @@
+/*
+ * 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.
+ */
+package org.apache.camel.component.webhook.springboot;
+
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.webhook.WebhookComponent;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.spring.boot.CamelContextConfiguration;
+
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.AvailablePortFinder;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+    classes = {
+        CamelAutoConfiguration.class,
+        WebhookPathTest.class,
+        WebhookPathTest.TestConfiguration.class
+    }
+)
+public class WebhookPathTest {
+    
+    private static int port;
+
+   
+    @Autowired
+    ProducerTemplate template;
+
+    @EndpointInject("mock:authors")
+    MockEndpoint mock;
+    
+    @BeforeAll
+    public static void initPort() {
+        port = AvailablePortFinder.getNextAvailable();
+    }
+    
+    @Bean
+    CamelContextConfiguration contextConfiguration() {
+        return new CamelContextConfiguration() {
+            @Override
+            public void beforeApplicationStart(CamelContext context) {
+                WebhookComponent comp = (WebhookComponent) context.getComponent("webhook");
+                comp.getConfiguration().setWebhookPath("/comp");
+            }
+            @Override
+            public void afterApplicationStart(CamelContext camelContext) {
+                //do nothing here
+            }
+
+        };
+    }
+
+    
+    @Bean("wb-delegate-component")
+    private TestComponent getTestComponent() {
+        return new TestComponent(endpoint -> {
+            endpoint.setWebhookHandler(proc -> ex -> {
+                ex.getMessage().setBody("webhook");
+                proc.process(ex);
+            });
+        });
+    }
+
+    @Test
+    public void testComponentPath() {
+        String result = template.requestBody("netty-http:http://localhost:" + port + "/comp", "", String.class);
+        assertEquals("msg: webhook", result);
+    }
+
+    @Test
+    public void testUriPath() {
+        String result = template.requestBody("netty-http:http://localhost:" + port + "/uri", "", String.class);
+        assertEquals("uri: webhook", result);
+    }
+
+    @Test
+    public void testRootPathError() {
+        assertThrows(CamelExecutionException.class,
+                () -> template.requestBody("netty-http:http://localhost:" + port, "", String.class));
+    }
+
+        
+
+    // *************************************
+    // Config
+    // *************************************
+
+    @Configuration
+    public static class TestConfiguration {
+
+        @Bean
+        public RouteBuilder routeBuilder() {
+            return new RouteBuilder() {
+                @Override
+                public void configure() throws Exception {
+
+                    restConfiguration().host("0.0.0.0").port(port);
+
+                    from("webhook:wb-delegate://xx").transform(body().prepend("msg: "));
+
+                    from("webhook:wb-delegate://xx?webhookPath=/uri").transform(body().prepend("uri: "));
+
+                }
+            };
+        }
+    }
+}
diff --git a/components-starter/camel-webhook-starter/src/test/java/org/apache/camel/component/webhook/springboot/WebhookUriEncodingTest.java b/components-starter/camel-webhook-starter/src/test/java/org/apache/camel/component/webhook/springboot/WebhookUriEncodingTest.java
new file mode 100644
index 0000000..c8998ad
--- /dev/null
+++ b/components-starter/camel-webhook-starter/src/test/java/org/apache/camel/component/webhook/springboot/WebhookUriEncodingTest.java
@@ -0,0 +1,117 @@
+/*
+ * 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.
+ */
+package org.apache.camel.component.webhook.springboot;
+
+
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.Message;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.AvailablePortFinder;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+    classes = {
+        CamelAutoConfiguration.class,
+        WebhookUriEncodingTest.class,
+        WebhookUriEncodingTest.TestConfiguration.class
+    }
+)
+public class WebhookUriEncodingTest {
+    
+    private static int port;
+
+   
+    @Autowired
+    ProducerTemplate template;
+
+    @EndpointInject("mock:authors")
+    MockEndpoint mock;
+    
+    @BeforeAll
+    public static void initPort() {
+        port = AvailablePortFinder.getNextAvailable();
+    }
+    
+    @Test
+    public void test() {
+        Exchange exchange = template.send("netty-http:http://localhost:" + port + "/base/uri", ExchangePattern.InOut,
+                e -> e.getMessage().setBody(""));
+        Message result = exchange.getMessage();
+        assertEquals("msg: webhook", result.getBody(String.class));
+        assertEquals("hello} world", result.getHeader("foo"));
+        assertEquals("hello} world", result.getHeader("bar"));
+    }
+    
+    @Bean("wb-delegate-component")
+    private TestComponent getTestComponent() {
+        return new TestComponent(endpoint -> {
+            endpoint.setWebhookHandler(proc -> ex -> {
+                ex.getMessage().setBody("webhook");
+                ex.getMessage().setHeader("foo", endpoint.getFoo());
+                ex.getMessage().setHeader("bar", endpoint.getBar());
+                proc.process(ex);
+            });
+        });
+    }
+
+            
+
+    // *************************************
+    // Config
+    // *************************************
+
+    @Configuration
+    public static class TestConfiguration {
+
+        @Bean
+        public RouteBuilder routeBuilder() {
+            return new RouteBuilder() {
+                @Override
+                public void configure() throws Exception {
+
+                    restConfiguration()
+                            .host("0.0.0.0")
+                            .port(port);
+
+                    from("webhook:wb-delegate://xx?webhookBasePath=/base&webhookPath=/uri&foo=hello} world&bar=RAW(hello} world)")
+                            .transform(body().prepend("msg: "));
+
+                }
+            };
+        }
+    }
+}