You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/05/22 17:30:37 UTC
[camel] 03/03: File Changed ReadLock Strategy with minAge only looks for lastModified (#10131)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-3.x
in repository https://gitbox.apache.org/repos/asf/camel.git
commit df63ca4c35564ded90d1e099018a2209bd478fe7
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon May 22 19:28:50 2023 +0200
File Changed ReadLock Strategy with minAge only looks for lastModified (#10131)
---
.../FileChangedReadLockMinAgeShortCircuitTest.java | 23 +++++++++++-----------
1 file changed, 12 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..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,8 +61,8 @@ 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"))
- .to(fileUri("out"), "mock:result");
+ "in?initialDelay=500&delay=10&readLock=changed&readLockMinAge=1000&readLockCheckInterval=10000&readLockTimeout=20000"))
+ .to(fileUri("out"), "mock:result");
}
};
}