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:23 UTC
[camel] 04/05: (chores) camel-netty: removed some usages of Thread.sleep
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();