Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDFS-16963: added asserts on the conditions used in FileSystem.hasPathCapablity #2

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -23,6 +23,7 @@
import org.apache.hadoop.hdfs.HdfsConfiguration;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;

import static org.apache.hadoop.fs.CommonPathCapabilities.FS_SYMLINKS;

Expand All @@ -37,16 +38,28 @@ public void testFS_SYMLINKS() throws Exception {
conf.set(FileSystem.FS_DEFAULT_NAME_KEY, "hdfs://localhost/");
final FileSystem fs = FileSystem.get(conf);
Assert.assertTrue(fs instanceof DistributedFileSystem);
final DistributedFileSystem dfs = (DistributedFileSystem) fs;
final DistributedFileSystem dfs = Mockito.spy((DistributedFileSystem) fs);
final Path path = new Path("/");
Assert.assertTrue(dfs.supportsSymlinks());

// Symlinks disabled
// Symlinks support disabled
Mockito.doReturn(false).when(dfs).supportsSymlinks();
Assert.assertFalse(FileSystem.areSymlinksEnabled());
Assert.assertFalse(dfs.hasPathCapability(path, FS_SYMLINKS));

// Symlinks support enabled
Mockito.doReturn(true).when(dfs).supportsSymlinks();
Assert.assertFalse(FileSystem.areSymlinksEnabled());
Assert.assertFalse(dfs.hasPathCapability(path, FS_SYMLINKS));

// Symlinks enabled
FileSystem.enableSymlinks();
Mockito.doReturn(true).when(dfs).supportsSymlinks();
Assert.assertTrue(FileSystem.areSymlinksEnabled());
Assert.assertTrue(dfs.hasPathCapability(path, FS_SYMLINKS));

// Symlinks enabled but symlink-support is disabled
FileSystem.enableSymlinks();
Mockito.doReturn(false).when(dfs).supportsSymlinks();
Assert.assertTrue(FileSystem.areSymlinksEnabled());
Assert.assertTrue(dfs.hasPathCapability(path, FS_SYMLINKS));
}
Expand Down