29 import java.io.IOException;
30 import java.io.OutputStream;
31 import java.nio.file.Files;
32 import java.nio.file.Paths;
33
34 import jdk.testlibrary.OutputAnalyzer;
35 import jdk.testlibrary.ProcessTools;
36
37 import org.testng.annotations.Test;
38
39 /**
40 * @test
41 * @bug 8058520
42 * @summary jar tf and jar xf should work on zip files with leading garbage
43 * @library /lib/testlibrary
44 * @run testng LeadingGarbage
45 */
46 @Test
47 public class LeadingGarbage {
48 final String jar =
49 Paths.get(new File(System.getProperty("java.home")).getParent(),
50 "bin", "jar").toString();
51 final File[] files = { new File("a"), new File("b") };
52 final File normalZip = new File("normal.zip");
53 final File leadingGarbageZip = new File("leadingGarbage.zip");
54
55 void createFile(File f) throws IOException {
56 try (OutputStream fos = new FileOutputStream(f)) {
57 fos.write(f.getName().getBytes("UTF-8"));
58 }
59 }
60
61 void createFiles() throws IOException {
62 for (File file : files)
63 createFile(file);
64 }
65
66 void deleteFiles() throws IOException {
67 for (File file : files)
68 assertTrue(file.delete());
69 }
70
|
29 import java.io.IOException;
30 import java.io.OutputStream;
31 import java.nio.file.Files;
32 import java.nio.file.Paths;
33
34 import jdk.testlibrary.OutputAnalyzer;
35 import jdk.testlibrary.ProcessTools;
36
37 import org.testng.annotations.Test;
38
39 /**
40 * @test
41 * @bug 8058520
42 * @summary jar tf and jar xf should work on zip files with leading garbage
43 * @library /lib/testlibrary
44 * @run testng LeadingGarbage
45 */
46 @Test
47 public class LeadingGarbage {
48 final String jar =
49 Paths.get(System.getProperty("java.home"), "bin", "jar").toString();
50 final File[] files = { new File("a"), new File("b") };
51 final File normalZip = new File("normal.zip");
52 final File leadingGarbageZip = new File("leadingGarbage.zip");
53
54 void createFile(File f) throws IOException {
55 try (OutputStream fos = new FileOutputStream(f)) {
56 fos.write(f.getName().getBytes("UTF-8"));
57 }
58 }
59
60 void createFiles() throws IOException {
61 for (File file : files)
62 createFile(file);
63 }
64
65 void deleteFiles() throws IOException {
66 for (File file : files)
67 assertTrue(file.delete());
68 }
69
|