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 2022/06/14 10:27:19 UTC
[camel] branch main updated (6a0781bec7c -> db7aaace51d)
This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
from 6a0781bec7c Regen for commit 45994e41d2d5c9a4425161ed50f5740adc1a61a4 (#7776)
new b3a46764b99 (chores) Rename manual tests
new 16f4b346747 (chores) camel-mybatis: removed usages of Thread.sleep
new 0588e153ec0 (chores) camel-netty-http: removed usages of Thread.sleep
new 0451c189756 (chores) camel-netty: removed some usages of Thread.sleep
new db7aaace51d (chores) camel-rabbitmq: removed some usages of Thread.sleep
The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
...SocketTests.java => JavaSocketManualTests.java} | 2 +-
components/camel-mybatis/pom.xml | 5 ++++
.../mybatis/MyBatisConsumerIdleMessageTest.java | 9 ++++--
.../camel/component/mybatis/MyBatisQueueTest.java | 10 +++++--
.../mybatis/MyBatisShutdownAllTasksTest.java | 10 ++++---
.../NettyHttpBasicAuthConstraintMapperTest.java | 20 ++++++++-----
...tpBasicAuthCustomSecurityAuthenticatorTest.java | 19 +++++++-----
.../netty/http/NettyHttpSuspendResume503Test.java | 14 +++++----
.../netty/http/NettyHttpSuspendResumeTest.java | 14 +++++----
components/camel-netty/pom.xml | 5 ++++
.../netty/ErrorDuringGracefullShutdownTest.java | 12 ++++++--
.../RabbitMQDeadLetterRoutingKeyIT.java | 5 ++--
.../rabbitmq/integration/RabbitMQProducerIT.java | 35 +++++++++++-----------
.../integration/spring/RabbitMQSpringIntTest.java | 12 ++++----
14 files changed, 108 insertions(+), 64 deletions(-)
rename components/camel-mllp/src/test/java/org/apache/camel/test/tcp/{JavaSocketTests.java => JavaSocketManualTests.java} (99%)
[camel] 02/05: (chores) camel-mybatis: removed usages of Thread.sleep
Posted by or...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 16f4b346747014717c95cc943d63ed23f684b1bf
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Tue Jun 14 10:25:41 2022 +0200
(chores) camel-mybatis: removed usages of Thread.sleep
---
components/camel-mybatis/pom.xml | 5 +++++
.../component/mybatis/MyBatisConsumerIdleMessageTest.java | 9 +++++++--
.../org/apache/camel/component/mybatis/MyBatisQueueTest.java | 10 +++++++---
.../camel/component/mybatis/MyBatisShutdownAllTasksTest.java | 10 ++++++----
4 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/components/camel-mybatis/pom.xml b/components/camel-mybatis/pom.xml
index c17fbd960ff..587f2ee81e1 100644
--- a/components/camel-mybatis/pom.xml
+++ b/components/camel-mybatis/pom.xml
@@ -75,5 +75,10 @@
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.awaitility</groupId>
+ <artifactId>awaitility</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisConsumerIdleMessageTest.java b/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisConsumerIdleMessageTest.java
index cbbd22b3c66..804eda4c8f9 100644
--- a/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisConsumerIdleMessageTest.java
+++ b/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisConsumerIdleMessageTest.java
@@ -16,10 +16,13 @@
*/
package org.apache.camel.component.mybatis;
+import java.util.concurrent.TimeUnit;
+
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Test;
+import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertNull;
/**
@@ -35,10 +38,12 @@ public class MyBatisConsumerIdleMessageTest extends MyBatisTestSupport {
@Test
public void testConsumeIdleMessages() throws Exception {
- Thread.sleep(110);
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMinimumMessageCount(2);
- assertMockEndpointsSatisfied();
+
+ await()
+ .atLeast(110, TimeUnit.MILLISECONDS)
+ .untilAsserted(() -> assertMockEndpointsSatisfied());
assertNull(mock.getExchanges().get(0).getIn().getBody());
assertNull(mock.getExchanges().get(1).getIn().getBody());
}
diff --git a/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisQueueTest.java b/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisQueueTest.java
index 5baa582c3cc..57386321b1e 100644
--- a/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisQueueTest.java
+++ b/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisQueueTest.java
@@ -17,12 +17,15 @@
package org.apache.camel.component.mybatis;
import java.util.List;
+import java.util.concurrent.TimeUnit;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
+import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
+import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class MyBatisQueueTest extends MyBatisTestSupport {
@@ -59,11 +62,12 @@ public class MyBatisQueueTest extends MyBatisTestSupport {
assertMockEndpointsSatisfied();
// need a delay here on slower machines
- Thread.sleep(1000);
+ List<?> body = await()
+ .atMost(1, TimeUnit.SECONDS)
+ .until(() -> template.requestBody("mybatis:selectProcessedAccounts?statementType=SelectList", null, List.class),
+ Matchers.notNullValue());
// now lets poll that the account has been inserted
- List<?> body = template.requestBody("mybatis:selectProcessedAccounts?statementType=SelectList", null, List.class);
-
assertEquals(2, body.size(), "Wrong size: " + body);
Account actual = assertIsInstanceOf(Account.class, body.get(0));
diff --git a/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisShutdownAllTasksTest.java b/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisShutdownAllTasksTest.java
index e565546d68a..bcd9e5b6f91 100644
--- a/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisShutdownAllTasksTest.java
+++ b/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisShutdownAllTasksTest.java
@@ -16,12 +16,15 @@
*/
package org.apache.camel.component.mybatis;
+import java.util.concurrent.TimeUnit;
+
import org.apache.camel.ShutdownRunningTask;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class MyBatisShutdownAllTasksTest extends MyBatisTestSupport {
@@ -95,11 +98,10 @@ public class MyBatisShutdownAllTasksTest extends MyBatisTestSupport {
// shutdown during processing
context.stop();
- // sleep a little
- Thread.sleep(1000);
-
// should route all 8
- assertEquals(8, bar.getReceivedCounter(), "Should complete all messages");
+ await()
+ .atMost(1, TimeUnit.SECONDS)
+ .untilAsserted(() -> assertEquals(8, bar.getReceivedCounter(), "Should complete all messages"));
}
@Override
[camel] 03/05: (chores) camel-netty-http: removed usages of Thread.sleep
Posted by or...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 0588e153ec0d346383c5bd1b8d2657ba892705d0
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Tue Jun 14 10:37:49 2022 +0200
(chores) camel-netty-http: removed usages of Thread.sleep
---
.../http/NettyHttpBasicAuthConstraintMapperTest.java | 20 +++++++++++++-------
...HttpBasicAuthCustomSecurityAuthenticatorTest.java | 19 +++++++++++--------
.../netty/http/NettyHttpSuspendResume503Test.java | 14 ++++++++------
.../netty/http/NettyHttpSuspendResumeTest.java | 14 +++++++++-----
4 files changed, 41 insertions(+), 26 deletions(-)
diff --git a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpBasicAuthConstraintMapperTest.java b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpBasicAuthConstraintMapperTest.java
index ff67314a4c0..c797b074dad 100644
--- a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpBasicAuthConstraintMapperTest.java
+++ b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpBasicAuthConstraintMapperTest.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel.component.netty.http;
+import java.util.concurrent.TimeUnit;
+
import org.apache.camel.BindToRegistry;
import org.apache.camel.CamelExecutionException;
import org.apache.camel.builder.RouteBuilder;
@@ -24,6 +26,7 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
+import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -74,14 +77,17 @@ public class NettyHttpBasicAuthConstraintMapperTest extends BaseNettyTest {
NettyHttpOperationFailedException cause = assertIsInstanceOf(NettyHttpOperationFailedException.class, e.getCause());
assertEquals(401, cause.getStatusCode());
- // wait a little bit before next as the connection was closed when denied
- Thread.sleep(500);
-
// username:password is scott:secret
- String auth = "Basic c2NvdHQ6c2VjcmV0";
- out = template.requestBodyAndHeader("netty-http:http://localhost:{{port}}/foo", "Hello World", "Authorization", auth,
- String.class);
- assertEquals("Bye World", out);
+ final String auth = "Basic c2NvdHQ6c2VjcmV0";
+
+ // wait a little bit before next as the connection was closed when denied
+ await().atMost(500, TimeUnit.MILLISECONDS)
+ .untilAsserted(() -> {
+ String nextOut = template.requestBodyAndHeader("netty-http:http://localhost:{{port}}/foo", "Hello World",
+ "Authorization", auth,
+ String.class);
+ assertEquals("Bye World", nextOut);
+ });
assertMockEndpointsSatisfied();
}
diff --git a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpBasicAuthCustomSecurityAuthenticatorTest.java b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpBasicAuthCustomSecurityAuthenticatorTest.java
index 8930c0d63b2..cb347582e7d 100644
--- a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpBasicAuthCustomSecurityAuthenticatorTest.java
+++ b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpBasicAuthCustomSecurityAuthenticatorTest.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel.component.netty.http;
+import java.util.concurrent.TimeUnit;
+
import javax.security.auth.Subject;
import javax.security.auth.login.LoginException;
@@ -25,6 +27,7 @@ import org.apache.camel.builder.RouteBuilder;
import org.junit.jupiter.api.Test;
import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
+import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
@@ -45,16 +48,16 @@ public class NettyHttpBasicAuthCustomSecurityAuthenticatorTest extends BaseNetty
// wait a little bit before next as the connection was closed when
// denied
- Thread.sleep(500);
-
- getMockEndpoint("mock:input").expectedBodiesReceived("Hello World");
-
- // username:password is scott:secret
String auth = "Basic c2NvdHQ6c2VjcmV0";
- String out = template.requestBodyAndHeader("netty-http:http://localhost:{{port}}/foo", "Hello World", "Authorization",
- auth, String.class);
- assertEquals("Bye World", out);
+ getMockEndpoint("mock:input").expectedBodiesReceived("Hello World");
+ await().atMost(500, TimeUnit.MILLISECONDS)
+ .untilAsserted(() -> {
+ String out = template.requestBodyAndHeader("netty-http:http://localhost:{{port}}/foo", "Hello World",
+ "Authorization",
+ auth, String.class);
+ assertEquals("Bye World", out);
+ });
assertMockEndpointsSatisfied();
}
diff --git a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpSuspendResume503Test.java b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpSuspendResume503Test.java
index 77a4e5dde7c..d329eb0bfc8 100644
--- a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpSuspendResume503Test.java
+++ b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpSuspendResume503Test.java
@@ -16,11 +16,14 @@
*/
package org.apache.camel.component.netty.http;
+import java.util.concurrent.TimeUnit;
+
import org.apache.camel.builder.RouteBuilder;
import org.junit.jupiter.api.Test;
import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
import static org.apache.camel.test.junit5.TestSupport.isPlatform;
+import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;
@@ -57,12 +60,11 @@ public class NettyHttpSuspendResume503Test extends BaseNettyTest {
// resume
consumer.resume();
-
- Thread.sleep(2000);
-
- // and send request which should be processed
- reply = template.requestBody(serverUri, "Moon", String.class);
- assertEquals("Bye Moon", reply);
+ await().atMost(2, TimeUnit.SECONDS)
+ .untilAsserted(() -> {
+ String nextReply = template.requestBody(serverUri, "Moon", String.class);
+ assertEquals("Bye Moon", nextReply);
+ });
}
@Override
diff --git a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpSuspendResumeTest.java b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpSuspendResumeTest.java
index 475ad6a4ddd..6aaebe1c959 100644
--- a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpSuspendResumeTest.java
+++ b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpSuspendResumeTest.java
@@ -16,10 +16,13 @@
*/
package org.apache.camel.component.netty.http;
+import java.util.concurrent.TimeUnit;
+
import org.apache.camel.builder.RouteBuilder;
import org.junit.jupiter.api.Test;
import static org.apache.camel.test.junit5.TestSupport.isPlatform;
+import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -57,11 +60,12 @@ public class NettyHttpSuspendResumeTest extends BaseNettyTest {
// resume
consumer.resume();
- Thread.sleep(2000);
-
- // and send request which should be processed
- reply = template.requestBody(serverUri, "Moon", String.class);
- assertEquals("Bye Moon", reply);
+ await().atMost(2, TimeUnit.SECONDS)
+ .untilAsserted(() -> {
+ // and send request which should be processed
+ String nextReply = template.requestBody(serverUri, "Moon", String.class);
+ assertEquals("Bye Moon", nextReply);
+ });
}
@Override
[camel] 04/05: (chores) camel-netty: removed some usages of Thread.sleep
Posted by or...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 0451c1897561d083b51f3bc9b650c4bc8c7256f6
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Tue Jun 14 10:52:17 2022 +0200
(chores) camel-netty: removed some usages of Thread.sleep
---
components/camel-netty/pom.xml | 5 +++++
.../component/netty/ErrorDuringGracefullShutdownTest.java | 12 +++++++++---
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/components/camel-netty/pom.xml b/components/camel-netty/pom.xml
index 2a64bb37bf7..e11d9828b15 100644
--- a/components/camel-netty/pom.xml
+++ b/components/camel-netty/pom.xml
@@ -113,6 +113,11 @@
<artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.awaitility</groupId>
+ <artifactId>awaitility</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/components/camel-netty/src/test/java/org/apache/camel/component/netty/ErrorDuringGracefullShutdownTest.java b/components/camel-netty/src/test/java/org/apache/camel/component/netty/ErrorDuringGracefullShutdownTest.java
index cf3dba589fd..ffede513ed0 100644
--- a/components/camel-netty/src/test/java/org/apache/camel/component/netty/ErrorDuringGracefullShutdownTest.java
+++ b/components/camel-netty/src/test/java/org/apache/camel/component/netty/ErrorDuringGracefullShutdownTest.java
@@ -16,11 +16,16 @@
*/
package org.apache.camel.component.netty;
+import java.util.concurrent.TimeUnit;
+
import org.apache.camel.RoutesBuilder;
import org.apache.camel.ServiceStatus;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.processor.errorhandler.DefaultErrorHandler;
+import org.awaitility.Awaitility;
+import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.api.parallel.Isolated;
import static org.assertj.core.api.Assertions.assertThat;
@@ -48,6 +53,7 @@ class ErrorDuringGracefullShutdownTest extends BaseNettyTest {
};
}
+ @Timeout(value = 1, unit = TimeUnit.MINUTES)
@Test
void shouldNotTriggerErrorDuringGracefullShutdown() throws Exception {
// given: successful request
@@ -55,9 +61,9 @@ class ErrorDuringGracefullShutdownTest extends BaseNettyTest {
// when: context is closed
context().close();
- while (context.getStatus() != ServiceStatus.Stopped) {
- Thread.sleep(1);
- }
+
+ Awaitility.await().atMost(10, TimeUnit.SECONDS)
+ .until(() -> context.getStatus(), Matchers.equalTo(ServiceStatus.Stopped));
// then: there should be no entries in log indicating that the callback was called twice
assertThat(LogCaptureAppender.hasEventsFor(DefaultErrorHandler.class)).isFalse();
[camel] 05/05: (chores) camel-rabbitmq: removed some usages of Thread.sleep
Posted by or...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit db7aaace51dd0c2b60b7954b002a0d3e8c35f7d4
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Tue Jun 14 11:17:22 2022 +0200
(chores) camel-rabbitmq: removed some usages of Thread.sleep
---
.../RabbitMQDeadLetterRoutingKeyIT.java | 5 ++--
.../rabbitmq/integration/RabbitMQProducerIT.java | 35 +++++++++++-----------
.../integration/spring/RabbitMQSpringIntTest.java | 12 ++++----
3 files changed, 27 insertions(+), 25 deletions(-)
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQDeadLetterRoutingKeyIT.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQDeadLetterRoutingKeyIT.java
index 43b63e3b26e..fd5520846a1 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQDeadLetterRoutingKeyIT.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQDeadLetterRoutingKeyIT.java
@@ -21,6 +21,7 @@ import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.TimeUnit;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
@@ -134,9 +135,9 @@ public class RabbitMQDeadLetterRoutingKeyIT extends AbstractRabbitMQIT {
deadLetterChannel.basicConsume("dlq", true, new DeadLetterRoutingKeyConsumer(received, routingKey));
- Thread.sleep(500);
+ Awaitility.await().atMost(500, TimeUnit.MILLISECONDS)
+ .untilAsserted(() -> assertListSize(received, 1));
- assertListSize(received, 1);
assertEquals("rk2", routingKey.toString());
}
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQProducerIT.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQProducerIT.java
index 8f2d18e89ac..05ae77b3c56 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQProducerIT.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/RabbitMQProducerIT.java
@@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
@@ -35,7 +36,6 @@ import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.rabbitmq.RabbitMQConstants;
import org.apache.camel.support.ObjectHelper;
import org.apache.camel.test.infra.rabbitmq.services.ConnectionProperties;
-import org.awaitility.Awaitility;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -43,6 +43,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.apache.camel.test.junit5.TestSupport.assertListSize;
+import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -137,7 +138,7 @@ public class RabbitMQProducerIT extends AbstractRabbitMQIT {
}
@Test
- public void producedMessageIsReceived() throws InterruptedException, IOException {
+ public void producedMessageIsReceived() throws IOException {
final List<String> received = new ArrayList<>();
channel.basicConsume("sammyq", true, new ArrayPopulatingConsumer(received));
@@ -191,7 +192,7 @@ public class RabbitMQProducerIT extends AbstractRabbitMQIT {
templateNotAllowCustomHeaders.sendBodyAndHeaders("new message", headers);
- Awaitility.await().atMost(Duration.ofSeconds(1))
+ await().atMost(Duration.ofSeconds(1))
.untilAsserted(() -> assertEquals("new message", received.get(0)));
assertTrue(receivedHeaders.containsKey(RabbitMQConstants.EXCHANGE_NAME));
assertFalse(receivedHeaders.containsKey(CUSTOM_HEADER));
@@ -210,16 +211,16 @@ public class RabbitMQProducerIT extends AbstractRabbitMQIT {
templateAllowCustomHeaders.sendBodyAndHeaders("new message", headers);
- Thread.sleep(500);
- assertEquals("new message", received.get(0));
+ await().atMost(500, TimeUnit.MILLISECONDS)
+ .untilAsserted(() -> assertEquals("new message", received.get(0)));
+
assertTrue(receivedHeaders.containsKey(RabbitMQConstants.EXCHANGE_NAME));
assertTrue(receivedHeaders.containsKey(CUSTOM_HEADER));
}
- private void assertThatBodiesReceivedIn(final List<String> received, final String... expected) throws InterruptedException {
- Thread.sleep(500);
-
- assertListSize(received, expected.length);
+ private void assertThatBodiesReceivedIn(final List<String> received, final String... expected) {
+ await().atMost(500, TimeUnit.MILLISECONDS)
+ .untilAsserted(() -> assertListSize(received, expected.length));
for (String body : expected) {
assertEquals(body, received.get(0));
}
@@ -227,11 +228,9 @@ public class RabbitMQProducerIT extends AbstractRabbitMQIT {
private void assertThatBodiesAndHeadersReceivedIn(
Map<String, Object> receivedHeaders, Map<String, Object> expectedHeaders, final List<String> received,
- final String... expected)
- throws InterruptedException {
- Thread.sleep(500);
-
- assertListSize(received, expected.length);
+ final String... expected) {
+ await().atMost(500, TimeUnit.MILLISECONDS)
+ .untilAsserted(() -> assertListSize(received, expected.length));
for (String body : expected) {
assertEquals(body, received.get(0));
}
@@ -248,7 +247,7 @@ public class RabbitMQProducerIT extends AbstractRabbitMQIT {
@Test
public void producedMessageIsReceivedWhenPublisherAcknowledgementsAreEnabled()
- throws InterruptedException, IOException {
+ throws IOException {
final List<String> received = new ArrayList<>();
channel.basicConsume("sammyq", true, new ArrayPopulatingConsumer(received));
@@ -259,7 +258,7 @@ public class RabbitMQProducerIT extends AbstractRabbitMQIT {
@Test
public void producedMessageIsReceivedWhenPublisherAcknowledgementsAreEnabledAndBadRoutingKeyIsUsed()
- throws InterruptedException, IOException {
+ throws IOException {
final List<String> received = new ArrayList<>();
channel.basicConsume("sammyq", true, new ArrayPopulatingConsumer(received));
@@ -270,7 +269,7 @@ public class RabbitMQProducerIT extends AbstractRabbitMQIT {
@Test
public void shouldSuccessfullyProduceMessageWhenGuaranteedDeliveryIsActivatedAndMessageIsMarkedAsMandatory()
- throws InterruptedException, IOException {
+ throws IOException {
final List<String> received = new ArrayList<>();
channel.basicConsume("sammyq", true, new ArrayPopulatingConsumer(received));
@@ -287,7 +286,7 @@ public class RabbitMQProducerIT extends AbstractRabbitMQIT {
@Test
public void shouldSuccessfullyProduceMessageWhenGuaranteedDeliveryIsActivatedOnABadRouteButMessageIsNotMandatory()
- throws InterruptedException, IOException {
+ throws IOException {
final List<String> received = new ArrayList<>();
channel.basicConsume("sammyq", true, new ArrayPopulatingConsumer(received));
diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/spring/RabbitMQSpringIntTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/spring/RabbitMQSpringIntTest.java
index 1ad38c9bf25..231f0528060 100644
--- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/spring/RabbitMQSpringIntTest.java
+++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/integration/spring/RabbitMQSpringIntTest.java
@@ -17,6 +17,7 @@
package org.apache.camel.component.rabbitmq.integration.spring;
import java.io.IOException;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import com.rabbitmq.client.AMQP;
@@ -28,6 +29,7 @@ import com.rabbitmq.client.Envelope;
import org.apache.camel.Produce;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.component.rabbitmq.RabbitMQConstants;
+import org.hamcrest.Matchers;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -35,6 +37,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.support.AbstractApplicationContext;
+import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
@@ -142,11 +145,10 @@ public class RabbitMQSpringIntTest extends AbstractRabbitMQSpringIntTest {
openChannel();
LastDeliveryConsumer consumer = new LastDeliveryConsumer(channel);
channel.basicConsume("q2", true, consumer);
- int i = 10;
- while (consumer.getLastBody() == null && i > 0) {
- Thread.sleep(1000L);
- i--;
- }
+
+ await().atMost(10, TimeUnit.SECONDS)
+ .until(() -> consumer.getLastBody(), Matchers.notNullValue());
+
assertEquals(body, consumer.getLastBodyAsString());
}
}
[camel] 01/05: (chores) Rename manual tests
Posted by or...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit b3a46764b99af81a2c90e160fe342e49fe6384cd
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Tue Jun 14 10:11:14 2022 +0200
(chores) Rename manual tests
Manual tests commmonly use practices that deviate from the standard
good practices - with reason - but that causes them to be flagged in
SonarQube analysis. Renaming them should help us reduce the incidence of
false alarms in the code analysis.
See: 31e0a33ed4f232b7d4616d0764b5be59d8a89df0
---
.../camel/test/tcp/{JavaSocketTests.java => JavaSocketManualTests.java} | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/test/tcp/JavaSocketTests.java b/components/camel-mllp/src/test/java/org/apache/camel/test/tcp/JavaSocketManualTests.java
similarity index 99%
rename from components/camel-mllp/src/test/java/org/apache/camel/test/tcp/JavaSocketTests.java
rename to components/camel-mllp/src/test/java/org/apache/camel/test/tcp/JavaSocketManualTests.java
index 15432a7663d..16a8c0c0175 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/test/tcp/JavaSocketTests.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/test/tcp/JavaSocketManualTests.java
@@ -44,7 +44,7 @@ import static org.junit.jupiter.api.Assertions.fail;
* NOTE: This class may be deleted in the future
*/
@Disabled(value = "Tests validating Java Socket behaviours")
-public class JavaSocketTests {
+public class JavaSocketManualTests {
Logger log = LoggerFactory.getLogger(this.getClass());
Socket clientSocket;