You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2021/04/19 12:13:26 UTC
[camel] branch master updated: CAMEL-16400: adjust manual
integration tests for camel-zendesk (#5417)
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 48b184a CAMEL-16400: adjust manual integration tests for camel-zendesk (#5417)
48b184a is described below
commit 48b184ad312fe5ae51aa5704f2ede1d942d37bcd
Author: Otavio Rodolfo Piske <or...@users.noreply.github.com>
AuthorDate: Mon Apr 19 14:12:55 2021 +0200
CAMEL-16400: adjust manual integration tests for camel-zendesk (#5417)
---
components/camel-zendesk/pom.xml | 32 +++-----------------
.../zendesk/AbstractZendeskTestSupport.java | 35 +++++++++++++++-------
...etIntegrationTest.java => ZendeskTicketIT.java} | 7 +++--
3 files changed, 34 insertions(+), 40 deletions(-)
diff --git a/components/camel-zendesk/pom.xml b/components/camel-zendesk/pom.xml
index 1ce188c..4ab03b1 100644
--- a/components/camel-zendesk/pom.xml
+++ b/components/camel-zendesk/pom.xml
@@ -213,6 +213,10 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ </plugin>
</plugins>
<pluginManagement>
<plugins>
@@ -229,33 +233,5 @@
</plugin>
</plugins>
</pluginManagement>
-
</build>
-
- <profiles>
- <profile>
- <id>zendesk-test</id>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <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-zendesk/src/test/java/org/apache/camel/component/zendesk/AbstractZendeskTestSupport.java b/components/camel-zendesk/src/test/java/org/apache/camel/component/zendesk/AbstractZendeskTestSupport.java
index f515162..a1a396e 100644
--- a/components/camel-zendesk/src/test/java/org/apache/camel/component/zendesk/AbstractZendeskTestSupport.java
+++ b/components/camel-zendesk/src/test/java/org/apache/camel/component/zendesk/AbstractZendeskTestSupport.java
@@ -47,22 +47,37 @@ public class AbstractZendeskTestSupport extends CamelTestSupport {
public static final String ENV_ZENDESK_TOKEN = "zendesk.token";
public static final String ENV_ZENDESK_OAUTH_TOKEN = "zendesk.oauthToken";
+ private static Properties loadProperties() {
+ final Properties properties = new Properties();
+ try {
+ properties.load(AbstractZendeskTestSupport.class.getResourceAsStream(TEST_OPTIONS_PROPERTIES));
+ } catch (Exception e) {
+ throw new RuntimeException("Unable to load test properties", e);
+ }
+ return properties;
+ }
+
+ @SuppressWarnings("unused")
+ public static boolean hasCredentials() {
+ Properties properties = loadProperties();
+
+ return !properties.getProperty("username", "").isEmpty() &&
+ !properties.getProperty("password", "").isEmpty();
+ }
+
@Override
protected CamelContext createCamelContext() throws Exception {
final CamelContext context = super.createCamelContext();
final ZendeskConfiguration configuration = new ZendeskConfiguration();
- final Properties properties = new Properties();
- try {
- properties.load(getClass().getResourceAsStream(TEST_OPTIONS_PROPERTIES));
- Map<String, Object> options = new HashMap<>();
- for (Map.Entry<Object, Object> entry : properties.entrySet()) {
- options.put(entry.getKey().toString(), entry.getValue());
- }
+ final Properties properties = loadProperties();
- PropertyBindingSupport.bindProperties(context, configuration, options);
- } catch (Exception e) {
- // ignore - system property or ENV may be supplied
+ Map<String, Object> options = new HashMap<>();
+ for (Map.Entry<Object, Object> entry : properties.entrySet()) {
+ options.put(entry.getKey().toString(), entry.getValue());
}
+
+ PropertyBindingSupport.bindProperties(context, configuration, options);
+
configuration.setServerUrl(System.getenv(ENV_ZENDESK_SERVER_URL) != null
? System.getenv(ENV_ZENDESK_SERVER_URL) : configuration.getServerUrl());
configuration.setUsername(System.getenv(ENV_ZENDESK_USERNAME) != null
diff --git a/components/camel-zendesk/src/test/java/org/apache/camel/component/zendesk/ZendeskTicketIntegrationTest.java b/components/camel-zendesk/src/test/java/org/apache/camel/component/zendesk/ZendeskTicketIT.java
similarity index 95%
rename from components/camel-zendesk/src/test/java/org/apache/camel/component/zendesk/ZendeskTicketIntegrationTest.java
rename to components/camel-zendesk/src/test/java/org/apache/camel/component/zendesk/ZendeskTicketIT.java
index d32c192..657cee9 100644
--- a/components/camel-zendesk/src/test/java/org/apache/camel/component/zendesk/ZendeskTicketIntegrationTest.java
+++ b/components/camel-zendesk/src/test/java/org/apache/camel/component/zendesk/ZendeskTicketIT.java
@@ -23,6 +23,7 @@ import java.util.Map;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.zendesk.internal.ZendeskApiMethod;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zendesk.client.v2.model.Comment;
@@ -36,8 +37,10 @@ import static org.junit.jupiter.api.Assertions.assertNull;
/**
* The integration tests for ticket related Zendesk API.
*/
-public class ZendeskTicketIntegrationTest extends AbstractZendeskTestSupport {
- private static final Logger LOG = LoggerFactory.getLogger(ZendeskTicketIntegrationTest.class);
+@EnabledIf(value = "org.apache.camel.component.zendesk.AbstractZendeskTestSupport#hasCredentials",
+ disabledReason = "Zendesk credentials were not provided")
+public class ZendeskTicketIT extends AbstractZendeskTestSupport {
+ private static final Logger LOG = LoggerFactory.getLogger(ZendeskTicketIT.class);
@Test
public void testGetTickets() throws Exception {