test/jdk/nio/zipfs/ZipFSTester.java

Print this page




  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import java.io.*;
  25 import java.nio.*;
  26 import java.nio.channels.*;
  27 import java.nio.file.*;
  28 import java.nio.file.spi.*;
  29 import java.nio.file.attribute.*;
  30 import java.net.*;
  31 import java.util.*;
  32 import java.util.concurrent.TimeUnit;
  33 import java.util.zip.*;
  34 
  35 import static java.nio.file.StandardOpenOption.*;
  36 import static java.nio.file.StandardCopyOption.*;
  37 
  38 /*
  39  * Tests various zipfs operations.





  40  */
  41 
  42 public class ZipFSTester {
  43 
  44     public static void main(String[] args) throws Throwable {
  45 
  46         try (FileSystem fs = newZipFileSystem(Paths.get(args[0]),
  47                                               new HashMap<String, Object>()))
  48         {
  49             test0(fs);
  50             test1(fs);
  51             test2(fs);   // more tests
  52             testTime(Paths.get(args[0]));
  53         }

  54     }
  55 
  56     static void test0(FileSystem fs)
  57         throws Exception
  58     {
  59         List<String> list = new LinkedList<>();
  60         try (ZipFile zf = new ZipFile(fs.toString())) {
  61             Enumeration<? extends ZipEntry> zes = zf.entries();
  62             while (zes.hasMoreElements()) {
  63                 list.add(zes.nextElement().getName());
  64             }
  65             for (String pname : list) {
  66                 Path path = fs.getPath(pname);
  67                 if (!Files.exists(path))
  68                     throw new RuntimeException("path existence check failed!");
  69                 while ((path = path.getParent()) != null) {
  70                     if (!Files.exists(path))
  71                         throw new RuntimeException("parent existence check failed!");
  72                 }
  73             }




  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import java.io.*;
  25 import java.nio.*;
  26 import java.nio.channels.*;
  27 import java.nio.file.*;
  28 import java.nio.file.spi.*;
  29 import java.nio.file.attribute.*;
  30 import java.net.*;
  31 import java.util.*;
  32 import java.util.concurrent.TimeUnit;
  33 import java.util.zip.*;
  34 
  35 import static java.nio.file.StandardOpenOption.*;
  36 import static java.nio.file.StandardCopyOption.*;
  37 
  38 /*
  39  * Tests various zipfs operations.
  40  *
  41  * @test
  42  * @bug 6990846 7009092 7009085 7015391 7014948 7005986 7017840 7007596
  43  *      7157656 8002390 7012868 7012856 8015728 8038500
  44  * @summary Test Zip filesystem provider
  45  */
  46 
  47 public class ZipFSTester {
  48 
  49     public static void main(String[] args) throws Throwable {
  50         try (FileSystem fs = newZipFileSystem(
  51                  Paths.get(System.getProperty("test.jdk"), "jre/lib/ext/zipfs.jar"),
  52                  new HashMap<String, Object>()))
  53         {
  54             test0(fs);
  55             test1(fs);
  56             test2(fs);   // more tests

  57         }
  58         testTime(Paths.get(System.getProperty("test.jdk"), "jre/lib/ext/zipfs.jar"));
  59     }
  60 
  61     static void test0(FileSystem fs)
  62         throws Exception
  63     {
  64         List<String> list = new LinkedList<>();
  65         try (ZipFile zf = new ZipFile(fs.toString())) {
  66             Enumeration<? extends ZipEntry> zes = zf.entries();
  67             while (zes.hasMoreElements()) {
  68                 list.add(zes.nextElement().getName());
  69             }
  70             for (String pname : list) {
  71                 Path path = fs.getPath(pname);
  72                 if (!Files.exists(path))
  73                     throw new RuntimeException("path existence check failed!");
  74                 while ((path = path.getParent()) != null) {
  75                     if (!Files.exists(path))
  76                         throw new RuntimeException("parent existence check failed!");
  77                 }
  78             }