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 f8beba379dda CAMEL-24026: Fix flaky XsltFromFileExceptionTest
f8beba379dda is described below
commit f8beba379dda065261e7b2d86d80bf713a423d1e
Author: Omar Atie <[email protected]>
AuthorDate: Wed Aug 5 02:17:42 2026 -0700
CAMEL-24026: Fix flaky XsltFromFileExceptionTest
Use assertMockEndpointsSatisfied(30, SECONDS) and Awaitility file-move
polling instead of the racy oneExchangeDone notify latch that fired on
the producer exchange before the file consumer route picked up the file.
Closes #25334
Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: Claude Opus 4.6 <[email protected]>
---
.../component/xslt/XsltFromFileExceptionTest.java | 41 +++++++++++++++-------
1 file changed, 28 insertions(+), 13 deletions(-)
diff --git
a/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltFromFileExceptionTest.java
b/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltFromFileExceptionTest.java
index 74f68c9e1a3f..d607cd0a202e 100644
---
a/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltFromFileExceptionTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltFromFileExceptionTest.java
@@ -16,45 +16,60 @@
*/
package org.apache.camel.component.xslt;
+import java.util.concurrent.TimeUnit;
+
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.junit.jupiter.api.Test;
+import static org.awaitility.Awaitility.await;
+
/**
*
*/
-public class XsltFromFileExceptionTest extends ContextTestSupport {
+class XsltFromFileExceptionTest extends ContextTestSupport {
+
+ private static final long TIMEOUT_SECONDS = 30;
@Test
- public void testXsltFromFileExceptionOk() throws Exception {
+ void testXsltFromFileExceptionOk() throws Exception {
getMockEndpoint("mock:result").expectedMessageCount(1);
getMockEndpoint("mock:error").expectedMessageCount(0);
template.sendBodyAndHeader(fileUri(), "<hello>world!</hello>",
Exchange.FILE_NAME, "hello.xml");
- assertMockEndpointsSatisfied();
+ // Do not use oneExchangeDone here: the producer write to fileUri()
can satisfy
+ // the global whenDone(1) notify before the file consumer route runs.
+ assertMockEndpointsSatisfied(TIMEOUT_SECONDS, TimeUnit.SECONDS);
- oneExchangeDone.matchesWaitTime();
-
- assertFileNotExists(testFile("hello.xml"));
- assertFileExists(testFile("ok/hello.xml"));
+ // File move happens after route processing; poll until the consumer
has moved the file.
+ await().atMost(TIMEOUT_SECONDS, TimeUnit.SECONDS)
+ .pollInterval(100, TimeUnit.MILLISECONDS)
+ .untilAsserted(() -> {
+ assertFileNotExists(testFile("hello.xml"));
+ assertFileExists(testFile("ok/hello.xml"));
+ });
}
@Test
- public void testXsltFromFileExceptionFail() throws Exception {
+ void testXsltFromFileExceptionFail() throws Exception {
getMockEndpoint("mock:result").expectedMessageCount(0);
getMockEndpoint("mock:error").expectedMessageCount(1);
// the last tag is not ended properly
template.sendBodyAndHeader(fileUri(), "<hello>world!</hello",
Exchange.FILE_NAME, "hello2.xml");
- assertMockEndpointsSatisfied();
-
- oneExchangeDone.matchesWaitTime();
+ // Do not use oneExchangeDone here: the producer write to fileUri()
can satisfy
+ // the global whenDone(1) notify before the file consumer route runs.
+ assertMockEndpointsSatisfied(TIMEOUT_SECONDS, TimeUnit.SECONDS);
- assertFileNotExists(testFile("hello2.xml"));
- assertFileExists(testFile("error/hello2.xml"));
+ await().atMost(TIMEOUT_SECONDS, TimeUnit.SECONDS)
+ .pollInterval(100, TimeUnit.MILLISECONDS)
+ .untilAsserted(() -> {
+ assertFileNotExists(testFile("hello2.xml"));
+ assertFileExists(testFile("error/hello2.xml"));
+ });
}
@Override