test/java/io/File/SetReadOnly.java

Print this page

        

*** 20,30 **** * or visit www.oracle.com if you need additional information or have any * questions. */ /* @test ! @bug 4091757 4939819 @summary Basic test for setReadOnly method */ import java.io.*; --- 20,30 ---- * or visit www.oracle.com if you need additional information or have any * questions. */ /* @test ! @bug 4091757 4939819 6728842 @summary Basic test for setReadOnly method */ import java.io.*;
*** 55,75 **** if (!f.delete()) throw new Exception("Can't delete test directory " + f); } if (!f.mkdir()) throw new Exception(f + ": Cannot create directory"); ! if (!f.setReadOnly()) ! throw new Exception(f + ": Failed on directory"); ! // The readonly attribute on Windows does not make a folder read-only ! if (System.getProperty("os.name").startsWith("Windows")) { ! if (!f.canWrite()) ! throw new Exception(f + ": Directory is not writeable"); ! } else { ! if (f.canWrite()) throw new Exception(f + ": Directory is writeable"); - } - if (!f.delete()) throw new Exception(f + ": Cannot delete directory"); } --- 55,66 ---- if (!f.delete()) throw new Exception("Can't delete test directory " + f); } if (!f.mkdir()) throw new Exception(f + ": Cannot create directory"); ! if (f.setReadOnly() && f.canWrite()) throw new Exception(f + ": Directory is writeable"); if (!f.delete()) throw new Exception(f + ": Cannot delete directory"); }