< prev index next >

test/jdk/internal/jrtfs/Basic.java

Print this page

        

@@ -26,10 +26,11 @@
  * @summary Basic test of jrt file system provider
  * @run testng Basic
  */
 
 import java.io.InputStream;
+import java.io.IOException;
 import java.io.DataInputStream;
 import java.nio.file.DirectoryStream;
 import java.nio.file.InvalidPathException;
 import java.nio.file.Files;
 import java.nio.file.FileSystem;

@@ -581,6 +582,35 @@
         } catch (InvalidPathException e) {
             ipe = e;
         }
         assertTrue(ipe != null);
     }
+
+    @DataProvider(name="packagesLinkedDirs")
+    private Object[][] packagesLinkedDirs() {
+        return new Object[][] {
+            { "/packages/java.lang/java.base/java/lang/ref" },
+            { "/packages/java.lang/java.base/java/util/zip" },
+            { "/packages/com.oracle/java.xml.ws/com" }
+        };
+    }
+
+    // @bug 8141521: jrt file system's DirectoryStream reports child paths
+    // with wrong paths for directories under /packages
+    @Test(dataProvider = "packagesLinkedDirs")
+    public void dirStreamContentUnderPackagesTest(String dirName) throws IOException {
+        FileSystem fs = FileSystems.getFileSystem(URI.create("jrt:/"));
+        Path path = fs.getPath(dirName);
+
+        int childCount = 0, dirPrefixOkayCount = 0;
+        try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(path)) {
+            for (Path child : dirStream) {
+                childCount++;
+                if (child.toString().startsWith(dirName)) {
+                    dirPrefixOkayCount++;
+                }
+            }
+        }
+
+        assertEquals(dirPrefixOkayCount, childCount);
+    }
 }
< prev index next >