You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2020/03/04 12:37:16 UTC
[camel] 01/02: Camel-AWS2-CW: Migrated tests to Junit5
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 8f622392de3348850b0350b707b5edf7d05c5987
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Mar 4 13:25:58 2020 +0100
Camel-AWS2-CW: Migrated tests to Junit5
---
components/camel-aws2-cw/pom.xml | 7 +------
.../aws2/cw/CwComponentConfigurationTest.java | 23 +++++++++++++++-------
.../aws2/cw/CwComponentRegistryClientTest.java | 11 ++++++++---
.../camel/component/aws2/cw/CwComponentTest.java | 5 +++--
.../aws2/cw/CwComponentVerifierExtensionTest.java | 10 +++++-----
.../cw/integration/CwComponentIntegrationTest.java | 9 +++++----
6 files changed, 38 insertions(+), 27 deletions(-)
diff --git a/components/camel-aws2-cw/pom.xml b/components/camel-aws2-cw/pom.xml
index 28fd553..30d58b4 100644
--- a/components/camel-aws2-cw/pom.xml
+++ b/components/camel-aws2-cw/pom.xml
@@ -53,13 +53,8 @@
<!-- for testing -->
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-test-spring</artifactId>
+ <artifactId>camel-test-spring-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/components/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/CwComponentConfigurationTest.java b/components/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/CwComponentConfigurationTest.java
index 6f8e169..922993b 100644
--- a/components/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/CwComponentConfigurationTest.java
+++ b/components/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/CwComponentConfigurationTest.java
@@ -19,11 +19,14 @@ package org.apache.camel.component.aws2.cw;
import java.time.Instant;
import org.apache.camel.BindToRegistry;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
import software.amazon.awssdk.core.Protocol;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.cloudwatch.CloudWatchClient;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class CwComponentConfigurationTest extends CamelTestSupport {
@@ -45,22 +48,28 @@ public class CwComponentConfigurationTest extends CamelTestSupport {
assertEquals(NOW, endpoint.getConfiguration().getTimestamp());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void createEndpointWithoutAccessKeyConfiguration() throws Exception {
Cw2Component component = context.getComponent("aws2-cw", Cw2Component.class);
- component.createEndpoint("aws2-cw://camel.apache.org/test?secretKey=yyy");
+ assertThrows(IllegalArgumentException.class, () -> {
+ component.createEndpoint("aws2-cw://camel.apache.org/test?secretKey=yyy");
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void createEndpointWithoutSecretKeyConfiguration() throws Exception {
Cw2Component component = context.getComponent("aws2-cw", Cw2Component.class);
- component.createEndpoint("aws2-cw://camel.apache.org/test?accessKey=xxx");
+ assertThrows(IllegalArgumentException.class, () -> {
+ component.createEndpoint("aws2-cw://camel.apache.org/test?accessKey=xxx");
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void createEndpointWithoutSecretKeyAndAccessKeyConfiguration() throws Exception {
Cw2Component component = context.getComponent("aws2-cw", Cw2Component.class);
+ assertThrows(IllegalArgumentException.class, () -> {
component.createEndpoint("aws2-cw://camel.apache.org/test?accessKey=xxx");
+ });
}
@Test
diff --git a/components/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/CwComponentRegistryClientTest.java b/components/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/CwComponentRegistryClientTest.java
index 69814f1..5055fbf 100644
--- a/components/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/CwComponentRegistryClientTest.java
+++ b/components/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/CwComponentRegistryClientTest.java
@@ -19,9 +19,12 @@ package org.apache.camel.component.aws2.cw;
import java.time.Instant;
import org.apache.camel.BindToRegistry;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
import software.amazon.awssdk.services.cloudwatch.CloudWatchClient;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class CwComponentRegistryClientTest extends CamelTestSupport {
@@ -42,9 +45,11 @@ public class CwComponentRegistryClientTest extends CamelTestSupport {
assertEquals(NOW, endpoint.getConfiguration().getTimestamp());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void createEndpointWithMinimalS3ClientMisconfiguration() throws Exception {
Cw2Component component = context.getComponent("aws2-cw", Cw2Component.class);
+ assertThrows(IllegalArgumentException.class, () -> {
Cw2Endpoint endpoint = (Cw2Endpoint)component.createEndpoint("aws2-cw://camel.apache.org/test");
+ });
}
}
diff --git a/components/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/CwComponentTest.java b/components/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/CwComponentTest.java
index 71f202b..42b622a 100644
--- a/components/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/CwComponentTest.java
+++ b/components/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/CwComponentTest.java
@@ -24,8 +24,9 @@ import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
import software.amazon.awssdk.services.cloudwatch.CloudWatchClient;
import software.amazon.awssdk.services.cloudwatch.model.StandardUnit;
diff --git a/components/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/CwComponentVerifierExtensionTest.java b/components/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/CwComponentVerifierExtensionTest.java
index ac50810..6073b71 100644
--- a/components/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/CwComponentVerifierExtensionTest.java
+++ b/components/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/CwComponentVerifierExtensionTest.java
@@ -21,9 +21,9 @@ import java.util.Map;
import org.apache.camel.Component;
import org.apache.camel.component.extension.ComponentVerifierExtension;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Assert;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class CwComponentVerifierExtensionTest extends CamelTestSupport {
@@ -49,7 +49,7 @@ public class CwComponentVerifierExtensionTest extends CamelTestSupport {
ComponentVerifierExtension.Result result = verifier.verify(ComponentVerifierExtension.Scope.PARAMETERS, parameters);
- Assert.assertEquals(ComponentVerifierExtension.Result.Status.OK, result.getStatus());
+ assertEquals(ComponentVerifierExtension.Result.Status.OK, result.getStatus());
}
@Test
@@ -65,7 +65,7 @@ public class CwComponentVerifierExtensionTest extends CamelTestSupport {
ComponentVerifierExtension.Result result = verifier.verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters);
- Assert.assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus());
+ assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus());
}
}
diff --git a/components/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/integration/CwComponentIntegrationTest.java b/components/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/integration/CwComponentIntegrationTest.java
index 34c815a..5173f5d 100644
--- a/components/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/integration/CwComponentIntegrationTest.java
+++ b/components/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/integration/CwComponentIntegrationTest.java
@@ -23,11 +23,12 @@ import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.aws2.cw.Cw2Constants;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Ignore;
-import org.junit.Test;
-@Ignore("Must be manually tested. Provide your own accessKey and secretKey!")
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+@Disabled("Must be manually tested. Provide your own accessKey and secretKey!")
public class CwComponentIntegrationTest extends CamelTestSupport {
@EndpointInject("mock:result")