@Test public void cacheShouldFailOnNonExistentEntries() throws Exception { FileSystemCache cache = new FileSystemCache(createTmpFile()); cache.put("foo", c1); cache.save(); cache = new FileSystemCache(createTmpFile()); assertFalse(cache.isUpToDate("bar", c2)); }
@Test public void cacheShouldPersistNewEntries() throws Exception { FileSystemCache cache = new FileSystemCache(createTmpFile()); cache.put("foo", c1); cache.put("bar", c2); cache.save(); cache = new FileSystemCache(createTmpFile()); assertTrue(cache.isUpToDate("foo", c1)); assertTrue(cache.isUpToDate("bar", c2)); }
@Test public void cacheShouldNotRewriteFileIfAllFilesTouched() throws Exception { FileSystemCache cache = new FileSystemCache(createTmpFile()); cache.put("foo", c1); cache.put("bar", c2); cache.save(); cache = new FileSystemCache(createTmpFile()); tmpFile.delete(); assertTrue(cache.isUpToDate("foo", c1)); assertTrue(cache.isUpToDate("bar", c2)); cache.save(); assertFalse(tmpFile.exists()); }