equal
deleted
inserted
replaced
26 */ |
26 */ |
27 |
27 |
28 /* |
28 /* |
29 * @test |
29 * @test |
30 * @bug 7201156 |
30 * @bug 7201156 |
31 * @modules jdk.jartool/sun.tools.jar |
31 * @modules jdk.jartool |
32 * @summary jar tool fails to convert file separation characters for list and extract |
32 * @summary jar tool fails to convert file separation characters for list and extract |
33 * @author Sean Chou |
33 * @author Sean Chou |
34 */ |
34 */ |
35 |
35 |
36 import java.io.File; |
36 import java.io.File; |
41 import java.io.PrintStream; |
41 import java.io.PrintStream; |
42 import java.util.ArrayList; |
42 import java.util.ArrayList; |
43 import java.util.List; |
43 import java.util.List; |
44 import java.util.jar.JarEntry; |
44 import java.util.jar.JarEntry; |
45 import java.util.jar.JarOutputStream; |
45 import java.util.jar.JarOutputStream; |
46 |
46 import java.util.spi.ToolProvider; |
47 import sun.tools.jar.Main; |
|
48 |
47 |
49 public class JarBackSlash { |
48 public class JarBackSlash { |
|
49 private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar") |
|
50 .orElseThrow(() -> |
|
51 new RuntimeException("jar tool not found") |
|
52 ); |
50 |
53 |
51 // used construct an entry JarBackSlash/dir/file.txt |
54 // used construct an entry JarBackSlash/dir/file.txt |
52 private static String JARBACKSLASH = "JarBackSlash"; |
55 private static String JARBACKSLASH = "JarBackSlash"; |
53 private static String DIR = "dir"; |
56 private static String DIR = "dir"; |
54 private static String FILENAME = "file.txt"; |
57 private static String FILENAME = "file.txt"; |
76 |
79 |
77 PipedOutputStream pipedOutput = new PipedOutputStream(); |
80 PipedOutputStream pipedOutput = new PipedOutputStream(); |
78 PipedInputStream pipedInput = new PipedInputStream(pipedOutput); |
81 PipedInputStream pipedInput = new PipedInputStream(pipedOutput); |
79 PrintStream out = new PrintStream(pipedOutput); |
82 PrintStream out = new PrintStream(pipedOutput); |
80 |
83 |
81 Main jarTool = new Main(out, System.err, "jar"); |
84 int rc = JAR_TOOL.run(out, System.err, jarArgs); |
82 if (!jarTool.run(jarArgs)) { |
85 if (rc != 0) { |
83 fail("Could not list jar file."); |
86 fail("Could not list jar file."); |
84 } |
87 } |
85 |
88 |
86 out.flush(); |
89 out.flush(); |
87 check(pipedInput.available() > 0); |
90 check(pipedInput.available() > 0); |
99 |
102 |
100 PipedOutputStream pipedOutput = new PipedOutputStream(); |
103 PipedOutputStream pipedOutput = new PipedOutputStream(); |
101 PipedInputStream pipedInput = new PipedInputStream(pipedOutput); |
104 PipedInputStream pipedInput = new PipedInputStream(pipedOutput); |
102 PrintStream out = new PrintStream(pipedOutput); |
105 PrintStream out = new PrintStream(pipedOutput); |
103 |
106 |
104 Main jarTool = new Main(out, System.err, "jar"); |
107 int rc = JAR_TOOL.run(out, System.err, jarArgs); |
105 if (!jarTool.run(jarArgs)) { |
108 if (rc != 0) { |
106 fail("Could not list jar file."); |
109 fail("Could not list jar file."); |
107 } |
110 } |
108 |
111 |
109 out.flush(); |
112 out.flush(); |
110 check(pipedInput.available() > 0); |
113 check(pipedInput.available() > 0); |