fsProvider.isHidden( null );
}
@Test
public void checkAccess() throws IOException {
final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider();
final Path path = GeneralPathImpl.create( fsProvider.getFileSystem( URI.create( "file:///" ) ), "/path/to/file.txt", false );
try {
fsProvider.checkAccess( path, WRITE );
fail( "can't have write access on non existent file" );
} catch ( Exception ex ) {
}
try {
fsProvider.checkAccess( path, READ );
fail( "can't have read access on non existent file" );
} catch ( Exception ex ) {
}
try {
fsProvider.checkAccess( path, EXECUTE );
fail( "can't have execute access on non existent file" );
} catch ( Exception ex ) {
}
final File tempFile = File.createTempFile( "foo", "bar" );
final Path path2 = GeneralPathImpl.newFromFile( fsProvider.getFileSystem( URI.create( "file:///" ) ), tempFile );
try {
fsProvider.checkAccess( path2, WRITE );
} catch ( Exception ex ) {
fail( "write access should be ok" );
}
tempFile.setWritable( false );
try {
fsProvider.checkAccess( path2, WRITE );
fail( "can't have write access on file" );
} catch ( Exception ex ) {
}
tempFile.setWritable( true );
try {
fsProvider.checkAccess( path2, READ );
} catch ( Exception ex ) {
fail( "read access should be ok" );
}
tempFile.setReadable( false );
try {
fsProvider.checkAccess( path2, READ );
fail( "can't have read access on file" );
} catch ( Exception ex ) {
}
tempFile.setReadable( true );
try {
fsProvider.checkAccess( path2, EXECUTE );
fail( "can't have execute access on file" );
} catch ( Exception ex ) {
}
tempFile.setExecutable( true );
try {
fsProvider.checkAccess( path2, EXECUTE );
} catch ( Exception ex ) {
fail( "execute access should be ok" );
}
try {
fsProvider.checkAccess( path2, READ, WRITE, EXECUTE );
} catch ( Exception ex ) {
fail( "all access should be ok" );
}
}