apupier commented on code in PR #24442:
URL: https://github.com/apache/camel/pull/24442#discussion_r3527393827
##########
core/camel-core/src/test/java/org/apache/camel/processor/SamplingThrottlerTest.java:
##########
@@ -66,8 +68,8 @@ public void testBurstySampling() throws Exception {
// send a burst of 5 exchanges, expecting only one to get through
sendExchangesThroughDroppingThrottler(sentExchanges, 5);
- // sleep through a complete period
- Thread.sleep(1100);
+ // wait through a complete sampling period (1s) using Awaitility
instead of Thread.sleep
+
await().pollDelay(Duration.ofMillis(1100)).atMost(Duration.ofSeconds(3)).until(()
-> true);
Review Comment:
I do not understand what it is changign compared to thread.sleeP. it will
always wait for the same amount of time
##########
core/camel-core/src/test/java/org/apache/camel/processor/SamplingThrottlerTest.java:
##########
@@ -116,28 +118,32 @@ public void testSamplingWithPropertyPlaceholder() throws
Exception {
public void testSamplingUsingMessageFrequency() throws Exception {
long totalMessages = 100;
MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedMinimumMessageCount(10);
- mock.setResultWaitTime(100);
for (int i = 0; i < totalMessages; i++) {
template.sendBody("direct:sample-messageFrequency", "<message>" +
i + "</message>");
}
- mock.assertIsSatisfied();
+ await().atMost(Duration.ofSeconds(5))
+ .untilAsserted(() -> {
+ int count = mock.getReceivedCounter();
+ assertTrue(count >= 10, "Expected at least 10 messages but
got " + count);
+ });
}
@Test
public void testSamplingUsingMessageFrequencyViaDSL() throws Exception {
long totalMessages = 50;
MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedMinimumMessageCount(10);
- mock.setResultWaitTime(100);
for (int i = 0; i < totalMessages; i++) {
template.sendBody("direct:sample-messageFrequency-via-dsl",
"<message>" + i + "</message>");
}
- mock.assertIsSatisfied();
+ await().atMost(Duration.ofSeconds(5))
+ .untilAsserted(() -> {
+ int count = mock.getReceivedCounter();
+ assertTrue(count >= 10, "Expected at least 10 messages but
got " + count);
+ });
Review Comment:
I think this is really equivalet to what we had before. Could you clarify in
which way it is different?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]