Skip to content

Commit

Permalink
Fix CacheFactoryTest
Browse files Browse the repository at this point in the history
  • Loading branch information
ppalaga committed Mar 10, 2021
1 parent 0bdf229 commit 9c1e3d7
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;
Expand Down Expand Up @@ -64,6 +65,12 @@ public void assertPutGet(Path tempDir, final Cache<String, CacheRecord> cache, i
Assertions.assertEquals(record2, cache.get(k2));
Assertions.assertFalse(record2.invalidated);

/* Make sure the new content is written a couple of ms later than the original lastModifiedTime */
final long deadline = Files.readAttributes(file1, BasicFileAttributes.class).lastModifiedTime().toMillis() + 10;
while (System.currentTimeMillis() < deadline) {
Thread.sleep(1);
}

Files.write(file1, "content1.1".getBytes(StandardCharsets.UTF_8));
if (asyncOpDelayMs > 0) {
Thread.sleep(asyncOpDelayMs);
Expand Down

0 comments on commit 9c1e3d7

Please sign in to comment.