VirtualFileSystem { protected VirtualFileSystemInode getInodeByPath(String path) throws FileNotFoundException { if (path.startsWith(" path = path.substring(1); } if (path.equals(separator)) { return _root; } path = path.substring(1); VirtualFileSystemDirectory walker = _root; VirtualFileSystemInode inode = null; String[] values = path.split(separator); for (int x = 0; x < values.length; x++) { inode = walker.getInodeByName(values[x]); if (inode.isDirectory()) { walker = (VirtualFileSystemDirectory) inode; } else if (inode.isLink() && (x != values.length - 1)) { walker = (VirtualFileSystemDirectory) getInodeByPath(((VirtualFileSystemLink) inode).getLinkPath()); } else { if (x != values.length - 1) { throw new FileNotFoundException("Inode does not exist"); } } } return inode; } private  VirtualFileSystem(); static String getLast(String path); static VirtualFileSystem getVirtualFileSystem(); static String stripLast(String path); static String fixPath(String path); static final String dirName; static final String fileSystemPath; static final String separator; }
@Test public void testRename() throws FileNotFoundException, FileExistsException { VirtualFileSystemInode inode = vfs.getInodeByPath("/Test"); ((VirtualFileSystemDirectory) inode).createFile("testme", "drftpd", "drftpd", "testSlave"); assertEquals("/Test", inode.getPath()); inode.rename("/Test2"); assertEquals("/Test2", inode.getPath()); assertNotNull(((VirtualFileSystemDirectory) inode).getInodeByName("testme")); }