You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2020/02/28 15:47:50 UTC
[camel-quarkus] branch master updated: Add Braintree extension
This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/master by this push:
new 1175fdc Add Braintree extension
1175fdc is described below
commit 1175fdc6dd5e6ee4a7782afa56b404803ad2e73d
Author: James Netherton <ja...@gmail.com>
AuthorDate: Fri Feb 28 14:07:45 2020 +0000
Add Braintree extension
Fixes #810
---
.github/workflows/pr-build.yaml | 1 +
.../pages/list-of-camel-quarkus-extensions.adoc | 5 +-
extensions/braintree/deployment/pom.xml | 75 +++++++++++++
.../braintree/deployment/BraintreeProcessor.java | 90 +++++++++++++++
extensions/braintree/pom.xml | 39 +++++++
extensions/braintree/runtime/pom.xml | 85 ++++++++++++++
.../braintree/graal/BraintreeRecorder.java | 36 ++++++
.../main/resources/META-INF/quarkus-extension.yaml | 27 +++++
extensions/pom.xml | 1 +
extensions/readme.adoc | 5 +-
integration-tests/braintree/README.adoc | 12 ++
integration-tests/braintree/pom.xml | 123 +++++++++++++++++++++
.../component/braintree/it/BraintreeResource.java | 99 +++++++++++++++++
.../src/main/resources/application.properties | 22 ++++
.../component/braintree/it/BraintreeIT.java | 28 +++++
.../component/braintree/it/BraintreeTest.java | 71 ++++++++++++
integration-tests/pom.xml | 1 +
poms/bom-deployment/pom.xml | 5 +
poms/bom/pom.xml | 10 ++
19 files changed, 733 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/pr-build.yaml b/.github/workflows/pr-build.yaml
index 685351f..a1a2414 100644
--- a/.github/workflows/pr-build.yaml
+++ b/.github/workflows/pr-build.yaml
@@ -369,6 +369,7 @@ jobs:
-Ddocker \
-DskipTests \
-pl :camel-quarkus-integration-test-bean-validator \
+ -pl :camel-quarkus-integration-test-braintree \
-pl :camel-quarkus-integration-test-dozer \
-pl :camel-quarkus-integration-test-ftp \
-pl :camel-quarkus-integration-test-mail \
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 b93d9f3..9171db3 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: 68 in 58 JAR artifacts (0 deprecated)
+Number of Camel components: 69 in 59 JAR artifacts (0 deprecated)
[width="100%",cols="4,1,5",options="header"]
|===
@@ -81,6 +81,9 @@ Number of Camel components: 68 in 58 JAR artifacts (0 deprecated)
| link:https://camel.apache.org/components/latest/box-component.html[Box] (camel-quarkus-box) +
`box:apiName/methodName` | 1.2.0 | For uploading downloading and managing files folders groups collaborations etc on box DOT com.
+| link:https://camel.apache.org/components/latest/braintree-component.html[Braintree] (camel-quarkus-braintree) +
+`braintree:apiName/methodName` | 1.2.0 | The braintree component is used for integrating with the Braintree Payment System.
+
| link:https://camel.apache.org/components/latest/class-component.html[Class] (camel-quarkus-bean) +
`class:beanName` | 0.2.0 | The Class component is for invoking Java classes (Java beans) from Camel.
diff --git a/extensions/braintree/deployment/pom.xml b/extensions/braintree/deployment/pom.xml
new file mode 100644
index 0000000..7e7bb48
--- /dev/null
+++ b/extensions/braintree/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-braintree-parent</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-braintree-deployment</artifactId>
+ <name>Camel Quarkus :: Braintree :: 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-braintree</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/braintree/deployment/src/main/java/org/apache/camel/quarkus/component/braintree/deployment/BraintreeProcessor.java b/extensions/braintree/deployment/src/main/java/org/apache/camel/quarkus/component/braintree/deployment/BraintreeProcessor.java
new file mode 100644
index 0000000..fae2cf2
--- /dev/null
+++ b/extensions/braintree/deployment/src/main/java/org/apache/camel/quarkus/component/braintree/deployment/BraintreeProcessor.java
@@ -0,0 +1,90 @@
+/*
+ * 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.braintree.deployment;
+
+import java.util.Collection;
+import java.util.stream.Collectors;
+
+import io.quarkus.deployment.annotations.BuildProducer;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.annotations.ExecutionTime;
+import io.quarkus.deployment.annotations.Record;
+import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
+import io.quarkus.deployment.builditem.FeatureBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
+import org.apache.camel.component.braintree.BraintreeComponent;
+import org.apache.camel.quarkus.component.braintree.graal.BraintreeRecorder;
+import org.apache.camel.quarkus.core.deployment.CamelBeanBuildItem;
+import org.apache.camel.quarkus.core.deployment.UnbannedReflectiveBuildItem;
+import org.jboss.jandex.AnnotationInstance;
+import org.jboss.jandex.AnnotationTarget;
+import org.jboss.jandex.DotName;
+import org.jboss.jandex.IndexView;
+
+class BraintreeProcessor {
+
+ private static final String FEATURE = "camel-braintree";
+
+ @BuildStep
+ FeatureBuildItem feature() {
+ return new FeatureBuildItem(FEATURE);
+ }
+
+ @BuildStep
+ void registerForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
+ BuildProducer<UnbannedReflectiveBuildItem> unbannedClass, CombinedIndexBuildItem combinedIndex) {
+ IndexView index = combinedIndex.getIndex();
+ Collection<AnnotationInstance> uriParams = index
+ .getAnnotations(DotName.createSimple("org.apache.camel.spi.UriParams"));
+
+ String[] braintreeConfigClasses = uriParams.stream()
+ .map(annotation -> annotation.target())
+ .filter(annotationTarget -> annotationTarget.kind().equals(AnnotationTarget.Kind.CLASS))
+ .map(annotationTarget -> annotationTarget.asClass().name().toString())
+ .filter(className -> className.startsWith("org.apache.camel.component.braintree"))
+ .collect(Collectors.toList())
+ .toArray(new String[0]);
+
+ reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, braintreeConfigClasses));
+ unbannedClass.produce(new UnbannedReflectiveBuildItem(braintreeConfigClasses));
+
+ reflectiveClass.produce(new ReflectiveClassBuildItem(true, false,
+ "com.braintreegateway.Address",
+ "com.braintreegateway.BraintreeGateway",
+ "com.braintreegateway.Customer",
+ "com.braintreegateway.DisputeEvidence",
+ "com.braintreegateway.DocumentUpload",
+ "com.braintreegateway.MerchantAccount",
+ "com.braintreegateway.PaymentMethod",
+ "com.braintreegateway.Transaction"));
+ }
+
+ @BuildStep
+ void nativeImageResources(BuildProducer<NativeImageResourceBuildItem> nativeImage) {
+ nativeImage.produce(new NativeImageResourceBuildItem(
+ "ssl/api_braintreegateway_com.ca.crt",
+ "ssl/payments_braintreeapi_com.ca.crt"));
+ }
+
+ @Record(ExecutionTime.STATIC_INIT)
+ @BuildStep
+ CamelBeanBuildItem configureBraintreeComponent(BraintreeRecorder recorder) {
+ return new CamelBeanBuildItem("braintree", BraintreeComponent.class.getName(),
+ recorder.configureBraintreeComponent());
+ }
+}
diff --git a/extensions/braintree/pom.xml b/extensions/braintree/pom.xml
new file mode 100644
index 0000000..09d1787
--- /dev/null
+++ b/extensions/braintree/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-braintree-parent</artifactId>
+ <name>Camel Quarkus :: Braintree</name>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>deployment</module>
+ <module>runtime</module>
+ </modules>
+</project>
diff --git a/extensions/braintree/runtime/pom.xml b/extensions/braintree/runtime/pom.xml
new file mode 100644
index 0000000..2afdc6b
--- /dev/null
+++ b/extensions/braintree/runtime/pom.xml
@@ -0,0 +1,85 @@
+<?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-braintree-parent</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-braintree</artifactId>
+ <name>Camel Quarkus :: Braintree :: Runtime</name>
+ <description>Braintree</description>
+
+ <properties>
+ <firstVersion>1.2.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-braintree</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/braintree/runtime/src/main/java/org/apache/camel/quarkus/component/braintree/graal/BraintreeRecorder.java b/extensions/braintree/runtime/src/main/java/org/apache/camel/quarkus/component/braintree/graal/BraintreeRecorder.java
new file mode 100644
index 0000000..cb87a09
--- /dev/null
+++ b/extensions/braintree/runtime/src/main/java/org/apache/camel/quarkus/component/braintree/graal/BraintreeRecorder.java
@@ -0,0 +1,36 @@
+/*
+ * 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.braintree.graal;
+
+import io.quarkus.runtime.RuntimeValue;
+import io.quarkus.runtime.annotations.Recorder;
+import org.apache.camel.component.braintree.BraintreeComponent;
+
+@Recorder
+public class BraintreeRecorder {
+
+ /**
+ * Always disable the {@link org.apache.camel.component.braintree.internal.BraintreeLogHandler}.
+ *
+ * It's not desirable to configure this where an existing JUL - SLF4J bridge exists on the classpath.
+ */
+ public RuntimeValue<BraintreeComponent> configureBraintreeComponent() {
+ BraintreeComponent component = new BraintreeComponent();
+ component.setLogHandlerEnabled(false);
+ return new RuntimeValue<>(component);
+ }
+}
diff --git a/extensions/braintree/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/braintree/runtime/src/main/resources/META-INF/quarkus-extension.yaml
new file mode 100644
index 0000000..6ea852e
--- /dev/null
+++ b/extensions/braintree/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 Braintree"
+description: "Camel Quarkus Braintree support"
+metadata:
+ keywords:
+ - "camel"
+ - "braintree"
+ guide: "https://quarkus.io/guides/camel"
+ categories:
+ - "integration"
diff --git a/extensions/pom.xml b/extensions/pom.xml
index 9042bd3..2bb2d79 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -63,6 +63,7 @@
<module>bean-validator</module>
<module>bindy</module>
<module>box</module>
+ <module>braintree</module>
<module>consul</module>
<module>controlbus</module>
<module>csv</module>
diff --git a/extensions/readme.adoc b/extensions/readme.adoc
index c89e3b9..b565346 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: 68 in 58 JAR artifacts (0 deprecated)
+Number of Camel components: 69 in 59 JAR artifacts (0 deprecated)
[width="100%",cols="4,1,5",options="header"]
|===
@@ -68,6 +68,9 @@ Number of Camel components: 68 in 58 JAR artifacts (0 deprecated)
| link:https://camel.apache.org/components/latest/box-component.html[Box] (camel-quarkus-box) +
`box:apiName/methodName` | 1.2.0 | For uploading downloading and managing files folders groups collaborations etc on box DOT com.
+| link:https://camel.apache.org/components/latest/braintree-component.html[Braintree] (camel-quarkus-braintree) +
+`braintree:apiName/methodName` | 1.2.0 | The braintree component is used for integrating with the Braintree Payment System.
+
| link:https://camel.apache.org/components/latest/class-component.html[Class] (camel-quarkus-bean) +
`class:beanName` | 0.2.0 | The Class component is for invoking Java classes (Java beans) from Camel.
diff --git a/integration-tests/braintree/README.adoc b/integration-tests/braintree/README.adoc
new file mode 100644
index 0000000..c112044
--- /dev/null
+++ b/integration-tests/braintree/README.adoc
@@ -0,0 +1,12 @@
+== Camel Quarkus Braintree Integration Tests
+
+To run `camel-quarkus-braintree` integration tests, you will need a https://www.braintreepayments.com/gb/sandbox[Braintree sandbox] account.
+
+Then set the following environment variables:
+
+[source,shell]
+----
+BRAINTREE_MERCHANT_ID=your-merchant-id
+BRAINTREE_PUBLIC_KEY=your-public-key
+BRAINTREE_PRIVATE_KEY=your-private-key
+----
diff --git a/integration-tests/braintree/pom.xml b/integration-tests/braintree/pom.xml
new file mode 100644
index 0000000..4f9d5ea
--- /dev/null
+++ b/integration-tests/braintree/pom.xml
@@ -0,0 +1,123 @@
+<?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-braintree</artifactId>
+ <name>Camel Quarkus :: Integration Tests :: Braintree</name>
+ <description>Integration tests for Camel Quarkus Braintree 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-braintree-deployment,camel-quarkus-support-policy-deployment</mvnd.builder.rule>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-braintree</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy-jsonb</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>
+ <quarkus.native.enable-https-url-handler>true</quarkus.native.enable-https-url-handler>
+ </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>
+ <configuration>
+ <systemProperties>
+ <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
+ </systemProperties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
diff --git a/integration-tests/braintree/src/main/java/org/apache/camel/quarkus/component/braintree/it/BraintreeResource.java b/integration-tests/braintree/src/main/java/org/apache/camel/quarkus/component/braintree/it/BraintreeResource.java
new file mode 100644
index 0000000..7db5faa
--- /dev/null
+++ b/integration-tests/braintree/src/main/java/org/apache/camel/quarkus/component/braintree/it/BraintreeResource.java
@@ -0,0 +1,99 @@
+/*
+ * 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.braintree.it;
+
+import java.math.BigDecimal;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.inject.Inject;
+import javax.json.Json;
+import javax.json.JsonObjectBuilder;
+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.braintreegateway.BraintreeGateway;
+import com.braintreegateway.Result;
+import com.braintreegateway.Transaction;
+import com.braintreegateway.TransactionRequest;
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.braintree.BraintreeComponent;
+import org.apache.camel.component.braintree.internal.BraintreeApiCollection;
+import org.apache.camel.component.braintree.internal.TransactionGatewayApiMethod;
+
+@Path("/braintree")
+public class BraintreeResource {
+
+ @Inject
+ ProducerTemplate producerTemplate;
+
+ @Path("/token")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String generateToken() throws Exception {
+ return producerTemplate.requestBody("braintree:clientToken/generate", null, String.class);
+ }
+
+ @Path("/sale")
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response sale() throws Exception {
+ String api = BraintreeApiCollection.getCollection().getApiName(TransactionGatewayApiMethod.class).getName();
+ TransactionRequest transaction = new TransactionRequest()
+ .amount(new BigDecimal("100.00"))
+ .paymentMethodNonce("fake-valid-nonce")
+ .options()
+ .submitForSettlement(true)
+ .done();
+ Result<Transaction> result = producerTemplate.requestBody("braintree:" + api + "/sale?inBody=request", transaction,
+ Result.class);
+
+ CamelContext camelContext = producerTemplate.getCamelContext();
+ BraintreeComponent component = camelContext.getComponent("braintree", BraintreeComponent.class);
+ BraintreeGateway gateway = component.getGateway(component.getConfiguration());
+ gateway.testing().settle(result.getTarget().getId());
+
+ JsonObjectBuilder objectBuilder = Json.createObjectBuilder();
+ objectBuilder.add("success", result.isSuccess());
+ objectBuilder.add("transactionId", result.getTarget().getId());
+
+ return Response.status(Response.Status.OK).entity(objectBuilder.build()).build();
+ }
+
+ @Path("/refund")
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response refund(String transactionId) throws Exception {
+ String api = BraintreeApiCollection.getCollection().getApiName(TransactionGatewayApiMethod.class).getName();
+ Map<String, Object> headers = new HashMap<>();
+ headers.put("CamelBraintree.id", transactionId);
+ headers.put("CamelBraintree.amount", new BigDecimal("99.00"));
+
+ Result<Transaction> result = producerTemplate.requestBodyAndHeaders("braintree:" + api + "/refund", null, headers,
+ Result.class);
+
+ JsonObjectBuilder objectBuilder = Json.createObjectBuilder();
+ objectBuilder.add("success", result.isSuccess());
+
+ return Response.status(Response.Status.OK).entity(objectBuilder.build()).build();
+ }
+}
diff --git a/integration-tests/braintree/src/main/resources/application.properties b/integration-tests/braintree/src/main/resources/application.properties
new file mode 100644
index 0000000..41539a4
--- /dev/null
+++ b/integration-tests/braintree/src/main/resources/application.properties
@@ -0,0 +1,22 @@
+## ---------------------------------------------------------------------------
+## 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.component.braintree.configuration = #class:org.apache.camel.component.braintree.BraintreeConfiguration
+camel.component.braintree.configuration.environment=SANDBOX
+camel.component.braintree.configuration.merchantId={{env:BRAINTREE_MERCHANT_ID}}
+camel.component.braintree.configuration.publicKey={{env:BRAINTREE_PUBLIC_KEY}}
+camel.component.braintree.configuration.privateKey={{env:BRAINTREE_PRIVATE_KEY}}
diff --git a/integration-tests/braintree/src/test/java/org/apache/camel/quarkus/component/braintree/it/BraintreeIT.java b/integration-tests/braintree/src/test/java/org/apache/camel/quarkus/component/braintree/it/BraintreeIT.java
new file mode 100644
index 0000000..16d69d1
--- /dev/null
+++ b/integration-tests/braintree/src/test/java/org/apache/camel/quarkus/component/braintree/it/BraintreeIT.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.braintree.it;
+
+import io.quarkus.test.junit.NativeImageTest;
+import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
+
+@NativeImageTest
+@EnabledIfEnvironmentVariable(named = "BRAINTREE_MERCHANT_ID", matches = ".+")
+@EnabledIfEnvironmentVariable(named = "BRAINTREE_PUBLIC_KEY", matches = ".+")
+@EnabledIfEnvironmentVariable(named = "BRAINTREE_PRIVATE_KEY", matches = ".+")
+class BraintreeIT extends BraintreeTest {
+
+}
diff --git a/integration-tests/braintree/src/test/java/org/apache/camel/quarkus/component/braintree/it/BraintreeTest.java b/integration-tests/braintree/src/test/java/org/apache/camel/quarkus/component/braintree/it/BraintreeTest.java
new file mode 100644
index 0000000..6bb8e75
--- /dev/null
+++ b/integration-tests/braintree/src/test/java/org/apache/camel/quarkus/component/braintree/it/BraintreeTest.java
@@ -0,0 +1,71 @@
+/*
+ * 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.braintree.it;
+
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import io.restassured.path.json.JsonPath;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+@QuarkusTest
+@EnabledIfEnvironmentVariable(named = "BRAINTREE_MERCHANT_ID", matches = ".+")
+@EnabledIfEnvironmentVariable(named = "BRAINTREE_PUBLIC_KEY", matches = ".+")
+@EnabledIfEnvironmentVariable(named = "BRAINTREE_PRIVATE_KEY", matches = ".+")
+class BraintreeTest {
+
+ @Test
+ public void testBraintreeComponent() {
+ String token = RestAssured
+ .get("/braintree/token")
+ .then()
+ .statusCode(200)
+ .extract()
+ .body()
+ .asString();
+
+ assertNotNull(token);
+ assertTrue(token.length() > 0);
+
+ JsonPath saleResult = RestAssured.given()
+ .post("/braintree/sale")
+ .then()
+ .statusCode(200)
+ .extract()
+ .body()
+ .jsonPath();
+
+ assertTrue(saleResult.getBoolean("success"));
+ assertNotNull(saleResult.getString("transactionId"));
+
+ String transactionId = saleResult.getString("transactionId");
+ JsonPath refundResult = RestAssured.given()
+ .body(transactionId)
+ .post("/braintree/refund")
+ .then()
+ .statusCode(200)
+ .extract()
+ .body()
+ .jsonPath();
+
+ assertTrue(refundResult.getBoolean("success"));
+ }
+
+}
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index 10c3333..f598207 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -176,6 +176,7 @@
<module>bean-validator</module>
<module>bindy</module>
<module>box</module>
+ <module>braintree</module>
<module>consul</module>
<module>controlbus</module>
<module>csv</module>
diff --git a/poms/bom-deployment/pom.xml b/poms/bom-deployment/pom.xml
index 575bbfc..ef93076 100644
--- a/poms/bom-deployment/pom.xml
+++ b/poms/bom-deployment/pom.xml
@@ -166,6 +166,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-braintree-deployment</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-consul-deployment</artifactId>
<version>${camel-quarkus.version}</version>
</dependency>
diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml
index 3f59e12..94e9e3e 100644
--- a/poms/bom/pom.xml
+++ b/poms/bom/pom.xml
@@ -178,6 +178,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-braintree</artifactId>
+ <version>${camel.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-caffeine-lrucache</artifactId>
<version>${camel.version}</version>
</dependency>
@@ -719,6 +724,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-braintree</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-consul</artifactId>
<version>${camel-quarkus.version}</version>
</dependency>