4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 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.net.*; 26 import java.util.*; 27 import java.io.IOException; 28 29 /** 30 * 31 * @test 32 * @bug 8038500 8040059 33 * @summary Tests path operations for zip provider. 34 * 35 * @run main PathOps 36 * @run main/othervm/java.security.policy=test.policy.readonly PathOps 37 */ 38 39 public class PathOps { 40 41 static final java.io.PrintStream out = System.out; 42 static FileSystem fs; 43 44 private String input; 45 private Path path; 46 private Exception exc; 47 48 private PathOps(String s) { 49 out.println(); 50 input = s; 51 try { 52 path = fs.getPath(s); 53 out.format("%s -> %s", s, path); 54 } catch (Exception x) { 55 exc = x; 56 out.format("%s -> %s", s, x); 435 try { 436 path.compareTo(null); 437 throw new RuntimeException("NullPointerException not thrown"); 438 } catch (NullPointerException npe) { 439 } 440 441 try { 442 path.startsWith((Path)null); 443 throw new RuntimeException("NullPointerException not thrown"); 444 } catch (NullPointerException npe) { 445 } 446 447 try { 448 path.endsWith((Path)null); 449 throw new RuntimeException("NullPointerException not thrown"); 450 } catch (NullPointerException npe) { 451 } 452 453 } 454 455 public static void main(String[] args) throws Throwable { 456 Path zipfile = Paths.get(System.getProperty("test.jdk"), 457 "jre/lib/ext/zipfs.jar"); 458 fs = FileSystems.newFileSystem(zipfile, null); 459 npes(); 460 doPathOpTests(); 461 fs.close(); 462 } 463 } | 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 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.io.IOException; 25 import java.nio.file.FileSystem; 26 import java.nio.file.FileSystems; 27 import java.nio.file.Files; 28 import java.nio.file.InvalidPathException; 29 import java.nio.file.Path; 30 31 /** 32 * 33 * @test 34 * @bug 8038500 8040059 35 * @summary Tests path operations for zip provider. 36 * 37 * @run main PathOps 38 * @run main/othervm/java.security.policy=test.policy PathOps 39 */ 40 41 public class PathOps { 42 43 static final java.io.PrintStream out = System.out; 44 static FileSystem fs; 45 46 private String input; 47 private Path path; 48 private Exception exc; 49 50 private PathOps(String s) { 51 out.println(); 52 input = s; 53 try { 54 path = fs.getPath(s); 55 out.format("%s -> %s", s, path); 56 } catch (Exception x) { 57 exc = x; 58 out.format("%s -> %s", s, x); 437 try { 438 path.compareTo(null); 439 throw new RuntimeException("NullPointerException not thrown"); 440 } catch (NullPointerException npe) { 441 } 442 443 try { 444 path.startsWith((Path)null); 445 throw new RuntimeException("NullPointerException not thrown"); 446 } catch (NullPointerException npe) { 447 } 448 449 try { 450 path.endsWith((Path)null); 451 throw new RuntimeException("NullPointerException not thrown"); 452 } catch (NullPointerException npe) { 453 } 454 455 } 456 457 public static void main(String[] args) throws IOException { 458 // create empty JAR file, test doesn't require any contents 459 Path emptyJar = Utils.createJarFile("empty.jar"); 460 461 fs = FileSystems.newFileSystem(emptyJar, null); 462 try { 463 npes(); 464 doPathOpTests(); 465 } finally { 466 fs.close(); 467 } 468 } 469 } |