This is an automated email from the ASF dual-hosted git repository. gnodet pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit 420e581dd83c66060ed3809cf33ea3d96f2e1017 Author: Guillaume Nodet <gno...@gmail.com> AuthorDate: Wed Jul 22 23:17:40 2020 +0200 [CAMEL-11807] Upgrade camel-soroush to junit5 --- components/camel-soroush/pom.xml | 2 +- .../component/ConsumerAutoDownloadFileTest.java | 12 ++-- .../ConsumerAutoReconnectAfterIdleTimeoutTest.java | 2 +- .../component/ConsumerCamelConcurrentTest.java | 13 ++-- ...nsumerExceptionHandledWithErrorHandlerTest.java | 2 +- .../component/ConsumerMultiThreadTest.java | 2 +- .../component/ConsumerNativeConcurrentTest.java | 10 +-- .../ConsumerQueueCapacityPerThreadTest.java | 2 +- .../ConsumerRetryOnConnectionFailureTest.java | 2 +- .../soroushbot/component/ConsumerTest.java | 7 ++- ...onentialBackOffProducerConnectionRetryTest.java | 11 ++-- .../FixedBackOffProducerConnectionRetryTest.java | 11 ++-- .../HandleExceptionWithErrorHandlerTest.java | 7 ++- .../LinearBackOffProducerConnectionRetryTest.java | 11 ++-- ...etryWaitingTimeProducerConnectionRetryTest.java | 11 ++-- .../ProducerAutoUploadFileIsFalseTest.java | 18 +++--- .../component/ProducerAutoUploadFileTest.java | 21 ++++--- .../component/ProducerConnectionRetryTest.java | 11 ++-- .../component/ProducerDownloadFileTest.java | 17 ++--- .../ProducerDownloadFileWithoutThumbnailTest.java | 18 +++--- .../ProducerMaxConnectionRetryReachedTest.java | 14 +++-- .../soroushbot/component/ProducerTest.java | 11 ++-- .../component/ProducerUploadFileTest.java | 17 ++--- .../soroushbot/service/SoroushServiceTest.java | 32 ++++++---- .../soroushbot/support/SoroushBotTestSupport.java | 10 +-- .../utils/MultiQueueWithTopicThreadPoolTest.java | 72 ++++++++++++---------- 26 files changed, 191 insertions(+), 155 deletions(-) diff --git a/components/camel-soroush/pom.xml b/components/camel-soroush/pom.xml index bb71b38..01f5d3a 100644 --- a/components/camel-soroush/pom.xml +++ b/components/camel-soroush/pom.xml @@ -81,7 +81,7 @@ <!-- test dependencies--> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-test</artifactId> + <artifactId>camel-test-junit5</artifactId> <scope>test</scope> </dependency> <dependency> diff --git a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerAutoDownloadFileTest.java b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerAutoDownloadFileTest.java index 22f1079..449b3bf 100644 --- a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerAutoDownloadFileTest.java +++ b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerAutoDownloadFileTest.java @@ -25,8 +25,10 @@ import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.component.soroushbot.models.SoroushAction; import org.apache.camel.component.soroushbot.models.SoroushMessage; import org.apache.camel.component.soroushbot.support.SoroushBotTestSupport; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ConsumerAutoDownloadFileTest extends SoroushBotTestSupport { @Override @@ -46,11 +48,11 @@ public class ConsumerAutoDownloadFileTest extends SoroushBotTestSupport { mockEndpoint.setExpectedCount(4); mockEndpoint.assertIsSatisfied(); List<Exchange> exchanges = mockEndpoint.getExchanges(); - Assert.assertEquals(exchanges.size(), 4); + assertEquals(exchanges.size(), 4); exchanges.forEach(exchange -> { SoroushMessage body = exchange.getIn().getBody(SoroushMessage.class); - Assert.assertTrue("if fileUrl is not null file may not be null and visa versa", body.getFile() == null ^ body.getFileUrl() != null); - Assert.assertTrue("if and only if thumbnail url is null thumbnail may be null", body.getThumbnail() == null ^ body.getThumbnailUrl() != null); + assertTrue(body.getFile() == null ^ body.getFileUrl() != null, "if fileUrl is not null file may not be null and visa versa"); + assertTrue(body.getThumbnail() == null ^ body.getThumbnailUrl() != null, "if and only if thumbnail url is null thumbnail may be null"); }); } diff --git a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerAutoReconnectAfterIdleTimeoutTest.java b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerAutoReconnectAfterIdleTimeoutTest.java index ac59869..23f4be7 100644 --- a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerAutoReconnectAfterIdleTimeoutTest.java +++ b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerAutoReconnectAfterIdleTimeoutTest.java @@ -22,7 +22,7 @@ import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.component.soroushbot.models.SoroushAction; import org.apache.camel.component.soroushbot.support.SoroushBotTestSupport; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ConsumerAutoReconnectAfterIdleTimeoutTest extends SoroushBotTestSupport { diff --git a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerCamelConcurrentTest.java b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerCamelConcurrentTest.java index af755c3..6092891 100644 --- a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerCamelConcurrentTest.java +++ b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerCamelConcurrentTest.java @@ -26,8 +26,9 @@ import org.apache.camel.component.soroushbot.models.SoroushAction; import org.apache.camel.component.soroushbot.models.SoroushMessage; import org.apache.camel.component.soroushbot.support.SoroushBotTestSupport; import org.apache.logging.log4j.LogManager; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class ConsumerCamelConcurrentTest extends SoroushBotTestSupport { final List<String> fromOrder = new ArrayList<>(); @@ -59,9 +60,9 @@ public class ConsumerCamelConcurrentTest extends SoroushBotTestSupport { mockEndpoint.expectedMessageCount(10); mockEndpoint.assertIsSatisfied(); LogManager.getLogger().info(fromOrder.toString()); - Assert.assertEquals(fromOrder.size(), 10); - Assert.assertEquals(fromOrder.get(7), "u0"); - Assert.assertEquals(fromOrder.get(8), "u0"); - Assert.assertEquals(fromOrder.get(9), "u0"); + assertEquals(fromOrder.size(), 10); + assertEquals(fromOrder.get(7), "u0"); + assertEquals(fromOrder.get(8), "u0"); + assertEquals(fromOrder.get(9), "u0"); } } \ No newline at end of file diff --git a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerExceptionHandledWithErrorHandlerTest.java b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerExceptionHandledWithErrorHandlerTest.java index 88319c8..6ee9fdd 100644 --- a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerExceptionHandledWithErrorHandlerTest.java +++ b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerExceptionHandledWithErrorHandlerTest.java @@ -24,7 +24,7 @@ import org.apache.camel.component.soroushbot.models.SoroushAction; import org.apache.camel.component.soroushbot.models.SoroushMessage; import org.apache.camel.component.soroushbot.support.SoroushBotTestSupport; import org.apache.camel.component.soroushbot.utils.CongestionException; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ConsumerExceptionHandledWithErrorHandlerTest extends SoroushBotTestSupport { @Override diff --git a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerMultiThreadTest.java b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerMultiThreadTest.java index f3aaf78..a57e184 100644 --- a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerMultiThreadTest.java +++ b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerMultiThreadTest.java @@ -21,7 +21,7 @@ import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.component.soroushbot.models.SoroushAction; import org.apache.camel.component.soroushbot.support.SoroushBotTestSupport; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ConsumerMultiThreadTest extends SoroushBotTestSupport { diff --git a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerNativeConcurrentTest.java b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerNativeConcurrentTest.java index e4f2249..6a8f29e 100644 --- a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerNativeConcurrentTest.java +++ b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerNativeConcurrentTest.java @@ -27,8 +27,10 @@ import org.apache.camel.component.soroushbot.models.SoroushAction; import org.apache.camel.component.soroushbot.models.SoroushMessage; import org.apache.camel.component.soroushbot.support.SoroushBotTestSupport; import org.apache.logging.log4j.LogManager; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ConsumerNativeConcurrentTest extends SoroushBotTestSupport { ConcurrentHashMap<String, Thread> userToThread; @@ -62,7 +64,7 @@ public class ConsumerNativeConcurrentTest extends SoroushBotTestSupport { mockEndpoint.assertIsSatisfied(); LogManager.getLogger().info(userToThread.size()); LogManager.getLogger().info(userToThread.values()); - Assert.assertEquals("previous and current thread must be equal", badThread.get(), 0); - Assert.assertTrue("there must be more than 1 thread in $userToThread unless this test is not useful", new HashSet(userToThread.values()).size() > 1); + assertEquals(badThread.get(), 0, "previous and current thread must be equal"); + assertTrue(new HashSet<>(userToThread.values()).size() > 1, "there must be more than 1 thread in $userToThread unless this test is not useful"); } } diff --git a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerQueueCapacityPerThreadTest.java b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerQueueCapacityPerThreadTest.java index d18acd1..5cadcd1 100644 --- a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerQueueCapacityPerThreadTest.java +++ b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerQueueCapacityPerThreadTest.java @@ -21,7 +21,7 @@ import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.component.soroushbot.models.SoroushAction; import org.apache.camel.component.soroushbot.support.SoroushBotTestSupport; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ConsumerQueueCapacityPerThreadTest extends SoroushBotTestSupport { @Override diff --git a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerRetryOnConnectionFailureTest.java b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerRetryOnConnectionFailureTest.java index a511e67..31a5699 100644 --- a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerRetryOnConnectionFailureTest.java +++ b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerRetryOnConnectionFailureTest.java @@ -21,7 +21,7 @@ import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.component.soroushbot.models.SoroushAction; import org.apache.camel.component.soroushbot.support.SoroushBotTestSupport; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ConsumerRetryOnConnectionFailureTest extends SoroushBotTestSupport { @Override diff --git a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerTest.java b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerTest.java index bb543af..5e32763 100644 --- a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerTest.java +++ b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ConsumerTest.java @@ -23,8 +23,9 @@ import org.apache.camel.component.soroushbot.models.SoroushAction; import org.apache.camel.component.soroushbot.models.SoroushMessage; import org.apache.camel.component.soroushbot.support.SoroushBotTestSupport; import org.apache.logging.log4j.LogManager; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class ConsumerTest extends SoroushBotTestSupport { @@ -36,7 +37,7 @@ public class ConsumerTest extends SoroushBotTestSupport { MockEndpoint mockEndpoint = getMockEndpoint("mock:generalTest"); mockEndpoint.setExpectedMessageCount(5); mockEndpoint.assertIsSatisfied(); - Assert.assertEquals("total number of successful message is equal to 5", 5, successMessageCount); + assertEquals(5, successMessageCount, "total number of successful message is equal to 5"); } @Override diff --git a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ExponentialBackOffProducerConnectionRetryTest.java b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ExponentialBackOffProducerConnectionRetryTest.java index 698b26d..8fb0193 100644 --- a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ExponentialBackOffProducerConnectionRetryTest.java +++ b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ExponentialBackOffProducerConnectionRetryTest.java @@ -25,9 +25,10 @@ import org.apache.camel.component.soroushbot.models.SoroushAction; import org.apache.camel.component.soroushbot.models.SoroushMessage; import org.apache.camel.component.soroushbot.support.SoroushBotTestSupport; import org.apache.camel.component.soroushbot.support.SoroushBotWS; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class ExponentialBackOffProducerConnectionRetryTest extends SoroushBotTestSupport { @@ -35,7 +36,7 @@ public class ExponentialBackOffProducerConnectionRetryTest extends SoroushBotTes org.apache.camel.Endpoint endpoint; @Override - @Before + @BeforeEach public void setUp() throws Exception { super.setUp(); SoroushBotWS.clear(); @@ -72,6 +73,6 @@ public class ExponentialBackOffProducerConnectionRetryTest extends SoroushBotTes //cause this thread to sleep an addition of 1 second, during this time,the message must be sent to the server afterAllRetry.setAssertPeriod(1000); afterAllRetry.assertIsSatisfied(); - Assert.assertEquals("message sent successfully", SoroushBotWS.getReceivedMessages().get(0), body); + assertEquals(SoroushBotWS.getReceivedMessages().get(0), body, "message sent successfully"); } } diff --git a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/FixedBackOffProducerConnectionRetryTest.java b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/FixedBackOffProducerConnectionRetryTest.java index a34b376..17117c7 100644 --- a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/FixedBackOffProducerConnectionRetryTest.java +++ b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/FixedBackOffProducerConnectionRetryTest.java @@ -25,9 +25,10 @@ import org.apache.camel.component.soroushbot.models.SoroushAction; import org.apache.camel.component.soroushbot.models.SoroushMessage; import org.apache.camel.component.soroushbot.support.SoroushBotTestSupport; import org.apache.camel.component.soroushbot.support.SoroushBotWS; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class FixedBackOffProducerConnectionRetryTest extends SoroushBotTestSupport { @@ -35,7 +36,7 @@ public class FixedBackOffProducerConnectionRetryTest extends SoroushBotTestSuppo org.apache.camel.Endpoint endpoint; @Override - @Before + @BeforeEach public void setUp() throws Exception { super.setUp(); SoroushBotWS.clear(); @@ -73,6 +74,6 @@ public class FixedBackOffProducerConnectionRetryTest extends SoroushBotTestSuppo //cause this thread to sleep an addition of .6 second, during this time,the message must be sent to the server afterAllRetry.setAssertPeriod(600); afterAllRetry.assertIsSatisfied(); - Assert.assertEquals("message sent successfully", SoroushBotWS.getReceivedMessages().get(0), body); + assertEquals(SoroushBotWS.getReceivedMessages().get(0), body, "message sent successfully"); } } diff --git a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/HandleExceptionWithErrorHandlerTest.java b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/HandleExceptionWithErrorHandlerTest.java index bed3c81..d19979f 100644 --- a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/HandleExceptionWithErrorHandlerTest.java +++ b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/HandleExceptionWithErrorHandlerTest.java @@ -25,8 +25,9 @@ import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.component.soroushbot.models.SoroushAction; import org.apache.camel.component.soroushbot.models.SoroushMessage; import org.apache.camel.component.soroushbot.support.SoroushBotTestSupport; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertFalse; public class HandleExceptionWithErrorHandlerTest extends SoroushBotTestSupport { @Override @@ -39,7 +40,7 @@ public class HandleExceptionWithErrorHandlerTest extends SoroushBotTestSupport { .process(exchange -> { SoroushMessage body = exchange.getIn().getBody(SoroushMessage.class); File file = new File("badFile-ShouldNotExits"); - Assert.assertFalse("file should not exists for this test", file.exists()); + assertFalse(file.exists(), "file should not exists for this test"); body.setFile(file); body.setTo(body.getFrom()); }) diff --git a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/LinearBackOffProducerConnectionRetryTest.java b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/LinearBackOffProducerConnectionRetryTest.java index c932e4f..a26d905 100644 --- a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/LinearBackOffProducerConnectionRetryTest.java +++ b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/LinearBackOffProducerConnectionRetryTest.java @@ -25,9 +25,10 @@ import org.apache.camel.component.soroushbot.models.SoroushAction; import org.apache.camel.component.soroushbot.models.SoroushMessage; import org.apache.camel.component.soroushbot.support.SoroushBotTestSupport; import org.apache.camel.component.soroushbot.support.SoroushBotWS; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class LinearBackOffProducerConnectionRetryTest extends SoroushBotTestSupport { @@ -35,7 +36,7 @@ public class LinearBackOffProducerConnectionRetryTest extends SoroushBotTestSupp org.apache.camel.Endpoint endpoint; @Override - @Before + @BeforeEach public void setUp() throws Exception { super.setUp(); SoroushBotWS.clear(); @@ -73,6 +74,6 @@ public class LinearBackOffProducerConnectionRetryTest extends SoroushBotTestSupp //cause this thread to sleep an addition of 1 second, during this time,the message must be sent to the server afterAllRetry.setAssertPeriod(2000); afterAllRetry.assertIsSatisfied(); - Assert.assertEquals("message sent successfully", SoroushBotWS.getReceivedMessages().get(0), body); + assertEquals(SoroushBotWS.getReceivedMessages().get(0), body, "message sent successfully"); } } diff --git a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/MaxRetryWaitingTimeProducerConnectionRetryTest.java b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/MaxRetryWaitingTimeProducerConnectionRetryTest.java index 881c21e..807d7f4 100644 --- a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/MaxRetryWaitingTimeProducerConnectionRetryTest.java +++ b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/MaxRetryWaitingTimeProducerConnectionRetryTest.java @@ -25,9 +25,10 @@ import org.apache.camel.component.soroushbot.models.SoroushAction; import org.apache.camel.component.soroushbot.models.SoroushMessage; import org.apache.camel.component.soroushbot.support.SoroushBotTestSupport; import org.apache.camel.component.soroushbot.support.SoroushBotWS; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class MaxRetryWaitingTimeProducerConnectionRetryTest extends SoroushBotTestSupport { @@ -35,7 +36,7 @@ public class MaxRetryWaitingTimeProducerConnectionRetryTest extends SoroushBotTe org.apache.camel.Endpoint endpoint; @Override - @Before + @BeforeEach public void setUp() throws Exception { super.setUp(); SoroushBotWS.clear(); @@ -72,6 +73,6 @@ public class MaxRetryWaitingTimeProducerConnectionRetryTest extends SoroushBotTe //cause this thread to sleep an addition of 1 second, during this time,the message must be sent to the server afterAllRetry.setAssertPeriod(1000); afterAllRetry.assertIsSatisfied(); - Assert.assertEquals("message sent successfully", SoroushBotWS.getReceivedMessages().get(0), body); + assertEquals(SoroushBotWS.getReceivedMessages().get(0), body, "message sent successfully"); } } diff --git a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerAutoUploadFileIsFalseTest.java b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerAutoUploadFileIsFalseTest.java index 1765b38..6b8825f 100644 --- a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerAutoUploadFileIsFalseTest.java +++ b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerAutoUploadFileIsFalseTest.java @@ -28,9 +28,11 @@ import org.apache.camel.component.soroushbot.models.SoroushAction; import org.apache.camel.component.soroushbot.models.SoroushMessage; import org.apache.camel.component.soroushbot.support.SoroushBotTestSupport; import org.apache.camel.component.soroushbot.support.SoroushBotWS; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; public class ProducerAutoUploadFileIsFalseTest extends SoroushBotTestSupport { @@ -38,7 +40,7 @@ public class ProducerAutoUploadFileIsFalseTest extends SoroushBotTestSupport { org.apache.camel.Endpoint endpoint; @Override - @Before + @BeforeEach public void setUp() throws Exception { super.setUp(); SoroushBotWS.clear(); @@ -78,11 +80,11 @@ public class ProducerAutoUploadFileIsFalseTest extends SoroushBotTestSupport { MockEndpoint mockEndpoint = getMockEndpoint("mock:soroush"); mockEndpoint.setExpectedMessageCount(1); mockEndpoint.assertIsSatisfied(); - Assert.assertEquals("message sent successfully", SoroushBotWS.getReceivedMessages().get(0), body); + assertEquals(SoroushBotWS.getReceivedMessages().get(0), body, "message sent successfully"); SoroushMessage mockedMessage = mockEndpoint.getExchanges().get(0).getIn().getBody(SoroushMessage.class); Map<String, String> fileIdToContent = SoroushBotWS.getFileIdToContent(); - Assert.assertEquals("file uploaded successfully", fileIdToContent.size(), 0); - Assert.assertEquals(mockedMessage.getFileUrl(), null); - Assert.assertEquals(mockedMessage.getThumbnailUrl(), null); + assertEquals(fileIdToContent.size(), 0, "file uploaded successfully"); + assertNull(mockedMessage.getFileUrl()); + assertNull(mockedMessage.getThumbnailUrl()); } } diff --git a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerAutoUploadFileTest.java b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerAutoUploadFileTest.java index 1fb9579..979a003 100644 --- a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerAutoUploadFileTest.java +++ b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerAutoUploadFileTest.java @@ -28,19 +28,20 @@ import org.apache.camel.component.soroushbot.models.SoroushAction; import org.apache.camel.component.soroushbot.models.SoroushMessage; import org.apache.camel.component.soroushbot.support.SoroushBotTestSupport; import org.apache.camel.component.soroushbot.support.SoroushBotWS; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; -@Ignore("CAMEL-13629 failing test") +import static org.junit.jupiter.api.Assertions.assertEquals; + +@Disabled("CAMEL-13629 failing test") public class ProducerAutoUploadFileTest extends SoroushBotTestSupport { @EndpointInject("direct:soroush") org.apache.camel.Endpoint endpoint; @Override - @Before + @BeforeEach public void setUp() throws Exception { super.setUp(); SoroushBotWS.clear(); @@ -80,11 +81,11 @@ public class ProducerAutoUploadFileTest extends SoroushBotTestSupport { MockEndpoint mockEndpoint = getMockEndpoint("mock:soroush"); mockEndpoint.setExpectedMessageCount(1); mockEndpoint.assertIsSatisfied(); - Assert.assertEquals("message sent successfully", SoroushBotWS.getReceivedMessages().get(0), body); + assertEquals(SoroushBotWS.getReceivedMessages().get(0), body, "message sent successfully"); SoroushMessage mockedMessage = mockEndpoint.getExchanges().get(0).getIn().getBody(SoroushMessage.class); Map<String, String> fileIdToContent = SoroushBotWS.getFileIdToContent(); - Assert.assertEquals("file uploaded successfully", fileIdToContent.size(), 2); - Assert.assertEquals(fileIdToContent.get(mockedMessage.getFileUrl()), fileContent); - Assert.assertEquals(fileIdToContent.get(mockedMessage.getThumbnailUrl()), thumbContent); + assertEquals(fileIdToContent.size(), 2, "file uploaded successfully"); + assertEquals(fileIdToContent.get(mockedMessage.getFileUrl()), fileContent); + assertEquals(fileIdToContent.get(mockedMessage.getThumbnailUrl()), thumbContent); } } diff --git a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerConnectionRetryTest.java b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerConnectionRetryTest.java index 13142fe..4fc88f2 100644 --- a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerConnectionRetryTest.java +++ b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerConnectionRetryTest.java @@ -25,9 +25,10 @@ import org.apache.camel.component.soroushbot.models.SoroushAction; import org.apache.camel.component.soroushbot.models.SoroushMessage; import org.apache.camel.component.soroushbot.support.SoroushBotTestSupport; import org.apache.camel.component.soroushbot.support.SoroushBotWS; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class ProducerConnectionRetryTest extends SoroushBotTestSupport { @@ -35,7 +36,7 @@ public class ProducerConnectionRetryTest extends SoroushBotTestSupport { org.apache.camel.Endpoint endpoint; @Override - @Before + @BeforeEach public void setUp() throws Exception { super.setUp(); SoroushBotWS.clear(); @@ -62,6 +63,6 @@ public class ProducerConnectionRetryTest extends SoroushBotTestSupport { MockEndpoint mockEndpoint = getMockEndpoint("mock:soroush"); mockEndpoint.setExpectedMessageCount(1); mockEndpoint.assertIsSatisfied(); - Assert.assertEquals("message sent successfully", SoroushBotWS.getReceivedMessages().get(0), body); + assertEquals(SoroushBotWS.getReceivedMessages().get(0), body, "message sent successfully"); } } diff --git a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerDownloadFileTest.java b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerDownloadFileTest.java index e5bc412..a975ff2 100644 --- a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerDownloadFileTest.java +++ b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerDownloadFileTest.java @@ -30,12 +30,13 @@ import org.apache.camel.component.soroushbot.models.SoroushAction; import org.apache.camel.component.soroushbot.models.SoroushMessage; import org.apache.camel.component.soroushbot.support.SoroushBotTestSupport; import org.apache.camel.component.soroushbot.support.SoroushBotWS; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; -@Ignore("CAMEL-13629 failing test") +import static org.junit.jupiter.api.Assertions.assertEquals; + +@Disabled("CAMEL-13629 failing test") public class ProducerDownloadFileTest extends SoroushBotTestSupport { @EndpointInject("direct:soroush") @@ -43,7 +44,7 @@ public class ProducerDownloadFileTest extends SoroushBotTestSupport { @Override - @Before + @BeforeEach public void setUp() throws Exception { super.setUp(); SoroushBotWS.clear(); @@ -81,8 +82,8 @@ public class ProducerDownloadFileTest extends SoroushBotTestSupport { mockEndpoint.setExpectedMessageCount(1); mockEndpoint.assertIsSatisfied(); SoroushMessage mockedMessage = mockEndpoint.getExchanges().get(0).getIn().getBody(SoroushMessage.class); - Assert.assertEquals("download file successfully", new String(IOUtils.readFully(mockedMessage.getFile(), 1000, false)), fileContent); - Assert.assertEquals("download thumbnail successfully", new String(IOUtils.readFully(mockedMessage.getThumbnail(), 1000, false)), thumbContent); + assertEquals(new String(IOUtils.readFully(mockedMessage.getFile(), 1000, false)), fileContent, "download file successfully"); + assertEquals(new String(IOUtils.readFully(mockedMessage.getThumbnail(), 1000, false)), thumbContent, "download thumbnail successfully"); } } diff --git a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerDownloadFileWithoutThumbnailTest.java b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerDownloadFileWithoutThumbnailTest.java index ae6cd86..4c03ec1 100644 --- a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerDownloadFileWithoutThumbnailTest.java +++ b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerDownloadFileWithoutThumbnailTest.java @@ -30,12 +30,14 @@ import org.apache.camel.component.soroushbot.models.SoroushAction; import org.apache.camel.component.soroushbot.models.SoroushMessage; import org.apache.camel.component.soroushbot.support.SoroushBotTestSupport; import org.apache.camel.component.soroushbot.support.SoroushBotWS; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; -@Ignore("CAMEL-13629 failing test") +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + +@Disabled("CAMEL-13629 failing test") public class ProducerDownloadFileWithoutThumbnailTest extends SoroushBotTestSupport { @EndpointInject("direct:soroush") @@ -43,7 +45,7 @@ public class ProducerDownloadFileWithoutThumbnailTest extends SoroushBotTestSupp @Override - @Before + @BeforeEach public void setUp() throws Exception { super.setUp(); SoroushBotWS.clear(); @@ -81,8 +83,8 @@ public class ProducerDownloadFileWithoutThumbnailTest extends SoroushBotTestSupp mockEndpoint.setExpectedMessageCount(1); mockEndpoint.assertIsSatisfied(); SoroushMessage mockedMessage = mockEndpoint.getExchanges().get(0).getIn().getBody(SoroushMessage.class); - Assert.assertEquals("download file successfully", new String(IOUtils.readFully(mockedMessage.getFile(), 1000, false)), fileContent); - Assert.assertEquals("download thumbnail successfully", mockedMessage.getThumbnail(), null); + assertEquals(new String(IOUtils.readFully(mockedMessage.getFile(), 1000, false)), fileContent, "download file successfully"); + assertNull(mockedMessage.getThumbnail(), "download thumbnail successfully"); } } diff --git a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerMaxConnectionRetryReachedTest.java b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerMaxConnectionRetryReachedTest.java index 1248568..bf84947 100644 --- a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerMaxConnectionRetryReachedTest.java +++ b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerMaxConnectionRetryReachedTest.java @@ -26,9 +26,11 @@ import org.apache.camel.component.soroushbot.models.SoroushAction; import org.apache.camel.component.soroushbot.models.SoroushMessage; import org.apache.camel.component.soroushbot.support.SoroushBotTestSupport; import org.apache.camel.component.soroushbot.support.SoroushBotWS; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ProducerMaxConnectionRetryReachedTest extends SoroushBotTestSupport { @@ -36,7 +38,7 @@ public class ProducerMaxConnectionRetryReachedTest extends SoroushBotTestSupport org.apache.camel.Endpoint endpoint; @Override - @Before + @BeforeEach public void setUp() throws Exception { super.setUp(); SoroushBotWS.clear(); @@ -65,11 +67,11 @@ public class ProducerMaxConnectionRetryReachedTest extends SoroushBotTestSupport } catch (CamelExecutionException ex) { exceptionOccur = true; } - Assert.assertTrue("an exception happend due to maximumConnetion try reached!", exceptionOccur); + assertTrue(exceptionOccur, "an exception happend due to maximumConnetion try reached!"); MockEndpoint mockEndpoint = getMockEndpoint("mock:soroush"); mockEndpoint.setAssertPeriod(1000); mockEndpoint.setExpectedMessageCount(0); mockEndpoint.assertIsSatisfied(); - Assert.assertEquals("message did not send", SoroushBotWS.getReceivedMessages().size(), 0); + assertEquals(SoroushBotWS.getReceivedMessages().size(), 0, "message did not send"); } } diff --git a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerTest.java b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerTest.java index 76fd000..0cf8cb6 100644 --- a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerTest.java +++ b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerTest.java @@ -25,9 +25,10 @@ import org.apache.camel.component.soroushbot.models.SoroushAction; import org.apache.camel.component.soroushbot.models.SoroushMessage; import org.apache.camel.component.soroushbot.support.SoroushBotTestSupport; import org.apache.camel.component.soroushbot.support.SoroushBotWS; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class ProducerTest extends SoroushBotTestSupport { @@ -35,7 +36,7 @@ public class ProducerTest extends SoroushBotTestSupport { org.apache.camel.Endpoint endpoint; @Override - @Before + @BeforeEach public void setUp() throws Exception { super.setUp(); SoroushBotWS.clear(); @@ -62,6 +63,6 @@ public class ProducerTest extends SoroushBotTestSupport { MockEndpoint mockEndpoint = getMockEndpoint("mock:soroush"); mockEndpoint.setExpectedMessageCount(1); mockEndpoint.assertIsSatisfied(); - Assert.assertEquals("message sent successfully", SoroushBotWS.getReceivedMessages().get(0), body); + assertEquals(SoroushBotWS.getReceivedMessages().get(0), body, "message sent successfully"); } } diff --git a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerUploadFileTest.java b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerUploadFileTest.java index 0c7a51b..e6a2d76 100644 --- a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerUploadFileTest.java +++ b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/component/ProducerUploadFileTest.java @@ -28,9 +28,10 @@ import org.apache.camel.component.soroushbot.models.SoroushAction; import org.apache.camel.component.soroushbot.models.SoroushMessage; import org.apache.camel.component.soroushbot.support.SoroushBotTestSupport; import org.apache.camel.component.soroushbot.support.SoroushBotWS; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class ProducerUploadFileTest extends SoroushBotTestSupport { @@ -38,7 +39,7 @@ public class ProducerUploadFileTest extends SoroushBotTestSupport { org.apache.camel.Endpoint endpoint; @Override - @Before + @BeforeEach public void setUp() throws Exception { super.setUp(); SoroushBotWS.clear(); @@ -78,12 +79,12 @@ public class ProducerUploadFileTest extends SoroushBotTestSupport { MockEndpoint mockEndpoint = getMockEndpoint("mock:soroush"); mockEndpoint.setExpectedMessageCount(1); mockEndpoint.assertIsSatisfied(); - Assert.assertEquals("no message sent.", SoroushBotWS.getReceivedMessages().size(), 0); + assertEquals(SoroushBotWS.getReceivedMessages().size(), 0, "no message sent."); SoroushMessage mockedMessage = mockEndpoint.getExchanges().get(0).getIn().getBody(SoroushMessage.class); Map<String, String> fileIdToContent = SoroushBotWS.getFileIdToContent(); - Assert.assertEquals("file uploaded successfully", fileIdToContent.size(), 2); - Assert.assertEquals(fileIdToContent.get(mockedMessage.getFileUrl()), fileContent); - Assert.assertEquals(fileIdToContent.get(mockedMessage.getThumbnailUrl()), thumbContent); + assertEquals(fileIdToContent.size(), 2, "file uploaded successfully"); + assertEquals(fileIdToContent.get(mockedMessage.getFileUrl()), fileContent); + assertEquals(fileIdToContent.get(mockedMessage.getThumbnailUrl()), thumbContent); } } diff --git a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/service/SoroushServiceTest.java b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/service/SoroushServiceTest.java index da85b68..9ddad57 100644 --- a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/service/SoroushServiceTest.java +++ b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/service/SoroushServiceTest.java @@ -39,26 +39,32 @@ import org.glassfish.jersey.media.multipart.file.StreamDataBodyPart; import org.glassfish.jersey.media.sse.EventInput; import org.glassfish.jersey.media.sse.InboundEvent; import org.glassfish.jersey.media.sse.SseFeature; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * check if soroush BOT Api work as expected */ -@Ignore("Need the token to work") +@Disabled("Need the token to work") public class SoroushServiceTest { static String authorizationToken; static String receiverId; private static SoroushService soroushService; - @BeforeClass + @BeforeAll public static void setUp() { authorizationToken = System.getenv("soroushBotAuthorizationToken"); receiverId = System.getenv("soroushBotReceiverId"); - Assert.assertTrue("you need to define `soroushBotAuthorizationToken` and " - + "`soroushBotReceiverId` environment variable in order to do integration test ", authorizationToken != null && receiverId != null); + assertTrue(authorizationToken != null && receiverId != null, + "you need to define `soroushBotAuthorizationToken` and " + + "`soroushBotReceiverId` environment variable in order to do integration test "); soroushService = SoroushService.get(); soroushService.setAlternativeUrl(null); } @@ -73,7 +79,7 @@ public class SoroushServiceTest { WebTarget target = client.target(soroushService.generateUrl(authorizationToken, SoroushAction.getMessage, null)); EventInput eventInput = target.request().get(EventInput.class); eventInput.setChunkType(MediaType.SERVER_SENT_EVENTS); - Assert.assertFalse(eventInput.isClosed()); + assertFalse(eventInput.isClosed()); } @Test @@ -83,9 +89,9 @@ public class SoroushServiceTest { WebTarget target = client.target(soroushService.generateUrl("bad_string" + authorizationToken, SoroushAction.getMessage, null)); EventInput eventInput = target.request().get(EventInput.class); eventInput.setChunkType(MediaType.SERVER_SENT_EVENTS); - Assert.assertFalse(eventInput.isClosed()); + assertFalse(eventInput.isClosed()); InboundEvent read = eventInput.read(); - Assert.assertNull(read); + assertNull(read); } @Test @@ -110,12 +116,12 @@ public class SoroushServiceTest { Response response = target.request(MediaType.APPLICATION_JSON_TYPE) .post(Entity.entity(multipart, multipart.getMediaType())); UploadFileResponse uploadFileResponse = soroushService.assertSuccessful(response, UploadFileResponse.class, null); - Assert.assertNotNull(uploadFileResponse.getFileUrl()); + assertNotNull(uploadFileResponse.getFileUrl()); WebTarget downloadFileTarget = soroushService.createDownloadFileTarget(authorizationToken, uploadFileResponse.getFileUrl(), 2000); Response downloadResponse = downloadFileTarget.request().get(); String remoteData = new String(IOUtils.readFully(downloadResponse.readEntity(InputStream.class), -1, false)); - Assert.assertEquals("file contents are identical", fileData, remoteData); + assertEquals(fileData, remoteData, "file contents are identical"); } } diff --git a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/support/SoroushBotTestSupport.java b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/support/SoroushBotTestSupport.java index 9a63844..7677876 100644 --- a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/support/SoroushBotTestSupport.java +++ b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/support/SoroushBotTestSupport.java @@ -18,10 +18,10 @@ package org.apache.camel.component.soroushbot.support; import org.apache.camel.component.soroushbot.service.SoroushService; -import org.apache.camel.test.junit4.CamelTestSupport; +import org.apache.camel.test.junit5.CamelTestSupport; import org.apache.logging.log4j.LogManager; -import org.junit.AfterClass; -import org.junit.BeforeClass; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; /** * A support test class for Soroush Bot tests. @@ -30,7 +30,7 @@ public class SoroushBotTestSupport extends CamelTestSupport { private static SoroushMockServer soroushMockServer; - @BeforeClass + @BeforeAll public static void init() throws Exception { if (soroushMockServer == null) { soroushMockServer = new SoroushMockServer(); @@ -41,7 +41,7 @@ public class SoroushBotTestSupport extends CamelTestSupport { LogManager.getLogger().info("soroushMockServer is up on port " + port); } - @AfterClass + @AfterAll public static void afterClass() { SoroushService.get().setAlternativeUrl(null); } diff --git a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/utils/MultiQueueWithTopicThreadPoolTest.java b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/utils/MultiQueueWithTopicThreadPoolTest.java index 7e773bc..2152407 100644 --- a/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/utils/MultiQueueWithTopicThreadPoolTest.java +++ b/components/camel-soroush/src/test/java/org/apache/camel/component/soroushbot/utils/MultiQueueWithTopicThreadPoolTest.java @@ -18,8 +18,10 @@ package org.apache.camel.component.soroushbot.utils; import java.util.concurrent.LinkedBlockingQueue; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class MultiQueueWithTopicThreadPoolTest { @Test @@ -43,22 +45,24 @@ public class MultiQueueWithTopicThreadPoolTest { }); } Thread.sleep(capacity * (capacity + 2) * 100 / 2); // wait enough time for all task to be done - Assert.assertArrayEquals("order of thread that executed is not what is expected", results, finalResultsOrder.toArray()); + assertArrayEquals(results, finalResultsOrder.toArray(), "order of thread that executed is not what is expected"); } - @Test(expected = IllegalStateException.class) + @Test public void singleThreadPoolSizeExceeded() { - int capacity = 10; - MultiQueueWithTopicThreadPool pool = new MultiQueueWithTopicThreadPool(1, capacity, "test"); - for (int i = 0; i < capacity + 2; i++) { - pool.execute(i % 3, () -> { - try { - Thread.sleep(100); - } catch (InterruptedException e) { - e.printStackTrace(); - } - }); - } + assertThrows(IllegalStateException.class, () -> { + int capacity = 10; + MultiQueueWithTopicThreadPool pool = new MultiQueueWithTopicThreadPool(1, capacity, "test"); + for (int i = 0; i < capacity + 2; i++) { + pool.execute(i % 3, () -> { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + e.printStackTrace(); + } + }); + } + }); } @Test @@ -89,7 +93,8 @@ public class MultiQueueWithTopicThreadPoolTest { }); } Thread.sleep(130 * 3 + 500); // wait enough time for all task to be done - Assert.assertArrayEquals("order of thread that executed is not what is expected", results, finalResultsOrder.toArray()); + assertArrayEquals(results, finalResultsOrder.toArray(), + "order of thread that executed is not what is expected"); } @Test @@ -120,24 +125,27 @@ public class MultiQueueWithTopicThreadPoolTest { Object[] finalResultsOrderList = finalResultsOrder.toArray(); //order of first three job is not fully determined so we set them to null finalResultsOrderList[0] = finalResultsOrderList[1] = finalResultsOrderList[2] = null; - Assert.assertArrayEquals("order of thread that executed is not what is expected", expectedResults, finalResultsOrderList); + assertArrayEquals(expectedResults, finalResultsOrderList, + "order of thread that executed is not what is expected"); } - @Test(expected = IllegalStateException.class) + @Test public void multiThreadPoolSizeExceeded() throws InterruptedException { - LinkedBlockingQueue<Integer> finalResultsOrder = new LinkedBlockingQueue<>(); - int capacity = 3; - int poolSize = 3; - MultiQueueWithTopicThreadPool pool = new MultiQueueWithTopicThreadPool(poolSize, capacity, "test"); - for (int i = 0; i < (capacity + 1) * poolSize + 1; i++) { - pool.execute(i % poolSize, () -> { - try { - Thread.sleep(100); - } catch (InterruptedException e) { - e.printStackTrace(); - } - }); - } - Thread.sleep(100); + assertThrows(IllegalStateException.class, () -> { + LinkedBlockingQueue<Integer> finalResultsOrder = new LinkedBlockingQueue<>(); + int capacity = 3; + int poolSize = 3; + MultiQueueWithTopicThreadPool pool = new MultiQueueWithTopicThreadPool(poolSize, capacity, "test"); + for (int i = 0; i < (capacity + 1) * poolSize + 1; i++) { + pool.execute(i % poolSize, () -> { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + e.printStackTrace(); + } + }); + } + Thread.sleep(100); + }); } }