author | rehn |
Fri, 07 Jul 2017 23:04:06 +0200 | |
changeset 46643 | cb5f289ba033 |
parent 45467 | 99c87a16a8e4 |
permissions | -rw-r--r-- |
41221
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
1 |
/* |
45286
cd809e28c082
8180887: move FileUtils to top level testlibrary
iignatyev
parents:
43098
diff
changeset
|
2 |
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. |
41221
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
4 |
* |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
8 |
* |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
13 |
* accompanied this code). |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
14 |
* |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
18 |
* |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
21 |
* questions. |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
22 |
*/ |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
23 |
|
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
24 |
/* |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
25 |
* @test |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
26 |
* @bug 8165944 |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
27 |
* @summary test several jar tool input file scenarios with variations on -C |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
28 |
* options with/without a --release option. Some input files are |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
29 |
* duplicates that sometimes cause exceptions and other times do not, |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
30 |
* demonstrating identical behavior to JDK 8 jar tool. |
45286
cd809e28c082
8180887: move FileUtils to top level testlibrary
iignatyev
parents:
43098
diff
changeset
|
31 |
* @library /test/lib |
41484
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
41221
diff
changeset
|
32 |
* @modules jdk.jartool |
45467
99c87a16a8e4
8181761: add explicit @build actions for jdk.test.lib classes in all :tier2 tests
iignatyev
parents:
45286
diff
changeset
|
33 |
* @build jdk.test.lib.Platform |
99c87a16a8e4
8181761: add explicit @build actions for jdk.test.lib classes in all :tier2 tests
iignatyev
parents:
45286
diff
changeset
|
34 |
* jdk.test.lib.util.FileUtils |
41221
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
35 |
* @run testng InputFilesTest |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
36 |
*/ |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
37 |
|
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
38 |
import org.testng.Assert; |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
39 |
import org.testng.annotations.AfterMethod; |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
40 |
import org.testng.annotations.BeforeMethod; |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
41 |
import org.testng.annotations.Test; |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
42 |
|
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
43 |
import java.io.ByteArrayOutputStream; |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
44 |
import java.io.IOException; |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
45 |
import java.io.PrintStream; |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
46 |
import java.io.UncheckedIOException; |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
47 |
import java.nio.file.Files; |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
48 |
import java.nio.file.Path; |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
49 |
import java.nio.file.Paths; |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
50 |
import java.util.Arrays; |
41484
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
41221
diff
changeset
|
51 |
import java.util.spi.ToolProvider; |
41221
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
52 |
import java.util.stream.Stream; |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
53 |
import java.util.zip.ZipException; |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
54 |
|
45286
cd809e28c082
8180887: move FileUtils to top level testlibrary
iignatyev
parents:
43098
diff
changeset
|
55 |
import jdk.test.lib.util.FileUtils; |
41221
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
56 |
|
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
57 |
public class InputFilesTest { |
41484
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
41221
diff
changeset
|
58 |
private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar") |
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
41221
diff
changeset
|
59 |
.orElseThrow(() -> |
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
41221
diff
changeset
|
60 |
new RuntimeException("jar tool not found") |
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
41221
diff
changeset
|
61 |
); |
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
41221
diff
changeset
|
62 |
|
41221
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
63 |
private final String nl = System.lineSeparator(); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
64 |
private final ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
65 |
private final PrintStream out = new PrintStream(baos); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
66 |
private Runnable onCompletion; |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
67 |
|
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
68 |
@BeforeMethod |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
69 |
public void reset() { |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
70 |
onCompletion = null; |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
71 |
} |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
72 |
|
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
73 |
@AfterMethod |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
74 |
public void run() { |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
75 |
if (onCompletion != null) { |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
76 |
onCompletion.run(); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
77 |
} |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
78 |
} |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
79 |
|
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
80 |
@Test |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
81 |
public void test1() throws IOException { |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
82 |
mkdir("test1 test2"); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
83 |
touch("test1/testfile1 test2/testfile2"); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
84 |
jar("cf test.jar -C test1 . -C test2 ."); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
85 |
jar("tf test.jar"); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
86 |
println(); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
87 |
String output = "META-INF/" + nl + |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
88 |
"META-INF/MANIFEST.MF" + nl + |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
89 |
"testfile1" + nl + |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
90 |
"testfile2" + nl; |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
91 |
rm("test.jar test1 test2"); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
92 |
Assert.assertEquals(baos.toByteArray(), output.getBytes()); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
93 |
} |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
94 |
|
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
95 |
@Test |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
96 |
public void test2() throws IOException { |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
97 |
mkdir("test1 test2 test3 test4"); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
98 |
touch("test1/testfile1 test2/testfile2 test3/testfile3 test4/testfile4"); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
99 |
jar("cf test.jar -C test1 . -C test2 . --release 9 -C test3 . -C test4 ."); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
100 |
jar("tf test.jar"); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
101 |
println(); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
102 |
String output = "META-INF/" + nl + |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
103 |
"META-INF/MANIFEST.MF" + nl + |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
104 |
"testfile1" + nl + |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
105 |
"testfile2" + nl + |
43098
124d24e7988c
8172761: Test change in tools/jar/InputFilesTest.java for JDK-8172432 is missing
sherman
parents:
41484
diff
changeset
|
106 |
"META-INF/versions/9/" + nl + |
41221
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
107 |
"META-INF/versions/9/testfile3" + nl + |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
108 |
"META-INF/versions/9/testfile4" + nl; |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
109 |
rm("test.jar test1 test2 test3 test4"); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
110 |
Assert.assertEquals(baos.toByteArray(), output.getBytes()); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
111 |
} |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
112 |
|
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
113 |
@Test |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
114 |
public void test3() throws IOException { |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
115 |
touch("test"); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
116 |
jar("cf test.jar test test"); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
117 |
jar("tf test.jar"); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
118 |
println(); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
119 |
String output = "META-INF/" + nl + |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
120 |
"META-INF/MANIFEST.MF" + nl + |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
121 |
"test" + nl; |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
122 |
rm("test.jar test"); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
123 |
Assert.assertEquals(baos.toByteArray(), output.getBytes()); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
124 |
} |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
125 |
|
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
126 |
@Test |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
127 |
public void test4() throws IOException { |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
128 |
mkdir("a"); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
129 |
touch("a/test"); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
130 |
jar("cf test.jar -C a test -C a test"); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
131 |
jar("tf test.jar"); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
132 |
println(); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
133 |
String output = "META-INF/" + nl + |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
134 |
"META-INF/MANIFEST.MF" + nl + |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
135 |
"test" + nl; |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
136 |
rm("test.jar a"); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
137 |
Assert.assertEquals(baos.toByteArray(), output.getBytes()); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
138 |
} |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
139 |
|
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
140 |
@Test(expectedExceptions = {ZipException.class}) |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
141 |
public void test5() throws IOException { |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
142 |
mkdir("a"); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
143 |
touch("test a/test"); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
144 |
onCompletion = () -> rm("test a"); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
145 |
jar("cf test.jar -C a test test"); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
146 |
} |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
147 |
|
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
148 |
@Test(expectedExceptions = {ZipException.class}) |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
149 |
public void test6() throws IOException { |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
150 |
mkdir("test1 test2"); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
151 |
touch("test1/a test2/a"); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
152 |
onCompletion = () -> rm("test1 test2"); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
153 |
jar("cf test.jar --release 9 -C test1 a -C test2 a"); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
154 |
} |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
155 |
|
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
156 |
private Stream<Path> mkpath(String... args) { |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
157 |
return Arrays.stream(args).map(d -> Paths.get(".", d.split("/"))); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
158 |
} |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
159 |
|
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
160 |
private void mkdir(String cmdline) { |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
161 |
System.out.println("mkdir -p " + cmdline); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
162 |
mkpath(cmdline.split(" +")).forEach(p -> { |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
163 |
try { |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
164 |
Files.createDirectories(p); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
165 |
} catch (IOException x) { |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
166 |
throw new UncheckedIOException(x); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
167 |
} |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
168 |
}); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
169 |
} |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
170 |
|
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
171 |
private void touch(String cmdline) { |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
172 |
System.out.println("touch " + cmdline); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
173 |
mkpath(cmdline.split(" +")).forEach(p -> { |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
174 |
try { |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
175 |
Files.createFile(p); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
176 |
} catch (IOException x) { |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
177 |
throw new UncheckedIOException(x); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
178 |
} |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
179 |
}); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
180 |
} |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
181 |
|
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
182 |
private void rm(String cmdline) { |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
183 |
System.out.println("rm -rf " + cmdline); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
184 |
mkpath(cmdline.split(" +")).forEach(p -> { |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
185 |
try { |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
186 |
if (Files.isDirectory(p)) { |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
187 |
FileUtils.deleteFileTreeWithRetry(p); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
188 |
} else { |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
189 |
FileUtils.deleteFileIfExistsWithRetry(p); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
190 |
} |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
191 |
} catch (IOException x) { |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
192 |
throw new UncheckedIOException(x); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
193 |
} |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
194 |
}); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
195 |
} |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
196 |
|
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
197 |
private void jar(String cmdline) throws IOException { |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
198 |
System.out.println("jar " + cmdline); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
199 |
baos.reset(); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
200 |
|
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
201 |
// the run method catches IOExceptions, we need to expose them |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
202 |
ByteArrayOutputStream baes = new ByteArrayOutputStream(); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
203 |
PrintStream err = new PrintStream(baes); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
204 |
PrintStream saveErr = System.err; |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
205 |
System.setErr(err); |
41484
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
41221
diff
changeset
|
206 |
int rc = JAR_TOOL.run(out, err, cmdline.split(" +")); |
41221
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
207 |
System.setErr(saveErr); |
41484
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
41221
diff
changeset
|
208 |
if (rc != 0) { |
41221
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
209 |
String s = baes.toString(); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
210 |
if (s.startsWith("java.util.zip.ZipException: duplicate entry: ")) { |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
211 |
throw new ZipException(s); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
212 |
} |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
213 |
throw new IOException(s); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
214 |
} |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
215 |
} |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
216 |
|
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
217 |
private void println() throws IOException { |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
218 |
System.out.println(new String(baos.toByteArray())); |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
219 |
} |
eb0dc5ea2302
8165944: jar utility doesn't process more than one -C argument
sdrach
parents:
diff
changeset
|
220 |
} |