This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch camel-master in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 5b22aa6218fb3d61d14ad92c3efde71b3271aac6 Author: Freeman Fang <freeman.f...@gmail.com> AuthorDate: Thu Feb 13 14:03:25 2020 -0500 create camel-jira extension #710 --- .../pages/list-of-camel-quarkus-extensions.adoc | 5 +- extensions/jira/deployment/pom.xml | 79 ++++++++ .../component/jira/deployment/JiraProcessor.java | 31 ++++ extensions/jira/pom.xml | 39 ++++ extensions/jira/runtime/pom.xml | 125 +++++++++++++ .../main/resources/META-INF/quarkus-extension.yaml | 27 +++ extensions/pom.xml | 1 + extensions/readme.adoc | 5 +- integration-tests/jira/pom.xml | 202 +++++++++++++++++++++ .../quarkus/component/jira/it/JiraResource.java | 86 +++++++++ .../component/jira/it/JiraRouteBuilder.java | 41 +++++ .../camel/quarkus/component/jira/it/JiraIT.java | 24 +++ .../camel/quarkus/component/jira/it/JiraTest.java | 41 +++++ integration-tests/pom.xml | 1 + pom.xml | 2 + poms/bom-deployment/pom.xml | 5 + poms/bom/pom.xml | 22 ++- 17 files changed, 733 insertions(+), 3 deletions(-) diff --git a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc index b97e9be..b884fda 100644 --- a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc +++ b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc @@ -18,7 +18,7 @@ In case you are missing some Camel feature in the list: == Camel Components // components: START -Number of Camel components: 63 in 54 JAR artifacts (0 deprecated) +Number of Camel components: 64 in 55 JAR artifacts (0 deprecated) [width="100%",cols="4,1,5",options="header"] |=== @@ -114,6 +114,9 @@ Number of Camel components: 63 in 54 JAR artifacts (0 deprecated) | link:https://camel.apache.org/components/latest/jdbc-component.html[JDBC] (camel-quarkus-jdbc) + `jdbc:dataSourceName` | 0.2.0 | The jdbc component enables you to access databases through JDBC, where SQL queries are sent in the message body. +| link:https://camel.apache.org/components/latest/jira-component.html[Jira] (camel-quarkus-jira) + +`jira:type` | 1.1.0 | The jira component interacts with the JIRA issue tracker. + | link:https://camel.apache.org/components/latest/kafka-component.html[Kafka] (camel-quarkus-kafka) + `kafka:topic` | 1.0.0-M1 | The kafka component allows messages to be sent to (or consumed from) Apache Kafka brokers. diff --git a/extensions/jira/deployment/pom.xml b/extensions/jira/deployment/pom.xml new file mode 100644 index 0000000..2e1dd6c --- /dev/null +++ b/extensions/jira/deployment/pom.xml @@ -0,0 +1,79 @@ +<?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-jira-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-jira-deployment</artifactId> + <name>Camel Quarkus :: Jira :: Deployment</name> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-bom-deployment</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-deployment</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-jira</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-commons-logging-deployment</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/jira/deployment/src/main/java/org/apache/camel/quarkus/component/jira/deployment/JiraProcessor.java b/extensions/jira/deployment/src/main/java/org/apache/camel/quarkus/component/jira/deployment/JiraProcessor.java new file mode 100644 index 0000000..befac44 --- /dev/null +++ b/extensions/jira/deployment/src/main/java/org/apache/camel/quarkus/component/jira/deployment/JiraProcessor.java @@ -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. + */ +package org.apache.camel.quarkus.component.jira.deployment; + +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.FeatureBuildItem; + +class JiraProcessor { + + private static final String FEATURE = "camel-jira"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } + +} diff --git a/extensions/jira/pom.xml b/extensions/jira/pom.xml new file mode 100644 index 0000000..31bd5ca --- /dev/null +++ b/extensions/jira/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-jira-parent</artifactId> + <name>Camel Quarkus :: Jira</name> + <packaging>pom</packaging> + + <modules> + <module>deployment</module> + <module>runtime</module> + </modules> +</project> diff --git a/extensions/jira/runtime/pom.xml b/extensions/jira/runtime/pom.xml new file mode 100644 index 0000000..6faa1d9 --- /dev/null +++ b/extensions/jira/runtime/pom.xml @@ -0,0 +1,125 @@ +<?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-jira-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-jira</artifactId> + <name>Camel Quarkus :: Jira :: Runtime</name> + + <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> + <repositories> + <repository> + <id>atlassian</id> + <url>https://packages.atlassian.com/maven-external/</url> + <name>atlassian exteranl repo</name> + <snapshots> + <enabled>false</enabled> + </snapshots> + <releases> + <enabled>true</enabled> + </releases> + </repository> + </repositories> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-core</artifactId> + </dependency> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-jira</artifactId> + <exclusions> + <exclusion> + <groupId>javax.ws.rs</groupId> + <artifactId>jsr311-api</artifactId> + </exclusion> + <exclusion> + <groupId>com.google.code.findbugs</groupId> + <artifactId>jsr305</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient-cache</artifactId> + </exclusion> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-commons-logging</artifactId> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient-cache</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <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/jira/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/jira/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 0000000..7646dad --- /dev/null +++ b/extensions/jira/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -0,0 +1,27 @@ +# +# 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. +# + +--- +name: "Camel Quarkus Jira" +description: "Camel Jira support" +metadata: + keywords: + - "camel" + - "jira" + guide: "https://quarkus.io/guides/camel" + categories: + - "integration" diff --git a/extensions/pom.xml b/extensions/pom.xml index 289a289..d562bf7 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -89,6 +89,7 @@ <module>netty-http</module> <module>olingo4</module> <module>opentracing</module> + <module>jira</module> <module>paho</module> <module>pdf</module> <module>platform-http</module> diff --git a/extensions/readme.adoc b/extensions/readme.adoc index fffd02d..ef64f14 100644 --- a/extensions/readme.adoc +++ b/extensions/readme.adoc @@ -5,7 +5,7 @@ Apache Camel Quarkus supports the following Camel artifacts as Quarkus Extension == Camel Components // components: START -Number of Camel components: 63 in 54 JAR artifacts (0 deprecated) +Number of Camel components: 64 in 55 JAR artifacts (0 deprecated) [width="100%",cols="4,1,5",options="header"] |=== @@ -101,6 +101,9 @@ Number of Camel components: 63 in 54 JAR artifacts (0 deprecated) | link:https://camel.apache.org/components/latest/jdbc-component.html[JDBC] (camel-quarkus-jdbc) + `jdbc:dataSourceName` | 0.2.0 | The jdbc component enables you to access databases through JDBC, where SQL queries are sent in the message body. +| link:https://camel.apache.org/components/latest/jira-component.html[Jira] (camel-quarkus-jira) + +`jira:type` | 1.1.0 | The jira component interacts with the JIRA issue tracker. + | link:https://camel.apache.org/components/latest/kafka-component.html[Kafka] (camel-quarkus-kafka) + `kafka:topic` | 1.0.0-M1 | The kafka component allows messages to be sent to (or consumed from) Apache Kafka brokers. diff --git a/integration-tests/jira/pom.xml b/integration-tests/jira/pom.xml new file mode 100644 index 0000000..195d96f --- /dev/null +++ b/integration-tests/jira/pom.xml @@ -0,0 +1,202 @@ +<?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> + </parent> + + <artifactId>camel-quarkus-integration-test-jira</artifactId> + <name>Camel Quarkus :: Integration Tests :: Jira</name> + <description>Integration tests for Camel Quarkus Jira extension</description> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-jira</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-log</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> + <exclusions> + <exclusion> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>io.rest-assured</groupId> + <artifactId>rest-assured</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> + <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> + <configuration> + <systemProperties> + <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path> + </systemProperties> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-maven-plugin</artifactId> + <executions> + <execution> + <id>native-image</id> + <goals> + <goal>native-image</goal> + </goals> + <configuration> + <reportErrorsAtRuntime>false</reportErrorsAtRuntime> + <cleanupServer>true</cleanupServer> + <enableHttpsUrlHandler>true</enableHttpsUrlHandler> + <enableServer>false</enableServer> + <dumpProxies>false</dumpProxies> + <graalvmHome>${graalvmHome}</graalvmHome> + <enableJni>true</enableJni> + <enableAllSecurityServices>true</enableAllSecurityServices> + <disableReports>true</disableReports> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles--> + <profiles> + <profile> + <id>native</id> + <activation> + <property> + <name>native</name> + </property> + </activation> + <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> + <configuration> + <systemProperties> + <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path> + </systemProperties> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-maven-plugin</artifactId> + <executions> + <execution> + <id>native-image</id> + <goals> + <goal>native-image</goal> + </goals> + <configuration> + <reportErrorsAtRuntime>false</reportErrorsAtRuntime> + <cleanupServer>true</cleanupServer> + <enableHttpsUrlHandler>true</enableHttpsUrlHandler> + <enableServer>false</enableServer> + <dumpProxies>false</dumpProxies> + <graalvmHome>${graalvmHome}</graalvmHome> + <enableJni>true</enableJni> + <enableAllSecurityServices>true</enableAllSecurityServices> + <disableReports>true</disableReports> + <additionalBuildArgs> + --initialize-at-run-time=com.google.api.client.auth.oauth.OAuthParameters,--allow-incomplete-classpath + </additionalBuildArgs> + <!--additionalBuildArg> + -H:ReflectionConfigurationFiles=${project.basedir}/reflection-config.json + </additionalBuildArg--> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> + +</project> diff --git a/integration-tests/jira/src/main/java/org/apache/camel/quarkus/component/jira/it/JiraResource.java b/integration-tests/jira/src/main/java/org/apache/camel/quarkus/component/jira/it/JiraResource.java new file mode 100644 index 0000000..9433680 --- /dev/null +++ b/integration-tests/jira/src/main/java/org/apache/camel/quarkus/component/jira/it/JiraResource.java @@ -0,0 +1,86 @@ +/* + * 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.jira.it; + +import java.net.URI; + +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.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import com.atlassian.jira.rest.client.api.RestClientException; +import org.apache.camel.ConsumerTemplate; +import org.apache.camel.ProducerTemplate; +import org.jboss.logging.Logger; + +@Path("/jira") +@ApplicationScoped +public class JiraResource { + + private static final Logger log = Logger.getLogger(JiraResource.class); + + String TEST_JIRA_URL = "https://somerepo.atlassian.net"; + String PROJECT = "TST"; + String USERNAME = "someguy"; + String PASSWORD = "my_password"; + String JIRA_CREDENTIALS = TEST_JIRA_URL + "&username=" + USERNAME + "&password=" + PASSWORD; + + @Inject + ProducerTemplate producerTemplate; + + @Inject + ConsumerTemplate consumerTemplate; + + @Path("/get") + @GET + @Produces(MediaType.TEXT_PLAIN) + public String get() throws Exception { + final String message = consumerTemplate.receiveBodyNoWait("jira:newIssues?jiraUrl=" + JIRA_CREDENTIALS, String.class); + log.infof("Received from jira: %s", message); + return message; + } + + @Path("/post") + @POST + @Consumes(MediaType.TEXT_PLAIN) + @Produces(MediaType.TEXT_PLAIN) + public Response post(String message) throws Exception { + + log.infof("Sending to jira: %s", message); + String response = null; + int statusCode = 0; + try { + response = (String) producerTemplate.requestBody("direct:start", message, String.class); + } catch (Exception ex) { + + statusCode = ((RestClientException) ex.getCause()).getStatusCode().get(); + } + + log.infof("Got response from jira: %s", response); + return Response + .created(new URI("https://camel.apache.org/")) + .entity(response) + .status(statusCode) + .build(); + } +} diff --git a/integration-tests/jira/src/main/java/org/apache/camel/quarkus/component/jira/it/JiraRouteBuilder.java b/integration-tests/jira/src/main/java/org/apache/camel/quarkus/component/jira/it/JiraRouteBuilder.java new file mode 100644 index 0000000..e73f71f --- /dev/null +++ b/integration-tests/jira/src/main/java/org/apache/camel/quarkus/component/jira/it/JiraRouteBuilder.java @@ -0,0 +1,41 @@ +/* + * 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.jira.it; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.jira.JiraConstants; + +public class JiraRouteBuilder extends RouteBuilder { + String TEST_JIRA_URL = "https://somerepo.atlassian.net"; + String PROJECT = "TST"; + String USERNAME = "someguy"; + String PASSWORD = "my_password"; + String JIRA_CREDENTIALS = TEST_JIRA_URL + "&username=" + USERNAME + "&password=" + PASSWORD; + + @Override + public void configure() { + + from("direct:start") + .setHeader(JiraConstants.ISSUE_PROJECT_KEY, constant("camel-jira")) + .setHeader(JiraConstants.ISSUE_TYPE_NAME, constant("Task")) + .setHeader(JiraConstants.ISSUE_SUMMARY, constant("Demo Bug jira")) + .setHeader(JiraConstants.ISSUE_PRIORITY_NAME, constant("Low")) + .setHeader(JiraConstants.ISSUE_ASSIGNEE, constant("Freeman")) + .to("jira://addIssue?jiraUrl=" + JIRA_CREDENTIALS); + + } +} diff --git a/integration-tests/jira/src/test/java/org/apache/camel/quarkus/component/jira/it/JiraIT.java b/integration-tests/jira/src/test/java/org/apache/camel/quarkus/component/jira/it/JiraIT.java new file mode 100644 index 0000000..93e4fbc --- /dev/null +++ b/integration-tests/jira/src/test/java/org/apache/camel/quarkus/component/jira/it/JiraIT.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.jira.it; + +import io.quarkus.test.junit.NativeImageTest; + +@NativeImageTest +class JiraIT extends JiraTest { + +} diff --git a/integration-tests/jira/src/test/java/org/apache/camel/quarkus/component/jira/it/JiraTest.java b/integration-tests/jira/src/test/java/org/apache/camel/quarkus/component/jira/it/JiraTest.java new file mode 100644 index 0000000..5db5c06 --- /dev/null +++ b/integration-tests/jira/src/test/java/org/apache/camel/quarkus/component/jira/it/JiraTest.java @@ -0,0 +1,41 @@ +/* + * 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.jira.it; + +import java.util.UUID; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +@QuarkusTest +class JiraTest { + + @Test + public void test() { + final String msg = UUID.randomUUID().toString().replace("-", ""); + RestAssured.given() // + .contentType(ContentType.TEXT).body(msg).post("/jira/post") + .then().statusCode(404);//external jira not exist, expect to return 404 + + String body = RestAssured.get("/jira/get").asString(); + Assertions.assertEquals(body, ""); + } + +} diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 57b4e8c..d7ac29e 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -197,6 +197,7 @@ <module>olingo4</module> <module>opentracing</module> <module>paho</module> + <module>jira</module> <module>pdf</module> <module>platform-http</module> <module>platform-http-engine</module> diff --git a/pom.xml b/pom.xml index aa66c18..5951b84 100644 --- a/pom.xml +++ b/pom.xml @@ -42,11 +42,13 @@ <ahc.version>2.10.4</ahc.version> <camel.version>3.0.1</camel.version> + <jira.guava.version>20.0</jira.guava.version> <hapi.version>4.1.0</hapi.version> <quarkus.version>1.3.0.Alpha1</quarkus.version> <httpmime.version>4.1.3</httpmime.version> <jetty.version>9.4.18.v20190429</jetty.version> <xstream.version>1.4.11</xstream.version> + <httpclient.cache.version>4.5.5</httpclient.cache.version> <snakeyaml.version>1.25</snakeyaml.version> <xalan.version>2.7.2</xalan.version> <xerces.version>2.12.0</xerces.version> diff --git a/poms/bom-deployment/pom.xml b/poms/bom-deployment/pom.xml index 364be6a..f9b32c5 100644 --- a/poms/bom-deployment/pom.xml +++ b/poms/bom-deployment/pom.xml @@ -55,6 +55,11 @@ <type>pom</type> <scope>import</scope> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-jira-deployment</artifactId> + <version>${project.version}</version> + </dependency> <!-- Dependencies a..z; do not remove this comment, it is important when sorting via mvn process-resources -Pformat --> diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index 4c50f6b..f994141 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -143,6 +143,16 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> + <artifactId>camel-jira</artifactId> + <version>${camel.version}</version> + </dependency> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + <version>${jira.guava.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> <artifactId>camel-base</artifactId> <version>${camel.version}</version> </dependency> @@ -970,7 +980,12 @@ <artifactId>camel-quarkus-zipfile</artifactId> <version>${camel-quarkus.version}</version> </dependency> - + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-jira</artifactId> + <version>${project.version}</version> + </dependency> + <!--$ Other third party dependencies $--> <dependency> <groupId>ca.uhn.hapi.fhir</groupId> @@ -1058,6 +1073,11 @@ <artifactId>xercesImpl</artifactId> <version>${xerces.version}</version> </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient-cache</artifactId> + <version>${httpclient.cache.version}</version> + </dependency> </dependencies> </dependencyManagement>