ChRootedFs extends AbstractFileSystem { @Override public boolean delete(final Path f, final boolean recursive) throws IOException, UnresolvedLinkException { return myFs.delete(fullPath(f), recursive); } ChRootedFs(final AbstractFileSystem fs, final Path theRoot); @Override boolean isValidName(String src); @Override URI getUri(); String stripOutRoot(final Path p); @Override Path getHomeDirectory(); @Override Path getInitialWorkingDirectory(); Path getResolvedQualifiedPath(final Path f); @Override FSDataOutputStream createInternal(final Path f,
      final EnumSet<CreateFlag> flag, final FsPermission absolutePermission,
      final int bufferSize, final short replication, final long blockSize,
      final Progressable progress, final ChecksumOpt checksumOpt,
      final boolean createParent); @Override boolean delete(final Path f, final boolean recursive); @Override BlockLocation[] getFileBlockLocations(final Path f, final long start,
      final long len); @Override FileChecksum getFileChecksum(final Path f); @Override FileStatus getFileStatus(final Path f); void access(Path path, FsAction mode); @Override FileStatus getFileLinkStatus(final Path f); @Override FsStatus getFsStatus(); @Override @Deprecated FsServerDefaults getServerDefaults(); @Override FsServerDefaults getServerDefaults(final Path f); @Override int getUriDefaultPort(); @Override FileStatus[] listStatus(final Path f); @Override RemoteIterator<FileStatus> listStatusIterator(final Path f); @Override RemoteIterator<LocatedFileStatus> listLocatedStatus(final Path f); @Override void mkdir(final Path dir, final FsPermission permission,
      final boolean createParent); @Override FSDataInputStream open(final Path f, final int bufferSize); @Override boolean truncate(final Path f, final long newLength); @Override void renameInternal(final Path src, final Path dst); @Override void renameInternal(final Path src, final Path dst, 
      final boolean overwrite); @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 void setStoragePolicy(Path path, String policyName); @Override void unsetStoragePolicy(final Path src); @Override BlockStoragePolicySpi getStoragePolicy(final Path src); @Override Collection<? extends BlockStoragePolicySpi> getAllStoragePolicies(); @Override void setVerifyChecksum(final boolean verifyChecksum); @Override boolean supportsSymlinks(); @Override void createSymlink(final Path target, final Path link,
      final boolean createParent); @Override Path getLinkTarget(final Path f); @Override List<Token<?>> getDelegationTokens(String renewer);  }
@Test public void testCreateDelete() throws IOException { fileContextTestHelper.createFileNonRecursive(fc, "/foo"); Assert.assertTrue(isFile(fc, new Path("/foo"))); Assert.assertTrue(isFile(fcTarget, new Path(chrootedTo, "foo"))); fileContextTestHelper.createFile(fc, "/newDir/foo"); Assert.assertTrue(isFile(fc, new Path("/newDir/foo"))); Assert.assertTrue(isFile(fcTarget, new Path(chrootedTo,"newDir/foo"))); Assert.assertTrue(fc.delete(new Path("/newDir/foo"), false)); Assert.assertFalse(exists(fc, new Path("/newDir/foo"))); Assert.assertFalse(exists(fcTarget, new Path(chrootedTo,"newDir/foo"))); fileContextTestHelper.createFile(fc, "/newDir/newDir2/foo"); Assert.assertTrue(isFile(fc, new Path("/newDir/newDir2/foo"))); Assert.assertTrue(isFile(fcTarget, new Path(chrootedTo,"newDir/newDir2/foo"))); Assert.assertTrue(fc.delete(new Path("/newDir/newDir2/foo"), false)); Assert.assertFalse(exists(fc, new Path("/newDir/newDir2/foo"))); Assert.assertFalse(exists(fcTarget, new Path(chrootedTo,"newDir/newDir2/foo"))); }