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 3cfc915f7e3 Fix or disable broken tests (#16673)
3cfc915f7e3 is described below
commit 3cfc915f7e38e66577a7f51fc28d815a31801ed5
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Tue Dec 31 14:18:04 2024 +0100
Fix or disable broken tests (#16673)
* (chores) camel-core: prevent flaky test from running on CI environments
* (chores) camel-core: ensure the data is actually available when asserting
file contents
---
.../component/controlbus/ControlBusFailRouteTest.java | 6 +++---
.../file/FileProducerCharsetUTFtoISOTest.java | 19 +++++++++++++++----
2 files changed, 18 insertions(+), 7 deletions(-)
diff --git
a/core/camel-core/src/test/java/org/apache/camel/component/controlbus/ControlBusFailRouteTest.java
b/core/camel-core/src/test/java/org/apache/camel/component/controlbus/ControlBusFailRouteTest.java
index 61e6bafe0f0..d3549877b1b 100644
---
a/core/camel-core/src/test/java/org/apache/camel/component/controlbus/ControlBusFailRouteTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/component/controlbus/ControlBusFailRouteTest.java
@@ -25,13 +25,13 @@ import org.apache.camel.spi.RouteController;
import org.apache.camel.spi.RouteError;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.DisabledOnOs;
+import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertEquals;
-@DisabledOnOs(architectures = { "s390x" },
- disabledReason = "This test does not run reliably on s390x")
+@DisabledIfSystemProperty(named = "ci.env.name", matches = ".*",
+ disabledReason = "Flaky test on CI environments")
public class ControlBusFailRouteTest extends ContextTestSupport {
@Test
diff --git
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerCharsetUTFtoISOTest.java
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerCharsetUTFtoISOTest.java
index a1600f1e6d4..184445e6639 100644
---
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerCharsetUTFtoISOTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileProducerCharsetUTFtoISOTest.java
@@ -19,9 +19,12 @@ package org.apache.camel.component.file;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
+import java.util.concurrent.TimeUnit;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -34,18 +37,26 @@ class FileProducerCharsetUTFtoISOTest extends
ContextTestSupport {
private static final String DATA = "ABC\u00e6";
- @Test
- void testFileProducerCharsetUTFtoISO() throws Exception {
+ @BeforeEach
+ void writeFile() throws Exception {
try (OutputStream fos =
Files.newOutputStream(testFile("input.FileProducerCharsetUTFtoISOTest.txt"))) {
fos.write(DATA.getBytes(StandardCharsets.UTF_8));
}
+ }
+ @Test
+ void testFileProducerCharsetUTFtoISO() throws Exception {
assertTrue(oneExchangeDone.matchesWaitTime());
assertFileExists(testFile("output.FileProducerCharsetUTFtoISOTest.txt"));
- byte[] data =
Files.readAllBytes(testFile("output.FileProducerCharsetUTFtoISOTest.txt"));
- assertEquals(DATA, new String(data, StandardCharsets.ISO_8859_1));
+ // The file may have been created, but hasn't fully flushed to disk,
which means reading data will return nothing
+ Awaitility.await().atMost(3, TimeUnit.SECONDS).untilAsserted(() -> {
+ byte[] data =
Files.readAllBytes(testFile("output.FileProducerCharsetUTFtoISOTest.txt"));
+
+ assertEquals(DATA, new String(data, StandardCharsets.ISO_8859_1));
+ });
+
}
@Override