This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new 78254b4 CAMEL-16400: adjust manual integration tests for camel-twilio
(#5412)
78254b4 is described below
commit 78254b4029c7362edb47ba91b86193055aa8f2e8
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Mon Apr 19 12:43:03 2021 +0200
CAMEL-16400: adjust manual integration tests for camel-twilio (#5412)
---
components/camel-twilio/pom.xml | 32 +++-------------------
.../twilio/AbstractTwilioTestSupport.java | 32 ++++++++++++++++------
...{AccountIntegrationTest.java => AccountIT.java} | 7 +++--
.../src/test/resources/test-options.properties | 4 +--
4 files changed, 34 insertions(+), 41 deletions(-)
diff --git a/components/camel-twilio/pom.xml b/components/camel-twilio/pom.xml
index bc220f9..a758b7e 100644
--- a/components/camel-twilio/pom.xml
+++ b/components/camel-twilio/pom.xml
@@ -642,6 +642,10 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ </plugin>
</plugins>
<pluginManagement>
@@ -661,32 +665,4 @@
</pluginManagement>
</build>
-
- <profiles>
- <profile>
- <id>twilio-test</id>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>${maven-surefire-plugin-version}</version>
- <configuration>
- <childDelegation>false</childDelegation>
- <useFile>true</useFile>
- <forkCount>1</forkCount>
- <reuseForks>true</reuseForks>
-
<forkedProcessTimeoutInSeconds>300</forkedProcessTimeoutInSeconds>
- <excludes>
- <exclude>**/*XXXTest.java</exclude>
- </excludes>
- <includes>
- <include>**/*Test.java</include>
- </includes>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
</project>
diff --git
a/components/camel-twilio/src/test/java/org/apache/camel/component/twilio/AbstractTwilioTestSupport.java
b/components/camel-twilio/src/test/java/org/apache/camel/component/twilio/AbstractTwilioTestSupport.java
index 9b3ce89..4575c1e 100644
---
a/components/camel-twilio/src/test/java/org/apache/camel/component/twilio/AbstractTwilioTestSupport.java
+++
b/components/camel-twilio/src/test/java/org/apache/camel/component/twilio/AbstractTwilioTestSupport.java
@@ -16,7 +16,6 @@
*/
package org.apache.camel.component.twilio;
-import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
@@ -34,25 +33,40 @@ import org.junit.jupiter.api.TestInstance;
public class AbstractTwilioTestSupport extends CamelTestSupport {
private static final String TEST_OPTIONS_PROPERTIES =
"/test-options.properties";
+ private static Properties properties = new Properties();
- @Override
- protected CamelContext createCamelContext() throws Exception {
-
- final CamelContext context = super.createCamelContext();
+ static {
+ loadProperties();
+ }
+ private static void loadProperties() {
// read Twilio component configuration from TEST_OPTIONS_PROPERTIES
- final Properties properties = new Properties();
try {
-
properties.load(getClass().getResourceAsStream(TEST_OPTIONS_PROPERTIES));
+
properties.load(AbstractTwilioTestSupport.class.getResourceAsStream(TEST_OPTIONS_PROPERTIES));
} catch (Exception e) {
- throw new IOException(
+ throw new RuntimeException(
String.format("%s could not be loaded: %s",
TEST_OPTIONS_PROPERTIES, e.getMessage()),
e);
}
+ }
+
+ private static boolean hasCredentials() {
+ if (properties.isEmpty()) {
+ loadProperties();
+ }
+
+ return !properties.getProperty("username", "").isEmpty()
+ && !properties.getProperty("password", "").isEmpty();
+ }
+
+ @Override
+ protected CamelContext createCamelContext() throws Exception {
+
+ final CamelContext context = super.createCamelContext();
Map<String, Object> options = new HashMap<>();
for (Map.Entry<Object, Object> entry : properties.entrySet()) {
- options.put(entry.getKey().toString(), entry.getValue());
+ options.put(entry.getKey().toString(),
entry.getValue().toString().isEmpty() ? "value" : entry.getValue());
}
// add TwilioComponent to Camel context
diff --git
a/components/camel-twilio/src/test/java/org/apache/camel/component/twilio/AccountIntegrationTest.java
b/components/camel-twilio/src/test/java/org/apache/camel/component/twilio/AccountIT.java
similarity index 93%
rename from
components/camel-twilio/src/test/java/org/apache/camel/component/twilio/AccountIntegrationTest.java
rename to
components/camel-twilio/src/test/java/org/apache/camel/component/twilio/AccountIT.java
index c89e2d2..d75fb0b 100644
---
a/components/camel-twilio/src/test/java/org/apache/camel/component/twilio/AccountIntegrationTest.java
+++
b/components/camel-twilio/src/test/java/org/apache/camel/component/twilio/AccountIT.java
@@ -25,6 +25,7 @@ import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.twilio.internal.AccountApiMethod;
import org.apache.camel.component.twilio.internal.TwilioApiCollection;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,9 +35,11 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Test class for {@link com.twilio.rest.api.v2010.Account} APIs.
*/
-public class AccountIntegrationTest extends AbstractTwilioTestSupport {
+@EnabledIf(value =
"org.apache.camel.component.twilio.AbstractTwilioTestSupport#hasCredentials",
+ disabledReason = "Twilio credentials were not provided")
+public class AccountIT extends AbstractTwilioTestSupport {
- private static final Logger LOG =
LoggerFactory.getLogger(AccountIntegrationTest.class);
+ private static final Logger LOG = LoggerFactory.getLogger(AccountIT.class);
private static final String PATH_PREFIX =
TwilioApiCollection.getCollection().getApiName(AccountApiMethod.class).getName();
@Test
diff --git a/components/camel-twilio/src/test/resources/test-options.properties
b/components/camel-twilio/src/test/resources/test-options.properties
index f5187da..2498d64 100644
--- a/components/camel-twilio/src/test/resources/test-options.properties
+++ b/components/camel-twilio/src/test/resources/test-options.properties
@@ -20,5 +20,5 @@
#################################################
## Account SID and password
## Create a free account on https://www.twilio.com and provide account SID and
password
-username=<your-account-sid>
-password=<your-auth-token>
+username=
+password=