71 * Tests various zipfs operations. |
71 * Tests various zipfs operations. |
72 * |
72 * |
73 * @test |
73 * @test |
74 * @bug 6990846 7009092 7009085 7015391 7014948 7005986 7017840 7007596 |
74 * @bug 6990846 7009092 7009085 7015391 7014948 7005986 7017840 7007596 |
75 * 7157656 8002390 7012868 7012856 8015728 8038500 8040059 8069211 |
75 * 7157656 8002390 7012868 7012856 8015728 8038500 8040059 8069211 |
76 * 8131067 8034802 |
76 * 8131067 8034802 8210899 |
77 * @summary Test Zip filesystem provider |
77 * @summary Test Zip filesystem provider |
78 * @modules jdk.zipfs |
78 * @modules jdk.zipfs |
79 * @run main ZipFSTester |
79 * @run main ZipFSTester |
80 * @run main/othervm/java.security.policy=test.policy ZipFSTester |
80 * @run main/othervm/java.security.policy=test.policy ZipFSTester |
81 */ |
81 */ |
432 return entries; |
431 return entries; |
433 } |
432 } |
434 |
433 |
435 // check the content of read from zipfs is equal to the "bytes" |
434 // check the content of read from zipfs is equal to the "bytes" |
436 private static void checkRead(Path path, byte[] expected) throws IOException { |
435 private static void checkRead(Path path, byte[] expected) throws IOException { |
|
436 |
|
437 // fileAttribute |
|
438 CRC32 crc32 = new CRC32(); |
|
439 crc32.update(expected); |
|
440 |
|
441 if (((Long)Files.getAttribute(path, "zip:crc")).intValue() != |
|
442 (int)crc32.getValue()) { |
|
443 System.out.printf(" getAttribute.crc <%s> failed %x vs %x ...%n", |
|
444 path.toString(), |
|
445 ((Long)Files.getAttribute(path, "zip:crc")).intValue(), |
|
446 (int)crc32.getValue()); |
|
447 throw new RuntimeException("CHECK FAILED!"); |
|
448 } |
|
449 |
|
450 if (((Long)Files.getAttribute(path, "zip:size")).intValue() != expected.length) { |
|
451 System.out.printf(" getAttribute.size <%s> failed %x vs %x ...%n", |
|
452 path.toString(), |
|
453 ((Long)Files.getAttribute(path, "zip:size")).intValue(), |
|
454 expected.length); |
|
455 throw new RuntimeException("CHECK FAILED!"); |
|
456 } |
|
457 |
437 //streams |
458 //streams |
438 try (InputStream is = Files.newInputStream(path)) { |
459 try (InputStream is = Files.newInputStream(path)) { |
439 if (!Arrays.equals(is.readAllBytes(), expected)) { |
460 if (!Arrays.equals(is.readAllBytes(), expected)) { |
440 System.out.printf(" newInputStream <%s> failed...%n", path.toString()); |
461 System.out.printf(" newInputStream <%s> failed...%n", path.toString()); |
441 throw new RuntimeException("CHECK FAILED!"); |
462 throw new RuntimeException("CHECK FAILED!"); |