[11u] RFR 8230870: (zipfs) Add a ZIP FS test that is similar to test/jdk/java/util/zip/EntryCount64k.java
Aleksey Shipilev
shade at redhat.com
Fri Jul 31 11:15:16 UTC 2020
Original fix:
https://bugs.openjdk.java.net/browse/JDK-8230870
https://hg.openjdk.java.net/jdk/jdk/rev/6a05019acb67
More tests for 11u! Unfortunately, it does not compile in 11u, because some FileSystem APIs are not
there. 11u webrev:
https://cr.openjdk.java.net/~shade/8230870/webrev.11u.01/
Testing: new test, tier{1,2}
The fix for 11u was like this:
diff -r f9225bbdf0c0 test/jdk/jdk/nio/zipfs/LargeEntriesTest.java
--- a/test/jdk/jdk/nio/zipfs/LargeEntriesTest.java Tue Sep 17 14:00:36 2019 -0400
+++ b/test/jdk/jdk/nio/zipfs/LargeEntriesTest.java Fri Jul 31 10:45:51 2020 +0200
@@ -23,15 +23,17 @@
*/
import org.testng.annotations.*;
import java.io.*;
+import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileSystem;
import java.nio.file.*;
import java.security.SecureRandom;
import java.util.Arrays;
+import java.util.Collections;
import java.util.Map;
import java.util.function.Consumer;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@@ -209,12 +211,14 @@
* @throws IOException If an error occurs while creating the ZIP file
*/
private void createZipFile(Path zipFile, Map<String, String> env,
int entries) throws IOException {
System.out.printf("Creating file = %s%n", zipFile);
+
+ URI uri = URI.create("jar:" + zipFile.toUri());
try (FileSystem zipfs =
- FileSystems.newFileSystem(zipFile, env)) {
+ FileSystems.newFileSystem(uri, env)) {
for (int i = 0; i < entries; i++) {
Files.writeString(zipfs.getPath("Entry-" + i), ZIP_FILE_VALUE);
}
}
@@ -238,12 +242,13 @@
+ System.lineSeparator()
+ "Main-Class: " + MANIFEST_MAIN_CLASS
+ System.lineSeparator()
+ "Created-By: " + jdkVersion + " (" + jdkVendor + ")";
+ URI uri = URI.create("jar:" + zipFile.toUri());
try (FileSystem zipfs =
- FileSystems.newFileSystem(zipFile, env);
+ FileSystems.newFileSystem(uri, env);
InputStream in = new ByteArrayInputStream(manifest.getBytes())) {
// Get ZIP FS path to META-INF/MANIFEST.MF
Path metadir = zipfs.getPath("/", "META-INF");
Path manifestFile = metadir.resolve("MANIFEST.MF");
@@ -329,11 +334,12 @@
assertTrue(Arrays.equals(bytes, ZIP_FILE_ENTRY));
}
}
}
// check entries with FileSystem API
- try (FileSystem fs = FileSystems.newFileSystem(zipfile)) {
+ URI uri = URI.create("jar:" + zipfile.toUri());
+ try (FileSystem fs = FileSystems.newFileSystem(uri, Collections.emptyMap())) {
// check entry count
Path top = fs.getPath("/");
long count = Files.find(top, Integer.MAX_VALUE, (path, attrs) ->
attrs.isRegularFile() || (attrs.isDirectory() &&
--
Thanks,
-Aleksey
More information about the jdk-updates-dev
mailing list