### Question:
GlusterFileSystemProvider extends FileSystemProvider { @Override public void checkAccess(Path path, AccessMode... accessModes) throws IOException { long volptr = ((GlusterFileSystem) path.getFileSystem()).getVolptr(); String pathString = ((GlusterPath) path).getString(); stat stat = new stat(); int ret = GLFS.glfs_lstat(volptr, pathString, stat); if (-1 == ret) { throw new NoSuchFileException(""); } for (AccessMode m : accessModes) { int access = GLFS.glfs_access(volptr, pathString, modeInt(m)); if (-1 == access) { throw new AccessDeniedException(pathString); } } }  @Override String getScheme(); @Override FileSystem newFileSystem(URI uri, Map<String, ?> stringMap); @Override FileSystem getFileSystem(URI uri); @Override Path getPath(URI uri); @Override SeekableByteChannel newByteChannel(Path path, Set<? extends OpenOption> openOptions, FileAttribute<?>... fileAttributes); @Override FileChannel newFileChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs); @Override DirectoryStream<Path> newDirectoryStream(Path path, DirectoryStream.Filter<? super Path> filter); @Override void createDirectory(Path path, FileAttribute<?>... fileAttributes); @Override void delete(Path path); @Override void copy(Path path, Path path2, CopyOption... copyOptions); @Override void move(Path path, Path path2, CopyOption... copyOptions); @Override boolean isSameFile(Path path, Path path2); @Override boolean isHidden(Path path); @Override FileStore getFileStore(Path path); @Override void checkAccess(Path path, AccessMode... accessModes); @Override V getFileAttributeView(Path path, Class<V> vClass, LinkOption... linkOptions); @Override A readAttributes(Path path, Class<A> type, LinkOption... linkOptions); @Override Map<String, Object> readAttributes(Path path, String s, LinkOption... linkOptions); @Override void setAttribute(Path path, String s, Object o, LinkOption... linkOptions); @Override Path readSymbolicLink(Path link); @Override void createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs); static final String GLUSTER; static final int GLUSTERD_PORT; static final String TCP; }### Answer:
@Test public void testCheckAccess() throws IOException { long volptr = 1234l; doReturn(mockFileSystem).when(mockPath).getFileSystem(); doReturn(volptr).when(mockFileSystem).getVolptr(); String path = "/foo/bar"; doReturn(path).when(mockPath).getString(); int mode = 4; stat stat = new stat(); PowerMockito.mockStatic(GLFS.class); when(GLFS.glfs_lstat(volptr, path, stat)).thenReturn(0); when(GLFS.glfs_access(volptr, path, mode)).thenReturn(0); AccessMode accessMode = AccessMode.READ; provider.checkAccess(mockPath, accessMode); PowerMockito.verifyStatic(); GLFS.glfs_access(volptr, path, mode); verify(mockPath).getFileSystem(); verify(mockFileSystem).getVolptr(); verify(mockPath).getString(); }