jdk/test/java/nio/file/Path/Misc.java
changeset 3423 3dd3615c1748
parent 3065 452aaa2899fc
child 3629 6035eed86b12
equal deleted inserted replaced
3421:e3af585364e7 3423:3dd3615c1748
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    21  * have any questions.
    21  * have any questions.
    22  */
    22  */
    23 
    23 
    24 /* @test
    24 /* @test
    25  * @bug 4313887 6838333
    25  * @bug 4313887 6838333 6866804
    26  * @summary Unit test for java.nio.file.Path for miscellenous methods not
    26  * @summary Unit test for java.nio.file.Path for miscellenous methods not
    27  *   covered by other tests
    27  *   covered by other tests
    28  * @library ..
    28  * @library ..
    29  */
    29  */
    30 
    30 
   103          */
   103          */
   104         dir.checkAccess();
   104         dir.checkAccess();
   105         dir.checkAccess(AccessMode.READ);
   105         dir.checkAccess(AccessMode.READ);
   106         dir.checkAccess(AccessMode.WRITE);
   106         dir.checkAccess(AccessMode.WRITE);
   107         dir.checkAccess(AccessMode.READ, AccessMode.WRITE);
   107         dir.checkAccess(AccessMode.READ, AccessMode.WRITE);
       
   108 
       
   109         /**
       
   110          * Test: Check access to all files in all root directories.
       
   111          * (A useful test on Windows for special files such as pagefile.sys)
       
   112          */
       
   113         for (Path root: FileSystems.getDefault().getRootDirectories()) {
       
   114             DirectoryStream<Path> stream;
       
   115             try {
       
   116                 stream = root.newDirectoryStream();
       
   117             } catch (IOException x) {
       
   118                 continue; // skip root directories that aren't accessible
       
   119             }
       
   120             try {
       
   121                 for (Path entry: stream) {
       
   122                     try {
       
   123                         entry.checkAccess();
       
   124                     } catch (AccessDeniedException ignore) { }
       
   125                 }
       
   126             } finally {
       
   127                 stream.close();
       
   128             }
       
   129         }
   108 
   130 
   109         /**
   131         /**
   110          * Test: File does not exist
   132          * Test: File does not exist
   111          */
   133          */
   112         Path doesNotExist = dir.resolve("thisDoesNotExists");
   134         Path doesNotExist = dir.resolve("thisDoesNotExists");