urunni88 commented on code in PR #28361:
URL: https://github.com/apache/camel/pull/28361#discussion_r4361153309


##########
components/camel-file-watch/src/test/java/org/apache/camel/component/file/watch/FileWatchComponentTest.java:
##########
@@ -136,6 +138,24 @@ public void testCreateBatch() throws Exception {
         MockEndpoint.assertIsSatisfied(context);
     }
 
+    @Test
+    public void testLastModifiedHeaderIsTimeOfFile() throws Exception {
+        MockEndpoint watchCreate = getMockEndpoint("mock:watchCreate");
+        watchCreate.expectedMessageCount(1);
+
+        // create the file outside the watched directory with an old last 
modified time, and move it in,
+        // so the last modified time of the file differs from the time of the 
event
+        Path staging = Files.createDirectories(folder.resolve("staging"));
+        Path file = Files.writeString(staging.resolve("old.txt"), "Hello");
+        long lastModified = 
Instant.parse("2020-01-01T00:00:00Z").toEpochMilli();
+        Files.setLastModifiedTime(file, FileTime.fromMillis(lastModified));
+        Files.move(file, Paths.get(testPath(), "old.txt"));
+
+        watchCreate.assertIsSatisfied();
+        assertEquals(lastModified,
+                
watchCreate.getExchanges().get(0).getIn().getHeader(FileWatchConstants.FILE_LAST_MODIFIED,
 Long.class));

Review Comment:
   Thanks, added testLastModifiedHeaderNotSetForDelete. It fails on the 
original code (expected: <null> but was: <1792768665001>) and passes with the 
fix. I added it to FileWatchComponentTest because FileWatchComponentDeleteTest 
is @Disabled(“Fails on CI server”).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to