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 bbfe1c5cc17 File Changed ReadLock Strategy with minAge only looks for
lastModified (#10131)
bbfe1c5cc17 is described below
commit bbfe1c5cc179e3ece4a97a4c896e888811db8354
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon May 22 19:28:50 2023 +0200
File Changed ReadLock Strategy with minAge only looks for lastModified
(#10131)
---
.../FileChangedReadLockMinAgeShortCircuitTest.java | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git
a/core/camel-core/src/test/java/org/apache/camel/component/file/strategy/FileChangedReadLockMinAgeShortCircuitTest.java
b/core/camel-core/src/test/java/org/apache/camel/component/file/strategy/FileChangedReadLockMinAgeShortCircuitTest.java
index a80a46f9917..cd4588b0a43 100644
---
a/core/camel-core/src/test/java/org/apache/camel/component/file/strategy/FileChangedReadLockMinAgeShortCircuitTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/component/file/strategy/FileChangedReadLockMinAgeShortCircuitTest.java
@@ -17,10 +17,8 @@
package org.apache.camel.component.file.strategy;
import java.nio.file.Files;
-import java.util.Date;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.BeforeEach;
@@ -43,15 +41,18 @@ public class FileChangedReadLockMinAgeShortCircuitTest
extends ContextTestSuppor
}
@Test
- public void testChangedReadLockMinAge() throws Exception {
+ public void testChangedReadLockMinAgeNotAcquired() throws Exception {
+ // terminate test quicker
+ context.getShutdownStrategy().setTimeout(1);
+
+ // we do not acquire read-lock because the check interval is 10s, so
"changed" requires at least a poll of 10s
+ // before we can determine that the file has same size as before
+
MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedMessageCount(1);
- mock.expectedFileExists(testFile("out/file.dat"));
- // We should get the file on the first poll
- mock.expectedMessagesMatches(
-
exchangeProperty(Exchange.RECEIVED_TIMESTAMP).convertTo(long.class).isLessThan(new
Date().getTime() + 15000));
+ mock.expectedMessageCount(0);
- assertMockEndpointsSatisfied();
+ // but the unit test only waits 2 seconds
+ mock.assertIsSatisfied(2000);
}
@Override
@@ -60,7 +61,7 @@ public class FileChangedReadLockMinAgeShortCircuitTest
extends ContextTestSuppor
@Override
public void configure() throws Exception {
from(fileUri(
-
"in?initialDelay=500&delay=10&readLock=changed&readLockMinAge=10&readLockCheckInterval=30000&readLockTimeout=90000"))
+
"in?initialDelay=500&delay=10&readLock=changed&readLockMinAge=1000&readLockCheckInterval=10000&readLockTimeout=20000"))
.to(fileUri("out"), "mock:result");
}
};