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 178aa4d  CAMEL-16400: split unit and integration tests for 
camel-digitalocean (#5421)
178aa4d is described below

commit 178aa4dd88b8ee6e1475b1ee800d37ee0be04508
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Mon Apr 19 16:17:07 2021 +0200

    CAMEL-16400: split unit and integration tests for camel-digitalocean (#5421)
---
 components/camel-digitalocean/pom.xml                  |  9 +++++++++
 ...tegrationTest.java => DigitalOceanComponentIT.java} |  7 ++++---
 .../integration/DigitalOceanTestSupport.java           | 18 ++++++++++++++++--
 .../src/test/resources/test-options.properties         |  2 +-
 4 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/components/camel-digitalocean/pom.xml 
b/components/camel-digitalocean/pom.xml
index d82e6a5..6c3152d 100644
--- a/components/camel-digitalocean/pom.xml
+++ b/components/camel-digitalocean/pom.xml
@@ -64,4 +64,13 @@
         </dependency>
     </dependencies>
 
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-failsafe-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
 </project>
diff --git 
a/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanComponentIntegrationTest.java
 
b/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanComponentIT.java
similarity index 97%
rename from 
components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanComponentIntegrationTest.java
rename to 
components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanComponentIT.java
index 2865112..299a699 100644
--- 
a/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanComponentIntegrationTest.java
+++ 
b/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanComponentIT.java
@@ -33,8 +33,8 @@ import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.digitalocean.constants.DigitalOceanHeaders;
 import 
org.apache.camel.component.digitalocean.constants.DigitalOceanOperations;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIf;
 
 import static org.apache.camel.test.junit5.TestSupport.assertCollectionSize;
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -42,8 +42,9 @@ import static 
org.junit.jupiter.api.Assertions.assertNotEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
-@Disabled("Must be manually tested. Provide your own oAuthToken")
-public class DigitalOceanComponentIntegrationTest extends 
DigitalOceanTestSupport {
+@EnabledIf(value = 
"org.apache.camel.component.digitalocean.integration.DigitalOceanTestSupport#hasCredentials",
+           disabledReason = "Must be manually tested. Provide your own 
oAuthToken on test-options.properties")
+public class DigitalOceanComponentIT extends DigitalOceanTestSupport {
 
     @EndpointInject("mock:result")
     protected MockEndpoint mockResultEndpoint;
diff --git 
a/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanTestSupport.java
 
b/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanTestSupport.java
index c8c5daa..fc400fe 100644
--- 
a/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanTestSupport.java
+++ 
b/components/camel-digitalocean/src/test/java/org/apache/camel/component/digitalocean/integration/DigitalOceanTestSupport.java
@@ -31,7 +31,19 @@ public class DigitalOceanTestSupport extends 
CamelTestSupport {
     protected final Properties properties;
 
     protected DigitalOceanTestSupport() {
-        URL url = getClass().getResource("/test-options.properties");
+        properties = loadProperties();
+    }
+
+    // This is used by JUnit to automatically determine whether or not to run 
the integration tests
+    @SuppressWarnings("unused")
+    private static boolean hasCredentials() {
+        Properties properties = loadProperties();
+
+        return !properties.getProperty("oAuthToken", "").isEmpty();
+    }
+
+    private static Properties loadProperties() {
+        URL url = 
DigitalOceanTestSupport.class.getResource("/test-options.properties");
 
         InputStream inStream;
         try {
@@ -41,9 +53,11 @@ public class DigitalOceanTestSupport extends 
CamelTestSupport {
             throw new IllegalAccessError("test-options.properties could not be 
found");
         }
 
-        properties = new Properties();
+        Properties properties = new Properties();
         try {
             properties.load(inStream);
+
+            return properties;
         } catch (IOException e) {
             LOG.error("I/O error reading the stream: {}", e.getMessage(), e);
             throw new IllegalAccessError("test-options.properties could not be 
found");
diff --git 
a/components/camel-digitalocean/src/test/resources/test-options.properties 
b/components/camel-digitalocean/src/test/resources/test-options.properties
index 74ff2ea..26cec30 100644
--- a/components/camel-digitalocean/src/test/resources/test-options.properties
+++ b/components/camel-digitalocean/src/test/resources/test-options.properties
@@ -14,4 +14,4 @@
 ## See the License for the specific language governing permissions and
 ## limitations under the License.
 ## ---------------------------------------------------------------------------
-oAuthToken=<yourOAuthToken>
\ No newline at end of file
+oAuthToken=

Reply via email to