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

jamesnetherton 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 7b07220  XChange native support
7b07220 is described below

commit 7b07220aa680aa00a2dd8d826abeb23dcbc7936a
Author: James Netherton <jamesnether...@gmail.com>
AuthorDate: Fri Apr 30 14:39:30 2021 +0100

    XChange native support
    
    Fixes #769
---
 .../ROOT/pages/reference/extensions/xchange.adoc   |  20 +++-
 .../partials/reference/components/xchange.adoc     |   6 +-
 extensions-jvm/pom.xml                             |   1 -
 .../xchange/deployment/XchangeProcessor.java       |  46 --------
 .../component/xchange/it/XchangeResource.java      |  51 --------
 extensions/pom.xml                                 |   1 +
 .../xchange/deployment/pom.xml                     |   4 +
 .../xchange/deployment/XchangeProcessor.java       | 128 +++++++++++++++++++++
 {extensions-jvm => extensions}/xchange/pom.xml     |   1 -
 .../xchange/runtime/pom.xml                        |  20 ++++
 .../graal/AnnotationUtilsSubstitutions.java        |  42 +++++++
 .../main/resources/META-INF/quarkus-extension.yaml |   3 +-
 integration-tests/pom.xml                          |   1 +
 .../xchange}/pom.xml                               |  47 +++++++-
 .../component/xchange/it/XchangeResource.java      | 104 +++++++++++++++++
 .../quarkus/component/xchange/it/XchangeIT.java    |  16 +--
 .../quarkus/component/xchange/it/XchangeTest.java  |  84 ++++++++++++++
 pom.xml                                            |   1 +
 poms/bom-test/pom.xml                              |   5 +
 tooling/scripts/test-categories.yaml               |   1 +
 20 files changed, 456 insertions(+), 126 deletions(-)

diff --git a/docs/modules/ROOT/pages/reference/extensions/xchange.adoc 
b/docs/modules/ROOT/pages/reference/extensions/xchange.adoc
index 25b9966..35e17e0 100644
--- a/docs/modules/ROOT/pages/reference/extensions/xchange.adoc
+++ b/docs/modules/ROOT/pages/reference/extensions/xchange.adoc
@@ -3,16 +3,16 @@
 = XChange
 :linkattrs:
 :cq-artifact-id: camel-quarkus-xchange
-:cq-native-supported: false
-:cq-status: Preview
-:cq-status-deprecation: Preview
+:cq-native-supported: true
+:cq-status: Stable
+:cq-status-deprecation: Stable
 :cq-description: Access market data and trade on Bitcoin and Altcoin exchanges.
 :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##
 
 Access market data and trade on Bitcoin and Altcoin exchanges.
 
@@ -24,6 +24,10 @@ Please refer to the above link for usage and configuration 
details.
 
 == Maven coordinates
 
+https://code.quarkus.io/?extension-search=camel-quarkus-xchange[Create a new 
project with this extension on code.quarkus.io, window="_blank"]
+
+Or add the coordinates to your existing project:
+
 [source,xml]
 ----
 <dependency>
@@ -33,3 +37,9 @@ 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.
+
+== SSL in native mode
+
+This extension auto-enables SSL support in native mode. Hence you do not need 
to add
+`quarkus.ssl.native=true` to your `application.properties` yourself. See also
+https://quarkus.io/guides/native-and-ssl[Quarkus SSL guide].
diff --git a/docs/modules/ROOT/partials/reference/components/xchange.adoc 
b/docs/modules/ROOT/partials/reference/components/xchange.adoc
index 03e585b..136216f 100644
--- a/docs/modules/ROOT/partials/reference/components/xchange.adoc
+++ b/docs/modules/ROOT/partials/reference/components/xchange.adoc
@@ -2,11 +2,11 @@
 // This file was generated by 
camel-quarkus-maven-plugin:update-extension-doc-page
 :cq-artifact-id: camel-quarkus-xchange
 :cq-artifact-id-base: xchange
-: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: xchange
 :cq-camel-part-title: XChange
 :cq-camel-part-description: Access market data and trade on Bitcoin and 
Altcoin exchanges.
diff --git a/extensions-jvm/pom.xml b/extensions-jvm/pom.xml
index b4c3b64..c8e7c6c 100644
--- a/extensions-jvm/pom.xml
+++ b/extensions-jvm/pom.xml
@@ -117,7 +117,6 @@
         <module>weka</module>
         <module>wordpress</module>
         <module>workday</module>
-        <module>xchange</module>
         <module>xj</module>
         <module>xmpp</module>
         <module>xslt-saxon</module>
diff --git 
a/extensions-jvm/xchange/deployment/src/main/java/org/apache/camel/quarkus/component/xchange/deployment/XchangeProcessor.java
 
b/extensions-jvm/xchange/deployment/src/main/java/org/apache/camel/quarkus/component/xchange/deployment/XchangeProcessor.java
deleted file mode 100644
index 55be8f1..0000000
--- 
a/extensions-jvm/xchange/deployment/src/main/java/org/apache/camel/quarkus/component/xchange/deployment/XchangeProcessor.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.xchange.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 XchangeProcessor {
-
-    private static final Logger LOG = Logger.getLogger(XchangeProcessor.class);
-    private static final String FEATURE = "camel-xchange";
-
-    @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/xchange/integration-test/src/main/java/org/apache/camel/quarkus/component/xchange/it/XchangeResource.java
 
b/extensions-jvm/xchange/integration-test/src/main/java/org/apache/camel/quarkus/component/xchange/it/XchangeResource.java
deleted file mode 100644
index 9ec3ceb..0000000
--- 
a/extensions-jvm/xchange/integration-test/src/main/java/org/apache/camel/quarkus/component/xchange/it/XchangeResource.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.xchange.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("/xchange")
-@ApplicationScoped
-public class XchangeResource {
-
-    private static final Logger LOG = Logger.getLogger(XchangeResource.class);
-
-    private static final String COMPONENT_XCHANGE = "xchange";
-    @Inject
-    CamelContext context;
-
-    @Path("/load/component/xchange")
-    @GET
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response loadComponentXchange() throws Exception {
-        /* This is an autogenerated test */
-        if (context.getComponent(COMPONENT_XCHANGE) != null) {
-            return Response.ok().build();
-        }
-        LOG.warnf("Could not load [%s] from the Camel context", 
COMPONENT_XCHANGE);
-        return Response.status(500, COMPONENT_XCHANGE + " could not be loaded 
from the Camel context").build();
-    }
-}
diff --git a/extensions/pom.xml b/extensions/pom.xml
index f53e710..86ca807 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -234,6 +234,7 @@
         <module>vertx-websocket</module>
         <module>vm</module>
         <module>weather</module>
+        <module>xchange</module>
         <module>xmlsecurity</module>
         <module>xpath</module>
         <module>xslt</module>
diff --git a/extensions-jvm/xchange/deployment/pom.xml 
b/extensions/xchange/deployment/pom.xml
similarity index 94%
rename from extensions-jvm/xchange/deployment/pom.xml
rename to extensions/xchange/deployment/pom.xml
index 0e38075..15a8e66 100644
--- a/extensions-jvm/xchange/deployment/pom.xml
+++ b/extensions/xchange/deployment/pom.xml
@@ -31,6 +31,10 @@
 
     <dependencies>
         <dependency>
+            <groupId>io.quarkus</groupId>
+            <artifactId>quarkus-jackson-deployment</artifactId>
+        </dependency>
+        <dependency>
             <groupId>org.apache.camel.quarkus</groupId>
             <artifactId>camel-quarkus-core-deployment</artifactId>
         </dependency>
diff --git 
a/extensions/xchange/deployment/src/main/java/org/apache/camel/quarkus/component/xchange/deployment/XchangeProcessor.java
 
b/extensions/xchange/deployment/src/main/java/org/apache/camel/quarkus/component/xchange/deployment/XchangeProcessor.java
new file mode 100644
index 0000000..c20fc90
--- /dev/null
+++ 
b/extensions/xchange/deployment/src/main/java/org/apache/camel/quarkus/component/xchange/deployment/XchangeProcessor.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.xchange.deployment;
+
+import java.lang.reflect.Modifier;
+import java.util.List;
+
+import io.quarkus.bootstrap.model.AppArtifact;
+import io.quarkus.bootstrap.model.AppDependency;
+import io.quarkus.deployment.annotations.BuildProducer;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
+import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem;
+import io.quarkus.deployment.builditem.FeatureBuildItem;
+import io.quarkus.deployment.builditem.IndexDependencyBuildItem;
+import 
io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem;
+import 
io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
+import io.quarkus.deployment.pkg.builditem.CurateOutcomeBuildItem;
+import org.jboss.jandex.AnnotationInstance;
+import org.jboss.jandex.AnnotationTarget;
+import org.jboss.jandex.ClassInfo;
+import org.jboss.jandex.DotName;
+import org.jboss.jandex.IndexView;
+import org.knowm.xchange.BaseExchange;
+
+class XchangeProcessor {
+
+    private static final String FEATURE = "camel-xchange";
+
+    @BuildStep
+    FeatureBuildItem feature() {
+        return new FeatureBuildItem(FEATURE);
+    }
+
+    @BuildStep
+    ExtensionSslNativeSupportBuildItem activateSslNativeSupport() {
+        return new ExtensionSslNativeSupportBuildItem(FEATURE);
+    }
+
+    @BuildStep
+    void indexDependenciesAndResources(
+            BuildProducer<IndexDependencyBuildItem> indexedDependency,
+            BuildProducer<NativeImageResourceBuildItem> nativeImageResource,
+            CurateOutcomeBuildItem curateOutcome) {
+
+        List<AppDependency> userDependencies = 
curateOutcome.getEffectiveModel().getUserDependencies();
+        for (AppDependency dependency : userDependencies) {
+            AppArtifact artifact = dependency.getArtifact();
+
+            if (artifact.getGroupId().equals("org.knowm.xchange")) {
+                // Index any org.knowm.xchange dependencies present on the 
classpath as they contain the APIs for interacting with each crypto exchange
+                String artifactId = artifact.getArtifactId();
+                indexedDependency.produce(new 
IndexDependencyBuildItem(artifact.getGroupId(), artifactId));
+
+                // Include crypto exchange metadata resources
+                String[] split = artifactId.split("-");
+                if (split.length > 1) {
+                    String cryptoExchange = split[split.length - 1];
+                    nativeImageResource.produce(new 
NativeImageResourceBuildItem(cryptoExchange + ".json"));
+                }
+            }
+        }
+
+        indexedDependency.produce(new 
IndexDependencyBuildItem("org.jboss.spec.javax.ws.rs", 
"jboss-jaxrs-api_2.1_spec"));
+    }
+
+    @BuildStep
+    void registerForReflection(BuildProducer<ReflectiveClassBuildItem> 
reflectiveClass, CombinedIndexBuildItem combinedIndex) {
+        // The xchange component dynamically instantiates Exchange classes so 
they must be registered for reflection
+        IndexView index = combinedIndex.getIndex();
+        String[] xchangeClasses = 
index.getAllKnownSubclasses(DotName.createSimple(BaseExchange.class.getName()))
+                .stream()
+                .map(classInfo -> classInfo.name().toString())
+                .toArray(String[]::new);
+        reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, 
xchangeClasses));
+
+        // DTO classes need to be serialized / deserialized
+        String[] dtoClasses = index.getKnownClasses()
+                .stream()
+                .map(classInfo -> classInfo.name().toString())
+                .filter(className -> 
className.startsWith("org.knowm.xchange.dto"))
+                .toArray(String[]::new);
+        reflectiveClass.produce(new ReflectiveClassBuildItem(false, true, 
dtoClasses));
+
+        // rescu REST framework needs reflective access to the value method on 
some JAX-RS annotations
+        String[] jaxrsAnnotations = index.getKnownClasses()
+                .stream()
+                .filter(ClassInfo::isAnnotation)
+                .filter(classInfo -> classInfo.firstMethod("value") != null)
+                .map(classInfo -> classInfo.name().toString())
+                .filter(className -> className.startsWith("javax.ws.rs"))
+                .toArray(String[]::new);
+        reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, 
jaxrsAnnotations));
+
+    }
+
+    @BuildStep
+    void 
registerProxyClasses(BuildProducer<NativeImageProxyDefinitionBuildItem> 
nativeImageProxy,
+            CombinedIndexBuildItem combinedIndexBuildItem) {
+        // Some xchange libraries use JAX-RS proxies to interact with the 
exchange APIs so we need to register them
+        IndexView index = combinedIndexBuildItem.getIndex();
+        index.getAnnotations(DotName.createSimple("javax.ws.rs.Path"))
+                .stream()
+                .map(AnnotationInstance::target)
+                .filter(target -> 
target.kind().equals(AnnotationTarget.Kind.CLASS))
+                .map(AnnotationTarget::asClass)
+                .filter(classInfo -> Modifier.isInterface(classInfo.flags()))
+                .map(classInfo -> classInfo.name().toString())
+                .filter(className -> className.startsWith("org.knowm.xchange"))
+                .map(NativeImageProxyDefinitionBuildItem::new)
+                .forEach(nativeImageProxy::produce);
+    }
+}
diff --git a/extensions-jvm/xchange/pom.xml b/extensions/xchange/pom.xml
similarity index 97%
rename from extensions-jvm/xchange/pom.xml
rename to extensions/xchange/pom.xml
index 06164a4..b92ad8a 100644
--- a/extensions-jvm/xchange/pom.xml
+++ b/extensions/xchange/pom.xml
@@ -33,6 +33,5 @@
     <modules>
         <module>deployment</module>
         <module>runtime</module>
-        <module>integration-test</module>
     </modules>
 </project>
diff --git a/extensions-jvm/xchange/runtime/pom.xml 
b/extensions/xchange/runtime/pom.xml
similarity index 84%
rename from extensions-jvm/xchange/runtime/pom.xml
rename to extensions/xchange/runtime/pom.xml
index 3365dcc..19041d2 100644
--- a/extensions-jvm/xchange/runtime/pom.xml
+++ b/extensions/xchange/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>
@@ -48,12 +49,31 @@
 
     <dependencies>
         <dependency>
+            <groupId>io.quarkus</groupId>
+            <artifactId>quarkus-jackson</artifactId>
+        </dependency>
+        <dependency>
             <groupId>org.apache.camel.quarkus</groupId>
             <artifactId>camel-quarkus-core</artifactId>
         </dependency>
         <dependency>
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-xchange</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>jakarta.ws.rs</groupId>
+                    <artifactId>jakarta.ws.rs-api</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.spec.javax.ws.rs</groupId>
+            <artifactId>jboss-jaxrs-api_2.1_spec</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.graalvm.nativeimage</groupId>
+            <artifactId>svm</artifactId>
+            <scope>provided</scope>
         </dependency>
     </dependencies>
 
diff --git 
a/extensions/xchange/runtime/src/main/java/org/apache/camel/quarkus/component/xchange/graal/AnnotationUtilsSubstitutions.java
 
b/extensions/xchange/runtime/src/main/java/org/apache/camel/quarkus/component/xchange/graal/AnnotationUtilsSubstitutions.java
new file mode 100644
index 0000000..f3bc432
--- /dev/null
+++ 
b/extensions/xchange/runtime/src/main/java/org/apache/camel/quarkus/component/xchange/graal/AnnotationUtilsSubstitutions.java
@@ -0,0 +1,42 @@
+/*
+ * 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.xchange.graal;
+
+import java.lang.annotation.Annotation;
+
+import com.oracle.svm.core.annotate.Substitute;
+import com.oracle.svm.core.annotate.TargetClass;
+import si.mazi.rescu.AnnotationUtils;
+
+@TargetClass(AnnotationUtils.class)
+public final class AnnotationUtilsSubstitutions {
+
+    // Replaces original impl to avoid reflective actions on proxy classes
+    @Substitute
+    static <T extends Annotation> String getValueOrNull(Class<T> 
annotationClass, Annotation ann) {
+        if (!annotationClass.isInstance(ann)) {
+            return null;
+        }
+
+        try {
+            return (String) annotationClass.getMethod("value").invoke(ann);
+        } catch (Exception e) {
+            throw new RuntimeException(
+                    "Can't access element 'value' in  " + annotationClass + ". 
This is probably a bug in rescu.", e);
+        }
+    }
+}
diff --git 
a/extensions-jvm/xchange/runtime/src/main/resources/META-INF/quarkus-extension.yaml
 b/extensions/xchange/runtime/src/main/resources/META-INF/quarkus-extension.yaml
similarity index 97%
rename from 
extensions-jvm/xchange/runtime/src/main/resources/META-INF/quarkus-extension.yaml
rename to 
extensions/xchange/runtime/src/main/resources/META-INF/quarkus-extension.yaml
index f2ce035..db5c8b6 100644
--- 
a/extensions-jvm/xchange/runtime/src/main/resources/META-INF/quarkus-extension.yaml
+++ 
b/extensions/xchange/runtime/src/main/resources/META-INF/quarkus-extension.yaml
@@ -24,9 +24,8 @@
 name: "Camel XChange"
 description: "Access market data and trade on Bitcoin and Altcoin exchanges"
 metadata:
-  unlisted: true
   guide: 
"https://camel.apache.org/camel-quarkus/latest/reference/extensions/xchange.html";
   categories:
   - "integration"
   status:
-  - "preview"
+  - "stable"
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index dbcdefd..67d6459 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -212,6 +212,7 @@
         <module>vertx-kafka</module>
         <module>vertx-websocket</module>
         <module>weather</module>
+        <module>xchange</module>
         <module>xml</module>
         <module>xmlsecurity</module>
         <module>xstream</module>
diff --git a/extensions-jvm/xchange/integration-test/pom.xml 
b/integration-tests/xchange/pom.xml
similarity index 66%
rename from extensions-jvm/xchange/integration-test/pom.xml
rename to integration-tests/xchange/pom.xml
index 5ac96c1..19183ef 100644
--- a/extensions-jvm/xchange/integration-test/pom.xml
+++ b/integration-tests/xchange/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-xchange-integration-test</artifactId>
-    <name>Camel Quarkus :: XChange :: Integration Test</name>
+    <artifactId>camel-quarkus-integration-test-xchange</artifactId>
+    <name>Camel Quarkus :: Integration Tests :: XChange</name>
     <description>Integration tests for Camel Quarkus XChange 
extension</description>
 
     <dependencyManagement>
@@ -51,6 +50,16 @@
             <groupId>io.quarkus</groupId>
             <artifactId>quarkus-resteasy</artifactId>
         </dependency>
+        <dependency>
+            <groupId>io.quarkus</groupId>
+            <artifactId>quarkus-resteasy-jsonb</artifactId>
+        </dependency>
+
+        <!-- Test adding additional crypto exchanges -->
+        <dependency>
+            <groupId>org.knowm.xchange</groupId>
+            <artifactId>xchange-coinbase</artifactId>
+        </dependency>
 
         <!-- test dependencies -->
         <dependency>
@@ -80,4 +89,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/integration-tests/xchange/src/main/java/org/apache/camel/quarkus/component/xchange/it/XchangeResource.java
 
b/integration-tests/xchange/src/main/java/org/apache/camel/quarkus/component/xchange/it/XchangeResource.java
new file mode 100644
index 0000000..0e205da
--- /dev/null
+++ 
b/integration-tests/xchange/src/main/java/org/apache/camel/quarkus/component/xchange/it/XchangeResource.java
@@ -0,0 +1,104 @@
+/*
+ * 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.xchange.it;
+
+import java.util.List;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.json.Json;
+import javax.json.JsonArrayBuilder;
+import javax.json.JsonObject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.camel.ProducerTemplate;
+import org.knowm.xchange.currency.Currency;
+import org.knowm.xchange.currency.CurrencyPair;
+import org.knowm.xchange.dto.marketdata.Ticker;
+import org.knowm.xchange.dto.meta.CurrencyMetaData;
+import org.knowm.xchange.dto.meta.CurrencyPairMetaData;
+
+@Path("/xchange")
+@ApplicationScoped
+public class XchangeResource {
+
+    @Inject
+    ProducerTemplate producerTemplate;
+
+    @Path("/ticker/{exchange}")
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public JsonObject currencyTicker(@PathParam("exchange") String 
cryptoExchange,
+            @QueryParam("currencyPair") String currencyPair) {
+        Ticker ticker = producerTemplate.requestBody(
+                "xchange:" + cryptoExchange + 
"?service=marketdata&method=ticker&currencyPair=" + currencyPair, null,
+                Ticker.class);
+        return Json.createObjectBuilder()
+                .add("open", ticker.getOpen().longValue())
+                .add("high", ticker.getHigh().longValue())
+                .add("low", ticker.getLow().longValue())
+                .build();
+    }
+
+    @Path("/currency")
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    @SuppressWarnings("unchecked")
+    public JsonObject currencies() {
+        List<Currency> currencies = 
producerTemplate.requestBody("xchange:binance?service=metadata&method=currencies",
 null,
+                List.class);
+        JsonArrayBuilder builder = Json.createArrayBuilder();
+        currencies.forEach(c -> builder.add(c.getSymbol()));
+        return Json.createObjectBuilder().add("currencies", 
builder.build()).build();
+    }
+
+    @Path("/currency/metadata/{symbol}")
+    @GET
+    @Produces(MediaType.TEXT_PLAIN)
+    public String currencyMetadata(@PathParam("symbol") String symbol) {
+        CurrencyMetaData metaData = 
producerTemplate.requestBody("xchange:binance?service=metadata&method=currencyMetaData",
+                Currency.getInstance(symbol), CurrencyMetaData.class);
+        return metaData.getWithdrawalFee().toPlainString();
+    }
+
+    @Path("/currency/pairs")
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    @SuppressWarnings("unchecked")
+    public JsonObject currencyPairs() {
+        List<CurrencyPair> currencyPairs = 
producerTemplate.requestBody("xchange:binance?service=metadata&method=currencyPairs",
+                null, List.class);
+        JsonArrayBuilder builder = Json.createArrayBuilder();
+        currencyPairs.forEach(cp -> builder.add(cp.toString()));
+        return Json.createObjectBuilder().add("currencyPairs", 
builder.build()).build();
+    }
+
+    @Path("/currency/pairs/metadata")
+    @GET
+    @Produces(MediaType.TEXT_PLAIN)
+    public String currencyPairsMetadata(@QueryParam("base") String base, 
@QueryParam("counter") String counter) {
+        CurrencyPairMetaData metaData = producerTemplate.requestBody(
+                
"xchange:binance?service=metadata&method=currencyPairMetaData", new 
CurrencyPair(base, counter),
+                CurrencyPairMetaData.class);
+        return metaData.getTradingFee().toPlainString();
+    }
+}
diff --git 
a/extensions-jvm/xchange/integration-test/src/test/java/org/apache/camel/quarkus/component/xchange/it/XchangeTest.java
 
b/integration-tests/xchange/src/test/java/org/apache/camel/quarkus/component/xchange/it/XchangeIT.java
similarity index 70%
rename from 
extensions-jvm/xchange/integration-test/src/test/java/org/apache/camel/quarkus/component/xchange/it/XchangeTest.java
rename to 
integration-tests/xchange/src/test/java/org/apache/camel/quarkus/component/xchange/it/XchangeIT.java
index bf17855..2928901 100644
--- 
a/extensions-jvm/xchange/integration-test/src/test/java/org/apache/camel/quarkus/component/xchange/it/XchangeTest.java
+++ 
b/integration-tests/xchange/src/test/java/org/apache/camel/quarkus/component/xchange/it/XchangeIT.java
@@ -16,19 +16,9 @@
  */
 package org.apache.camel.quarkus.component.xchange.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 XchangeTest {
-
-    @Test
-    public void loadComponentXchange() {
-        /* A simple autogenerated test */
-        RestAssured.get("/xchange/load/component/xchange")
-                .then()
-                .statusCode(200);
-    }
+@NativeImageTest
+class XchangeIT extends XchangeTest {
 
 }
diff --git 
a/integration-tests/xchange/src/test/java/org/apache/camel/quarkus/component/xchange/it/XchangeTest.java
 
b/integration-tests/xchange/src/test/java/org/apache/camel/quarkus/component/xchange/it/XchangeTest.java
new file mode 100644
index 0000000..a541952
--- /dev/null
+++ 
b/integration-tests/xchange/src/test/java/org/apache/camel/quarkus/component/xchange/it/XchangeTest.java
@@ -0,0 +1,84 @@
+/*
+ * 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.xchange.it;
+
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+import static org.hamcrest.Matchers.emptyOrNullString;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.hasItems;
+import static org.hamcrest.Matchers.not;
+
+@QuarkusTest
+class XchangeTest {
+
+    @ParameterizedTest
+    @ValueSource(strings = { "binance", "coinbase" })
+    public void currencyTicker(String cryptoExchange) {
+        RestAssured.given()
+                .queryParam("currencyPair", "BTC/USDT")
+                .get("/xchange/ticker/" + cryptoExchange)
+                .then()
+                .statusCode(200)
+                .body(
+                        "open", greaterThan(0),
+                        "high", greaterThan(0),
+                        "low", greaterThan(0));
+    }
+
+    @Test
+    public void currencies() {
+        RestAssured.given()
+                .get("/xchange/currency")
+                .then()
+                .statusCode(200)
+                .body("currencies", hasItems("BTC", "ETH"));
+    }
+
+    @Test
+    public void currencyMetadata() {
+        RestAssured.given()
+                .get("/xchange/currency/metadata/BTC")
+                .then()
+                .statusCode(200)
+                .body(not(emptyOrNullString()));
+    }
+
+    @Test
+    public void currencyPairs() {
+        RestAssured.given()
+                .get("/xchange/currency/pairs")
+                .then()
+                .statusCode(200)
+                .body("currencyPairs", hasItems("BTC/USDT", "ETH/USDT"));
+    }
+
+    @Test
+    public void currencyPairMetadata() {
+        RestAssured.given()
+                .queryParam("base", "BTC")
+                .queryParam("counter", "USDT")
+                .get("/xchange/currency/pairs/metadata")
+                .then()
+                .statusCode(200)
+                .body(not(emptyOrNullString()));
+    }
+}
diff --git a/pom.xml b/pom.xml
index 4626003..19a07ad 100644
--- a/pom.xml
+++ b/pom.xml
@@ -117,6 +117,7 @@
         <snappy.version>1.1.7.7</snappy.version><!-- Spark -->
         <threetenbp.version>1.4.0</threetenbp.version>
         <xalan.version>${xalan-version}</xalan.version>
+        <xchange.version>${xchange-version}</xchange.version>
         <xerces.version>${xerces-version}</xerces.version>
         <xmlgraphics-commons.version>2.3</xmlgraphics-commons.version><!-- 
mess in FOP transitive deps -->
         <xstream.version>${xstream-version}</xstream.version>
diff --git a/poms/bom-test/pom.xml b/poms/bom-test/pom.xml
index ad37bec..3ddfad7 100644
--- a/poms/bom-test/pom.xml
+++ b/poms/bom-test/pom.xml
@@ -163,6 +163,11 @@
                 <version>${sshd.version}</version>
             </dependency>
             <dependency>
+                <groupId>org.knowm.xchange</groupId>
+                <artifactId>xchange-coinbase</artifactId>
+                <version>${xchange.version}</version>
+            </dependency>
+            <dependency>
                 <groupId>org.jvnet.mock-javamail</groupId>
                 <artifactId>mock-javamail</artifactId>
                 <version>${mock-javamail.version}</version>
diff --git a/tooling/scripts/test-categories.yaml 
b/tooling/scripts/test-categories.yaml
index f28c5c4..5cd8b71 100644
--- a/tooling/scripts/test-categories.yaml
+++ b/tooling/scripts/test-categories.yaml
@@ -136,6 +136,7 @@ group-09:
   - nats
   - splunk
   - spring-rabbitmq
+  - xchange
 group-10:
   - as2
   - atlasmap

Reply via email to