This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 2d59db12ddb CAMEL-19537: Reduce use of thread sleep.
2d59db12ddb is described below
commit 2d59db12ddb826d3feaa50dae4461362230f4259
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Mar 3 13:25:10 2025 +0100
CAMEL-19537: Reduce use of thread sleep.
---
.../component/mina/MinaExchangeDefaultTimeOutTest.java | 6 ++----
.../camel/component/mina/MinaExchangeTimeOutTest.java | 13 ++++++++-----
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git
a/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeDefaultTimeOutTest.java
b/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeDefaultTimeOutTest.java
index bd5235315b1..03d4f97d50d 100644
---
a/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeDefaultTimeOutTest.java
+++
b/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeDefaultTimeOutTest.java
@@ -42,10 +42,8 @@ public class MinaExchangeDefaultTimeOutTest extends
BaseMinaTest {
public void configure() {
fromF("mina:tcp://localhost:%1$s?textline=true&sync=true",
getPort()).process(e -> {
assertEquals("Hello World",
e.getIn().getBody(String.class));
- // MinaProducer has a default timeout of 3 seconds so we
just wait 5 seconds
- // (template.requestBody is a MinaProducer behind the
doors)
- Thread.sleep(1000);
-
+ // just be a little bit slow
+ Thread.sleep(250);
e.getMessage().setBody("Okay I will be faster in the
future");
});
}
diff --git
a/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTimeOutTest.java
b/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTimeOutTest.java
index 9e86a3ff8c9..2b4b8753266 100644
---
a/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTimeOutTest.java
+++
b/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTimeOutTest.java
@@ -16,6 +16,9 @@
*/
package org.apache.camel.component.mina;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
import org.apache.camel.ExchangeTimedOutException;
@@ -31,6 +34,8 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
*/
public class MinaExchangeTimeOutTest extends BaseMinaTest {
+ private final CountDownLatch latch = new CountDownLatch(1);
+
@Test
public void testUsingTimeoutParameter() throws Exception {
// use a timeout value of 2 seconds (timeout is in millis) so we
should actually get a response in this test
@@ -43,6 +48,8 @@ public class MinaExchangeTimeOutTest extends BaseMinaTest {
assertThrows(ExchangeTimedOutException.class,
() -> producer.process(exchange));
producer.stop();
+
+ latch.countDown();
}
@Override
@@ -53,11 +60,7 @@ public class MinaExchangeTimeOutTest extends BaseMinaTest {
fromF("mina:tcp://localhost:%1$s?textline=true&sync=true&timeout=30000",
getPort())
.process(e -> {
assertEquals("Hello World",
e.getIn().getBody(String.class));
- // MinaProducer has a default timeout of 3 seconds
so we just wait 2 seconds
- // (template.requestBody is a MinaProducer behind
the doors)
- Thread.sleep(2000);
-
- e.getMessage().setBody("Okay I will be faster in
the future");
+ latch.await(5, TimeUnit.SECONDS);
});
}
};