ChRootedFileSystem extends FilterFileSystem { @Override public boolean delete(final Path f, final boolean recursive) throws IOException { return super.delete(fullPath(f), recursive); } ChRootedFileSystem(final URI uri, Configuration conf); @Override void initialize(final URI name, final Configuration conf); @Override URI getUri(); Path getResolvedQualifiedPath(final Path f); @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 FSDataOutputStream createNonRecursive(Path f, FsPermission permission,
      EnumSet<CreateFlag> flags, int bufferSize, short replication, long blockSize,
      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 void access(Path path, FsAction mode); @Override FsStatus getStatus(Path p); @Override FileStatus[] listStatus(final Path f); @Override RemoteIterator<LocatedFileStatus> listLocatedStatus(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 modifyAclEntries(Path path, List<AclEntry> aclSpec); @Override void removeAclEntries(Path path, List<AclEntry> aclSpec); @Override void removeDefaultAcl(Path path); @Override void removeAcl(Path path); @Override void setAcl(Path path, List<AclEntry> aclSpec); @Override AclStatus getAclStatus(Path path); @Override void setXAttr(Path path, String name, byte[] value,
      EnumSet<XAttrSetFlag> flag); @Override byte[] getXAttr(Path path, String name); @Override Map<String, byte[]> getXAttrs(Path path); @Override Map<String, byte[]> getXAttrs(Path path, List<String> names); @Override List<String> listXAttrs(Path path); @Override void removeXAttr(Path path, String name); @Override Path createSnapshot(Path path, String name); @Override void renameSnapshot(Path path, String snapshotOldName,
      String snapshotNewName); @Override void deleteSnapshot(Path snapshotDir, String snapshotName); @Override Path resolvePath(final Path p); @Override ContentSummary getContentSummary(Path f); @Override long getDefaultBlockSize(); @Override long getDefaultBlockSize(Path f); @Override short getDefaultReplication(); @Override short getDefaultReplication(Path f); @Override FsServerDefaults getServerDefaults(); @Override FsServerDefaults getServerDefaults(Path f);  }
@Test public void testCreateDelete() throws IOException { fileSystemTestHelper.createFile(fSys, "/foo"); Assert.assertTrue(fSys.isFile(new Path("/foo"))); Assert.assertTrue(fSysTarget.isFile(new Path(chrootedTo, "foo"))); fileSystemTestHelper.createFile(fSys, "/newDir/foo"); Assert.assertTrue(fSys.isFile(new Path("/newDir/foo"))); Assert.assertTrue(fSysTarget.isFile(new Path(chrootedTo,"newDir/foo"))); Assert.assertTrue(fSys.delete(new Path("/newDir/foo"), false)); Assert.assertFalse(fSys.exists(new Path("/newDir/foo"))); Assert.assertFalse(fSysTarget.exists(new Path(chrootedTo, "newDir/foo"))); fileSystemTestHelper.createFile(fSys, "/newDir/newDir2/foo"); Assert.assertTrue(fSys.isFile(new Path("/newDir/newDir2/foo"))); Assert.assertTrue(fSysTarget.isFile(new Path(chrootedTo,"newDir/newDir2/foo"))); Assert.assertTrue(fSys.delete(new Path("/newDir/newDir2/foo"), false)); Assert.assertFalse(fSys.exists(new Path("/newDir/newDir2/foo"))); Assert.assertFalse(fSysTarget.exists(new Path(chrootedTo,"newDir/newDir2/foo"))); }