This is an automated email from the ASF dual-hosted git repository. acosentino 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 34c1f46 Add Slack extension new 80c0f95 Merge pull request #331 from jamesnetherton/slack-extension 34c1f46 is described below commit 34c1f46d01c320f07ec90c86a0cd5ab75f21903f Author: James Netherton <jamesnether...@gmail.com> AuthorDate: Thu Oct 24 16:15:01 2019 +0100 Add Slack extension fixes #305 --- .../pages/list-of-camel-quarkus-extensions.adoc | 11 +- extensions/pom.xml | 1 + extensions/readme.adoc | 11 +- extensions/slack/deployment/pom.xml | 75 ++++++++++++ .../component/slack/deployment/SlackProcessor.java | 44 +++++++ extensions/slack/pom.xml | 39 ++++++ extensions/slack/runtime/pom.xml | 92 ++++++++++++++ .../main/resources/META-INF/quarkus-extension.json | 9 ++ integration-tests/pom.xml | 1 + integration-tests/slack/pom.xml | 136 +++++++++++++++++++++ .../quarkus/component/slack/it/SlackResource.java | 62 ++++++++++ .../quarkus/component/slack/it/SlackRoutes.java | 46 +++++++ .../src/main/resources/application.properties | 26 ++++ .../camel/quarkus/component/slack/it/SlackIT.java | 24 ++++ .../quarkus/component/slack/it/SlackTest.java | 51 ++++++++ poms/bom-deployment/pom.xml | 5 + poms/bom/pom.xml | 10 ++ 17 files changed, 635 insertions(+), 8 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 d82a469..6777c66 100644 --- a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc +++ b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc @@ -6,7 +6,7 @@ As of Camel Quarkus {camel-quarkus-last-release} the following Camel artifacts a == Camel Components // components: START -Number of Camel components: 23 in 19 JAR artifacts (0 deprecated) +Number of Camel components: 24 in 20 JAR artifacts (0 deprecated) [width="100%",cols="4,1,5",options="header"] |=== @@ -33,7 +33,7 @@ Number of Camel components: 23 in 19 JAR artifacts (0 deprecated) | link:https://camel.apache.org/components/latest/direct-component.html[Direct] (camel-quarkus-direct) + `direct:name` | 0.2 | The direct component provides direct, synchronous call to another endpoint from the same CamelContext. -| link:https://camel.apache.org/components/latest/fhir-component.html[FHIR] (camel-quarkus-fhir) + +| xref:extensions/fhir.adoc[FHIR] (camel-quarkus-fhir) + `fhir:apiName/methodName` | 0.2 | The fhir component is used for working with the FHIR protocol (health care). | link:https://camel.apache.org/components/latest/infinispan-component.html[Infinispan] (camel-quarkus-infinispan) + @@ -69,6 +69,9 @@ Number of Camel components: 23 in 19 JAR artifacts (0 deprecated) | link:https://camel.apache.org/components/latest/servlet-component.html[Servlet] (camel-quarkus-servlet) + `servlet:contextPath` | 0.2 | To use a HTTP Servlet as entry for Camel routes when running in a servlet container. +| link:https://camel.apache.org/components/latest/slack-component.html[Slack] (camel-quarkus-slack) + +`slack:channel` | 0.3 | The slack component allows you to send messages to Slack. + | link:https://camel.apache.org/components/latest/timer-component.html[Timer] (camel-quarkus-timer) + `timer:timerName` | 0.2 | The timer component is used for generating message exchanges when a timer fires. @@ -95,9 +98,9 @@ Number of Camel data formats: 6 in 5 JAR artifacts (0 deprecated) | link:https://camel.apache.org/components/latest/csv-dataformat.html[CSV] (camel-quarkus-csv) | 0.2 | The CSV data format is used for handling CSV payloads. -| link:https://camel.apache.org/components/latest/fhirJson-dataformat.html[FHIR JSon] (camel-quarkus-fhir) | 0.2 | The FHIR JSon data format is used to marshall/unmarshall to/from FHIR objects to/from JSON. +| xref:extensions/fhir.adoc[FHIR JSon] (camel-quarkus-fhir) | 0.2 | The FHIR JSon data format is used to marshall/unmarshall to/from FHIR objects to/from JSON. -| link:https://camel.apache.org/components/latest/fhirXml-dataformat.html[FHIR XML] (camel-quarkus-fhir) | 0.2 | The FHIR XML data format is used to marshall/unmarshall from/to FHIR objects to/from XML. +| xref:extensions/fhir.adoc[FHIR XML] (camel-quarkus-fhir) | 0.2 | The FHIR XML data format is used to marshall/unmarshall from/to FHIR objects to/from XML. | link:https://camel.apache.org/components/latest/mime-multipart-dataformat.html[MIME Multipart] (camel-quarkus-mail) | 0.2 | The MIME Multipart data format is used for marshalling Camel messages with attachments into MIME-Multipart message, and vise-versa. diff --git a/extensions/pom.xml b/extensions/pom.xml index 2833d8e..6242bf8 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -64,6 +64,7 @@ <module>rest</module> <module>salesforce</module> <module>servlet</module> + <module>slack</module> <module>tarfile</module> <module>timer</module> <module>twitter</module> diff --git a/extensions/readme.adoc b/extensions/readme.adoc index d9d4749..3d434a3 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: 23 in 19 JAR artifacts (0 deprecated) +Number of Camel components: 24 in 20 JAR artifacts (0 deprecated) [width="100%",cols="4,1,5",options="header"] |=== @@ -32,7 +32,7 @@ Number of Camel components: 23 in 19 JAR artifacts (0 deprecated) | link:https://camel.apache.org/components/latest/direct-component.html[Direct] (camel-quarkus-direct) + `direct:name` | 0.2 | The direct component provides direct, synchronous call to another endpoint from the same CamelContext. -| link:https://camel.apache.org/components/latest/fhir-component.html[FHIR] (camel-quarkus-fhir) + +| xref:extensions/fhir.adoc[FHIR] (camel-quarkus-fhir) + `fhir:apiName/methodName` | 0.2 | The fhir component is used for working with the FHIR protocol (health care). | link:https://camel.apache.org/components/latest/infinispan-component.html[Infinispan] (camel-quarkus-infinispan) + @@ -68,6 +68,9 @@ Number of Camel components: 23 in 19 JAR artifacts (0 deprecated) | link:https://camel.apache.org/components/latest/servlet-component.html[Servlet] (camel-quarkus-servlet) + `servlet:contextPath` | 0.2 | To use a HTTP Servlet as entry for Camel routes when running in a servlet container. +| link:https://camel.apache.org/components/latest/slack-component.html[Slack] (camel-quarkus-slack) + +`slack:channel` | 0.3 | The slack component allows you to send messages to Slack. + | link:https://camel.apache.org/components/latest/timer-component.html[Timer] (camel-quarkus-timer) + `timer:timerName` | 0.2 | The timer component is used for generating message exchanges when a timer fires. @@ -95,9 +98,9 @@ Number of Camel data formats: 6 in 5 JAR artifacts (0 deprecated) | link:https://camel.apache.org/components/latest/csv-dataformat.html[CSV] (camel-quarkus-csv) | 0.2 | The CSV data format is used for handling CSV payloads. -| link:https://camel.apache.org/components/latest/fhirJson-dataformat.html[FHIR JSon] (camel-quarkus-fhir) | 0.2 | The FHIR JSon data format is used to marshall/unmarshall to/from FHIR objects to/from JSON. +| xref:extensions/fhir.adoc[FHIR JSon] (camel-quarkus-fhir) | 0.2 | The FHIR JSon data format is used to marshall/unmarshall to/from FHIR objects to/from JSON. -| link:https://camel.apache.org/components/latest/fhirXml-dataformat.html[FHIR XML] (camel-quarkus-fhir) | 0.2 | The FHIR XML data format is used to marshall/unmarshall from/to FHIR objects to/from XML. +| xref:extensions/fhir.adoc[FHIR XML] (camel-quarkus-fhir) | 0.2 | The FHIR XML data format is used to marshall/unmarshall from/to FHIR objects to/from XML. | link:https://camel.apache.org/components/latest/mime-multipart-dataformat.html[MIME Multipart] (camel-quarkus-mail) | 0.2 | The MIME Multipart data format is used for marshalling Camel messages with attachments into MIME-Multipart message, and vise-versa. diff --git a/extensions/slack/deployment/pom.xml b/extensions/slack/deployment/pom.xml new file mode 100644 index 0000000..509597b --- /dev/null +++ b/extensions/slack/deployment/pom.xml @@ -0,0 +1,75 @@ +<?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-slack-parent</artifactId> + <version>0.2.1-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-slack-deployment</artifactId> + <name>Camel Quarkus :: Slack :: 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-slack</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/slack/deployment/src/main/java/org/apache/camel/quarkus/component/slack/deployment/SlackProcessor.java b/extensions/slack/deployment/src/main/java/org/apache/camel/quarkus/component/slack/deployment/SlackProcessor.java new file mode 100644 index 0000000..6c83499 --- /dev/null +++ b/extensions/slack/deployment/src/main/java/org/apache/camel/quarkus/component/slack/deployment/SlackProcessor.java @@ -0,0 +1,44 @@ +/* + * 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.slack.deployment; + +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; +import io.quarkus.deployment.builditem.FeatureBuildItem; +import io.quarkus.deployment.builditem.substrate.SubstrateResourceBuildItem; + +class SlackProcessor { + + private static final String FEATURE = "camel-slack"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } + + @BuildStep + ExtensionSslNativeSupportBuildItem activateSslNativeSupport() { + return new ExtensionSslNativeSupportBuildItem(FEATURE); + } + + @BuildStep + SubstrateResourceBuildItem suffixListResource() { + // Required by org.apache.http.conn.util.PublicSuffixMatcher + return new SubstrateResourceBuildItem("mozilla/public-suffix-list.txt"); + } + +} diff --git a/extensions/slack/pom.xml b/extensions/slack/pom.xml new file mode 100644 index 0000000..9352696 --- /dev/null +++ b/extensions/slack/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>0.2.1-SNAPSHOT</version> + <relativePath>../../poms/build-parent/pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-slack-parent</artifactId> + <name>Camel Quarkus :: Slack</name> + <packaging>pom</packaging> + + <modules> + <module>deployment</module> + <module>runtime</module> + </modules> +</project> diff --git a/extensions/slack/runtime/pom.xml b/extensions/slack/runtime/pom.xml new file mode 100644 index 0000000..ab3817d --- /dev/null +++ b/extensions/slack/runtime/pom.xml @@ -0,0 +1,92 @@ +<?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-slack-parent</artifactId> + <version>0.2.1-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-slack</artifactId> + <name>Camel Quarkus :: Slack :: Runtime</name> + + <properties> + <firstVersion>0.3.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>org.apache.camel</groupId> + <artifactId>camel-slack</artifactId> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.jboss.logging</groupId> + <artifactId>commons-logging-jboss-logging</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/slack/runtime/src/main/resources/META-INF/quarkus-extension.json b/extensions/slack/runtime/src/main/resources/META-INF/quarkus-extension.json new file mode 100644 index 0000000..d43dee5 --- /dev/null +++ b/extensions/slack/runtime/src/main/resources/META-INF/quarkus-extension.json @@ -0,0 +1,9 @@ +{ + "name": "Camel Quarkus Slack", + "labels": [ + "integration", + "camel", + "slack" + ], + "guide": "https://quarkus.io/guides/camel" +} diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index d75164b..f6799f3 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -104,6 +104,7 @@ <module>platform-http</module> <module>salesforce</module> <module>servlet</module> + <module>slack</module> <module>tarfile</module> <module>twitter</module> <module>zipfile</module> diff --git a/integration-tests/slack/pom.xml b/integration-tests/slack/pom.xml new file mode 100644 index 0000000..fbc6ee9 --- /dev/null +++ b/integration-tests/slack/pom.xml @@ -0,0 +1,136 @@ +<?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>0.2.1-SNAPSHOT</version> + </parent> + + <artifactId>camel-quarkus-integration-test-slack</artifactId> + <name>Camel Quarkus :: Integration Tests :: Slack</name> + <description>Integration tests for Camel Quarkus Slack extension</description> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-netty-http</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-rest</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-slack</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> + </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-image</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> + +</project> diff --git a/integration-tests/slack/src/main/java/org/apache/camel/quarkus/component/slack/it/SlackResource.java b/integration-tests/slack/src/main/java/org/apache/camel/quarkus/component/slack/it/SlackResource.java new file mode 100644 index 0000000..bf98b6c --- /dev/null +++ b/integration-tests/slack/src/main/java/org/apache/camel/quarkus/component/slack/it/SlackResource.java @@ -0,0 +1,62 @@ +/* + * 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.slack.it; + +import java.net.URI; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +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 org.apache.camel.ConsumerTemplate; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.component.slack.helper.SlackMessage; + +@Path("/slack") +@ApplicationScoped +public class SlackResource { + + private static final String SLACK_AUTH_PARAMS = "serverUrl={{env:SLACK_SERVER_URL:http://localhost:8099/slack}}&token={{env:SLACK_TOKEN:a-fake-token-for-testing}}"; + + @Inject + ProducerTemplate producerTemplate; + + @Inject + ConsumerTemplate consumerTemplate; + + @Path("/messages") + @GET + @Produces(MediaType.TEXT_PLAIN) + public String getSlackMessages() throws Exception { + SlackMessage message = consumerTemplate.receiveBody("slack://general?maxResults=1&" + SLACK_AUTH_PARAMS, SlackMessage.class); + return message.getText(); + } + + @Path("/message") + @POST + public Response createSlackMessage(String message) throws Exception { + producerTemplate.requestBody("slack://general?" + SLACK_AUTH_PARAMS, "Hello Camel Quarkus Slack"); + return Response + .created(new URI("https://camel.apache.org/")) + .build(); + } +} diff --git a/integration-tests/slack/src/main/java/org/apache/camel/quarkus/component/slack/it/SlackRoutes.java b/integration-tests/slack/src/main/java/org/apache/camel/quarkus/component/slack/it/SlackRoutes.java new file mode 100644 index 0000000..edf04a6 --- /dev/null +++ b/integration-tests/slack/src/main/java/org/apache/camel/quarkus/component/slack/it/SlackRoutes.java @@ -0,0 +1,46 @@ +/* + * 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.slack.it; + +import org.apache.camel.builder.RouteBuilder; + +public class SlackRoutes extends RouteBuilder { + @Override + public void configure() throws Exception { + + // Stubbed API endpoints for testing without slack API credentials + restConfiguration() + .component("netty-http") + .host("0.0.0.0") + .port(8099); + + rest() + .post("/webhook") + .route() + .setBody(constant("{\"ok\": true}")) + .endRest() + .post("/slack/api/channels.list") + .route() + .setBody(constant("{\"ok\":true,\"channels\":[{\"id\":\"ABC12345\",\"name\":\"general\",\"is_channel\":true,\"created\":1571904169}]}")) + .endRest() + .post("/slack/api/channels.history") + .route() + .setBody(constant("{\"ok\":true,\"messages\":[{\"type\":\"message\",\"subtype\":\"bot_message\",\"text\":\"Hello Camel Quarkus Slack\"" + + ",\"ts\":\"1571912155.001300\",\"bot_id\":\"ABC12345C\"}],\"has_more\":true" + + ",\"channel_actions_ts\":null,\"channel_actions_count\":0}")); + } +} diff --git a/integration-tests/slack/src/main/resources/application.properties b/integration-tests/slack/src/main/resources/application.properties new file mode 100644 index 0000000..729b329 --- /dev/null +++ b/integration-tests/slack/src/main/resources/application.properties @@ -0,0 +1,26 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# +# Camel +# +camel.context.name = quarkus-camel-example + +# +# Camel :: Slack +# +camel.component.slack.webhook-url={{env:SLACK_WEBHOOK_URL:http://localhost:8099/webhook}} diff --git a/integration-tests/slack/src/test/java/org/apache/camel/quarkus/component/slack/it/SlackIT.java b/integration-tests/slack/src/test/java/org/apache/camel/quarkus/component/slack/it/SlackIT.java new file mode 100644 index 0000000..4f65122 --- /dev/null +++ b/integration-tests/slack/src/test/java/org/apache/camel/quarkus/component/slack/it/SlackIT.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.slack.it; + +import io.quarkus.test.junit.SubstrateTest; + +@SubstrateTest +class SlackIT extends SlackTest { + +} diff --git a/integration-tests/slack/src/test/java/org/apache/camel/quarkus/component/slack/it/SlackTest.java b/integration-tests/slack/src/test/java/org/apache/camel/quarkus/component/slack/it/SlackTest.java new file mode 100644 index 0000000..e7797cf --- /dev/null +++ b/integration-tests/slack/src/test/java/org/apache/camel/quarkus/component/slack/it/SlackTest.java @@ -0,0 +1,51 @@ +/* + * 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.slack.it; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; + +import org.junit.jupiter.api.Test; +import static org.hamcrest.CoreMatchers.equalTo; + +/** + * Camel Slack component tests. + * + * By default tests configure the Slack component to use stubbed Slack API responses + * that are configured in {@link SlackRoutes} + * + * To test against a real Slack instance. Set up environment variables like the following: + * + * SLACK_WEBHOOK_URL=https://hooks.slack.com/services/unique/hook/path + * SLACK_SERVER_URL=https://slack.com + * SLACK_TOKEN=your-slack-api-access-token + */ +@QuarkusTest +class SlackTest { + + @Test + public void testSlackProduceConsumeMessages() { + RestAssured.post("/slack/message") + .then() + .statusCode(201); + + RestAssured.get("/slack/messages") + .then() + .statusCode(200) + .body(equalTo("Hello Camel Quarkus Slack")); + } +} diff --git a/poms/bom-deployment/pom.xml b/poms/bom-deployment/pom.xml index 396b8d8..5f4a5ee 100644 --- a/poms/bom-deployment/pom.xml +++ b/poms/bom-deployment/pom.xml @@ -212,6 +212,11 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-slack-deployment</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-timer-deployment</artifactId> <version>${camel-quarkus.version}</version> </dependency> diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index d83878a..b1a5c80 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -233,6 +233,11 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> + <artifactId>camel-slack</artifactId> + <version>${camel.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> <artifactId>camel-support</artifactId> <version>${camel.version}</version> </dependency> @@ -424,6 +429,11 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-slack</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-tarfile</artifactId> <version>${camel-quarkus.version}</version> </dependency>