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

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


The following commit(s) were added to refs/heads/main by this push:
     new 66565dd  XQuery component and language native support #1710
66565dd is described below

commit 66565dd0ea7ffd65184a3574fc20fd216fac5fdc
Author: aldettinger <[email protected]>
AuthorDate: Mon May 10 16:42:05 2021 +0200

    XQuery component and language native support #1710
---
 .../ROOT/pages/reference/extensions/saxon.adoc     | 34 +++++++--
 .../ROOT/partials/reference/components/xquery.adoc |  6 +-
 .../ROOT/partials/reference/languages/xquery.adoc  |  6 +-
 extensions-jvm/pom.xml                             |  1 -
 .../component/saxon/deployment/SaxonProcessor.java | 46 ------------
 .../quarkus/component/saxon/it/SaxonResource.java  | 64 -----------------
 extensions/pom.xml                                 |  1 +
 .../saxon/deployment/pom.xml                       |  0
 .../component/saxon/deployment/SaxonProcessor.java | 66 +++++++++++++++++
 {extensions-jvm => extensions}/saxon/pom.xml       |  1 -
 .../saxon/runtime/pom.xml                          |  1 +
 .../saxon/runtime/src/main/doc/configuration.adoc  | 16 +++++
 .../main/resources/META-INF/quarkus-extension.yaml |  3 +-
 integration-tests/pom.xml                          |  1 +
 .../saxon}/pom.xml                                 | 71 ++++++++++++++++--
 .../camel/quarkus/component/saxon/it/MyBean.java   | 32 ++++-----
 .../quarkus/component/saxon/it/SaxonResource.java  | 83 ++++++++++++++++++++++
 .../quarkus/component/saxon/it/SaxonRoutes.java    | 50 +++++++++++++
 .../component/saxon/it/SimpleExtension.java        | 71 ++++++++++++++++++
 .../src/main/resources/application.properties      | 17 +++++
 .../saxon/src/main/resources/myxquery.txt          |  1 +
 .../saxon/src/main/resources/transform.xquery      |  3 +
 .../main/resources/transformWithExtension.xquery   |  6 ++
 .../camel/quarkus/component/saxon/it/SaxonIT.java  | 24 +------
 .../quarkus/component/saxon/it/SaxonTest.java      | 70 ++++++++++++++++++
 .../saxon/src/test/resources/myinput.xml           | 27 +++----
 pom.xml                                            |  1 +
 tooling/scripts/test-categories.yaml               |  1 +
 28 files changed, 515 insertions(+), 188 deletions(-)

diff --git a/docs/modules/ROOT/pages/reference/extensions/saxon.adoc 
b/docs/modules/ROOT/pages/reference/extensions/saxon.adoc
index eeb85a5..e1e5adf 100644
--- a/docs/modules/ROOT/pages/reference/extensions/saxon.adoc
+++ b/docs/modules/ROOT/pages/reference/extensions/saxon.adoc
@@ -3,16 +3,16 @@
 = XQuery
 :linkattrs:
 :cq-artifact-id: camel-quarkus-saxon
-:cq-native-supported: false
-:cq-status: Preview
-:cq-status-deprecation: Preview
+:cq-native-supported: true
+:cq-status: Stable
+:cq-status-deprecation: Stable
 :cq-description: Query and/or transform XML payloads using XQuery and Saxon.
 :cq-deprecated: false
 :cq-jvm-since: 1.1.0
-:cq-native-since: n/a
+:cq-native-since: 1.9.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.9.0##
 
 Query and/or transform XML payloads using XQuery and Saxon.
 
@@ -25,6 +25,10 @@ Please refer to the above links for usage and configuration 
details.
 
 == Maven coordinates
 
+https://code.quarkus.io/?extension-search=camel-quarkus-saxon[Create a new 
project with this extension on code.quarkus.io, window="_blank"]
+
+Or add the coordinates to your existing project:
+
 [source,xml]
 ----
 <dependency>
@@ -34,3 +38,23 @@ Please refer to the above links for usage and configuration 
details.
 ----
 
 Check the xref:user-guide/index.adoc[User guide] for more information about 
writing Camel Quarkus applications.
+
+== Additional Camel Quarkus configuration
+
+Beyond standard usages described above, a trick is needed when using the 
xquery language and component with 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 2 routes below would load a xquery script from 2 classpath 
resources respectively named _myxquery.txt_ and _another-xquery.txt_:
+[source,java]
+----
+from("direct:start").transform().xquery("resource:classpath:myxquery.txt", 
String.class);
+from("direct:start").to("xquery:another-xquery.txt");
+----
+
+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 = *.txt
+----
+
+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/xquery.adoc 
b/docs/modules/ROOT/partials/reference/components/xquery.adoc
index 7e6d67d..caa6f61 100644
--- a/docs/modules/ROOT/partials/reference/components/xquery.adoc
+++ b/docs/modules/ROOT/partials/reference/components/xquery.adoc
@@ -2,11 +2,11 @@
 // This file was generated by 
camel-quarkus-maven-plugin:update-extension-doc-page
 :cq-artifact-id: camel-quarkus-saxon
 :cq-artifact-id-base: saxon
-: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.9.0
 :cq-camel-part-name: xquery
 :cq-camel-part-title: XQuery
 :cq-camel-part-description: Query and/or transform XML payloads using XQuery 
and Saxon.
diff --git a/docs/modules/ROOT/partials/reference/languages/xquery.adoc 
b/docs/modules/ROOT/partials/reference/languages/xquery.adoc
index ecc87c0..1d46c88 100644
--- a/docs/modules/ROOT/partials/reference/languages/xquery.adoc
+++ b/docs/modules/ROOT/partials/reference/languages/xquery.adoc
@@ -2,11 +2,11 @@
 // This file was generated by 
camel-quarkus-maven-plugin:update-extension-doc-page
 :cq-artifact-id: camel-quarkus-saxon
 :cq-artifact-id-base: saxon
-: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.9.0
 :cq-camel-part-name: xquery
 :cq-camel-part-title: XQuery
 :cq-camel-part-description: Evaluate an XQuery expressions against an XML 
payload.
diff --git a/extensions-jvm/pom.xml b/extensions-jvm/pom.xml
index c8e7c6c..885e3b7 100644
--- a/extensions-jvm/pom.xml
+++ b/extensions-jvm/pom.xml
@@ -101,7 +101,6 @@
         <module>redis</module>
         <module>ribbon</module>
         <module>robotframework</module>
-        <module>saxon</module>
         <module>schematron</module>
         <module>sip</module>
         <module>smpp</module>
diff --git 
a/extensions-jvm/saxon/deployment/src/main/java/org/apache/camel/quarkus/component/saxon/deployment/SaxonProcessor.java
 
b/extensions-jvm/saxon/deployment/src/main/java/org/apache/camel/quarkus/component/saxon/deployment/SaxonProcessor.java
deleted file mode 100644
index a511bec..0000000
--- 
a/extensions-jvm/saxon/deployment/src/main/java/org/apache/camel/quarkus/component/saxon/deployment/SaxonProcessor.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.saxon.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 SaxonProcessor {
-
-    private static final Logger LOG = Logger.getLogger(SaxonProcessor.class);
-    private static final String FEATURE = "camel-saxon";
-
-    @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/saxon/integration-test/src/main/java/org/apache/camel/quarkus/component/saxon/it/SaxonResource.java
 
b/extensions-jvm/saxon/integration-test/src/main/java/org/apache/camel/quarkus/component/saxon/it/SaxonResource.java
deleted file mode 100644
index 7fc0cde..0000000
--- 
a/extensions-jvm/saxon/integration-test/src/main/java/org/apache/camel/quarkus/component/saxon/it/SaxonResource.java
+++ /dev/null
@@ -1,64 +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.saxon.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("/saxon")
-@ApplicationScoped
-public class SaxonResource {
-
-    private static final Logger LOG = Logger.getLogger(SaxonResource.class);
-
-    private static final String COMPONENT_XQUERY = "xquery";
-    private static final String LANGUAGE_XQUERY = "xquery";
-    @Inject
-    CamelContext context;
-
-    @Path("/load/component/xquery")
-    @GET
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response loadComponentXquery() throws Exception {
-        /* This is an autogenerated test */
-        if (context.getComponent(COMPONENT_XQUERY) != null) {
-            return Response.ok().build();
-        }
-        LOG.warnf("Could not load [%s] from the Camel context", 
COMPONENT_XQUERY);
-        return Response.status(500, COMPONENT_XQUERY + " could not be loaded 
from the Camel context").build();
-    }
-
-    @Path("/load/language/xquery")
-    @GET
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response loadLanguageXquery() throws Exception {
-        /* This is an autogenerated test */
-        if (context.resolveLanguage(LANGUAGE_XQUERY) != null) {
-            return Response.ok().build();
-        }
-        LOG.warnf("Could not load [%s] from the Camel context", 
LANGUAGE_XQUERY);
-        return Response.status(500, LANGUAGE_XQUERY + " could not be loaded 
from the Camel context").build();
-    }
-}
diff --git a/extensions/pom.xml b/extensions/pom.xml
index 3a8940c..13ce969 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -199,6 +199,7 @@
         <module>saga</module>
         <module>salesforce</module>
         <module>sap-netweaver</module>
+        <module>saxon</module>
         <module>scheduler</module>
         <module>seda</module>
         <module>servicenow</module>
diff --git a/extensions-jvm/saxon/deployment/pom.xml 
b/extensions/saxon/deployment/pom.xml
similarity index 100%
rename from extensions-jvm/saxon/deployment/pom.xml
rename to extensions/saxon/deployment/pom.xml
diff --git 
a/extensions/saxon/deployment/src/main/java/org/apache/camel/quarkus/component/saxon/deployment/SaxonProcessor.java
 
b/extensions/saxon/deployment/src/main/java/org/apache/camel/quarkus/component/saxon/deployment/SaxonProcessor.java
new file mode 100644
index 0000000..1d2afe0
--- /dev/null
+++ 
b/extensions/saxon/deployment/src/main/java/org/apache/camel/quarkus/component/saxon/deployment/SaxonProcessor.java
@@ -0,0 +1,66 @@
+/*
+ * 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.saxon.deployment;
+
+import java.util.Collection;
+
+import org.w3c.dom.Document;
+
+import io.quarkus.deployment.annotations.BuildProducer;
+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.ReflectiveClassBuildItem;
+import net.sf.saxon.functions.SystemFunction;
+import org.jboss.jandex.ClassInfo;
+import org.jboss.jandex.DotName;
+import org.jboss.logging.Logger;
+
+class SaxonProcessor {
+
+    private static final Logger LOG = Logger.getLogger(SaxonProcessor.class);
+    private static final String FEATURE = "camel-saxon";
+
+    @BuildStep
+    FeatureBuildItem feature() {
+        return new FeatureBuildItem(FEATURE);
+    }
+
+    @BuildStep
+    void registerReflectiveClasses(BuildProducer<ReflectiveClassBuildItem> 
reflectiveClasses,
+            CombinedIndexBuildItem index) {
+
+        // Needed to register default object models when initializing the 
net.sf.saxon.java.JavaPlatform
+        reflectiveClasses.produce(new ReflectiveClassBuildItem(false, false, 
Document.class));
+
+        // Register saxon functions as reflective
+        Collection<ClassInfo> cis = index.getIndex()
+                
.getAllKnownSubclasses(DotName.createSimple(SystemFunction.class.getName()));
+        cis.stream().forEach(ci -> {
+            String clazzName = ci.asClass().name().toString();
+            ReflectiveClassBuildItem clazz = new 
ReflectiveClassBuildItem(false, false, clazzName);
+            LOG.debugf("Registering saxon function '%s' as reflective", 
clazzName);
+            reflectiveClasses.produce(clazz);
+        });
+    }
+
+    @BuildStep
+    void indexSaxonHe(BuildProducer<IndexDependencyBuildItem> deps) {
+        deps.produce(new IndexDependencyBuildItem("net.sf.saxon", "Saxon-HE"));
+    }
+}
diff --git a/extensions-jvm/saxon/pom.xml b/extensions/saxon/pom.xml
similarity index 97%
copy from extensions-jvm/saxon/pom.xml
copy to extensions/saxon/pom.xml
index df860b2..e6921b6 100644
--- a/extensions-jvm/saxon/pom.xml
+++ b/extensions/saxon/pom.xml
@@ -33,6 +33,5 @@
     <modules>
         <module>deployment</module>
         <module>runtime</module>
-        <module>integration-test</module>
     </modules>
 </project>
diff --git a/extensions-jvm/saxon/runtime/pom.xml 
b/extensions/saxon/runtime/pom.xml
similarity index 98%
rename from extensions-jvm/saxon/runtime/pom.xml
rename to extensions/saxon/runtime/pom.xml
index be7ac0a..6da74e5 100644
--- a/extensions-jvm/saxon/runtime/pom.xml
+++ b/extensions/saxon/runtime/pom.xml
@@ -32,6 +32,7 @@
 
     <properties>
         <camel.quarkus.jvmSince>1.1.0</camel.quarkus.jvmSince>
+        <camel.quarkus.nativeSince>1.9.0</camel.quarkus.nativeSince>
     </properties>
 
     <dependencyManagement>
diff --git a/extensions/saxon/runtime/src/main/doc/configuration.adoc 
b/extensions/saxon/runtime/src/main/doc/configuration.adoc
new file mode 100644
index 0000000..0e22c61
--- /dev/null
+++ b/extensions/saxon/runtime/src/main/doc/configuration.adoc
@@ -0,0 +1,16 @@
+Beyond standard usages described above, a trick is needed when using the 
xquery language and component with 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 2 routes below would load a xquery script from 2 classpath 
resources respectively named _myxquery.txt_ and _another-xquery.txt_:
+[source,java]
+----
+from("direct:start").transform().xquery("resource:classpath:myxquery.txt", 
String.class);
+from("direct:start").to("xquery:another-xquery.txt");
+----
+
+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 = *.txt
+----
+
+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].
\ No newline at end of file
diff --git 
a/extensions-jvm/saxon/runtime/src/main/resources/META-INF/quarkus-extension.yaml
 b/extensions/saxon/runtime/src/main/resources/META-INF/quarkus-extension.yaml
similarity index 97%
rename from 
extensions-jvm/saxon/runtime/src/main/resources/META-INF/quarkus-extension.yaml
rename to 
extensions/saxon/runtime/src/main/resources/META-INF/quarkus-extension.yaml
index 52cd8ab..f17af03 100644
--- 
a/extensions-jvm/saxon/runtime/src/main/resources/META-INF/quarkus-extension.yaml
+++ 
b/extensions/saxon/runtime/src/main/resources/META-INF/quarkus-extension.yaml
@@ -24,9 +24,8 @@
 name: "Camel XQuery"
 description: "Query and/or transform XML payloads using XQuery and Saxon"
 metadata:
-  unlisted: true
   guide: 
"https://camel.apache.org/camel-quarkus/latest/reference/extensions/saxon.html";
   categories:
   - "integration"
   status:
-  - "preview"
+  - "stable"
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index cbeb566..3c84a51 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -184,6 +184,7 @@
         <module>saga</module>
         <module>salesforce</module>
         <module>sap-netweaver</module>
+        <module>saxon</module>
         <module>servicenow</module>
         <module>servlet</module>
         <module>shiro</module>
diff --git a/extensions-jvm/saxon/integration-test/pom.xml 
b/integration-tests/saxon/pom.xml
similarity index 55%
rename from extensions-jvm/saxon/integration-test/pom.xml
rename to integration-tests/saxon/pom.xml
index 1993f35..d381a6e 100644
--- a/extensions-jvm/saxon/integration-test/pom.xml
+++ b/integration-tests/saxon/pom.xml
@@ -21,13 +21,12 @@
     <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.9.0-SNAPSHOT</version>
-        <relativePath>../../../poms/build-parent-it/pom.xml</relativePath>
     </parent>
 
-    <artifactId>camel-quarkus-saxon-integration-test</artifactId>
-    <name>Camel Quarkus :: XQuery :: Integration Test</name>
+    <artifactId>camel-quarkus-integration-test-saxon</artifactId>
+    <name>Camel Quarkus :: Integration Tests :: XQuery</name>
     <description>Integration tests for Camel Quarkus XQuery 
extension</description>
 
     <dependencyManagement>
@@ -45,6 +44,14 @@
     <dependencies>
         <dependency>
             <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-bean</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-direct</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
             <artifactId>camel-quarkus-saxon</artifactId>
         </dependency>
         <dependency>
@@ -67,6 +74,32 @@
         <!-- 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-bean-deployment</artifactId>
+            <version>${project.version}</version>
+            <type>pom</type>
+            <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>*</groupId>
+                    <artifactId>*</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-direct-deployment</artifactId>
+            <version>${project.version}</version>
+            <type>pom</type>
+            <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>*</groupId>
+                    <artifactId>*</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
             <artifactId>camel-quarkus-saxon-deployment</artifactId>
             <version>${project.version}</version>
             <type>pom</type>
@@ -80,4 +113,34 @@
         </dependency>
     </dependencies>
 
+    <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/saxon/integration-test/src/test/java/org/apache/camel/quarkus/component/saxon/it/SaxonTest.java
 
b/integration-tests/saxon/src/main/java/org/apache/camel/quarkus/component/saxon/it/MyBean.java
similarity index 60%
copy from 
extensions-jvm/saxon/integration-test/src/test/java/org/apache/camel/quarkus/component/saxon/it/SaxonTest.java
copy to 
integration-tests/saxon/src/main/java/org/apache/camel/quarkus/component/saxon/it/MyBean.java
index 6f61d02..f9391a7 100644
--- 
a/extensions-jvm/saxon/integration-test/src/test/java/org/apache/camel/quarkus/component/saxon/it/SaxonTest.java
+++ 
b/integration-tests/saxon/src/main/java/org/apache/camel/quarkus/component/saxon/it/MyBean.java
@@ -16,27 +16,21 @@
  */
 package org.apache.camel.quarkus.component.saxon.it;
 
-import io.quarkus.test.junit.QuarkusTest;
-import io.restassured.RestAssured;
-import org.junit.jupiter.api.Test;
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Named;
 
-@QuarkusTest
-class SaxonTest {
+import io.quarkus.runtime.annotations.RegisterForReflection;
+import org.apache.camel.component.xquery.XQuery;
+import org.jboss.logging.Logger;
 
-    @Test
-    public void loadComponentXquery() {
-        /* A simple autogenerated test */
-        RestAssured.get("/saxon/load/component/xquery")
-                .then()
-                .statusCode(200);
-    }
+@ApplicationScoped
+@Named("myBean")
+@RegisterForReflection(fields = false)
+public class MyBean {
+    private static final Logger LOG = Logger.getLogger(MyBean.class);
 
-    @Test
-    public void loadLanguageXquery() {
-        /* A simple autogenerated test */
-        RestAssured.get("/saxon/load/language/xquery")
-                .then()
-                .statusCode(200);
+    public String extractFooId(@XQuery("/foo/@id") String foo) {
+        LOG.info("extractFooId() method called on " + this);
+        return String.format("Foo id is '%s'", foo);
     }
-
 }
diff --git 
a/integration-tests/saxon/src/main/java/org/apache/camel/quarkus/component/saxon/it/SaxonResource.java
 
b/integration-tests/saxon/src/main/java/org/apache/camel/quarkus/component/saxon/it/SaxonResource.java
new file mode 100644
index 0000000..73cbcc8
--- /dev/null
+++ 
b/integration-tests/saxon/src/main/java/org/apache/camel/quarkus/component/saxon/it/SaxonResource.java
@@ -0,0 +1,83 @@
+/*
+ * 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.saxon.it;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.camel.ProducerTemplate;
+
+@Path("/xquery")
+@ApplicationScoped
+public class SaxonResource {
+
+    @Inject
+    ProducerTemplate template;
+
+    @Path("/filter")
+    @GET
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public String filter(String xml) {
+        return template.requestBody("direct:filter", xml, String.class);
+    }
+
+    @Path("/transform")
+    @GET
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public String transform(String xml) {
+        return template.requestBody("direct:transform", xml, String.class);
+    }
+
+    @Path("/resource")
+    @GET
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public String resource(String xml) {
+        return template.requestBody("direct:resource", xml, String.class);
+    }
+
+    @Path("/produce")
+    @GET
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public String produce(String xml) {
+        return template.requestBody("direct:produce", xml, String.class);
+    }
+
+    @Path("/extension")
+    @GET
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public String extension(String xml) {
+        return template.requestBody("direct:extension", xml, String.class);
+    }
+
+    @Path("/bean")
+    @GET
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public String bean(String xml) {
+        return template.requestBody("direct:bean", xml, String.class);
+    }
+}
diff --git 
a/integration-tests/saxon/src/main/java/org/apache/camel/quarkus/component/saxon/it/SaxonRoutes.java
 
b/integration-tests/saxon/src/main/java/org/apache/camel/quarkus/component/saxon/it/SaxonRoutes.java
new file mode 100644
index 0000000..79ee4b5
--- /dev/null
+++ 
b/integration-tests/saxon/src/main/java/org/apache/camel/quarkus/component/saxon/it/SaxonRoutes.java
@@ -0,0 +1,50 @@
+/*
+ * 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.saxon.it;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Named;
+
+import net.sf.saxon.Configuration;
+import org.apache.camel.builder.RouteBuilder;
+
+@ApplicationScoped
+public class SaxonRoutes extends RouteBuilder {
+
+    @Named("saxonConf")
+    public Configuration loadConf() {
+        Configuration conf = new Configuration();
+        conf.registerExtensionFunction(new SimpleExtension());
+        return conf;
+    }
+
+    @Override
+    public void configure() {
+        
from("direct:filter").filter().xquery("/person[@name='James']").setBody(constant("JAMES"));
+
+        
from("direct:transform").transform().xquery("concat(/Envelope/Body/getEmployee/EmpId/text(),\"Suffix\")",
 String.class);
+
+        
from("direct:resource").transform().xquery("resource:classpath:myxquery.txt", 
String.class);
+
+        from("direct:produce").to("xquery:transform.xquery");
+
+        
from("direct:extension").to("xquery:transformWithExtension.xquery?configuration=#saxonConf");
+
+        from("direct:bean").bean("myBean");
+    }
+
+}
diff --git 
a/integration-tests/saxon/src/main/java/org/apache/camel/quarkus/component/saxon/it/SimpleExtension.java
 
b/integration-tests/saxon/src/main/java/org/apache/camel/quarkus/component/saxon/it/SimpleExtension.java
new file mode 100644
index 0000000..1648f87
--- /dev/null
+++ 
b/integration-tests/saxon/src/main/java/org/apache/camel/quarkus/component/saxon/it/SimpleExtension.java
@@ -0,0 +1,71 @@
+/*
+ * 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.saxon.it;
+
+import net.sf.saxon.expr.XPathContext;
+import net.sf.saxon.lib.ExtensionFunctionCall;
+import net.sf.saxon.lib.ExtensionFunctionDefinition;
+import net.sf.saxon.om.Item;
+import net.sf.saxon.om.Sequence;
+import net.sf.saxon.om.StructuredQName;
+import net.sf.saxon.trans.XPathException;
+import net.sf.saxon.value.SequenceType;
+import net.sf.saxon.value.StringValue;
+
+/**
+ * This is a very simple example of a saxon extension function.
+ * <p/>
+ * Example: <code>efx:simple('some text')</code> will be rendered to
+ * <code>arg1[some text]</code> and returned in the XQuery response.
+ */
+public final class SimpleExtension extends ExtensionFunctionDefinition {
+
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    public SequenceType[] getArgumentTypes() {
+        return new SequenceType[] { SequenceType.SINGLE_STRING };
+    }
+
+    @Override
+    public SequenceType getResultType(SequenceType[] suppliedArgumentTypes) {
+        return SequenceType.SINGLE_STRING;
+    }
+
+    @Override
+    public StructuredQName getFunctionQName() {
+        return new StructuredQName("efx", "http://test/saxon/ext";, "simple");
+    }
+
+    @Override
+    public ExtensionFunctionCall makeCallExpression() {
+        return new ExtensionFunctionCall() {
+
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public Sequence<?> call(XPathContext xPathContext, Sequence[] 
sequences) throws XPathException {
+                // get value of first arg passed to the function
+                Item<?> arg1 = sequences[0].head();
+                String arg1Val = arg1.getStringValue();
+
+                // return a altered version of the first arg
+                return new StringValue("arg1[" + arg1Val + "]");
+            }
+        };
+    }
+}
diff --git a/integration-tests/saxon/src/main/resources/application.properties 
b/integration-tests/saxon/src/main/resources/application.properties
new file mode 100644
index 0000000..f3e342d
--- /dev/null
+++ b/integration-tests/saxon/src/main/resources/application.properties
@@ -0,0 +1,17 @@
+## ---------------------------------------------------------------------------
+## 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 = *.txt,*.xquery
diff --git a/integration-tests/saxon/src/main/resources/myxquery.txt 
b/integration-tests/saxon/src/main/resources/myxquery.txt
new file mode 100644
index 0000000..f583d99
--- /dev/null
+++ b/integration-tests/saxon/src/main/resources/myxquery.txt
@@ -0,0 +1 @@
+/person/@city
\ No newline at end of file
diff --git a/integration-tests/saxon/src/main/resources/transform.xquery 
b/integration-tests/saxon/src/main/resources/transform.xquery
new file mode 100644
index 0000000..655450e
--- /dev/null
+++ b/integration-tests/saxon/src/main/resources/transform.xquery
@@ -0,0 +1,3 @@
+<transformed subject="{mail/subject}">
+{.}
+</transformed>
\ No newline at end of file
diff --git 
a/integration-tests/saxon/src/main/resources/transformWithExtension.xquery 
b/integration-tests/saxon/src/main/resources/transformWithExtension.xquery
new file mode 100644
index 0000000..dff3ece
--- /dev/null
+++ b/integration-tests/saxon/src/main/resources/transformWithExtension.xquery
@@ -0,0 +1,6 @@
+xquery version "1.0" encoding "UTF-8";
+
+(: the prefix declaration for our custom extension :)
+declare namespace efx = "http://test/saxon/ext";;
+
+<transformed extension-function-render="{efx:simple(/body/text())}" />
\ No newline at end of file
diff --git 
a/extensions-jvm/saxon/integration-test/src/test/java/org/apache/camel/quarkus/component/saxon/it/SaxonTest.java
 
b/integration-tests/saxon/src/test/java/org/apache/camel/quarkus/component/saxon/it/SaxonIT.java
similarity index 60%
rename from 
extensions-jvm/saxon/integration-test/src/test/java/org/apache/camel/quarkus/component/saxon/it/SaxonTest.java
rename to 
integration-tests/saxon/src/test/java/org/apache/camel/quarkus/component/saxon/it/SaxonIT.java
index 6f61d02..0a0a9b3 100644
--- 
a/extensions-jvm/saxon/integration-test/src/test/java/org/apache/camel/quarkus/component/saxon/it/SaxonTest.java
+++ 
b/integration-tests/saxon/src/test/java/org/apache/camel/quarkus/component/saxon/it/SaxonIT.java
@@ -16,27 +16,9 @@
  */
 package org.apache.camel.quarkus.component.saxon.it;
 
-import io.quarkus.test.junit.QuarkusTest;
-import io.restassured.RestAssured;
-import org.junit.jupiter.api.Test;
+import io.quarkus.test.junit.NativeImageTest;
 
-@QuarkusTest
-class SaxonTest {
-
-    @Test
-    public void loadComponentXquery() {
-        /* A simple autogenerated test */
-        RestAssured.get("/saxon/load/component/xquery")
-                .then()
-                .statusCode(200);
-    }
-
-    @Test
-    public void loadLanguageXquery() {
-        /* A simple autogenerated test */
-        RestAssured.get("/saxon/load/language/xquery")
-                .then()
-                .statusCode(200);
-    }
+@NativeImageTest
+class SaxonIT extends SaxonTest {
 
 }
diff --git 
a/integration-tests/saxon/src/test/java/org/apache/camel/quarkus/component/saxon/it/SaxonTest.java
 
b/integration-tests/saxon/src/test/java/org/apache/camel/quarkus/component/saxon/it/SaxonTest.java
new file mode 100644
index 0000000..3800743
--- /dev/null
+++ 
b/integration-tests/saxon/src/test/java/org/apache/camel/quarkus/component/saxon/it/SaxonTest.java
@@ -0,0 +1,70 @@
+/*
+ * 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.saxon.it;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+
+import io.quarkus.test.junit.QuarkusTest;
+import org.junit.jupiter.api.Test;
+
+import static io.restassured.RestAssured.given;
+import static org.apache.commons.io.IOUtils.resourceToString;
+import static org.hamcrest.Matchers.is;
+
+@QuarkusTest
+class SaxonTest {
+
+    @Test
+    public void xqueyrFilterShouldMatchJames() {
+        String xml = "<person name='James' city='London'/>";
+        
given().body(xml).get("/xquery/filter").then().statusCode(200).body(is("JAMES"));
+    }
+
+    @Test
+    public void xqueryTransformShouldConcatEmployeeIdAndSuffix() throws 
IOException {
+        String xml = resourceToString("/myinput.xml", StandardCharsets.UTF_8);
+        
given().body(xml).get("/xquery/transform").then().statusCode(200).body(is("123Suffix"));
+    }
+
+    @Test
+    public void xqueryFromResourceShouldReturnLondon() {
+        String xml = "<person name='James' city='London'/>";
+        
given().body(xml).get("/xquery/resource").then().statusCode(200).body(is("London"));
+    }
+
+    @Test
+    public void produceToXQueryComponentShouldTransformMessage() {
+        String expectedXml = "<transformed 
subject=\"Hey\"><mail><subject>Hey</subject><body>Hello 
world!</body></mail></transformed>";
+        String xml = "<mail><subject>Hey</subject><body>Hello 
world!</body></mail>";
+        
given().body(xml).get("/xquery/produce").then().statusCode(200).body(is(expectedXml));
+    }
+
+    @Test
+    public void customExtensionShouldTransformMessage() {
+        String expectedXml = "<transformed 
extension-function-render=\"arg1[test]\"/>";
+        String xml = "<body>test</body>";
+        
given().body(xml).get("/xquery/extension").then().statusCode(200).body(is(expectedXml));
+    }
+
+    @Test
+    public void xqueryAnnotationOnBeanParameterShouldExtractFooId() {
+        String expected = "Foo id is 'bar'";
+        String xml = "<foo id='bar'>hello</foo>";
+        
given().body(xml).get("/xquery/bean").then().statusCode(200).body(is(expected));
+    }
+}
diff --git a/extensions-jvm/saxon/pom.xml 
b/integration-tests/saxon/src/test/resources/myinput.xml
similarity index 52%
rename from extensions-jvm/saxon/pom.xml
rename to integration-tests/saxon/src/test/resources/myinput.xml
index df860b2..d7ca32e 100644
--- a/extensions-jvm/saxon/pom.xml
+++ b/integration-tests/saxon/src/test/resources/myinput.xml
@@ -17,22 +17,11 @@
     limitations under the License.
 
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>org.apache.camel.quarkus</groupId>
-        <artifactId>camel-quarkus-build-parent</artifactId>
-        <version>1.9.0-SNAPSHOT</version>
-        <relativePath>../../poms/build-parent/pom.xml</relativePath>
-    </parent>
-
-    <artifactId>camel-quarkus-saxon-parent</artifactId>
-    <name>Camel Quarkus :: XQuery</name>
-    <packaging>pom</packaging>
-
-    <modules>
-        <module>deployment</module>
-        <module>runtime</module>
-        <module>integration-test</module>
-    </modules>
-</project>
+<Envelope>
+  <Header/>
+  <Body>
+    <getEmployee>
+      <EmpId>123</EmpId>
+    </getEmployee>
+  </Body>
+</Envelope>
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index b3211bc..82a2cef 100644
--- a/pom.xml
+++ b/pom.xml
@@ -453,6 +453,7 @@
                             <exclude>**/*.proto</exclude>
                             <exclude>**/*.spec</exclude>
                             <exclude>**/*.txt</exclude>
+                            <exclude>**/*.xquery</exclude>
                             <exclude>**/.factorypath</exclude>
                             <exclude>**/.pnp.js</exclude>
                             <exclude>**/.yarnrc.yml</exclude>
diff --git a/tooling/scripts/test-categories.yaml 
b/tooling/scripts/test-categories.yaml
index c796d9d..b98b8f8 100644
--- a/tooling/scripts/test-categories.yaml
+++ b/tooling/scripts/test-categories.yaml
@@ -119,6 +119,7 @@ group-08:
   - dozer
   - master
   - pdf
+  - saxon
   - syndication
   - telegram
   - tika

Reply via email to