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

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


The following commit(s) were added to refs/heads/master by this push:
     new 6023d9f  IPFS native support
6023d9f is described below

commit 6023d9f17f419bf2f8c84953568d0e56de3ddb37
Author: James Netherton <jamesnether...@gmail.com>
AuthorDate: Fri Jan 22 10:48:29 2021 +0000

    IPFS native support
    
    Fixes #770
---
 .../ROOT/pages/reference/extensions/ipfs.adoc      |  8 +--
 .../ROOT/partials/reference/components/ipfs.adoc   |  6 +-
 extensions-jvm/pom.xml                             |  1 -
 .../ipfs/deployment/pom.xml                        |  0
 .../component/ipfs/deployment/IpfsProcessor.java   | 16 -----
 {extensions-jvm => extensions}/ipfs/pom.xml        |  1 -
 .../ipfs/runtime/pom.xml                           |  1 +
 .../main/resources/META-INF/quarkus-extension.yaml |  3 +-
 extensions/pom.xml                                 |  1 +
 .../ipfs}/pom.xml                                  | 59 ++++++++++++++--
 .../quarkus/component/ipfs/it/IpfsResource.java    | 41 ++++++-----
 .../camel/quarkus/component/ipfs/it/IpfsIT.java    | 16 +----
 .../camel/quarkus/component/ipfs/it/IpfsTest.java  | 79 ++++++++++++++++++++++
 .../component/ipfs/it/IpfsTestResource.java        | 54 +++++++++++++++
 integration-tests/pom.xml                          |  1 +
 tooling/scripts/test-categories.yaml               |  1 +
 16 files changed, 227 insertions(+), 61 deletions(-)

diff --git a/docs/modules/ROOT/pages/reference/extensions/ipfs.adoc 
b/docs/modules/ROOT/pages/reference/extensions/ipfs.adoc
index 106a412..f2252ce 100644
--- a/docs/modules/ROOT/pages/reference/extensions/ipfs.adoc
+++ b/docs/modules/ROOT/pages/reference/extensions/ipfs.adoc
@@ -2,15 +2,15 @@
 // This file was generated by 
camel-quarkus-maven-plugin:update-extension-doc-page
 = IPFS
 :cq-artifact-id: camel-quarkus-ipfs
-:cq-native-supported: false
-:cq-status: Preview
+:cq-native-supported: true
+:cq-status: Stable
 :cq-description: Access the Interplanetary File System (IPFS).
 :cq-deprecated: false
 :cq-jvm-since: 1.1.0
-:cq-native-since: n/a
+:cq-native-since: 1.7.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.7.0##
 
 Access the Interplanetary File System (IPFS).
 
diff --git a/docs/modules/ROOT/partials/reference/components/ipfs.adoc 
b/docs/modules/ROOT/partials/reference/components/ipfs.adoc
index 96e5dc8..99005c8 100644
--- a/docs/modules/ROOT/partials/reference/components/ipfs.adoc
+++ b/docs/modules/ROOT/partials/reference/components/ipfs.adoc
@@ -2,11 +2,11 @@
 // This file was generated by 
camel-quarkus-maven-plugin:update-extension-doc-page
 :cq-artifact-id: camel-quarkus-ipfs
 :cq-artifact-id-base: ipfs
-: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.7.0
 :cq-camel-part-name: ipfs
 :cq-camel-part-title: IPFS
 :cq-camel-part-description: Access the Interplanetary File System (IPFS).
diff --git a/extensions-jvm/pom.xml b/extensions-jvm/pom.xml
index 79aef61..5b1ad12 100644
--- a/extensions-jvm/pom.xml
+++ b/extensions-jvm/pom.xml
@@ -77,7 +77,6 @@
         <module>iec60870</module>
         <module>ignite</module>
         <module>iota</module>
-        <module>ipfs</module>
         <module>irc</module>
         <module>jasypt</module>
         <module>jbpm</module>
diff --git a/extensions-jvm/ipfs/deployment/pom.xml 
b/extensions/ipfs/deployment/pom.xml
similarity index 100%
rename from extensions-jvm/ipfs/deployment/pom.xml
rename to extensions/ipfs/deployment/pom.xml
diff --git 
a/extensions-jvm/ipfs/deployment/src/main/java/org/apache/camel/quarkus/component/ipfs/deployment/IpfsProcessor.java
 
b/extensions/ipfs/deployment/src/main/java/org/apache/camel/quarkus/component/ipfs/deployment/IpfsProcessor.java
similarity index 62%
rename from 
extensions-jvm/ipfs/deployment/src/main/java/org/apache/camel/quarkus/component/ipfs/deployment/IpfsProcessor.java
rename to 
extensions/ipfs/deployment/src/main/java/org/apache/camel/quarkus/component/ipfs/deployment/IpfsProcessor.java
index c9dfa54..1220635 100644
--- 
a/extensions-jvm/ipfs/deployment/src/main/java/org/apache/camel/quarkus/component/ipfs/deployment/IpfsProcessor.java
+++ 
b/extensions/ipfs/deployment/src/main/java/org/apache/camel/quarkus/component/ipfs/deployment/IpfsProcessor.java
@@ -17,30 +17,14 @@
 package org.apache.camel.quarkus.component.ipfs.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 IpfsProcessor {
 
-    private static final Logger LOG = Logger.getLogger(IpfsProcessor.class);
     private static final String FEATURE = "camel-ipfs";
 
     @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/ipfs/pom.xml b/extensions/ipfs/pom.xml
similarity index 97%
rename from extensions-jvm/ipfs/pom.xml
rename to extensions/ipfs/pom.xml
index 9844b4c..f1a34da 100644
--- a/extensions-jvm/ipfs/pom.xml
+++ b/extensions/ipfs/pom.xml
@@ -33,6 +33,5 @@
     <modules>
         <module>deployment</module>
         <module>runtime</module>
-        <module>integration-test</module>
     </modules>
 </project>
diff --git a/extensions-jvm/ipfs/runtime/pom.xml 
b/extensions/ipfs/runtime/pom.xml
similarity index 98%
rename from extensions-jvm/ipfs/runtime/pom.xml
rename to extensions/ipfs/runtime/pom.xml
index fbe363f..1b7144f 100644
--- a/extensions-jvm/ipfs/runtime/pom.xml
+++ b/extensions/ipfs/runtime/pom.xml
@@ -32,6 +32,7 @@
 
     <properties>
         <camel.quarkus.jvmSince>1.1.0</camel.quarkus.jvmSince>
+        <camel.quarkus.nativeSince>1.7.0</camel.quarkus.nativeSince>
     </properties>
 
     <repositories>
diff --git 
a/extensions-jvm/ipfs/runtime/src/main/resources/META-INF/quarkus-extension.yaml
 b/extensions/ipfs/runtime/src/main/resources/META-INF/quarkus-extension.yaml
similarity index 97%
rename from 
extensions-jvm/ipfs/runtime/src/main/resources/META-INF/quarkus-extension.yaml
rename to 
extensions/ipfs/runtime/src/main/resources/META-INF/quarkus-extension.yaml
index bd6a24c..786e8c8 100644
--- 
a/extensions-jvm/ipfs/runtime/src/main/resources/META-INF/quarkus-extension.yaml
+++ b/extensions/ipfs/runtime/src/main/resources/META-INF/quarkus-extension.yaml
@@ -24,9 +24,8 @@
 name: "Camel IPFS"
 description: "Access the Interplanetary File System (IPFS)"
 metadata:
-  unlisted: true
   guide: 
"https://camel.apache.org/camel-quarkus/latest/reference/extensions/ipfs.html";
   categories:
   - "integration"
   status:
-  - "preview"
+  - "stable"
diff --git a/extensions/pom.xml b/extensions/pom.xml
index a170f40..44b86c2 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -130,6 +130,7 @@
         <module>ical</module>
         <module>infinispan</module>
         <module>influxdb</module>
+        <module>ipfs</module>
         <module>jackson</module>
         <module>jacksonxml</module>
         <module>jaxb</module>
diff --git a/extensions-jvm/ipfs/integration-test/pom.xml 
b/integration-tests/ipfs/pom.xml
similarity index 60%
rename from extensions-jvm/ipfs/integration-test/pom.xml
rename to integration-tests/ipfs/pom.xml
index 9afdaaf..29800fb 100644
--- a/extensions-jvm/ipfs/integration-test/pom.xml
+++ b/integration-tests/ipfs/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.7.0-SNAPSHOT</version>
-        <relativePath>../../../poms/build-parent-it/pom.xml</relativePath>
     </parent>
 
-    <artifactId>camel-quarkus-ipfs-integration-test</artifactId>
-    <name>Camel Quarkus :: IPFS :: Integration Test</name>
+    <artifactId>camel-quarkus-integration-test-ipfs</artifactId>
+    <name>Camel Quarkus :: Integration Tests :: IPFS</name>
     <description>Integration tests for Camel Quarkus IPFS 
extension</description>
 
     <dependencyManagement>
@@ -45,12 +44,21 @@
     <dependencies>
         <dependency>
             <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-main</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
             <artifactId>camel-quarkus-ipfs</artifactId>
         </dependency>
         <dependency>
             <groupId>io.quarkus</groupId>
             <artifactId>quarkus-resteasy</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            
<artifactId>camel-quarkus-integration-testcontainers-support</artifactId>
+            <scope>test</scope>
+        </dependency>
 
         <!-- test dependencies -->
         <dependency>
@@ -78,6 +86,49 @@
                 </exclusion>
             </exclusions>
         </dependency>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-main-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-jvm/ipfs/integration-test/src/main/java/org/apache/camel/quarkus/component/ipfs/it/IpfsResource.java
 
b/integration-tests/ipfs/src/main/java/org/apache/camel/quarkus/component/ipfs/it/IpfsResource.java
similarity index 58%
rename from 
extensions-jvm/ipfs/integration-test/src/main/java/org/apache/camel/quarkus/component/ipfs/it/IpfsResource.java
rename to 
integration-tests/ipfs/src/main/java/org/apache/camel/quarkus/component/ipfs/it/IpfsResource.java
index ed264c7..b015144 100644
--- 
a/extensions-jvm/ipfs/integration-test/src/main/java/org/apache/camel/quarkus/component/ipfs/it/IpfsResource.java
+++ 
b/integration-tests/ipfs/src/main/java/org/apache/camel/quarkus/component/ipfs/it/IpfsResource.java
@@ -16,36 +16,43 @@
  */
 package org.apache.camel.quarkus.component.ipfs.it;
 
-import javax.enterprise.context.ApplicationScoped;
+import java.nio.file.Paths;
+
 import javax.inject.Inject;
+import javax.ws.rs.Consumes;
 import javax.ws.rs.GET;
+import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
 
-import org.apache.camel.CamelContext;
-import org.jboss.logging.Logger;
+import org.apache.camel.ProducerTemplate;
 
 @Path("/ipfs")
-@ApplicationScoped
 public class IpfsResource {
 
-    private static final Logger LOG = Logger.getLogger(IpfsResource.class);
-
-    private static final String COMPONENT_IPFS = "ipfs";
     @Inject
-    CamelContext context;
+    ProducerTemplate producerTemplate;
+
+    @Path("/add")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    public String addFile(String path) {
+        return producerTemplate.requestBody("ipfs:add", Paths.get(path), 
String.class);
+    }
+
+    @Path("/cat")
+    @GET
+    @Produces(MediaType.TEXT_PLAIN)
+    public String catFile(@QueryParam("hash") String hash) {
+        return producerTemplate.requestBody("ipfs:cat", hash, String.class);
+    }
 
-    @Path("/load/component/ipfs")
+    @Path("/get")
     @GET
     @Produces(MediaType.TEXT_PLAIN)
-    public Response loadComponentIpfs() throws Exception {
-        /* This is an autogenerated test */
-        if (context.getComponent(COMPONENT_IPFS) != null) {
-            return Response.ok().build();
-        }
-        LOG.warnf("Could not load [%s] from the Camel context", 
COMPONENT_IPFS);
-        return Response.status(500, COMPONENT_IPFS + " could not be loaded 
from the Camel context").build();
+    public String getFilePath(@QueryParam("hash") String hash) throws 
Exception {
+        return producerTemplate.requestBody("ipfs:get?outdir=target", hash, 
String.class);
     }
 }
diff --git 
a/extensions-jvm/ipfs/integration-test/src/test/java/org/apache/camel/quarkus/component/ipfs/it/IpfsTest.java
 
b/integration-tests/ipfs/src/test/java/org/apache/camel/quarkus/component/ipfs/it/IpfsIT.java
similarity index 71%
rename from 
extensions-jvm/ipfs/integration-test/src/test/java/org/apache/camel/quarkus/component/ipfs/it/IpfsTest.java
rename to 
integration-tests/ipfs/src/test/java/org/apache/camel/quarkus/component/ipfs/it/IpfsIT.java
index 635846b..6b920e7 100644
--- 
a/extensions-jvm/ipfs/integration-test/src/test/java/org/apache/camel/quarkus/component/ipfs/it/IpfsTest.java
+++ 
b/integration-tests/ipfs/src/test/java/org/apache/camel/quarkus/component/ipfs/it/IpfsIT.java
@@ -16,19 +16,9 @@
  */
 package org.apache.camel.quarkus.component.ipfs.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 IpfsTest {
-
-    @Test
-    public void loadComponentIpfs() {
-        /* A simple autogenerated test */
-        RestAssured.get("/ipfs/load/component/ipfs")
-                .then()
-                .statusCode(200);
-    }
+@NativeImageTest
+class IpfsIT extends IpfsTest {
 
 }
diff --git 
a/integration-tests/ipfs/src/test/java/org/apache/camel/quarkus/component/ipfs/it/IpfsTest.java
 
b/integration-tests/ipfs/src/test/java/org/apache/camel/quarkus/component/ipfs/it/IpfsTest.java
new file mode 100644
index 0000000..038f9ed
--- /dev/null
+++ 
b/integration-tests/ipfs/src/test/java/org/apache/camel/quarkus/component/ipfs/it/IpfsTest.java
@@ -0,0 +1,79 @@
+/*
+ * 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.ipfs.it;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+@QuarkusTest
+@QuarkusTestResource(IpfsTestResource.class)
+class IpfsTest {
+
+    @Test
+    public void ipfsComponent() throws IOException {
+        String fileContent = "Hello Camel Quarkus IPFS";
+
+        Path tempFile = Files.createTempFile("ipfs", ".txt");
+        Files.write(tempFile, fileContent.getBytes(StandardCharsets.UTF_8));
+
+        try {
+            // Add file
+            String hash = RestAssured.given()
+                    .body(tempFile.toString())
+                    .post("/ipfs/add")
+                    .then()
+                    .statusCode(200)
+                    .extract()
+                    .body()
+                    .asString();
+
+            // Cat file
+            RestAssured.given()
+                    .queryParam("hash", hash)
+                    .get("/ipfs/cat")
+                    .then()
+                    .statusCode(200)
+                    .body(is(fileContent));
+
+            // Retrieve file path
+            String filePath = RestAssured.given()
+                    .queryParam("hash", hash)
+                    .get("/ipfs/get")
+                    .then()
+                    .statusCode(200)
+                    .extract()
+                    .body()
+                    .asString();
+
+            byte[] bytes = Files.readAllBytes(Paths.get(filePath));
+            assertEquals(fileContent, new String(bytes, 
StandardCharsets.UTF_8));
+        } finally {
+            Files.delete(tempFile);
+        }
+    }
+}
diff --git 
a/integration-tests/ipfs/src/test/java/org/apache/camel/quarkus/component/ipfs/it/IpfsTestResource.java
 
b/integration-tests/ipfs/src/test/java/org/apache/camel/quarkus/component/ipfs/it/IpfsTestResource.java
new file mode 100644
index 0000000..689b39a
--- /dev/null
+++ 
b/integration-tests/ipfs/src/test/java/org/apache/camel/quarkus/component/ipfs/it/IpfsTestResource.java
@@ -0,0 +1,54 @@
+/*
+ * 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.ipfs.it;
+
+import java.util.Map;
+
+import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
+import org.apache.camel.util.CollectionHelper;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.wait.strategy.Wait;
+
+public class IpfsTestResource implements QuarkusTestResourceLifecycleManager {
+
+    private static final String IPFS_IMAGE = "ipfs/go-ipfs:v0.4.11";
+    private static final int IPFS_PORT = 5001;
+
+    private GenericContainer<?> container;
+
+    @Override
+    public Map<String, String> start() {
+        container = new GenericContainer<>(IPFS_IMAGE)
+                .withExposedPorts(IPFS_PORT)
+                .waitingFor(Wait.forListeningPort());
+        container.start();
+
+        return CollectionHelper.mapOf("camel.component.ipfs.ipfs-host", 
"127.0.0.1",
+                "camel.component.ipfs.ipfs-port", 
container.getMappedPort(IPFS_PORT).toString());
+    }
+
+    @Override
+    public void stop() {
+        try {
+            if (container != null) {
+                container.stop();
+            }
+        } catch (Exception e) {
+            // Ignored
+        }
+    }
+}
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index 143d9f0..51ad396 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -113,6 +113,7 @@
         <module>hystrix</module>
         <module>infinispan</module>
         <module>influxdb</module>
+        <module>ipfs</module>
         <module>jaxb</module>
         <module>jdbc</module>
         <module>jing</module>
diff --git a/tooling/scripts/test-categories.yaml 
b/tooling/scripts/test-categories.yaml
index 32e4b92..467e83a 100644
--- a/tooling/scripts/test-categories.yaml
+++ b/tooling/scripts/test-categories.yaml
@@ -25,6 +25,7 @@ cache-networking3:
   - jsch
   - ssh
   - hazelcast
+  - ipfs
 cloud:
   - solr
   - aws

Reply via email to