You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pp...@apache.org on 2020/09/25 13:33:58 UTC

[camel-quarkus] branch master updated: Velocity Support #837

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

ppalaga pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git


The following commit(s) were added to refs/heads/master by this push:
     new c1ad4e2  Velocity Support #837
c1ad4e2 is described below

commit c1ad4e219ba3ff443b821c5b0a95bce7dc398de5
Author: JiriOndrusek <on...@gmail.com>
AuthorDate: Thu Sep 17 15:43:29 2020 +0200

    Velocity Support #837
---
 .../ROOT/pages/reference/extensions/velocity.adoc  |  37 +++-
 .../partials/reference/components/velocity.adoc    |   6 +-
 extensions-jvm/pom.xml                             |   1 -
 .../velocity/deployment/VelocityProcessor.java     |  46 -----
 .../component/velocity/it/VelocityResource.java    |  51 ------
 extensions/pom.xml                                 |   1 +
 .../velocity/deployment/pom.xml                    |   0
 .../velocity/deployment/VelocityProcessor.java     |  72 ++++++++
 {extensions-jvm => extensions}/velocity/pom.xml    |   1 -
 .../velocity/runtime/pom.xml                       |   1 +
 .../runtime/src/main/doc/configuration.adoc        |  15 ++
 .../velocity/runtime/src/main/doc/limitations.adoc |   6 +
 .../main/resources/META-INF/quarkus-extension.yaml |   3 +-
 integration-tests/pom.xml                          |   1 +
 .../velocity}/pom.xml                              |  68 ++++++--
 .../quarkus/component/velocity/it/Person.java      |  52 ++++--
 .../component/velocity/it/VelocityResource.java    | 192 +++++++++++++++++++++
 .../src/main/resources/application.properties      |  18 ++
 .../main/resources/template/BodyAsDomainObject.vm  |  33 ++++
 .../velocity/src/main/resources/template/letter.vm |  38 ++++
 .../main/resources/template/velocity.properties    |  22 +++
 .../quarkus/component/velocity/it/VelocityIT.java  |  17 +-
 .../component/velocity/it/VelocityTest.java        | 187 ++++++++++++++++++++
 tooling/scripts/test-categories.yaml               |   1 +
 24 files changed, 720 insertions(+), 149 deletions(-)

diff --git a/docs/modules/ROOT/pages/reference/extensions/velocity.adoc b/docs/modules/ROOT/pages/reference/extensions/velocity.adoc
index d9045c9..9432f7c 100644
--- a/docs/modules/ROOT/pages/reference/extensions/velocity.adoc
+++ b/docs/modules/ROOT/pages/reference/extensions/velocity.adoc
@@ -2,15 +2,15 @@
 // This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
 = Velocity
 :cq-artifact-id: camel-quarkus-velocity
-:cq-native-supported: false
-:cq-status: Preview
+:cq-native-supported: true
+:cq-status: Stable
 :cq-description: Transform messages using a Velocity template.
 :cq-deprecated: false
 :cq-jvm-since: 1.1.0
-:cq-native-since: n/a
+:cq-native-since: 1.2.0
 
 [.badges]
-[.badge-key]##JVM since##[.badge-supported]##1.1.0## [.badge-key]##Native##[.badge-unsupported]##unsupported##
+[.badge-key]##JVM since##[.badge-supported]##1.1.0## [.badge-key]##Native since##[.badge-supported]##1.2.0##
 
 Transform messages using a Velocity template.
 
@@ -31,3 +31,32 @@ Please refer to the above link for usage and configuration details.
 ----
 
 Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
+
+== Camel Quarkus limitations
+
+If property `allowContextMapAll` is set to `true` there is a limitation in native mode. Reflective calls to methods
+of several classes in camel are not allowed (for example `org.apache.camel.support.DefaultExchange`). Therefore
+some expressions won't work (for example `${exchange.properties.*}).
+
+You can allow reflective calls to such classes (for example by using application.properties), but keep in mind that it brings
+some security risks.
+
+
+== Additional Camel Quarkus configuration
+
+Beyond standard usages described above, a trick is needed when using velocity templates from classpath resources in native mode. In such a situation, one needs to explicitly embed the resources in the native executable by specifying the `include-patterns` option.
+
+For instance, the route below would load the velocity template from a classpath resource named _template/simple.vm_:
+[source,java]
+----
+from("direct:start").to("velocity://template/simple.vm");
+----
+
+In order to work in native mode the `include-patterns` configuration should be set. For instance, in the `application.properties` file as below :
+[source,properties]
+----
+quarkus.camel.native.resources.include-patterns = template/*.vm
+----
+
+More information about selecting resources for inclusion in the native executable could be found at xref:user-guide/native-mode.adoc#embedding-resource-in-native-executable[Embedding resource in native executable].
+
diff --git a/docs/modules/ROOT/partials/reference/components/velocity.adoc b/docs/modules/ROOT/partials/reference/components/velocity.adoc
index 6fb16f7..add29b3 100644
--- a/docs/modules/ROOT/partials/reference/components/velocity.adoc
+++ b/docs/modules/ROOT/partials/reference/components/velocity.adoc
@@ -2,11 +2,11 @@
 // This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
 :cq-artifact-id: camel-quarkus-velocity
 :cq-artifact-id-base: velocity
-:cq-native-supported: false
-:cq-status: Preview
+:cq-native-supported: true
+:cq-status: Stable
 :cq-deprecated: false
 :cq-jvm-since: 1.1.0
-:cq-native-since: n/a
+:cq-native-since: 1.2.0
 :cq-camel-part-name: velocity
 :cq-camel-part-title: Velocity
 :cq-camel-part-description: Transform messages using a Velocity template.
diff --git a/extensions-jvm/pom.xml b/extensions-jvm/pom.xml
index 5a8d2b1..17e0dd6 100644
--- a/extensions-jvm/pom.xml
+++ b/extensions-jvm/pom.xml
@@ -142,7 +142,6 @@
         <module>syslog</module>
         <module>thrift</module>
         <module>twilio</module>
-        <module>velocity</module>
         <module>web3j</module>
         <module>weka</module>
         <module>wordpress</module>
diff --git a/extensions-jvm/velocity/deployment/src/main/java/org/apache/camel/quarkus/component/velocity/deployment/VelocityProcessor.java b/extensions-jvm/velocity/deployment/src/main/java/org/apache/camel/quarkus/component/velocity/deployment/VelocityProcessor.java
deleted file mode 100644
index 1e5e25a..0000000
--- a/extensions-jvm/velocity/deployment/src/main/java/org/apache/camel/quarkus/component/velocity/deployment/VelocityProcessor.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.quarkus.component.velocity.deployment;
-
-import io.quarkus.deployment.annotations.BuildStep;
-import io.quarkus.deployment.annotations.ExecutionTime;
-import io.quarkus.deployment.annotations.Record;
-import io.quarkus.deployment.builditem.FeatureBuildItem;
-import io.quarkus.deployment.pkg.steps.NativeBuild;
-import org.apache.camel.quarkus.core.JvmOnlyRecorder;
-import org.jboss.logging.Logger;
-
-class VelocityProcessor {
-
-    private static final Logger LOG = Logger.getLogger(VelocityProcessor.class);
-    private static final String FEATURE = "camel-velocity";
-
-    @BuildStep
-    FeatureBuildItem feature() {
-        return new FeatureBuildItem(FEATURE);
-    }
-
-    /**
-     * Remove this once this extension starts supporting the native mode.
-     */
-    @BuildStep(onlyIf = NativeBuild.class)
-    @Record(value = ExecutionTime.RUNTIME_INIT)
-    void warnJvmInNative(JvmOnlyRecorder recorder) {
-        JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
-        recorder.warnJvmInNative(FEATURE); // warn at runtime
-    }
-}
diff --git a/extensions-jvm/velocity/integration-test/src/main/java/org/apache/camel/quarkus/component/velocity/it/VelocityResource.java b/extensions-jvm/velocity/integration-test/src/main/java/org/apache/camel/quarkus/component/velocity/it/VelocityResource.java
deleted file mode 100644
index 410717f..0000000
--- a/extensions-jvm/velocity/integration-test/src/main/java/org/apache/camel/quarkus/component/velocity/it/VelocityResource.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.quarkus.component.velocity.it;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.inject.Inject;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.apache.camel.CamelContext;
-import org.jboss.logging.Logger;
-
-@Path("/velocity")
-@ApplicationScoped
-public class VelocityResource {
-
-    private static final Logger LOG = Logger.getLogger(VelocityResource.class);
-
-    private static final String COMPONENT_VELOCITY = "velocity";
-    @Inject
-    CamelContext context;
-
-    @Path("/load/component/velocity")
-    @GET
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response loadComponentVelocity() throws Exception {
-        /* This is an autogenerated test */
-        if (context.getComponent(COMPONENT_VELOCITY) != null) {
-            return Response.ok().build();
-        }
-        LOG.warnf("Could not load [%s] from the Camel context", COMPONENT_VELOCITY);
-        return Response.status(500, COMPONENT_VELOCITY + " could not be loaded from the Camel context").build();
-    }
-}
diff --git a/extensions/pom.xml b/extensions/pom.xml
index 324a44e..7501bdf 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -187,6 +187,7 @@
         <module>twitter</module>
         <module>univocity-parsers</module>
         <module>validator</module>
+        <module>velocity</module>
         <module>vertx</module>
         <module>vertx-http</module>
         <module>vertx-websocket</module>
diff --git a/extensions-jvm/velocity/deployment/pom.xml b/extensions/velocity/deployment/pom.xml
similarity index 100%
rename from extensions-jvm/velocity/deployment/pom.xml
rename to extensions/velocity/deployment/pom.xml
diff --git a/extensions/velocity/deployment/src/main/java/org/apache/camel/quarkus/component/velocity/deployment/VelocityProcessor.java b/extensions/velocity/deployment/src/main/java/org/apache/camel/quarkus/component/velocity/deployment/VelocityProcessor.java
new file mode 100644
index 0000000..72ada8b
--- /dev/null
+++ b/extensions/velocity/deployment/src/main/java/org/apache/camel/quarkus/component/velocity/deployment/VelocityProcessor.java
@@ -0,0 +1,72 @@
+/*
+ * 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.quarkus.component.velocity.deployment;
+
+import java.util.ArrayList;
+import java.util.TreeMap;
+
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
+import io.quarkus.deployment.builditem.FeatureBuildItem;
+import io.quarkus.deployment.builditem.IndexDependencyBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
+import org.apache.camel.component.velocity.CamelVelocityClasspathResourceLoader;
+import org.jboss.jandex.IndexView;
+
+import static java.util.stream.Collectors.toCollection;
+
+class VelocityProcessor {
+
+    private static final String FEATURE = "camel-velocity";
+
+    @BuildStep
+    FeatureBuildItem feature() {
+        return new FeatureBuildItem(FEATURE);
+    }
+
+    @BuildStep
+    NativeImageResourceBuildItem initResources() {
+        return new NativeImageResourceBuildItem(
+                "org/apache/velocity/runtime/defaults/velocity.properties",
+                "org/apache/velocity/runtime/defaults/directive.properties");
+    }
+
+    @BuildStep
+    ReflectiveClassBuildItem registerForReflection(CombinedIndexBuildItem combinedIndex) {
+        IndexView index = combinedIndex.getIndex();
+
+        ArrayList<String> dtos = index.getKnownClasses().stream().map(ci -> ci.name().toString())
+                .filter(n -> n.startsWith("org.apache.velocity.runtime") ||
+                        n.startsWith("org.apache.velocity.util.introspection"))
+                .collect(toCollection(ArrayList::new));
+
+        dtos.add(CamelVelocityClasspathResourceLoader.class.getName());
+
+        return new ReflectiveClassBuildItem(false, false, dtos.toArray(new String[dtos.size()]));
+    }
+
+    @BuildStep
+    ReflectiveClassBuildItem registerForReflectionWithMethods() {
+        return new ReflectiveClassBuildItem(true, false, TreeMap.class.getName());
+    }
+
+    @BuildStep
+    IndexDependencyBuildItem registerDependencyForIndex() {
+        return new IndexDependencyBuildItem("org.apache.velocity", "velocity-engine-core");
+    }
+}
diff --git a/extensions-jvm/velocity/pom.xml b/extensions/velocity/pom.xml
similarity index 97%
rename from extensions-jvm/velocity/pom.xml
rename to extensions/velocity/pom.xml
index bd7cb3f..9c5dd5e 100644
--- a/extensions-jvm/velocity/pom.xml
+++ b/extensions/velocity/pom.xml
@@ -35,6 +35,5 @@
     <modules>
         <module>deployment</module>
         <module>runtime</module>
-        <module>integration-test</module>
     </modules>
 </project>
diff --git a/extensions-jvm/velocity/runtime/pom.xml b/extensions/velocity/runtime/pom.xml
similarity index 98%
rename from extensions-jvm/velocity/runtime/pom.xml
rename to extensions/velocity/runtime/pom.xml
index 328c055..727b32b 100644
--- a/extensions-jvm/velocity/runtime/pom.xml
+++ b/extensions/velocity/runtime/pom.xml
@@ -34,6 +34,7 @@
 
     <properties>
         <camel.quarkus.jvmSince>1.1.0</camel.quarkus.jvmSince>
+        <camel.quarkus.nativeSince>1.2.0</camel.quarkus.nativeSince>
     </properties>
 
     <dependencyManagement>
diff --git a/extensions/velocity/runtime/src/main/doc/configuration.adoc b/extensions/velocity/runtime/src/main/doc/configuration.adoc
new file mode 100644
index 0000000..fb06ad0
--- /dev/null
+++ b/extensions/velocity/runtime/src/main/doc/configuration.adoc
@@ -0,0 +1,15 @@
+Beyond standard usages described above, a trick is needed when using velocity templates from classpath resources in native mode. In such a situation, one needs to explicitly embed the resources in the native executable by specifying the `include-patterns` option.
+
+For instance, the route below would load the velocity template from a classpath resource named _template/simple.vm_:
+[source,java]
+----
+from("direct:start").to("velocity://template/simple.vm");
+----
+
+In order to work in native mode the `include-patterns` configuration should be set. For instance, in the `application.properties` file as below :
+[source,properties]
+----
+quarkus.camel.native.resources.include-patterns = template/*.vm
+----
+
+More information about selecting resources for inclusion in the native executable could be found at xref:user-guide/native-mode.adoc#embedding-resource-in-native-executable[Embedding resource in native executable].
diff --git a/extensions/velocity/runtime/src/main/doc/limitations.adoc b/extensions/velocity/runtime/src/main/doc/limitations.adoc
new file mode 100644
index 0000000..5e543e9
--- /dev/null
+++ b/extensions/velocity/runtime/src/main/doc/limitations.adoc
@@ -0,0 +1,6 @@
+If property `allowContextMapAll` is set to `true` there is a limitation in native mode. Reflective calls to methods
+of several classes in camel are not allowed (for example `org.apache.camel.support.DefaultExchange`). Therefore
+some expressions won't work (for example `${exchange.properties.*}).
+
+You can allow reflective calls to such classes (for example by using application.properties), but keep in mind that it brings
+some security risks.
diff --git a/extensions-jvm/velocity/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/velocity/runtime/src/main/resources/META-INF/quarkus-extension.yaml
similarity index 97%
rename from extensions-jvm/velocity/runtime/src/main/resources/META-INF/quarkus-extension.yaml
rename to extensions/velocity/runtime/src/main/resources/META-INF/quarkus-extension.yaml
index 670bbe8..b3f4fac 100644
--- a/extensions-jvm/velocity/runtime/src/main/resources/META-INF/quarkus-extension.yaml
+++ b/extensions/velocity/runtime/src/main/resources/META-INF/quarkus-extension.yaml
@@ -24,9 +24,8 @@
 name: "Camel Velocity"
 description: "Transform messages using a Velocity template"
 metadata:
-  unlisted: true
   guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/velocity.html"
   categories:
   - "integration"
   status:
-  - "preview"
+  - "stable"
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index e325763..ea9705e 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -154,6 +154,7 @@
         <module>twitter</module>
         <module>univocity-parsers</module>
         <module>validator</module>
+        <module>velocity</module>
         <module>vertx</module>
         <module>vertx-websocket</module>
         <module>weather</module>
diff --git a/extensions-jvm/velocity/integration-test/pom.xml b/integration-tests/velocity/pom.xml
similarity index 58%
rename from extensions-jvm/velocity/integration-test/pom.xml
rename to integration-tests/velocity/pom.xml
index a1bd58d..1e51d27 100644
--- a/extensions-jvm/velocity/integration-test/pom.xml
+++ b/integration-tests/velocity/pom.xml
@@ -23,25 +23,15 @@
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.apache.camel.quarkus</groupId>
-        <artifactId>camel-quarkus-build-parent-it</artifactId>
+        <artifactId>camel-quarkus-integration-tests</artifactId>
         <version>1.2.0-SNAPSHOT</version>
-        <relativePath>../../../poms/build-parent-it/pom.xml</relativePath>
+        <relativePath>../pom.xml</relativePath>
     </parent>
 
-    <artifactId>camel-quarkus-velocity-integration-test</artifactId>
-    <name>Camel Quarkus :: Velocity :: Integration Test</name>
+    <artifactId>camel-quarkus-integration-test-velocity</artifactId>
+    <name>Camel Quarkus :: Integration Tests :: Velocity</name>
     <description>Integration tests for Camel Quarkus Velocity extension</description>
 
-    <properties>
-        <!-- mvnd, a.k.a. Maven Daemon: https://github.com/mvndaemon/mvnd -->
-        <!-- The following rule tells mvnd to build the listed deployment modules before this module. -->
-        <!-- This is important because mvnd builds modules in parallel by default. The deployment modules are not -->
-        <!-- explicit dependencies of this module in the Maven sense, although they are required by the Quarkus Maven plugin. -->
-        <!-- Please update the rule whenever you change the dependencies of this module by running -->
-        <!--     mvn process-resources -Pformat    from the root directory -->
-        <mvnd.builder.rule>camel-quarkus-support-policy-deployment,camel-quarkus-velocity-deployment</mvnd.builder.rule>
-    </properties>
-
     <dependencyManagement>
         <dependencies>
             <dependency>
@@ -63,6 +53,10 @@
             <groupId>io.quarkus</groupId>
             <artifactId>quarkus-resteasy</artifactId>
         </dependency>
+        <dependency>
+            <groupId>io.quarkus</groupId>
+            <artifactId>quarkus-resteasy-jackson</artifactId>
+        </dependency>
 
         <!-- test dependencies -->
         <dependency>
@@ -75,6 +69,21 @@
             <artifactId>rest-assured</artifactId>
             <scope>test</scope>
         </dependency>
+
+        <!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory -->
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-velocity-deployment</artifactId>
+            <version>${project.version}</version>
+            <type>pom</type>
+            <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>*</groupId>
+                    <artifactId>*</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
     </dependencies>
 
     <build>
@@ -92,4 +101,35 @@
             </plugin>
         </plugins>
     </build>
+
+    <profiles>
+        <profile>
+            <id>native</id>
+            <activation>
+                <property>
+                    <name>native</name>
+                </property>
+            </activation>
+            <properties>
+                <quarkus.package.type>native</quarkus.package.type>
+            </properties>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-failsafe-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <goals>
+                                    <goal>integration-test</goal>
+                                    <goal>verify</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+
 </project>
diff --git a/extensions-jvm/velocity/integration-test/src/test/java/org/apache/camel/quarkus/component/velocity/it/VelocityTest.java b/integration-tests/velocity/src/main/java/org/apache/camel/quarkus/component/velocity/it/Person.java
similarity index 52%
copy from extensions-jvm/velocity/integration-test/src/test/java/org/apache/camel/quarkus/component/velocity/it/VelocityTest.java
copy to integration-tests/velocity/src/main/java/org/apache/camel/quarkus/component/velocity/it/Person.java
index 6ba13ca..9ba60b6 100644
--- a/extensions-jvm/velocity/integration-test/src/test/java/org/apache/camel/quarkus/component/velocity/it/VelocityTest.java
+++ b/integration-tests/velocity/src/main/java/org/apache/camel/quarkus/component/velocity/it/Person.java
@@ -16,19 +16,45 @@
  */
 package org.apache.camel.quarkus.component.velocity.it;
 
-import io.quarkus.test.junit.QuarkusTest;
-import io.restassured.RestAssured;
-import org.junit.jupiter.api.Test;
-
-@QuarkusTest
-class VelocityTest {
-
-    @Test
-    public void loadComponentVelocity() {
-        /* A simple autogenerated test */
-        RestAssured.get("/velocity/load/component/velocity")
-                .then()
-                .statusCode(200);
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+public class Person {
+
+    private String name;
+    private String country;
+
+    public Person() {
+    }
+
+    public Person(String name, String country) {
+        this.name = name;
+        this.country = country;
+    }
+
+    public String getName() {
+        return name;
     }
 
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getCountry() {
+        return country;
+    }
+
+    public void setCountry(String country) {
+        this.country = country;
+    }
+
+    @Override
+    public String toString() {
+        return "Person{"
+                + "name='"
+                + name + '\''
+                + ", country='"
+                + country + '\''
+                + '}';
+    }
 }
diff --git a/integration-tests/velocity/src/main/java/org/apache/camel/quarkus/component/velocity/it/VelocityResource.java b/integration-tests/velocity/src/main/java/org/apache/camel/quarkus/component/velocity/it/VelocityResource.java
new file mode 100644
index 0000000..f3313de
--- /dev/null
+++ b/integration-tests/velocity/src/main/java/org/apache/camel/quarkus/component/velocity/it/VelocityResource.java
@@ -0,0 +1,192 @@
+/*
+ * 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.quarkus.component.velocity.it;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.velocity.VelocityConstants;
+import org.jboss.logging.Logger;
+
+@Path("/velocity")
+@ApplicationScoped
+public class VelocityResource {
+
+    private static final Logger LOG = Logger.getLogger(VelocityResource.class);
+
+    @Inject
+    ProducerTemplate producerTemplate;
+    private String endpointUri;
+
+    @Path("/template")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response template(String message, @QueryParam("item") String item,
+            @QueryParam("name") String name, @QueryParam("template") String template,
+            @QueryParam("propertiesFile") String propertiesFile,
+            @QueryParam("contentCache") String contentCache,
+            @QueryParam("expectFailure") String exectFaiure) throws Exception {
+        LOG.infof("Sending to velocity: %s", message);
+        Map<String, Object> headers = new HashMap() {
+            {
+                if (item != null) {
+                    put("item", item);
+                }
+                if (name != null) {
+                    put("name", name);
+                }
+                put(VelocityConstants.VELOCITY_TEMPLATE, message);
+            }
+        };
+        String endpointUrl = "velocity:" + template;
+        if (propertiesFile != null) {
+            endpointUrl = endpointUrl + "?propertiesFile=" + propertiesFile;
+        }
+        if (contentCache != null) {
+            endpointUrl = endpointUrl + "?contentCache=" + contentCache;
+        }
+        try {
+            final String response = producerTemplate.requestBodyAndHeaders(endpointUrl, message,
+                    headers,
+                    String.class);
+            LOG.infof("Got response from velocity: %s", response);
+            return Response
+                    .created(new URI("https://camel.apache.org/"))
+                    .entity(response)
+                    .build();
+        } catch (Exception e) {
+            if (exectFaiure != null && Boolean.parseBoolean(exectFaiure)) {
+                return Response
+                        .created(new URI("https://camel.apache.org/"))
+                        .entity(e.toString())
+                        .status(500)
+                        .build();
+            } else {
+                throw e;
+            }
+        }
+    }
+
+    @Path("/bodyAsDomainObject")
+    @POST
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response bodyAsDomainObject(Person person, @QueryParam("givenName") String givenName,
+            @QueryParam("familyName") String familyName) throws Exception {
+        LOG.infof("Sending to velocity: %s", person);
+        final String response = producerTemplate.requestBody("velocity://template/BodyAsDomainObject.vm", person,
+                String.class);
+        LOG.infof("Got response from velocity: %s", response);
+        return Response
+                .created(new URI("https://camel.apache.org/"))
+                .entity(response)
+                .build();
+    }
+
+    @Path("/templateViaHeader")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response templateViaHeader(String message, @QueryParam("body") String body, @QueryParam("item") String item,
+            @QueryParam("name") String name) throws Exception {
+        LOG.infof("Sending to velocity: %s", body);
+        Map<String, Object> headers = new HashMap() {
+            {
+                put("item", item);
+                put("name", name);
+                put(VelocityConstants.VELOCITY_TEMPLATE, message);
+            }
+        };
+        final String response = producerTemplate.requestBodyAndHeaders("velocity::dummy?allowTemplateFromHeader=true", body,
+                headers,
+                String.class);
+        LOG.infof("Got response from velocity: %s", response);
+        return Response
+                .created(new URI("https://camel.apache.org/"))
+                .entity(response)
+                .build();
+    }
+
+    @Path("/withProperties")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response withProperties(String message, @QueryParam("item") String item,
+            @QueryParam("name") String name) throws Exception {
+        LOG.infof("Sending to velocity: %s", message);
+        final Exchange response = producerTemplate
+                .request("velocity::dummy?allowTemplateFromHeader=true&allowContextMapAll=true", exchange -> {
+                    exchange.getIn().setHeader(VelocityConstants.VELOCITY_TEMPLATE, message);
+                    exchange.setProperty("name", name);
+                    exchange.setProperty("item", item);
+                });
+        LOG.infof("Got response from velocity: %s", response);
+        return Response
+                .created(new URI("https://camel.apache.org/"))
+                .entity(response.getMessage().getBody())
+                .build();
+    }
+
+    @Path("/supplementalContext")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response supplementalContext(String message, @QueryParam("body") String body,
+            @QueryParam("supplementalBody") String supplementalBody) throws Exception {
+        LOG.infof("Sending to velocity: %s", body);
+
+        final Map<String, Object> supplementalContext = new HashMap<>();
+        supplementalContext.put("body", supplementalBody);
+
+        Map<String, Object> headers = new HashMap() {
+            {
+                put(VelocityConstants.VELOCITY_TEMPLATE, message);
+                put(VelocityConstants.VELOCITY_SUPPLEMENTAL_CONTEXT, supplementalContext);
+            }
+        };
+
+        final Exchange result = producerTemplate.request("velocity::dummy?allowTemplateFromHeader=true",
+                exchange -> {
+                    exchange.getMessage().setHeaders(headers);
+                    exchange.getMessage().setBody(body);
+                });
+        LOG.infof("Got response from velocity: %s", result);
+
+        Map<String, String> resultMap = result.getMessage().getHeaders().entrySet().stream()
+                .filter(e -> e.getValue() instanceof String)
+                .collect(Collectors.toMap(e -> e.getKey(), e -> (String) e.getValue()));
+        resultMap.put("result_value", result.getMessage().getBody(String.class));
+
+        return Response.status(Response.Status.OK).entity(resultMap).build();
+
+    }
+}
diff --git a/integration-tests/velocity/src/main/resources/application.properties b/integration-tests/velocity/src/main/resources/application.properties
new file mode 100644
index 0000000..a079822
--- /dev/null
+++ b/integration-tests/velocity/src/main/resources/application.properties
@@ -0,0 +1,18 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+quarkus.camel.native.resources.include-patterns = template/*
\ No newline at end of file
diff --git a/integration-tests/velocity/src/main/resources/template/BodyAsDomainObject.vm b/integration-tests/velocity/src/main/resources/template/BodyAsDomainObject.vm
new file mode 100644
index 0000000..d58dbfe
--- /dev/null
+++ b/integration-tests/velocity/src/main/resources/template/BodyAsDomainObject.vm
@@ -0,0 +1,33 @@
+#*
+ * 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.
+ *#
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+Hi $body.name from $body.country
\ No newline at end of file
diff --git a/integration-tests/velocity/src/main/resources/template/letter.vm b/integration-tests/velocity/src/main/resources/template/letter.vm
new file mode 100644
index 0000000..d01e930
--- /dev/null
+++ b/integration-tests/velocity/src/main/resources/template/letter.vm
@@ -0,0 +1,38 @@
+#*
+ * 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.
+ *#
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+Dear ${headers.name}
+
+Thanks for the order of ${headers.item}.
+
+Regards Apache Camel Riders Bookstore
+${body}
\ No newline at end of file
diff --git a/integration-tests/velocity/src/main/resources/template/velocity.properties b/integration-tests/velocity/src/main/resources/template/velocity.properties
new file mode 100644
index 0000000..2e774d0
--- /dev/null
+++ b/integration-tests/velocity/src/main/resources/template/velocity.properties
@@ -0,0 +1,22 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+#
+# specify three resource loaders to use
+#
+resource.loaders =file
+
diff --git a/extensions-jvm/velocity/integration-test/src/test/java/org/apache/camel/quarkus/component/velocity/it/VelocityTest.java b/integration-tests/velocity/src/test/java/org/apache/camel/quarkus/component/velocity/it/VelocityIT.java
similarity index 70%
rename from extensions-jvm/velocity/integration-test/src/test/java/org/apache/camel/quarkus/component/velocity/it/VelocityTest.java
rename to integration-tests/velocity/src/test/java/org/apache/camel/quarkus/component/velocity/it/VelocityIT.java
index 6ba13ca..f8a4922 100644
--- a/extensions-jvm/velocity/integration-test/src/test/java/org/apache/camel/quarkus/component/velocity/it/VelocityTest.java
+++ b/integration-tests/velocity/src/test/java/org/apache/camel/quarkus/component/velocity/it/VelocityIT.java
@@ -16,19 +16,8 @@
  */
 package org.apache.camel.quarkus.component.velocity.it;
 
-import io.quarkus.test.junit.QuarkusTest;
-import io.restassured.RestAssured;
-import org.junit.jupiter.api.Test;
-
-@QuarkusTest
-class VelocityTest {
-
-    @Test
-    public void loadComponentVelocity() {
-        /* A simple autogenerated test */
-        RestAssured.get("/velocity/load/component/velocity")
-                .then()
-                .statusCode(200);
-    }
+import io.quarkus.test.junit.NativeImageTest;
 
+@NativeImageTest
+class VelocityIT extends VelocityTest {
 }
diff --git a/integration-tests/velocity/src/test/java/org/apache/camel/quarkus/component/velocity/it/VelocityTest.java b/integration-tests/velocity/src/test/java/org/apache/camel/quarkus/component/velocity/it/VelocityTest.java
new file mode 100644
index 0000000..d425c58
--- /dev/null
+++ b/integration-tests/velocity/src/test/java/org/apache/camel/quarkus/component/velocity/it/VelocityTest.java
@@ -0,0 +1,187 @@
+/*
+ * 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.quarkus.component.velocity.it;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Map;
+
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+@QuarkusTest
+class VelocityTest {
+
+    public static final String OLD_BODY = "old_body";
+    public static final String BODY = "bar";
+    public static final String NEW_BODY = "new_body";
+    public static final String MSG = "\nDear Sheldon\n" +
+            "\n" +
+            "Thanks for the order of Camel in Action.\n" +
+            "\n" +
+            "Regards Apache Camel Riders Bookstore\n" +
+            "PS: Next beer is on me";
+
+    @Test
+    public void testTemplateViaFile() throws IOException {
+        File template = createFile("velocity_test", "Hi ${headers.name}. You have got ${headers.item}. ${body}");
+        RestAssured.given()
+                .queryParam("name", "Sheldon")
+                .queryParam("item", "Camel in Action")
+                .queryParam("template", "file:/" + template.getPath())
+                .contentType(ContentType.TEXT)
+                .body("PS: Next beer is on me")
+                .post("/velocity/template")
+                .then()
+                .statusCode(201)
+                .body(equalTo("Hi Sheldon. You have got Camel in Action. PS: Next beer is on me"));
+    }
+
+    @Test
+    public void testTemplateViaClasspath() {
+        RestAssured.given()
+                .queryParam("name", "Sheldon")
+                .queryParam("item", "Camel in Action")
+                .queryParam("template", "//template/letter.vm")
+                .contentType(ContentType.TEXT)
+                .body("PS: Next beer is on me")
+                .post("/velocity/template")
+                .then()
+                .statusCode(201)
+                .body(equalTo(MSG));
+    }
+
+    @Test
+    public void testTemplateViaClasspathWithProperties() {
+        //class loader is forbidden by properties, response should fail
+        RestAssured.given()
+                .queryParam("name", "Sheldon")
+                .queryParam("item", "Camel in Action")
+                .queryParam("template", "//template/template.vm")
+                .queryParam("propertiesFile", "/template/velocity.properties")
+                .queryParam("expectFailure", "true")
+                .contentType(ContentType.TEXT)
+                .body("PS: Next beer is on me")
+                .post("/velocity/template")
+                .then()
+                .statusCode(500)
+                .body(containsString("Exception"));
+    }
+
+    @Test
+    public void testTemplateViaHeader() {
+        RestAssured.given()
+                .queryParam("body", "PS: Next beer is on me.")
+                .queryParam("name", "Sheldon")
+                .queryParam("item", "Camel in Action")
+                .contentType(ContentType.TEXT)
+                .body("Hi ${headers.name}. Thanks for ${headers.item}. ${body}")
+                .post("/velocity/templateViaHeader")
+                .then()
+                .statusCode(201)
+                .body(equalTo("Hi Sheldon. Thanks for Camel in Action. PS: Next beer is on me."));
+    }
+
+    @Test
+    public void testSupplementalContext() {
+        final String template = "#set( $headers.body = ${body} )\n" + BODY;
+        Map result = RestAssured.given()
+                .queryParam("body", OLD_BODY)
+                .queryParam("supplementalBody", NEW_BODY)
+                .contentType(ContentType.TEXT)
+                .body(template)
+                .post("/velocity/supplementalContext")
+                .then()
+                .statusCode(200)
+                .extract().as(Map.class);
+
+        assertTrue(result.containsKey("result_value"));
+        assertEquals(BODY, result.get("result_value"));
+        assertTrue(result.containsKey("body"));
+        assertEquals(NEW_BODY, result.get("body"));
+    }
+
+    @Test
+    public void testBodyAsDomainObject() {
+        RestAssured.given()
+                .queryParam("name", "Sheldon")
+                .queryParam("country", "Earth 1")
+                .contentType(ContentType.JSON)
+                .body(new Person("Sheldon", "Earth 2"))
+                .post("/velocity/bodyAsDomainObject")
+                .then()
+                .statusCode(201)
+                .body(equalTo("\nHi Sheldon from Earth 2"));
+    }
+
+    @Test
+    public void testContentCacheFalse() throws Exception {
+        testContentCache(false);
+    }
+
+    @Test
+    public void testContentCacheTrue() throws Exception {
+        testContentCache(true);
+    }
+
+    private void testContentCache(boolean useContentCache) throws Exception {
+        File template = createFile("velocity_test", "Hi ${body}");
+
+        RestAssured.given()
+                .queryParam("template", "file:/" + template.getPath())
+                .queryParam("contentCache", useContentCache)
+                .contentType(ContentType.TEXT)
+                .body("Sheldon")
+                .post("/velocity/template")
+                .then()
+                .statusCode(201)
+                .body(equalTo("Hi Sheldon"));
+
+        //override file
+        Files.write(Paths.get(template.getPath()), "Bye ${body}".getBytes(StandardCharsets.UTF_8));
+
+        RestAssured.given()
+                .queryParam("template", "file:/" + template.getPath())
+                .queryParam("contentCache", useContentCache)
+                .contentType(ContentType.TEXT)
+                .body("Sheldon")
+                .post("/velocity/template")
+                .then()
+
+                .statusCode(201)
+                .body(equalTo(useContentCache ? "Hi Sheldon" : "Bye Sheldon"));
+    }
+
+    private File createFile(String fileName, String body) throws IOException {
+        File tmpFile = File.createTempFile(fileName, ".vm");
+
+        Files.write(tmpFile.toPath(), body.getBytes(StandardCharsets.UTF_8));
+
+        tmpFile.deleteOnExit();
+        return tmpFile;
+    }
+}
diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml
index 140bfff..4317c69 100644
--- a/tooling/scripts/test-categories.yaml
+++ b/tooling/scripts/test-categories.yaml
@@ -102,6 +102,7 @@ misc:
   - pdf
   - qute
   - tika
+  - velocity
   - as2
   - kotlin
   - disruptor