test/jdk/jdk/nio/zipfs/Basic.java
Print this page
*** 41,51 ****
import java.util.Collections;
import java.util.Map;
import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE;
/**
* @test
! * @bug 8038500 8040059 8150366 8150496 8147539
* @summary Basic test for zip provider
*
* @modules jdk.zipfs
* @run main Basic
* @run main/othervm/java.security.policy=test.policy Basic
--- 41,51 ----
import java.util.Collections;
import java.util.Map;
import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE;
/**
* @test
! * @bug 8038500 8040059 8150366 8150496 8147539 8211385
* @summary Basic test for zip provider
*
* @modules jdk.zipfs
* @run main Basic
* @run main/othervm/java.security.policy=test.policy Basic
*** 87,106 ****
// Test: exercise directory iterator and retrieval of basic attributes
Files.walkFileTree(fs.getPath("/"), new FileTreePrinter());
// Test: DirectoryStream
found = false;
try (DirectoryStream<Path> stream = Files.newDirectoryStream(fs.getPath("/"))) {
for (Path entry: stream) {
found = entry.toString().equals("/META-INF");
if (found) break;
}
}
-
if (!found)
throw new RuntimeException("Expected file not found");
// Test: copy file from zip file to current (scratch) directory
Path source = fs.getPath("/META-INF/services/java.nio.file.spi.FileSystemProvider");
if (Files.exists(source)) {
Path target = Paths.get(source.getFileName().toString());
Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING);
--- 87,120 ----
// Test: exercise directory iterator and retrieval of basic attributes
Files.walkFileTree(fs.getPath("/"), new FileTreePrinter());
// Test: DirectoryStream
found = false;
+
try (DirectoryStream<Path> stream = Files.newDirectoryStream(fs.getPath("/"))) {
for (Path entry: stream) {
found = entry.toString().equals("/META-INF");
if (found) break;
}
}
if (!found)
throw new RuntimeException("Expected file not found");
+ try (DirectoryStream<Path> stream = Files.newDirectoryStream(fs.getPath("META-INF"))) {
+ for (Path entry: stream) {
+ if (entry.toString().equals("/META-INF/services"))
+ throw new RuntimeException("child path should be relative");
+ }
+ }
+
+ try (DirectoryStream<Path> stream = Files.newDirectoryStream(fs.getPath("/META-INF"))) {
+ for (Path entry: stream) {
+ if (entry.toString().equals("META-INF/services"))
+ throw new RuntimeException("child path should be absolute");
+ }
+ }
+
// Test: copy file from zip file to current (scratch) directory
Path source = fs.getPath("/META-INF/services/java.nio.file.spi.FileSystemProvider");
if (Files.exists(source)) {
Path target = Paths.get(source.getFileName().toString());
Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING);
*** 131,140 ****
--- 145,156 ----
if (fs.isOpen())
throw new RuntimeException("FileSystem should be closed");
try {
fs.provider().checkAccess(fs.getPath("/missing"), AccessMode.READ);
} catch (ClosedFileSystemException x) { }
+
+ Files.deleteIfExists(jarFile);
}
// FileVisitor that pretty prints a file tree
static class FileTreePrinter extends SimpleFileVisitor<Path> {
private int indent = 0;