This is an automated email from the ASF dual-hosted git repository. ppalaga pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 3a90749eee2bc915142e215555151c6c12cfa8a6 Author: Peter Palaga <ppal...@redhat.com> AuthorDate: Thu Aug 20 13:26:09 2020 +0200 Fix #765 Git support --- catalog/pom.xml | 2 +- docs/modules/ROOT/nav.adoc | 1 + docs/modules/ROOT/pages/reference/components.adoc | 5 +- .../ROOT/pages/reference/extensions/git.adoc | 34 ++++++ docs/modules/ROOT/pages/reference/index.adoc | 5 +- extensions/git/deployment/pom.xml | 67 +++++++++++ .../component/git/deployment/GitProcessor.java | 30 +++++ extensions/git/pom.xml | 39 ++++++ extensions/git/runtime/pom.xml | 98 +++++++++++++++ .../git/runtime/src/main/doc/configuration.adoc | 1 + .../main/resources/META-INF/quarkus-extension.yaml | 31 +++++ extensions/pom.xml | 1 + integration-tests/git/pom.xml | 131 +++++++++++++++++++++ .../quarkus/component/git/it/GitResource.java | 98 +++++++++++++++ .../camel/quarkus/component/git/it/GitIT.java | 24 ++++ .../camel/quarkus/component/git/it/GitTest.java | 74 ++++++++++++ integration-tests/pom.xml | 1 + poms/bom/pom.xml | 15 +++ tooling/scripts/test-categories.yaml | 1 + 19 files changed, 655 insertions(+), 3 deletions(-) diff --git a/catalog/pom.xml b/catalog/pom.xml index 1502be9..0737d3c 100644 --- a/catalog/pom.xml +++ b/catalog/pom.xml @@ -37,7 +37,7 @@ <!-- explicit dependencies of this module in the Maven sense, although they are required by the Quarkus Maven plugin. --> <!-- Please update rule whenever you change the dependencies of this module by running --> <!-- mvn process-resources -Pformat from the root directory --> - <mvnd.builder.rule>camel-quarkus-activemq,camel-quarkus-ahc,camel-quarkus-ahc-ws,camel-quarkus-amqp,camel-quarkus-attachments,camel-quarkus-avro,camel-quarkus-avro-rpc,camel-quarkus-aws-ec2,camel-quarkus-aws-ecs,camel-quarkus-aws-eks,camel-quarkus-aws-iam,camel-quarkus-aws-kinesis,camel-quarkus-aws-kms,camel-quarkus-aws-lambda,camel-quarkus-aws-s3,camel-quarkus-aws-sdb,camel-quarkus-aws-sns,camel-quarkus-aws-sqs,camel-quarkus-aws-swf,camel-quarkus-aws-translate,camel-quarkus-aws2 [...] + <mvnd.builder.rule>camel-quarkus-activemq,camel-quarkus-ahc,camel-quarkus-ahc-ws,camel-quarkus-amqp,camel-quarkus-attachments,camel-quarkus-avro,camel-quarkus-avro-rpc,camel-quarkus-aws-ec2,camel-quarkus-aws-ecs,camel-quarkus-aws-eks,camel-quarkus-aws-iam,camel-quarkus-aws-kinesis,camel-quarkus-aws-kms,camel-quarkus-aws-lambda,camel-quarkus-aws-s3,camel-quarkus-aws-sdb,camel-quarkus-aws-sns,camel-quarkus-aws-sqs,camel-quarkus-aws-swf,camel-quarkus-aws-translate,camel-quarkus-aws2 [...] </properties> <dependencies> diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index a9a50bb..e1bd803 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -82,6 +82,7 @@ *** xref:reference/extensions/file-watch.adoc[File Watch] *** xref:reference/extensions/flatpack.adoc[Flatpack] *** xref:reference/extensions/ftp.adoc[FTP] +*** xref:reference/extensions/git.adoc[Git] *** xref:reference/extensions/github.adoc[GitHub] *** xref:reference/extensions/google-bigquery.adoc[Google BigQuery] *** xref:reference/extensions/google-calendar.adoc[Google Calendar] diff --git a/docs/modules/ROOT/pages/reference/components.adoc b/docs/modules/ROOT/pages/reference/components.adoc index c686f6a..90d6459 100644 --- a/docs/modules/ROOT/pages/reference/components.adoc +++ b/docs/modules/ROOT/pages/reference/components.adoc @@ -4,7 +4,7 @@ [camel-quarkus-components] = Camel components supported on Quarkus -157 components in 122 JAR artifacts (0 deprecated, 17 JVM only) +158 components in 123 JAR artifacts (0 deprecated, 17 JVM only) [width="100%",cols="4,1,1,1,5",options="header"] |=== @@ -199,6 +199,9 @@ Stable | 1.0.0 | Upload and download files to/from FTP servers. | xref:reference/extensions/ftp.adoc[FTPS] | camel-quarkus-ftp | Native + Stable | 1.0.0 | Upload and download files to/from FTP servers supporting the FTPS protocol. +| xref:reference/extensions/git.adoc[Git] | camel-quarkus-git | Native + +Stable | 1.1.0 | Perform operations on git repositories. + | xref:reference/extensions/github.adoc[GitHub] | camel-quarkus-github | Native + Stable | 1.0.0 | Interact with the GitHub API. diff --git a/docs/modules/ROOT/pages/reference/extensions/git.adoc b/docs/modules/ROOT/pages/reference/extensions/git.adoc new file mode 100644 index 0000000..9ccbafa --- /dev/null +++ b/docs/modules/ROOT/pages/reference/extensions/git.adoc @@ -0,0 +1,34 @@ +// Do not edit directly! +// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page + +[[git]] += Git +:page-aliases: extensions/git.adoc + +[.badges] +[.badge-key]##Since Camel Quarkus##[.badge-version]##1.1.0## [.badge-key]##JVM##[.badge-supported]##supported## [.badge-key]##Native##[.badge-supported]##supported## + +Perform operations on git repositories. + +== What's inside + +* https://camel.apache.org/components/latest/git-component.html[Git component], URI syntax: `git:localPath` + +Please refer to the above link for usage and configuration details. + +== Maven coordinates + +[source,xml] +---- +<dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-git</artifactId> +</dependency> +---- + +Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications. + +== Additional Camel Quarkus configuration + +If you plan to run your application in native mode and the remote Git repositories it will access require SSL, you will need to set `quarkus.ssl.native=true` in your `application.properties`. See https://quarkus.io/guides/native-and-ssl[Quarkus native and SSL guide] for more details. + diff --git a/docs/modules/ROOT/pages/reference/index.adoc b/docs/modules/ROOT/pages/reference/index.adoc index e477ede..83f7fa9 100644 --- a/docs/modules/ROOT/pages/reference/index.adoc +++ b/docs/modules/ROOT/pages/reference/index.adoc @@ -17,7 +17,7 @@ In case you are missing some extension in the list: https://github.com/apache/camel-quarkus/issues[report] any issues you encounter. ==== -166 extensions (1 deprecated, 14 JVM only) +167 extensions (1 deprecated, 14 JVM only) [width="100%",cols="4,1,1,1,5",options="header"] |=== @@ -227,6 +227,9 @@ Stable | 1.1.0 | Parse fixed width and delimited files using the FlatPack librar | xref:reference/extensions/ftp.adoc[FTP] | camel-quarkus-ftp | Native + Stable | 1.0.0 | Upload and download files to/from FTP or SFTP servers. +| xref:reference/extensions/git.adoc[Git] | camel-quarkus-git | Native + +Stable | 1.1.0 | Perform operations on git repositories. + | xref:reference/extensions/github.adoc[GitHub] | camel-quarkus-github | Native + Stable | 1.0.0 | Interact with the GitHub API. diff --git a/extensions/git/deployment/pom.xml b/extensions/git/deployment/pom.xml new file mode 100644 index 0000000..12e324b --- /dev/null +++ b/extensions/git/deployment/pom.xml @@ -0,0 +1,67 @@ +<?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"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-git-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-git-deployment</artifactId> + <name>Camel Quarkus :: Git :: Deployment</name> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-core-deployment</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-jgit-deployment</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-git</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <annotationProcessorPaths> + <path> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-extension-processor</artifactId> + <version>${quarkus.version}</version> + </path> + </annotationProcessorPaths> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/extensions/git/deployment/src/main/java/org/apache/camel/quarkus/component/git/deployment/GitProcessor.java b/extensions/git/deployment/src/main/java/org/apache/camel/quarkus/component/git/deployment/GitProcessor.java new file mode 100644 index 0000000..416d001 --- /dev/null +++ b/extensions/git/deployment/src/main/java/org/apache/camel/quarkus/component/git/deployment/GitProcessor.java @@ -0,0 +1,30 @@ +/* + * 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.git.deployment; + +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.FeatureBuildItem; + +class GitProcessor { + + private static final String FEATURE = "camel-git"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } +} diff --git a/extensions/git/pom.xml b/extensions/git/pom.xml new file mode 100644 index 0000000..57d5fcc --- /dev/null +++ b/extensions/git/pom.xml @@ -0,0 +1,39 @@ +<?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"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-build-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + <relativePath>../../poms/build-parent/pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-git-parent</artifactId> + <name>Camel Quarkus :: Git</name> + <packaging>pom</packaging> + + <modules> + <module>deployment</module> + <module>runtime</module> + </modules> +</project> diff --git a/extensions/git/runtime/pom.xml b/extensions/git/runtime/pom.xml new file mode 100644 index 0000000..ea73dce --- /dev/null +++ b/extensions/git/runtime/pom.xml @@ -0,0 +1,98 @@ +<?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"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-git-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-git</artifactId> + <name>Camel Quarkus :: Git :: Runtime</name> + <description>Perform operations on git repositories.</description> + + <properties> + <firstVersion>1.1.0</firstVersion> + </properties> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-bom</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-core</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-jgit</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-git</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-maven-plugin</artifactId> + <executions> + <execution> + <id>update-extension-doc-page</id> + <goals><goal>update-extension-doc-page</goal></goals> + <phase>process-classes</phase> + </execution> + </executions> + </plugin> + <plugin> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-bootstrap-maven-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <annotationProcessorPaths> + <path> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-extension-processor</artifactId> + <version>${quarkus.version}</version> + </path> + </annotationProcessorPaths> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/extensions/git/runtime/src/main/doc/configuration.adoc b/extensions/git/runtime/src/main/doc/configuration.adoc new file mode 100644 index 0000000..be8bd9b --- /dev/null +++ b/extensions/git/runtime/src/main/doc/configuration.adoc @@ -0,0 +1 @@ +If you plan to run your application in native mode and the remote Git repositories it will access require SSL, you will need to set `quarkus.ssl.native=true` in your `application.properties`. See https://quarkus.io/guides/native-and-ssl[Quarkus native and SSL guide] for more details. \ No newline at end of file diff --git a/extensions/git/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/git/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 0000000..c19cda4 --- /dev/null +++ b/extensions/git/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -0,0 +1,31 @@ +# +# 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. +# + +# This is a generated file. Do not edit directly! +# To re-generate, run the following command from the top level directory: +# +# mvn -N cq:update-quarkus-metadata +# +--- +name: "Camel Git" +description: "Perform operations on git repositories" +metadata: + guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/git.html" + categories: + - "integration" + status: + - "stable" diff --git a/extensions/pom.xml b/extensions/pom.xml index 3284d70..7e9e033 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -94,6 +94,7 @@ <module>file-watch</module> <module>flatpack</module> <module>ftp</module> + <module>git</module> <module>github</module> <module>google-calendar</module> <module>google-drive</module> diff --git a/integration-tests/git/pom.xml b/integration-tests/git/pom.xml new file mode 100644 index 0000000..05b20c5 --- /dev/null +++ b/integration-tests/git/pom.xml @@ -0,0 +1,131 @@ +<?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"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-integration-tests</artifactId> + <version>1.1.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-integration-test-git</artifactId> + <name>Camel Quarkus :: Integration Tests :: Git</name> + <description>Integration tests for Camel Quarkus Git extension</description> + + <properties> + <!-- mvnd, a.k.a. Maven Daemon: https://github.com/gnodet/mvnd --> + <!-- The following rule tells mvnd to build the listed deployment modules before this module. --> + <!-- This is important because mvnd builds modules in parallel by default. The deployment modules are not --> + <!-- explicit dependencies of this module in the Maven sense, although they are required by the Quarkus Maven plugin. --> + <!-- Please update rule whenever you change the dependencies of this module by running --> + <!-- mvn process-resources -Pformat from the root directory --> + <mvnd.builder.rule>camel-quarkus-git-deployment,camel-quarkus-support-policy-deployment</mvnd.builder.rule> + </properties> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-bom-test</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-git</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> + <dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-maven-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>build</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + + <profiles> + <profile> + <id>native</id> + <activation> + <property> + <name>native</name> + </property> + </activation> + <properties> + <quarkus.package.type>native</quarkus.package.type> + </properties> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-failsafe-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> + +</project> diff --git a/integration-tests/git/src/main/java/org/apache/camel/quarkus/component/git/it/GitResource.java b/integration-tests/git/src/main/java/org/apache/camel/quarkus/component/git/it/GitResource.java new file mode 100644 index 0000000..1923baf --- /dev/null +++ b/integration-tests/git/src/main/java/org/apache/camel/quarkus/component/git/it/GitResource.java @@ -0,0 +1,98 @@ +/* + * 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.git.it; + +import java.net.URI; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.stream.Collectors; +import java.util.stream.StreamSupport; + +import javax.enterprise.context.ApplicationScoped; +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.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.apache.camel.ConsumerTemplate; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.component.git.GitConstants; +import org.eclipse.jgit.revwalk.RevCommit; + +@Path("/git") +@ApplicationScoped +public class GitResource { + + @Inject + ProducerTemplate producerTemplate; + + @Inject + ConsumerTemplate consumerTemplate; + + @Path("/init/{repoName}") + @POST + @Consumes(MediaType.TEXT_PLAIN) + @Produces(MediaType.TEXT_PLAIN) + public Response init(@PathParam("repoName") String repoName) throws Exception { + producerTemplate.requestBody("git:target/" + repoName + "?operation=init", (Object) null); + + return Response + .created(new URI("https://camel.apache.org/")) + .entity("target/" + repoName) + .build(); + + } + + @Path("/add-and-commit/{repoName}/{file:(.+)?}") + @POST + @Consumes(MediaType.APPLICATION_OCTET_STREAM) + @Produces(MediaType.TEXT_PLAIN) + public Response addAndCommit(@PathParam("repoName") String repoName, @PathParam("file") String file, byte[] content) + throws Exception { + final java.nio.file.Path path = Paths.get("target/" + repoName + "/" + file); + Files.createDirectories(path.getParent()); + Files.write(path, content); + producerTemplate.requestBodyAndHeader("git:target/" + repoName + "?operation=add", (Object) null, + GitConstants.GIT_FILE_NAME, + file); + producerTemplate.requestBodyAndHeader("git:target/" + repoName + "?operation=commit", (Object) null, + GitConstants.GIT_COMMIT_MESSAGE, "Add " + file); + + return Response + .created(new URI("https://camel.apache.org/")) + .entity("target/" + repoName + "/" + file) + .build(); + + } + + @Path("/log/{repoName}") + @GET + @Produces(MediaType.TEXT_PLAIN) + public String log(@PathParam("repoName") String repoName) throws Exception { + Iterable<RevCommit> it = producerTemplate.requestBody("git:target/" + repoName + "?operation=log", null, + Iterable.class); + return StreamSupport.stream(it.spliterator(), false) + .map(commit -> commit.getName() + " " + commit.getFullMessage()) + .collect(Collectors.joining("\n")); + } + +} diff --git a/integration-tests/git/src/test/java/org/apache/camel/quarkus/component/git/it/GitIT.java b/integration-tests/git/src/test/java/org/apache/camel/quarkus/component/git/it/GitIT.java new file mode 100644 index 0000000..035daad --- /dev/null +++ b/integration-tests/git/src/test/java/org/apache/camel/quarkus/component/git/it/GitIT.java @@ -0,0 +1,24 @@ +/* + * 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.git.it; + +import io.quarkus.test.junit.NativeImageTest; + +@NativeImageTest +class GitIT extends GitTest { + +} diff --git a/integration-tests/git/src/test/java/org/apache/camel/quarkus/component/git/it/GitTest.java b/integration-tests/git/src/test/java/org/apache/camel/quarkus/component/git/it/GitTest.java new file mode 100644 index 0000000..93f6746 --- /dev/null +++ b/integration-tests/git/src/test/java/org/apache/camel/quarkus/component/git/it/GitTest.java @@ -0,0 +1,74 @@ +/* + * 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.git.it; + +import java.nio.charset.StandardCharsets; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.UUID; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.core.Is.is; + +@QuarkusTest +class GitTest { + + @Test + void initAddCommit() { + final String repoName = "testRepo-" + UUID.randomUUID().toString(); + final String path = RestAssured.given() + .contentType(ContentType.TEXT) + .post("/git/init/" + repoName) + .then() + .statusCode(201) + .extract() + .body() + .asString(); + final Path repoPath = Paths.get(path); + + assertThat(repoPath).exists(); + assertThat(repoPath.resolve(".git")).exists(); + + final String file = "foo/bar.txt"; + final String fileContent = "foo/bar"; + RestAssured.given() + .contentType(ContentType.BINARY) + .body(fileContent.getBytes(StandardCharsets.UTF_8)) + .post("/git/add-and-commit/" + repoName + "/" + file) + .then() + .statusCode(201) + .body(is("target/" + repoName + "/" + file)); + + assertThat(repoPath).exists(); + assertThat(repoPath.resolve(file)).exists().hasContent(fileContent); + + RestAssured.given() + .contentType(ContentType.TEXT) + .get("/git/log/" + repoName) + .then() + .statusCode(200) + .body(containsString("Add " + file)); + + } + +} diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 05d91bb..195a912 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -91,6 +91,7 @@ <module>file</module> <module>flatpack</module> <module>ftp</module> + <module>git</module> <module>github</module> <module>google</module> <module>graphql</module> diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index 93adef3..75d3104 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -593,6 +593,11 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> + <artifactId>camel-git</artifactId> + <version>${camel.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> <artifactId>camel-github</artifactId> <version>${camel.version}</version> </dependency> @@ -1921,6 +1926,16 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-git</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-git-deployment</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-github</artifactId> <version>${camel-quarkus.version}</version> </dependency> diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml index a563a20..2c70314 100644 --- a/tooling/scripts/test-categories.yaml +++ b/tooling/scripts/test-categories.yaml @@ -63,6 +63,7 @@ foundation: - ref - seda - send-dynamic-http + - git memoryhog-dataformat-json: - dataformats-json memoryhog-dozer: