@Test public void skipsFirstCacheBecauseIgnored() throws IOException { Path path = Paths.get("world.txt"); Path fullPath = tmp.getRootPath().resolve(path); ProjectFilesystem filesystem = new ProjectFilesystem(tmp.getRootPath(), ImmutableSet.of(path)); filesystem.touch(path); DefaultFileHashCache innerCache = new DefaultFileHashCache(filesystem); StackedFileHashCache cache = new StackedFileHashCache(ImmutableList.of(innerCache)); expectedException.expect(NoSuchFileException.class); cache.get(fullPath); }
@Test public void usesFirstCache() throws IOException { ProjectFilesystem filesystem = FakeProjectFilesystem.createJavaOnlyFilesystem(); Path path = Paths.get("world.txt"); filesystem.touch(path); Path fullPath = filesystem.resolve(path); DefaultFileHashCache innerCache = new DefaultFileHashCache(filesystem); StackedFileHashCache cache = new StackedFileHashCache(ImmutableList.of(innerCache)); cache.get(fullPath); assertTrue(innerCache.willGet(path)); }
@Test public void usesSecondCache() throws IOException { Path path = Paths.get("world.txt"); Path fullPath = tmp2.getRootPath().resolve(path); DefaultFileHashCache innerCache = new DefaultFileHashCache(new ProjectFilesystem(tmp.getRootPath())); // The second project filesystem has the file. ProjectFilesystem filesystem2 = new ProjectFilesystem(tmp2.getRootPath()); DefaultFileHashCache innerCache2 = new DefaultFileHashCache(filesystem2); filesystem2.touch(path); StackedFileHashCache cache = new StackedFileHashCache(ImmutableList.of(innerCache, innerCache2)); cache.get(fullPath); assertTrue(innerCache2.willGet(path)); }