test/jdk/nio/zipfs/Basic.java

Print this page




  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import java.nio.file.*;
  25 import java.nio.file.attribute.*;
  26 import java.nio.file.spi.FileSystemProvider;
  27 import java.util.*;
  28 import java.net.URI;
  29 import java.io.IOException;
  30 
  31 /**
  32  * Basic test for zip provider



  33  */
  34 
  35 public class Basic {
  36     public static void main(String[] args) throws Exception {
  37         Path zipfile = Paths.get(args[0]);
  38 
  39         // Test: zip should should be returned in provider list
  40         boolean found = false;
  41 
  42         for (FileSystemProvider provider: FileSystemProvider.installedProviders()) {
  43             if (provider.getScheme().equalsIgnoreCase("jar")) {
  44                 found = true;
  45                 break;
  46             }
  47         }
  48         if (!found)
  49             throw new RuntimeException("'jar' provider not installed");
  50 
  51         // Test: FileSystems#newFileSystem(Path)
  52         Map<String,?> env = new HashMap<String,Object>();
  53         FileSystems.newFileSystem(zipfile, null).close();
  54 
  55         // Test: FileSystems#newFileSystem(URI)
  56         URI uri = new URI("jar", zipfile.toUri().toString(), null);
  57         FileSystem fs = FileSystems.newFileSystem(uri, env, null);
  58 




  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import java.nio.file.*;
  25 import java.nio.file.attribute.*;
  26 import java.nio.file.spi.FileSystemProvider;
  27 import java.util.*;
  28 import java.net.URI;
  29 import java.io.IOException;
  30 
  31 /**
  32  *
  33  * @test
  34  * @bug 8038500
  35  * @summary Basic test for zip provider
  36  */
  37 
  38 public class Basic {
  39     public static void main(String[] args) throws Exception {
  40         Path zipfile = Paths.get(System.getProperty("test.jdk"),
  41                                  "jre/lib/ext/zipfs.jar");
  42         // Test: zip should should be returned in provider list
  43         boolean found = false;
  44 
  45         for (FileSystemProvider provider: FileSystemProvider.installedProviders()) {
  46             if (provider.getScheme().equalsIgnoreCase("jar")) {
  47                 found = true;
  48                 break;
  49             }
  50         }
  51         if (!found)
  52             throw new RuntimeException("'jar' provider not installed");
  53 
  54         // Test: FileSystems#newFileSystem(Path)
  55         Map<String,?> env = new HashMap<String,Object>();
  56         FileSystems.newFileSystem(zipfile, null).close();
  57 
  58         // Test: FileSystems#newFileSystem(URI)
  59         URI uri = new URI("jar", zipfile.toUri().toString(), null);
  60         FileSystem fs = FileSystems.newFileSystem(uri, env, null);
  61