Author: mturk
Date: Sat Jun 13 08:01:14 2009
New Revision: 784347
URL: http://svn.apache.org/viewvc?rev=784347&view=rev
Log:
Add two more attributes tests.
Note the system.out will go away from the test
Modified:
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestFile.java
Modified:
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestFile.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestFile.java?rev=784347&r1=784346&r2=784347&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestFile.java
(original)
+++
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestFile.java
Sat Jun 13 08:01:14 2009
@@ -222,10 +222,46 @@
f.createNewFile();
EnumSet <FileProtection> fp = f.getFileProtection();
System.out.println("Org Attr Protection " + fp);
+ // Set the rdonly attributes
f.setFileAttributes(EnumSet.of(FileAttributes.READ),
EnumSet.allOf(FileAttributes.class));
EnumSet <FileProtection> np = f.getFileProtection();
System.out.println("Set Attr Protection " + np);
- assertFalse("GWRITE", np.contains(FileProtection.GWRITE));
+ assertFalse("UWRITE", np.contains(FileProtection.UWRITE));
+ f.delete();
+ }
+
+ public void testSetRdonlyAttributes()
+ throws Exception
+ {
+ File f = new File("ffoo");
+ f.createNewFile();
+ EnumSet <FileProtection> fp = f.getFileProtection();
+ System.out.println("Org Attr Protection " + fp);
+ // Set the rdonly attributes
+ f.setFileAttributes(EnumSet.of(FileAttributes.READ),
EnumSet.allOf(FileAttributes.class));
+ // Clear the rdonly attributes
+ f.setFileAttributes(EnumSet.noneOf(FileAttributes.class),
EnumSet.of(FileAttributes.READ));
+ EnumSet <FileProtection> np = f.getFileProtection();
+ System.out.println("Set Attr Protection " + np);
+ assertTrue("GWRITE", np.contains(FileProtection.GWRITE));
+ f.delete();
+ }
+
+ public void testClearAttributes()
+ throws Exception
+ {
+ File f = new File("ffoo");
+ f.createNewFile();
+ EnumSet <FileProtection> fp = f.getFileProtection();
+ System.out.println("Clr Attr Protection " + fp);
+ f.setFileAttributes(EnumSet.allOf(FileAttributes.class),
EnumSet.allOf(FileAttributes.class));
+ EnumSet <FileProtection> cp = f.getFileProtection();
+ System.out.println("Rst Attr Protection " + cp);
+ // Clear the rdonly attributes
+ f.setFileAttributes(EnumSet.noneOf(FileAttributes.class),
EnumSet.of(FileAttributes.READ));
+ EnumSet <FileProtection> np = f.getFileProtection();
+ System.out.println("Set Attr Protection " + np);
+ assertTrue("WEXECUTE", np.contains(FileProtection.WEXECUTE));
f.delete();
}