InMemorySCMStore extends SCMStore { @Override public String addResourceReference(String key, SharedCacheResourceReference ref) { String interned = intern(key); synchronized (interned) { SharedCacheResource resource = cachedResources.get(interned); if (resource == null) { return null; } resource.addReference(ref); resource.updateAccessTime(); return resource.getFileName(); } } InMemorySCMStore(); @VisibleForTesting  InMemorySCMStore(AppChecker appChecker); @Override String addResource(String key, String fileName); @Override String addResourceReference(String key,
      SharedCacheResourceReference ref); @Override Collection<SharedCacheResourceReference> getResourceReferences(String key); @Override boolean removeResourceReference(String key, SharedCacheResourceReference ref,
      boolean updateAccessTime); @Override void removeResourceReferences(String key,
      Collection<SharedCacheResourceReference> refs, boolean updateAccessTime); @Override void cleanResourceReferences(String key); @Override boolean removeResource(String key); @Override boolean isResourceEvictable(String key, FileStatus file);  }
@Test public void testAddResourceRefNonExistentResource() throws Exception { startEmptyStore(); String key = "key1"; ApplicationId id = createAppId(1, 1L); assertNull(store.addResourceReference(key, new SharedCacheResourceReference(id, "user"))); }
@Test public void testBootstrapping() throws Exception { Map<String, String> initialCachedResources = startStoreWithResources(); int count = initialCachedResources.size(); ApplicationId id = createAppId(1, 1L); for (int i = 0; i < count; i++) { String key = String.valueOf(i); String fileName = key + ".jar"; String result = store.addResourceReference(key, new SharedCacheResourceReference(id, "user")); assertEquals(fileName, result); assertTrue(initialCachedResources.isEmpty()); } }