ContentCacheImpl implements ContentCache { public void setCacheRoot(File cacheRoot) { if (cacheRoot == null) { throw new IllegalArgumentException("cacheRoot cannot be null."); } if (!cacheRoot.exists()) { cacheRoot.mkdirs(); } this.cacheRoot = cacheRoot; }  @Override boolean contains(String contentUrl); boolean contains(Key key); void putIntoLookup(Key key, String value); String getCacheFilePath(String contentUrl); String getContentUrl(File file); @Override ContentReader getReader(String contentUrl); @Override boolean put(String contentUrl, ContentReader source); @Override void remove(String contentUrl); void removeAll(); @Override void deleteFile(String url); @Override ContentWriter getWriter(final String url); static String createNewCacheFilePath(); void setMemoryStore(SimpleCache<Key, String> memoryStore); void setCacheRoot(File cacheRoot); @Override File getCacheRoot(); void processFiles(FileHandler handler);  }
@Test(expected=IllegalArgumentException.class) public void cannotSetNullCacheRoot() { contentCache.setCacheRoot(null); }
@Test public void willCreateNonExistentCacheRoot() { File cacheRoot = new File(TempFileProvider.getTempDir(), GUID.generate()); cacheRoot.deleteOnExit(); assertFalse("Pre-condition of test is that cacheRoot does not exist", cacheRoot.exists()); contentCache.setCacheRoot(cacheRoot); assertTrue("cacheRoot should have been created", cacheRoot.exists()); }