### Question:
ChRootedFileSystem extends FileSystem { @Override public boolean rename(final Path src, final Path dst) throws IOException { return myFs.rename(fullPath(src), fullPath(dst)); } ChRootedFileSystem(final FileSystem fs, final Path theRoot); void initialize(final URI name, final Configuration conf); @Override URI getUri(); @Override Path makeQualified(final Path path); Path getResolvedQualifiedPath(final Path f); @Override Path getHomeDirectory(); @Override Path getWorkingDirectory(); @Override void setWorkingDirectory(final Path new_dir); @Override FSDataOutputStream create(final Path f, final FsPermission permission,
      final boolean overwrite, final int bufferSize, final short replication,
      final long blockSize, final Progressable progress); @Override boolean delete(final Path f, final boolean recursive); @Override @SuppressWarnings("deprecation") boolean delete(Path f); @Override BlockLocation[] getFileBlockLocations(final FileStatus fs, final long start,
      final long len); @Override FileChecksum getFileChecksum(final Path f); @Override FileStatus getFileStatus(final Path f); @Override FsStatus getStatus(Path p); @Override FsServerDefaults getServerDefaults(); @Override FileStatus[] listStatus(final Path f); @Override boolean mkdirs(final Path f, final FsPermission permission); @Override FSDataInputStream open(final Path f, final int bufferSize); @Override FSDataOutputStream append(final Path f, final int bufferSize,
      final Progressable progress); @Override boolean rename(final Path src, final Path dst); @Override void setOwner(final Path f, final String username,
      final String groupname); @Override void setPermission(final Path f, final FsPermission permission); @Override boolean setReplication(final Path f, final short replication); @Override void setTimes(final Path f, final long mtime, final long atime); @Override void setVerifyChecksum(final boolean verifyChecksum); @Override List<Token<?>> getDelegationTokens(String renewer);  }### Answer:
@Test public void testRename() throws IOException { FileSystemTestHelper.createFile(fSys, "/newDir/foo"); fSys.rename(new Path("/newDir/foo"), new Path("/newDir/fooBar")); Assert.assertFalse(fSys.exists(new Path("/newDir/foo"))); Assert.assertFalse(fSysTarget.exists(new Path(chrootedTo,"newDir/foo"))); Assert.assertTrue(fSys.isFile(FileSystemTestHelper.getTestRootPath(fSys,"/newDir/fooBar"))); Assert.assertTrue(fSysTarget.isFile(new Path(chrootedTo,"newDir/fooBar"))); fSys.mkdirs(new Path("/newDir/dirFoo")); fSys.rename(new Path("/newDir/dirFoo"), new Path("/newDir/dirFooBar")); Assert.assertFalse(fSys.exists(new Path("/newDir/dirFoo"))); Assert.assertFalse(fSysTarget.exists(new Path(chrootedTo,"newDir/dirFoo"))); Assert.assertTrue(fSys.isDirectory(FileSystemTestHelper.getTestRootPath(fSys,"/newDir/dirFooBar"))); Assert.assertTrue(fSysTarget.isDirectory(new Path(chrootedTo,"newDir/dirFooBar"))); }