You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pp...@apache.org on 2020/03/25 08:53:17 UTC
[camel-quarkus] 01/02: Update to add the camel-servicenow extension
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 496d68c73798780a7b9e7e6f49b0d3614d3d34fc
Author: Amos Feng <zf...@redhat.com>
AuthorDate: Wed Mar 18 16:44:26 2020 +0800
Update to add the camel-servicenow extension
---
.github/workflows/pr-build.yaml | 1 +
.../pages/list-of-camel-quarkus-extensions.adoc | 6 +-
extensions/pom.xml | 1 +
extensions/servicenow/deployment/pom.xml | 75 ++++++++++++++
.../servicenow/deployment/ServicenowProcessor.java | 54 ++++++++++
extensions/servicenow/pom.xml | 39 +++++++
extensions/servicenow/runtime/pom.xml | 91 +++++++++++++++++
.../servicenow/graal/WebClientSubstitution.java | 65 ++++++++++++
.../main/resources/META-INF/quarkus-extension.yaml | 30 ++++++
integration-tests/pom.xml | 1 +
integration-tests/servicenow/README.adoc | 12 +++
integration-tests/servicenow/pom.xml | 113 +++++++++++++++++++++
.../servicenow/it/ServicenowResource.java | 82 +++++++++++++++
.../component/servicenow/it/model/Incident.java | 95 +++++++++++++++++
.../src/main/resources/application.properties | 25 +++++
.../component/servicenow/it/ServicenowIT.java | 28 +++++
.../component/servicenow/it/ServicenowTest.java | 43 ++++++++
poms/bom-deployment/pom.xml | 5 +
poms/bom/pom.xml | 10 ++
19 files changed, 775 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/pr-build.yaml b/.github/workflows/pr-build.yaml
index 485a2fb..b544565 100644
--- a/.github/workflows/pr-build.yaml
+++ b/.github/workflows/pr-build.yaml
@@ -181,6 +181,7 @@ jobs:
google
jira
salesforce
+ servicenow
slack
twitter
- category: SQL
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 2fc1ce4..1967641 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: 142 in 107 JAR artifacts (0 deprecated)
+Number of Camel components: 143 in 108 JAR artifacts (0 deprecated)
[width="100%",cols="4,1,1,5",options="header"]
|===
@@ -525,6 +525,10 @@ Level | Since | Description
`seda:name` | Native +
Stable | 1.0.0-M1 | The seda component provides asynchronous call to another endpoint from any CamelContext in the same JVM.
+| link:https://camel.apache.org/components/latest/servicenow-component.html[ServiceNow] (camel-quarkus-servicenow) +
+`servicenow:instanceName` | Native +
+ Stable | 1.0.0-M6 | The servicenow component is used to integrate Camel with ServiceNow cloud services.
+
| link:https://camel.apache.org/components/latest/servlet-component.html[Servlet] (camel-quarkus-servlet) +
`servlet:contextPath` | Native +
Stable | 0.2.0 | To use a HTTP Servlet as entry for Camel routes when running in a servlet container.
diff --git a/extensions/pom.xml b/extensions/pom.xml
index aec6856..0071756 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -111,6 +111,7 @@
<module>salesforce</module>
<module>scheduler</module>
<module>seda</module>
+ <module>servicenow</module>
<module>servlet</module>
<module>sjms</module>
<module>sjms2</module>
diff --git a/extensions/servicenow/deployment/pom.xml b/extensions/servicenow/deployment/pom.xml
new file mode 100644
index 0000000..4a0630a
--- /dev/null
+++ b/extensions/servicenow/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-servicenow-parent</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-servicenow-deployment</artifactId>
+ <name>Camel Quarkus :: ServiceNow :: 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-servicenow</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/servicenow/deployment/src/main/java/org/apache/camel/quarkus/component/servicenow/deployment/ServicenowProcessor.java b/extensions/servicenow/deployment/src/main/java/org/apache/camel/quarkus/component/servicenow/deployment/ServicenowProcessor.java
new file mode 100644
index 0000000..7618732
--- /dev/null
+++ b/extensions/servicenow/deployment/src/main/java/org/apache/camel/quarkus/component/servicenow/deployment/ServicenowProcessor.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.servicenow.deployment;
+
+import io.quarkus.deployment.annotations.BuildProducer;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
+import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem;
+import io.quarkus.deployment.builditem.FeatureBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
+import org.apache.camel.component.servicenow.ServiceNowConfiguration;
+import org.apache.camel.quarkus.core.deployment.UnbannedReflectiveBuildItem;
+import org.apache.cxf.transport.http.HTTPTransportFactory;
+
+class ServicenowProcessor {
+
+ private static final String FEATURE = "camel-servicenow";
+
+ private static final String[] reflectionClasses = new String[] {
+ ServiceNowConfiguration.class.getCanonicalName(),
+ HTTPTransportFactory.class.getCanonicalName()
+ };
+
+ @BuildStep
+ FeatureBuildItem feature() {
+ return new FeatureBuildItem(FEATURE);
+ }
+
+ @BuildStep
+ ExtensionSslNativeSupportBuildItem activateSslNativeSupport() {
+ return new ExtensionSslNativeSupportBuildItem(FEATURE);
+ }
+
+ @BuildStep
+ void registerForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
+ BuildProducer<UnbannedReflectiveBuildItem> unbannedClass, CombinedIndexBuildItem combinedIndex) {
+ reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, reflectionClasses));
+ unbannedClass.produce(new UnbannedReflectiveBuildItem(reflectionClasses));
+ }
+}
diff --git a/extensions/servicenow/pom.xml b/extensions/servicenow/pom.xml
new file mode 100644
index 0000000..73d956d
--- /dev/null
+++ b/extensions/servicenow/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-servicenow-parent</artifactId>
+ <name>Camel Quarkus :: ServiceNow</name>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>deployment</module>
+ <module>runtime</module>
+ </modules>
+</project>
diff --git a/extensions/servicenow/runtime/pom.xml b/extensions/servicenow/runtime/pom.xml
new file mode 100644
index 0000000..7c2ca72
--- /dev/null
+++ b/extensions/servicenow/runtime/pom.xml
@@ -0,0 +1,91 @@
+<?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-servicenow-parent</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-servicenow</artifactId>
+ <name>Camel Quarkus :: ServiceNow :: Runtime</name>
+ <description>The servicenow component is used to integrate Camel with ServiceNow cloud services.</description>
+
+ <properties>
+ <firstVersion>1.0.0-M6</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.graalvm.nativeimage</groupId>
+ <artifactId>svm</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-servicenow</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>jakarta.servlet</groupId>
+ <artifactId>jakarta.servlet-api</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/servicenow/runtime/src/main/java/org/apache/camel/quarkus/component/servicenow/graal/WebClientSubstitution.java b/extensions/servicenow/runtime/src/main/java/org/apache/camel/quarkus/component/servicenow/graal/WebClientSubstitution.java
new file mode 100644
index 0000000..325551e
--- /dev/null
+++ b/extensions/servicenow/runtime/src/main/java/org/apache/camel/quarkus/component/servicenow/graal/WebClientSubstitution.java
@@ -0,0 +1,65 @@
+/*
+ * 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.servicenow.graal;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.oracle.svm.core.annotate.Substitute;
+import com.oracle.svm.core.annotate.TargetClass;
+import org.apache.cxf.Bus;
+import org.apache.cxf.bus.CXFBusFactory;
+import org.apache.cxf.bus.extension.Extension;
+import org.apache.cxf.bus.extension.ExtensionRegistry;
+import org.apache.cxf.bus.managers.ClientLifeCycleManagerImpl;
+import org.apache.cxf.bus.managers.ConduitInitiatorManagerImpl;
+import org.apache.cxf.bus.managers.PhaseManagerImpl;
+import org.apache.cxf.endpoint.ClientLifeCycleManager;
+import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.cxf.phase.PhaseManager;
+import org.apache.cxf.transport.ConduitInitiatorManager;
+import org.apache.cxf.transport.http.HTTPTransportFactory;
+
+@TargetClass(WebClient.class)
+final public class WebClientSubstitution {
+
+ @Substitute
+ static JAXRSClientFactoryBean getBean(String baseAddress, String configLocation) {
+ JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
+ // configLocation is always null and no need to create SpringBusFactory.
+ CXFBusFactory bf = new CXFBusFactory();
+
+ // It can not load the extensions from the bus-extensions.txt dynamically.
+ // So have to set all of necessary ones here.
+ List<Extension> extensions = new ArrayList<>();
+ Extension http = new Extension();
+ http.setClassname(HTTPTransportFactory.class.getName());
+ http.setDeferred(true);
+ extensions.add(http);
+ ExtensionRegistry.addExtensions(extensions);
+
+ Bus bus = bf.createBus();
+ bus.setExtension(new PhaseManagerImpl(), PhaseManager.class);
+ bus.setExtension(new ClientLifeCycleManagerImpl(), ClientLifeCycleManager.class);
+ bus.setExtension(new ConduitInitiatorManagerImpl(bus), ConduitInitiatorManager.class);
+
+ bean.setBus(bus);
+ bean.setAddress(baseAddress);
+ return bean;
+ }
+}
diff --git a/extensions/servicenow/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/servicenow/runtime/src/main/resources/META-INF/quarkus-extension.yaml
new file mode 100644
index 0000000..cbe3015
--- /dev/null
+++ b/extensions/servicenow/runtime/src/main/resources/META-INF/quarkus-extension.yaml
@@ -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.
+#
+
+---
+name: "ServiceNow"
+description: "The servicenow component is used to integrate Camel with ServiceNow cloud services."
+metadata:
+ keywords:
+ - "camel"
+ - "api"
+ - "cloud"
+ - "management"
+ guide: "https://quarkus.io/guides/camel"
+ categories:
+ - "integration"
+ status: "preview"
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index 76f50e2..c090178 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -206,6 +206,7 @@
<module>salesforce</module>
<module>scheduler</module>
<module>seda</module>
+ <module>servicenow</module>
<module>servlet</module>
<module>slack</module>
<module>soap</module>
diff --git a/integration-tests/servicenow/README.adoc b/integration-tests/servicenow/README.adoc
new file mode 100644
index 0000000..528da26
--- /dev/null
+++ b/integration-tests/servicenow/README.adoc
@@ -0,0 +1,12 @@
+== Camel Quarkus ServiceNow Integration Tests
+
+To run the `camel-quarkus-servicenow` integration tests, you will need a https://servicenow.com[ServiceNow] instance.
+
+Then set the following environment variables:
+
+[source,shell]
+----
+export SERVICENOW_INSTANCE=my-instance
+export SERVICENOW_USERNAME=my-username
+export SERVICENOW_PASSWORD=my-password
+----
diff --git a/integration-tests/servicenow/pom.xml b/integration-tests/servicenow/pom.xml
new file mode 100644
index 0000000..7749b0c
--- /dev/null
+++ b/integration-tests/servicenow/pom.xml
@@ -0,0 +1,113 @@
+<?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-servicenow</artifactId>
+ <name>Camel Quarkus :: Integration Tests :: ServiceNow</name>
+ <description>Integration tests for Camel Quarkus ServiceNow 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-servicenow-deployment,camel-quarkus-support-policy-deployment</mvnd.builder.rule>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-servicenow</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</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/servicenow/src/main/java/org/apache/camel/quarkus/component/servicenow/it/ServicenowResource.java b/integration-tests/servicenow/src/main/java/org/apache/camel/quarkus/component/servicenow/it/ServicenowResource.java
new file mode 100644
index 0000000..b59b21c
--- /dev/null
+++ b/integration-tests/servicenow/src/main/java/org/apache/camel/quarkus/component/servicenow/it/ServicenowResource.java
@@ -0,0 +1,82 @@
+/*
+ * 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.servicenow.it;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.ws.rs.Consumes;
+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.fasterxml.jackson.databind.JsonNode;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.servicenow.ServiceNowConstants;
+import org.apache.camel.component.servicenow.ServiceNowParams;
+import org.apache.camel.quarkus.component.servicenow.it.model.Incident;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+import org.jboss.logging.Logger;
+
+@Path("/servicenow")
+@ApplicationScoped
+public class ServicenowResource {
+
+ private static final Logger LOG = Logger.getLogger(ServicenowResource.class);
+
+ @Inject
+ ProducerTemplate producerTemplate;
+
+ @ConfigProperty(name = "servicenow.instance")
+ String instance;
+
+ @Path("/post")
+ @POST
+ @Consumes(MediaType.TEXT_PLAIN)
+ @Produces(MediaType.TEXT_PLAIN)
+ public Response post(String message) throws Exception {
+ Map<String, Object> headers = new HashMap<>();
+ headers.put(ServiceNowConstants.RESOURCE, ServiceNowConstants.RESOURCE_TABLE);
+ headers.put(ServiceNowConstants.API_VERSION, "v1");
+ headers.put(ServiceNowConstants.ACTION, ServiceNowConstants.ACTION_CREATE);
+ headers.put(ServiceNowConstants.REQUEST_MODEL, Incident.class);
+ headers.put(ServiceNowConstants.RESPONSE_MODEL, JsonNode.class);
+ headers.put(ServiceNowParams.PARAM_TABLE_NAME.getHeader(), "incident");
+
+ Incident incident = new Incident();
+ incident.setDescription(message);
+ incident.setImpact(1);
+ incident.setSeverity(1);
+
+ LOG.infof("Sending to servicenow: %s", message);
+ final JsonNode response = producerTemplate.requestBodyAndHeaders(
+ "servicenow:" + instance, incident, headers, JsonNode.class);
+
+ String number = response.findPath("number").textValue();
+
+ LOG.infof("Got response from servicenow: %s", response);
+ return Response
+ .created(new URI("https://camel.apache.org/"))
+ .entity(number)
+ .build();
+ }
+}
diff --git a/integration-tests/servicenow/src/main/java/org/apache/camel/quarkus/component/servicenow/it/model/Incident.java b/integration-tests/servicenow/src/main/java/org/apache/camel/quarkus/component/servicenow/it/model/Incident.java
new file mode 100644
index 0000000..91f5f18
--- /dev/null
+++ b/integration-tests/servicenow/src/main/java/org/apache/camel/quarkus/component/servicenow/it/model/Incident.java
@@ -0,0 +1,95 @@
+/*
+ * 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.servicenow.it.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class Incident {
+ @JsonProperty("sys_id")
+ private String id;
+
+ @JsonProperty("number")
+ private String number;
+
+ @JsonProperty("description")
+ private String description;
+
+ @JsonProperty("short_description")
+ private String shortDescription;
+
+ @JsonProperty("severity")
+ private int severity;
+
+ @JsonProperty("impact")
+ private int impact;
+
+ public Incident() {
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getNumber() {
+ return number;
+ }
+
+ public void setNumber(String number) {
+ this.number = number;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getShortDescription() {
+ return shortDescription;
+ }
+
+ public void setShortDescription(String shortDescription) {
+ this.shortDescription = shortDescription;
+ }
+
+ public int getSeverity() {
+ return severity;
+ }
+
+ public void setSeverity(int severity) {
+ this.severity = severity;
+ }
+
+ public int getImpact() {
+ return impact;
+ }
+
+ public void setImpact(int impact) {
+ this.impact = impact;
+ }
+
+}
diff --git a/integration-tests/servicenow/src/main/resources/application.properties b/integration-tests/servicenow/src/main/resources/application.properties
new file mode 100644
index 0000000..bfdee1e
--- /dev/null
+++ b/integration-tests/servicenow/src/main/resources/application.properties
@@ -0,0 +1,25 @@
+## ---------------------------------------------------------------------------
+## 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 :: ServiceNow
+#
+servicenow.instance={{env:SERVICENOW_INSTANCE}}
+
+camel.component.servicenow.configuration = #class:org.apache.camel.component.servicenow.ServiceNowConfiguration
+camel.component.servicenow.configuration.username={{env:SERVICENOW_USERNAME}}
+camel.component.servicenow.configuration.password={{env:SERVICENOW_PASSWORD}}
diff --git a/integration-tests/servicenow/src/test/java/org/apache/camel/quarkus/component/servicenow/it/ServicenowIT.java b/integration-tests/servicenow/src/test/java/org/apache/camel/quarkus/component/servicenow/it/ServicenowIT.java
new file mode 100644
index 0000000..0d0e0c1
--- /dev/null
+++ b/integration-tests/servicenow/src/test/java/org/apache/camel/quarkus/component/servicenow/it/ServicenowIT.java
@@ -0,0 +1,28 @@
+/*
+ * 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.servicenow.it;
+
+import io.quarkus.test.junit.NativeImageTest;
+import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
+
+@NativeImageTest
+@EnabledIfEnvironmentVariable(named = "SERVICENOW_INSTANCE", matches = ".+")
+@EnabledIfEnvironmentVariable(named = "SERVICENOW_USERNAME", matches = ".+")
+@EnabledIfEnvironmentVariable(named = "SERVICENOW_PASSWORD", matches = ".+")
+class ServicenowIT extends ServicenowTest {
+
+}
diff --git a/integration-tests/servicenow/src/test/java/org/apache/camel/quarkus/component/servicenow/it/ServicenowTest.java b/integration-tests/servicenow/src/test/java/org/apache/camel/quarkus/component/servicenow/it/ServicenowTest.java
new file mode 100644
index 0000000..8168518
--- /dev/null
+++ b/integration-tests/servicenow/src/test/java/org/apache/camel/quarkus/component/servicenow/it/ServicenowTest.java
@@ -0,0 +1,43 @@
+/*
+ * 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.servicenow.it;
+
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
+
+import static org.hamcrest.Matchers.matchesPattern;
+
+@QuarkusTest
+@EnabledIfEnvironmentVariable(named = "SERVICENOW_INSTANCE", matches = ".+")
+@EnabledIfEnvironmentVariable(named = "SERVICENOW_USERNAME", matches = ".+")
+@EnabledIfEnvironmentVariable(named = "SERVICENOW_PASSWORD", matches = ".+")
+class ServicenowTest {
+
+ @Test
+ public void test() {
+ RestAssured.given()
+ .contentType(ContentType.TEXT)
+ .body("Demo incident")
+ .post("/servicenow/post")
+ .then()
+ .statusCode(201)
+ .body(matchesPattern("INC[0-9]+"));
+ }
+}
diff --git a/poms/bom-deployment/pom.xml b/poms/bom-deployment/pom.xml
index 927fd39..84c3682 100644
--- a/poms/bom-deployment/pom.xml
+++ b/poms/bom-deployment/pom.xml
@@ -664,6 +664,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-servicenow-deployment</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-servlet-deployment</artifactId>
<version>${camel-quarkus.version}</version>
</dependency>
diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml
index 2aed324..f9d5c60 100644
--- a/poms/bom/pom.xml
+++ b/poms/bom/pom.xml
@@ -841,6 +841,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-servicenow</artifactId>
+ <version>${camel.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-servlet</artifactId>
<version>${camel.version}</version>
</dependency>
@@ -1589,6 +1594,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-servicenow</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-servlet</artifactId>
<version>${camel-quarkus.version}</version>
</dependency>