This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch camel-3.18.x in repository https://gitbox.apache.org/repos/asf/camel.git
commit bfe34c69ba70ed0ea33d989cb2b8b21a4db5e672 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Mon May 22 19:28:50 2023 +0200 File Changed ReadLock Strategy with minAge only looks for lastModified (#10131) --- .../FileChangedReadLockMinAgeShortCircuitTest.java | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 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 60bdfc610dc..356f0b41830 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 @@ -59,8 +60,7 @@ public class FileChangedReadLockMinAgeShortCircuitTest extends ContextTestSuppor return new RouteBuilder() { @Override public void configure() throws Exception { - from(fileUri( - "in?initialDelay=500&delay=10&readLock=changed&readLockMinAge=10&readLockCheckInterval=30000&readLockTimeout=90000")) + from(fileUri("in?initialDelay=500&delay=10&readLock=changed&readLockMinAge=1000&readLockCheckInterval=10000&readLockTimeout=20000")) .to(fileUri("out"), "mock:result"); } };