This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 1f74009b81a (chores) camel-braintree: update to support loading
properties from external files
1f74009b81a is described below
commit 1f74009b81a3db56892ea6ea4e750cf4a7640a7e
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Fri May 31 14:09:58 2024 +0200
(chores) camel-braintree: update to support loading properties from
external files
---
components/camel-braintree/README.md | 6 ++++++
.../camel/component/braintree/AbstractBraintreeTestSupport.java | 9 ++++++++-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/components/camel-braintree/README.md
b/components/camel-braintree/README.md
index b1969516468..d0fe17b8e01 100644
--- a/components/camel-braintree/README.md
+++ b/components/camel-braintree/README.md
@@ -26,6 +26,12 @@ It's also possible to run a smaller set of tests by running
them without the env
mvn -DbraintreeAuthenticationType=PUBLIC_PRIVATE_KEYS clean verify
```
+Lastly, you can also use an external file outside the build location.
+
+```
+CAMEL_BRAINTREE_REPORT_DATE=$(date '+%Y-%m-%d') mvn
-DbraintreeAuthenticationType=PUBLIC_PRIVATE_KEYS
-Dbraintree.properties.location=/path/to/test-options.properties verify
+```
+
# Authentication types
The authentication type can be passed via `braintreeAuthenticationType` system
property.
diff --git
a/components/camel-braintree/src/test/java/org/apache/camel/component/braintree/AbstractBraintreeTestSupport.java
b/components/camel-braintree/src/test/java/org/apache/camel/component/braintree/AbstractBraintreeTestSupport.java
index 935bb897e44..43f87991aa5 100644
---
a/components/camel-braintree/src/test/java/org/apache/camel/component/braintree/AbstractBraintreeTestSupport.java
+++
b/components/camel-braintree/src/test/java/org/apache/camel/component/braintree/AbstractBraintreeTestSupport.java
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.braintree;
+import java.io.FileInputStream;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
@@ -80,7 +81,13 @@ public class AbstractBraintreeTestSupport extends
CamelTestSupport {
final Properties properties = new Properties();
try {
-
properties.load(getClass().getResourceAsStream(TEST_OPTIONS_PROPERTIES));
+ final String propertiesLocation =
System.getProperty("braintree.properties.location");
+
+ if (propertiesLocation != null) {
+ properties.load(new FileInputStream(propertiesLocation));
+ } else {
+
properties.load(getClass().getResourceAsStream(TEST_OPTIONS_PROPERTIES));
+ }
} catch (Exception e) {
throw new IOException(String.format("%s could not be loaded: %s",
TEST_OPTIONS_PROPERTIES, e.getMessage()), e);
}