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

aldettinger 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 78b45f4  xpath: Fixed native issue and completed tests/documentation 
#2547
78b45f4 is described below

commit 78b45f44b9ad0580783dec00a2eafe80f7442efe
Author: aldettinger <[email protected]>
AuthorDate: Tue May 4 16:09:54 2021 +0200

    xpath: Fixed native issue and completed tests/documentation #2547
---
 .../ROOT/pages/reference/extensions/xpath.adoc     |  19 +++
 .../component/xpath/deployment/XPathProcessor.java |  50 ++++++++
 .../xpath/runtime/src/main/doc/configuration.adoc  |  15 +++
 integration-tests/pom.xml                          |   1 +
 integration-tests/xpath/pom.xml                    | 134 +++++++++++++++++++++
 .../camel/quarkus/language/xpath/PriceBean.java    |  28 +++--
 .../quarkus/language/xpath/XPathResource.java      | 105 ++++++++++++++++
 .../camel/quarkus/language/xpath/XPathRoutes.java  |  50 ++++++++
 .../src/main/resources/application.properties      |  20 +++
 .../xpath/src/main/resources/myxpath.txt           |   1 +
 .../camel/quarkus/language/xpath/XPathIT.java      |  21 +---
 .../camel/quarkus/language/xpath/XPathTest.java    |  80 ++++++++++++
 .../xpath/src/test/resources/students.xml          |  27 +++++
 tooling/scripts/test-categories.yaml               |   1 +
 14 files changed, 522 insertions(+), 30 deletions(-)

diff --git a/docs/modules/ROOT/pages/reference/extensions/xpath.adoc 
b/docs/modules/ROOT/pages/reference/extensions/xpath.adoc
index 3ea6f04..101594d 100644
--- a/docs/modules/ROOT/pages/reference/extensions/xpath.adoc
+++ b/docs/modules/ROOT/pages/reference/extensions/xpath.adoc
@@ -38,3 +38,22 @@ Or add the coordinates to your existing project:
 ----
 
 Check the xref:user-guide/index.adoc[User guide] for more information about 
writing Camel Quarkus applications.
+
+== Additional Camel Quarkus configuration
+
+Beyond standard usages, a trick is needed when using the xpath language 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 route below would load an xpath script from a classpath 
resource named _myxpath.txt_:
+[source,java]
+----
+from("direct:start").transform().xpath("resource:classpath:myxpath.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/extensions/xpath/deployment/src/main/java/org/apache/camel/quarkus/component/xpath/deployment/XPathProcessor.java
 
b/extensions/xpath/deployment/src/main/java/org/apache/camel/quarkus/component/xpath/deployment/XPathProcessor.java
index 6be188b..8290706 100644
--- 
a/extensions/xpath/deployment/src/main/java/org/apache/camel/quarkus/component/xpath/deployment/XPathProcessor.java
+++ 
b/extensions/xpath/deployment/src/main/java/org/apache/camel/quarkus/component/xpath/deployment/XPathProcessor.java
@@ -16,13 +16,55 @@
  */
 package org.apache.camel.quarkus.component.xpath.deployment;
 
+import io.quarkus.deployment.annotations.BuildProducer;
 import io.quarkus.deployment.annotations.BuildStep;
 import io.quarkus.deployment.builditem.FeatureBuildItem;
 import io.quarkus.deployment.builditem.SystemPropertyBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
+import org.jboss.logging.Logger;
 
 class XPathProcessor {
 
     private static final String FEATURE = "camel-xpath";
+    private static final Logger LOG = Logger.getLogger(XPathProcessor.class);
+    private static final String[] CORE_XPATH_FUNCTION_CLASSES = new String[] {
+            "com.sun.org.apache.xpath.internal.functions.FuncBoolean",
+            "com.sun.org.apache.xpath.internal.functions.FuncCeiling",
+            "com.sun.org.apache.xpath.internal.functions.FuncConcat",
+            "com.sun.org.apache.xpath.internal.functions.FuncContains",
+            "com.sun.org.apache.xpath.internal.functions.FuncCount",
+            "com.sun.org.apache.xpath.internal.functions.FuncCurrent",
+            "com.sun.org.apache.xpath.internal.functions.FuncDoclocation",
+            
"com.sun.org.apache.xpath.internal.functions.FuncExtElementAvailable",
+            "com.sun.org.apache.xpath.internal.functions.FuncExtFunction",
+            
"com.sun.org.apache.xpath.internal.functions.FuncExtFunctionAvailable",
+            "com.sun.org.apache.xpath.internal.functions.FuncFalse",
+            "com.sun.org.apache.xpath.internal.functions.FuncFloor",
+            "com.sun.org.apache.xpath.internal.functions.FuncGenerateId",
+            "com.sun.org.apache.xpath.internal.functions.FuncHere",
+            "com.sun.org.apache.xpath.internal.functions.FuncId",
+            "com.sun.org.apache.xpath.internal.functions.FuncLang",
+            "com.sun.org.apache.xpath.internal.functions.FuncLast",
+            "com.sun.org.apache.xpath.internal.functions.FuncLocalPart",
+            "com.sun.org.apache.xpath.internal.functions.FuncNamespace",
+            "com.sun.org.apache.xpath.internal.functions.FuncNormalizeSpace",
+            "com.sun.org.apache.xpath.internal.functions.FuncNot",
+            "com.sun.org.apache.xpath.internal.functions.FuncNumber",
+            "com.sun.org.apache.xpath.internal.functions.FuncPosition",
+            "com.sun.org.apache.xpath.internal.functions.FuncQname",
+            "com.sun.org.apache.xpath.internal.functions.FuncRound",
+            "com.sun.org.apache.xpath.internal.functions.FuncStartsWith",
+            "com.sun.org.apache.xpath.internal.functions.FuncString",
+            "com.sun.org.apache.xpath.internal.functions.FuncStringLength",
+            "com.sun.org.apache.xpath.internal.functions.FuncSubstring",
+            "com.sun.org.apache.xpath.internal.functions.FuncSubstringAfter",
+            "com.sun.org.apache.xpath.internal.functions.FuncSubstringBefore",
+            "com.sun.org.apache.xpath.internal.functions.FuncSum",
+            "com.sun.org.apache.xpath.internal.functions.FuncSystemProperty",
+            "com.sun.org.apache.xpath.internal.functions.FuncTranslate",
+            "com.sun.org.apache.xpath.internal.functions.FuncTrue",
+            "com.sun.org.apache.xpath.internal.functions.FuncUnparsedEntityURI"
+    };
 
     @BuildStep
     FeatureBuildItem feature() {
@@ -34,4 +76,12 @@ class XPathProcessor {
         // See https://issues.apache.org/jira/browse/XALANJ-2540
         return new SystemPropertyBuildItem("org.apache.xml.dtm.DTMManager", 
"org.apache.xml.dtm.ref.DTMManagerDefault");
     }
+
+    @BuildStep
+    void 
registerCoreXPathFunctionsAsReflective(BuildProducer<ReflectiveClassBuildItem> 
producer) {
+        for (String coreXPathFunctionClass : CORE_XPATH_FUNCTION_CLASSES) {
+            LOG.debugf("Registerering core XPath function class '%s' as 
reflective", coreXPathFunctionClass);
+            producer.produce(new ReflectiveClassBuildItem(false, false, 
coreXPathFunctionClass));
+        }
+    }
 }
diff --git a/extensions/xpath/runtime/src/main/doc/configuration.adoc 
b/extensions/xpath/runtime/src/main/doc/configuration.adoc
new file mode 100644
index 0000000..2d65305
--- /dev/null
+++ b/extensions/xpath/runtime/src/main/doc/configuration.adoc
@@ -0,0 +1,15 @@
+Beyond standard usages, a trick is needed when using the xpath language 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 route below would load an xpath script from a classpath 
resource named _myxpath.txt_:
+[source,java]
+----
+from("direct:start").transform().xpath("resource:classpath:myxpath.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/integration-tests/pom.xml b/integration-tests/pom.xml
index 67d6459..4afb05f 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -215,6 +215,7 @@
         <module>xchange</module>
         <module>xml</module>
         <module>xmlsecurity</module>
+        <module>xpath</module>
         <module>xstream</module>
         <module>zendesk</module>
     </modules>
diff --git a/integration-tests/xpath/pom.xml b/integration-tests/xpath/pom.xml
new file mode 100644
index 0000000..a0a3f6b
--- /dev/null
+++ b/integration-tests/xpath/pom.xml
@@ -0,0 +1,134 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<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";>
+    <parent>
+        <groupId>org.apache.camel.quarkus</groupId>
+        <artifactId>camel-quarkus-integration-tests</artifactId>
+        <version>1.9.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>camel-quarkus-integration-test-xpath</artifactId>
+    <name>Camel Quarkus :: Integration Tests :: XPath</name>
+    <description>The camel quarkus integration tests for the XPath 
language</description>
+
+    <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-xpath</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.quarkus</groupId>
+            <artifactId>quarkus-resteasy</artifactId>
+        </dependency>
+
+        <!-- test dependencies -->
+        <dependency>
+            <groupId>io.quarkus</groupId>
+            <artifactId>quarkus-junit5</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>io.rest-assured</groupId>
+            <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-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-xpath-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>
+    </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/xpath/deployment/src/main/java/org/apache/camel/quarkus/component/xpath/deployment/XPathProcessor.java
 
b/integration-tests/xpath/src/main/java/org/apache/camel/quarkus/language/xpath/PriceBean.java
similarity index 55%
copy from 
extensions/xpath/deployment/src/main/java/org/apache/camel/quarkus/component/xpath/deployment/XPathProcessor.java
copy to 
integration-tests/xpath/src/main/java/org/apache/camel/quarkus/language/xpath/PriceBean.java
index 6be188b..9c93995 100644
--- 
a/extensions/xpath/deployment/src/main/java/org/apache/camel/quarkus/component/xpath/deployment/XPathProcessor.java
+++ 
b/integration-tests/xpath/src/main/java/org/apache/camel/quarkus/language/xpath/PriceBean.java
@@ -14,24 +14,26 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.quarkus.component.xpath.deployment;
+package org.apache.camel.quarkus.language.xpath;
 
-import io.quarkus.deployment.annotations.BuildStep;
-import io.quarkus.deployment.builditem.FeatureBuildItem;
-import io.quarkus.deployment.builditem.SystemPropertyBuildItem;
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Named;
 
-class XPathProcessor {
+import io.quarkus.runtime.annotations.RegisterForReflection;
+import org.apache.camel.language.xpath.XPath;
 
-    private static final String FEATURE = "camel-xpath";
+@Named("priceBean")
+@ApplicationScoped
+@RegisterForReflection(fields = false)
+public class PriceBean {
 
-    @BuildStep
-    FeatureBuildItem feature() {
-        return new FeatureBuildItem(FEATURE);
+    private String price;
+
+    public String getPrice() {
+        return price;
     }
 
-    @BuildStep
-    SystemPropertyBuildItem xpathSystemProperties() {
-        // See https://issues.apache.org/jira/browse/XALANJ-2540
-        return new SystemPropertyBuildItem("org.apache.xml.dtm.DTMManager", 
"org.apache.xml.dtm.ref.DTMManagerDefault");
+    public void read(@XPath("/soap:Envelope/soap:Body/price/text()") String 
price) {
+        this.price = price + ".0€";
     }
 }
diff --git 
a/integration-tests/xpath/src/main/java/org/apache/camel/quarkus/language/xpath/XPathResource.java
 
b/integration-tests/xpath/src/main/java/org/apache/camel/quarkus/language/xpath/XPathResource.java
new file mode 100644
index 0000000..82fca52
--- /dev/null
+++ 
b/integration-tests/xpath/src/main/java/org/apache/camel/quarkus/language/xpath/XPathResource.java
@@ -0,0 +1,105 @@
+/*
+ * 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.language.xpath;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+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("/xpath")
+@ApplicationScoped
+public class XPathResource {
+
+    @Inject
+    ProducerTemplate template;
+
+    @Inject
+    @Named("priceBean")
+    PriceBean priceBean;
+
+    @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("/choice")
+    @GET
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public String choice(String xml) {
+        return template.requestBody("direct:choice", xml, String.class);
+    }
+
+    @Path("/coreXPathFunctions")
+    @GET
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public String coreXPathFunctions(String xml) {
+        return template.requestBody("direct:coreXPathFunctions", xml, 
String.class);
+    }
+
+    @Path("/camelXPathFunctions")
+    @GET
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public String camelXPathFunctions(String fooHeaderValue) {
+        return template.requestBodyAndHeader("direct:camelXPathFunctions", 
null, "foo", fooHeaderValue, 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("/annotation")
+    @GET
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public String annotation(String xml) {
+        template.requestBody("direct:annotation", xml, String.class);
+        return priceBean.getPrice();
+    }
+
+    @Path("/properties")
+    @GET
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public String properties(String typeHeaderValue) {
+        return template.requestBodyAndHeader("direct:properties", null, 
"type", typeHeaderValue, String.class);
+    }
+
+    @Path("/simple")
+    @GET
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public String simple(String xml) {
+        return template.requestBody("direct:simple", xml, String.class);
+    }
+}
diff --git 
a/integration-tests/xpath/src/main/java/org/apache/camel/quarkus/language/xpath/XPathRoutes.java
 
b/integration-tests/xpath/src/main/java/org/apache/camel/quarkus/language/xpath/XPathRoutes.java
new file mode 100644
index 0000000..d3b4139
--- /dev/null
+++ 
b/integration-tests/xpath/src/main/java/org/apache/camel/quarkus/language/xpath/XPathRoutes.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.language.xpath;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.camel.builder.RouteBuilder;
+
+@ApplicationScoped
+public class XPathRoutes extends RouteBuilder {
+
+    @Inject
+    @Named("priceBean")
+    PriceBean priceBean;
+
+    @Override
+    public void configure() {
+        
from("direct:transform").transform().xpath("//students/student/name/text()");
+
+        
from("direct:choice").choice().when().xpath("/body[@id='a']").setBody(constant("A"));
+
+        
from("direct:coreXPathFunctions").transform().xpath("concat('foo-',//person/@name)",
 String.class);
+
+        
from("direct:camelXPathFunctions").choice().when().xpath("in:header('foo') = 
'bar'").setBody(constant("BAR"));
+
+        
from("direct:resource").transform().xpath("resource:classpath:myxpath.txt");
+
+        from("direct:annotation").transform().method(priceBean, "read");
+
+        from("direct:properties").choice().when().xpath("$type = 
function:properties('foo')").setBody(constant("FOO"));
+
+        from("direct:simple").choice().when().xpath("//name = 
function:simple('{{bar}}')").setBody(constant("BAR"));
+    }
+}
diff --git a/integration-tests/xpath/src/main/resources/application.properties 
b/integration-tests/xpath/src/main/resources/application.properties
new file mode 100644
index 0000000..0651d9e
--- /dev/null
+++ b/integration-tests/xpath/src/main/resources/application.properties
@@ -0,0 +1,20 @@
+## ---------------------------------------------------------------------------
+## 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
+
+foo = Camel
+bar = Kong
\ No newline at end of file
diff --git a/integration-tests/xpath/src/main/resources/myxpath.txt 
b/integration-tests/xpath/src/main/resources/myxpath.txt
new file mode 100644
index 0000000..3e3440a
--- /dev/null
+++ b/integration-tests/xpath/src/main/resources/myxpath.txt
@@ -0,0 +1 @@
+/person/name/text()
\ No newline at end of file
diff --git 
a/extensions/xpath/deployment/src/main/java/org/apache/camel/quarkus/component/xpath/deployment/XPathProcessor.java
 
b/integration-tests/xpath/src/test/java/org/apache/camel/quarkus/language/xpath/XPathIT.java
similarity index 54%
copy from 
extensions/xpath/deployment/src/main/java/org/apache/camel/quarkus/component/xpath/deployment/XPathProcessor.java
copy to 
integration-tests/xpath/src/test/java/org/apache/camel/quarkus/language/xpath/XPathIT.java
index 6be188b..5b8aace 100644
--- 
a/extensions/xpath/deployment/src/main/java/org/apache/camel/quarkus/component/xpath/deployment/XPathProcessor.java
+++ 
b/integration-tests/xpath/src/test/java/org/apache/camel/quarkus/language/xpath/XPathIT.java
@@ -14,24 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.quarkus.component.xpath.deployment;
+package org.apache.camel.quarkus.language.xpath;
 
-import io.quarkus.deployment.annotations.BuildStep;
-import io.quarkus.deployment.builditem.FeatureBuildItem;
-import io.quarkus.deployment.builditem.SystemPropertyBuildItem;
+import io.quarkus.test.junit.NativeImageTest;
 
-class XPathProcessor {
+@NativeImageTest
+public class XPathIT extends XPathTest {
 
-    private static final String FEATURE = "camel-xpath";
-
-    @BuildStep
-    FeatureBuildItem feature() {
-        return new FeatureBuildItem(FEATURE);
-    }
-
-    @BuildStep
-    SystemPropertyBuildItem xpathSystemProperties() {
-        // See https://issues.apache.org/jira/browse/XALANJ-2540
-        return new SystemPropertyBuildItem("org.apache.xml.dtm.DTMManager", 
"org.apache.xml.dtm.ref.DTMManagerDefault");
-    }
 }
diff --git 
a/integration-tests/xpath/src/test/java/org/apache/camel/quarkus/language/xpath/XPathTest.java
 
b/integration-tests/xpath/src/test/java/org/apache/camel/quarkus/language/xpath/XPathTest.java
new file mode 100644
index 0000000..8eac7d2
--- /dev/null
+++ 
b/integration-tests/xpath/src/test/java/org/apache/camel/quarkus/language/xpath/XPathTest.java
@@ -0,0 +1,80 @@
+/*
+ * 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.language.xpath;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+
+import io.quarkus.test.junit.QuarkusTest;
+import org.apache.commons.io.IOUtils;
+import org.junit.jupiter.api.Test;
+
+import static io.restassured.RestAssured.given;
+import static org.hamcrest.Matchers.is;
+
+@QuarkusTest
+public class XPathTest {
+
+    @Test
+    public void transformShouldSucceed() throws IOException {
+        String xml = 
IOUtils.toString(XPathTest.class.getResourceAsStream("/students.xml"), 
StandardCharsets.UTF_8);
+        
given().body(xml).when().get("/xpath/transform").then().statusCode(200).body(is("ClausHadrian"));
+    }
+
+    @Test
+    public void whenPredicateShouldMatchWhenIdHasValueA() {
+        String xml = "<body id='a'/>";
+        
given().body(xml).when().get("/xpath/choice").then().statusCode(200).body(is("A"));
+    }
+
+    @Test
+    public void concatCoreXPathFunctionShouldPrependFooBeforeMonica() {
+        String xml = "<person name='Monica'/>";
+        
given().body(xml).when().get("/xpath/coreXPathFunctions").then().statusCode(200).body(is("foo-Monica"));
+    }
+
+    @Test
+    public void headerCamelXPathFunctionShouldMatchFooHeaderWhenValueIsBar() {
+        String fooHeader = "bar";
+        
given().body(fooHeader).when().get("/xpath/camelXPathFunctions").then().statusCode(200).body(is("BAR"));
+    }
+
+    @Test
+    public void xpathLoadedFromResourceShouldSucceed() {
+        String xml = "<person><name>Caroline</name></person>";
+        
given().body(xml).when().get("/xpath/resource").then().statusCode(200).body(is("Caroline"));
+    }
+
+    @Test
+    public void 
xpathAnnotationAppliedOnPriceBeanMethodParameterShouldSucceed() {
+        String xml = "<env:Envelope 
xmlns:env='http://www.w3.org/2003/05/soap-envelope'><env:Body><price>38</price></env:Body></env:Envelope>";
+        
given().body(xml).when().get("/xpath/annotation").then().statusCode(200).body(is("38.0€"));
+    }
+
+    @Test
+    public void 
xpathWithPropertiesFunctionShouldMatchWhenTypeHeaderHasValueCamel() {
+        String typeHeaderValue = "Camel";
+        
given().body(typeHeaderValue).when().get("/xpath/properties").then().statusCode(200).body(is("FOO"));
+    }
+
+    @Test
+    public void 
xpathWithSimpleFunctionEvaluatingBarPropertyShouldMatchWhenNameIsKong() {
+        String xml = "<name>Kong</name>";
+        
given().body(xml).when().get("/xpath/simple").then().statusCode(200).body(is("BAR"));
+    }
+
+}
diff --git a/integration-tests/xpath/src/test/resources/students.xml 
b/integration-tests/xpath/src/test/resources/students.xml
new file mode 100644
index 0000000..7740a89
--- /dev/null
+++ b/integration-tests/xpath/src/test/resources/students.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<students>
+    <student>
+        <name>Claus</name>
+    </student>
+    <student>
+        <name>Hadrian</name>
+    </student>
+</students>
\ No newline at end of file
diff --git a/tooling/scripts/test-categories.yaml 
b/tooling/scripts/test-categories.yaml
index 5cd8b71..49099ca 100644
--- a/tooling/scripts/test-categories.yaml
+++ b/tooling/scripts/test-categories.yaml
@@ -137,6 +137,7 @@ group-09:
   - splunk
   - spring-rabbitmq
   - xchange
+  - xpath
 group-10:
   - as2
   - atlasmap

Reply via email to