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 8ebb6003d6979ac3ba4be70cd5a1b32c2995c150 Author: Andrea Cosentino <[email protected]> AuthorDate: Fri Mar 13 10:43:19 2020 +0100 Camel-AWS2-SES: Migrated tests to Junit5 --- components/camel-aws2-ses/pom.xml | 7 +---- .../aws2/ses/SESComponentClientRegistryTest.java | 13 +++++--- .../aws2/ses/SesComponentConfigurationTest.java | 35 +++++++++++++++------- .../component/aws2/ses/SesComponentSpringTest.java | 11 ++++--- .../camel/component/aws2/ses/SesComponentTest.java | 8 +++-- .../ses/SesComponentVerifierExtensionTest.java | 11 +++---- .../integration/SesComponentIntegrationTest.java | 10 ++++--- 7 files changed, 60 insertions(+), 35 deletions(-) diff --git a/components/camel-aws2-ses/pom.xml b/components/camel-aws2-ses/pom.xml index 8254c6f..e5ed0ab 100644 --- a/components/camel-aws2-ses/pom.xml +++ b/components/camel-aws2-ses/pom.xml @@ -58,13 +58,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-ses/src/test/java/org/apache/camel/component/aws2/ses/SESComponentClientRegistryTest.java b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SESComponentClientRegistryTest.java index d76a2ae..047ba09 100644 --- a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SESComponentClientRegistryTest.java +++ b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SESComponentClientRegistryTest.java @@ -16,8 +16,11 @@ */ package org.apache.camel.component.aws2.ses; -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 static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; public class SESComponentClientRegistryTest extends CamelTestSupport { @@ -32,10 +35,12 @@ public class SESComponentClientRegistryTest extends CamelTestSupport { assertNotNull(endpoint.getConfiguration().getAmazonSESClient()); } - @Test(expected = IllegalArgumentException.class) + @Test public void createEndpointWithMinimalSESClientMisconfiguration() throws Exception { Ses2Component component = new Ses2Component(context); - Ses2Endpoint endpoint = (Ses2Endpoint)component.createEndpoint("aws-ses://[email protected]"); + assertThrows(IllegalArgumentException.class, () -> { + Ses2Endpoint endpoint = (Ses2Endpoint)component.createEndpoint("aws-ses://[email protected]"); + }); } } diff --git a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentConfigurationTest.java b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentConfigurationTest.java index 8da40e3..d7b9351 100644 --- a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentConfigurationTest.java +++ b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentConfigurationTest.java @@ -19,11 +19,18 @@ package org.apache.camel.component.aws2.ses; import java.util.ArrayList; import java.util.List; -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.core.Protocol; import software.amazon.awssdk.regions.Region; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class SesComponentConfigurationTest extends CamelTestSupport { @Test @@ -111,28 +118,36 @@ public class SesComponentConfigurationTest extends CamelTestSupport { assertTrue(endpoint.getConfiguration().getReplyToAddresses().contains("[email protected]")); } - @Test(expected = IllegalArgumentException.class) + @Test public void createEndpointWithoutSourceName() throws Exception { Ses2Component component = context.getComponent("aws2-ses", Ses2Component.class); - component.createEndpoint("aws2-ses:// "); + assertThrows(IllegalArgumentException.class, () -> { + component.createEndpoint("aws2-ses:// "); + }); } - @Test(expected = IllegalArgumentException.class) + @Test public void createEndpointWithoutAmazonSESClientConfiguration() throws Exception { Ses2Component component = context.getComponent("aws2-ses", Ses2Component.class); - component.createEndpoint("aws2-ses://[email protected]"); + assertThrows(IllegalArgumentException.class, () -> { + component.createEndpoint("aws2-ses://[email protected]"); + }); } - @Test(expected = IllegalArgumentException.class) + @Test public void createEndpointWithoutAccessKeyConfiguration() throws Exception { Ses2Component component = context.getComponent("aws2-ses", Ses2Component.class); - component.createEndpoint("aws2-ses://[email protected]?secretKey=yyy"); + assertThrows(IllegalArgumentException.class, () -> { + component.createEndpoint("aws2-ses://[email protected]?secretKey=yyy"); + }); } - @Test(expected = IllegalArgumentException.class) + @Test public void createEndpointWithoutSecretKeyConfiguration() throws Exception { Ses2Component component = context.getComponent("aws2-ses", Ses2Component.class); - component.createEndpoint("aws2-ses://[email protected]?accessKey=xxx"); + assertThrows(IllegalArgumentException.class, () -> { + component.createEndpoint("aws2-ses://[email protected]?accessKey=xxx"); + }); } @Test diff --git a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentSpringTest.java b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentSpringTest.java index 4f2b461..01e5300 100644 --- a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentSpringTest.java +++ b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentSpringTest.java @@ -21,20 +21,23 @@ import java.util.List; import org.apache.camel.Exchange; import org.apache.camel.Processor; -import org.apache.camel.test.spring.CamelSpringTestSupport; -import org.junit.Before; -import org.junit.Test; +import org.apache.camel.test.spring.junit5.CamelSpringTestSupport; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.context.support.AbstractApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import software.amazon.awssdk.services.ses.model.SendEmailRequest; import software.amazon.awssdk.services.ses.model.SendRawEmailRequest; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class SesComponentSpringTest extends CamelSpringTestSupport { private AmazonSESClientMock sesClient; @Override - @Before + @BeforeEach public void setUp() throws Exception { super.setUp(); diff --git a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentTest.java b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentTest.java index df78663..2323b73 100644 --- a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentTest.java +++ b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentTest.java @@ -23,8 +23,12 @@ import org.apache.camel.BindToRegistry; import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; -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 static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import software.amazon.awssdk.services.ses.model.SendEmailRequest; public class SesComponentTest extends CamelTestSupport { diff --git a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentVerifierExtensionTest.java b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentVerifierExtensionTest.java index 67e3447..97d9fe2 100644 --- a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentVerifierExtensionTest.java +++ b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SesComponentVerifierExtensionTest.java @@ -21,9 +21,10 @@ 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 SesComponentVerifierExtensionTest extends CamelTestSupport { @@ -49,7 +50,7 @@ public class SesComponentVerifierExtensionTest 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 +66,7 @@ public class SesComponentVerifierExtensionTest 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-ses/src/test/java/org/apache/camel/component/aws2/ses/integration/SesComponentIntegrationTest.java b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/integration/SesComponentIntegrationTest.java index 58a0499..6101fef 100644 --- a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/integration/SesComponentIntegrationTest.java +++ b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/integration/SesComponentIntegrationTest.java @@ -23,11 +23,13 @@ import org.apache.camel.ExchangePattern; import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.aws2.ses.Ses2Constants; -import org.apache.camel.test.junit4.CamelTestSupport; -import org.junit.Ignore; -import org.junit.Test; +import org.apache.camel.test.junit5.CamelTestSupport; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; -@Ignore("Must be manually tested. Provide your own accessKey and secretKey!") +import static org.junit.jupiter.api.Assertions.assertNotNull; + +@Disabled("Must be manually tested. Provide your own accessKey and secretKey!") public class SesComponentIntegrationTest extends CamelTestSupport { @Test
