### Question:
MetadataCache { protected void renamePrefix(String path, String newPath) { if (path.isEmpty() || !enabled) { return; } TreeSet<String> tempPaths = new TreeSet<String>(); writeLock.lock(); try { MetadataCacheEntry entry = cache.remove(path); cache.put(newPath, entry); if (!path.endsWith("/")) path = path + "/"; if (!newPath.endsWith("/")) newPath = newPath + "/"; for (String renamePath : pathIndex.tailSet(path)) { if (!renamePath.startsWith(path)) { break; } entry = cache.remove(renamePath); cache.put(renamePath.replaceFirst(path, newPath), entry); tempPaths.add(renamePath.replaceFirst(path, newPath)); } for (String tmpPath : tempPaths) { pathIndex.remove(tmpPath); pathIndex.add(tmpPath.replace(path, newPath)); } } finally { writeLock.unlock(); } } protected  MetadataCache(long maxNumberOfEntries, long ttlS);   }### Answer:
@Test public void testRenamePrefix() throws Exception { metadataCache = new MetadataCache(1024, 3600); Stat.Builder a, b, c, d; a = getIntializedStatBuilder(); b = getIntializedStatBuilder(); c = getIntializedStatBuilder(); d = getIntializedStatBuilder(); a.setIno(0); b.setIno(1); c.setIno(2); d.setIno(3); String dir = "/dir"; metadataCache.updateStat(dir, a.build()); metadataCache.updateStat(dir + "/file1", b.build()); metadataCache.updateStat(dir + ".file1", c.build()); metadataCache.updateStat(dir + "Zfile1", d.build()); assertEquals(4l, metadataCache.size()); metadataCache.renamePrefix(dir, "/newDir"); assertEquals(4l, metadataCache.size()); Stat statA = metadataCache.getStat("/newDir"); assertNotNull(statA); assertEquals(0, statA.getIno()); Stat statB = metadataCache.getStat("/newDir" + "/file1"); assertNotNull(statB); assertEquals(1, statB.getIno()); Stat statC = metadataCache.getStat(dir + ".file1"); assertNotNull(statC); assertEquals(2, statC.getIno()); Stat statD = metadataCache.getStat(dir + "Zfile1"); assertNotNull(statD); assertEquals(3, statD.getIno()); }