You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by tk...@apache.org on 2015/10/17 16:48:34 UTC

nifi git commit: NIFI-995 TestGetFile.testAttributes() failed in case of a NTFS partition in Linux, because Files.setPosixFilePermissions() did not have any effect on the files and did not throw Exception. closes #95. Signed off by Tony Kurc (tkurc@apach

Repository: nifi
Updated Branches:
  refs/heads/master 9a8d763d8 -> 22924c656


NIFI-995 TestGetFile.testAttributes() failed in case of a NTFS partition in Linux, because Files.setPosixFilePermissions() did not have any effect on the files and did not throw Exception. closes #95. Signed off by Tony Kurc (tkurc@apache.org)


Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/22924c65
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/22924c65
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/22924c65

Branch: refs/heads/master
Commit: 22924c656bfdcf749bd618f055ffa816aca17ae5
Parents: 9a8d763
Author: Joe <jo...@impresstv.com>
Authored: Sat Oct 17 10:46:49 2015 -0400
Committer: Tony Kurc <tr...@gmail.com>
Committed: Sat Oct 17 10:46:49 2015 -0400

----------------------------------------------------------------------
 .../nifi/processors/standard/TestGetFile.java   | 21 ++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/22924c65/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestGetFile.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestGetFile.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestGetFile.java
index 018cbdc..eb8a764 100644
--- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestGetFile.java
+++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestGetFile.java
@@ -26,6 +26,7 @@ import java.io.File;
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
+import java.nio.file.attribute.PosixFilePermission;
 import java.nio.file.attribute.PosixFilePermissions;
 import java.text.DateFormat;
 import java.text.ParseException;
@@ -33,6 +34,7 @@ import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
 import java.util.Locale;
+import java.util.Set;
 
 import org.apache.nifi.flowfile.attributes.CoreAttributes;
 import org.apache.nifi.util.MockFlowFile;
@@ -158,8 +160,23 @@ public class TestGetFile {
 
         boolean verifyPermissions = false;
         try {
-            Files.setPosixFilePermissions(targetPath, PosixFilePermissions.fromString("r--r-----"));
-            verifyPermissions = true;
+            // If you mount an NTFS partition in Linux, you are unable to change the permissions of the files,
+            // because every file has the same permissions, controlled by the 'fmask' and 'dmask' mount options.
+            // Executing a chmod command will not fail, but it does not change the file's permissions.
+            // From Java perspective the NTFS mount point, as a FileStore supports the 'unix' and 'posix' file
+            // attribute views, but the setPosixFilePermissions() has no effect.
+            //
+            // If you set verifyPermissions to true without the following extra check, the test case will fail
+            // on a file system, where Nifi source is located on a NTFS mount point in Linux.
+            // The purpose of the extra check is to ensure, that setPosixFilePermissions() changes the file's
+            // permissions, and set verifyPermissions, after we are convinced.
+            Set<PosixFilePermission> perms = PosixFilePermissions.fromString("r--r-----");
+            Files.setPosixFilePermissions(targetPath, perms);
+            Set<PosixFilePermission> permsAfterSet =  Files.getPosixFilePermissions(targetPath);
+            if (perms.equals(permsAfterSet)) {
+               verifyPermissions = true;
+            }
+
         } catch (Exception donothing) {
         }