ChRootedFileSystem extends FilterFileSystem { @Override public BlockStoragePolicySpi getStoragePolicy(Path src) throws IOException { return super.getStoragePolicy(fullPath(src)); } ChRootedFileSystem(final FileSystem fs, URI uri);  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 FileChecksum getFileChecksum(final Path f, final long length); @Override FileStatus getFileStatus(final Path f); @Override Path getLinkTarget(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 boolean mkdirs(final Path f); @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 boolean truncate(Path path, long newLength); @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 QuotaUsage getQuotaUsage(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); @Override BlockStoragePolicySpi getStoragePolicy(Path src); @Override void satisfyStoragePolicy(Path src); @Override void setStoragePolicy(Path src, String policyName); @Override void unsetStoragePolicy(Path src); @Override FSDataOutputStreamBuilder createFile(final Path path); @Override FutureDataInputStreamBuilder openFile(final Path path); @Override boolean hasPathCapability(final Path path, final String capability);  }
@Test(timeout = 30000) public void testGetStoragePolicy() throws Exception { Path storagePolicyPath = new Path("/storagePolicy"); Path chRootedStoragePolicyPath = new Path("/a/b/storagePolicy"); Configuration conf = new Configuration(); conf.setClass("fs.mockfs.impl", MockFileSystem.class, FileSystem.class); URI chrootUri = URI.create("mockfs: ChRootedFileSystem chrootFs = new ChRootedFileSystem(chrootUri, conf); FileSystem mockFs = ((FilterFileSystem) chrootFs.getRawFileSystem()) .getRawFileSystem(); chrootFs.getStoragePolicy(storagePolicyPath); verify(mockFs).getStoragePolicy(chRootedStoragePolicyPath); }