author | lancea |
Thu, 14 Nov 2019 10:54:32 -0500 | |
changeset 59083 | 3e4d8b5856f3 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
13249
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
1 |
/* |
28255
ddb0157601ed
8067889: 4 pack200 tests fail on mac since jdk became modular
ksrini
parents:
18594
diff
changeset
|
2 |
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. |
13249
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
4 |
* |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
8 |
* |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
13 |
* accompanied this code). |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
14 |
* |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
18 |
* |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
21 |
* questions. |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
22 |
*/ |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
23 |
import java.io.File; |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
24 |
import java.io.IOException; |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
25 |
import java.util.ArrayList; |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
26 |
import java.util.List; |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
27 |
/* |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
28 |
* @test |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
29 |
* @bug 7184145 |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
30 |
* @summary tests repacking of a simple named jarfile. |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
31 |
* @compile -XDignore.symbol.file Utils.java RepackTest.java |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
32 |
* @run main RepackTest |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
33 |
* @author ksrini |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
34 |
*/ |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
35 |
public class RepackTest { |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
36 |
|
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
37 |
public static void main(String... args) throws Exception { |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
38 |
testRepack(); |
18594
b6a3c9f71ac8
8017463: [TEST_BUG] 2 tests from tools/pack200/ remain about 1 GB of data in work directory after execution
ksrini
parents:
13249
diff
changeset
|
39 |
Utils.cleanup(); |
13249
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
40 |
} |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
41 |
|
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
42 |
/* |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
43 |
* there are two cases we need to test, where the file in question is |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
44 |
* orpaned, ie. without a parent ie. not qualified by a parent path |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
45 |
* relative nor absolute |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
46 |
* case 1: src and dest are the same |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
47 |
* case 2: src and dest are different |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
48 |
*/ |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
49 |
static void testRepack() throws IOException { |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
50 |
|
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
51 |
// make a copy of the test specimen to local directory |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
52 |
File testFile = new File("src_tools.jar"); |
28255
ddb0157601ed
8067889: 4 pack200 tests fail on mac since jdk became modular
ksrini
parents:
18594
diff
changeset
|
53 |
Utils.copyFile(Utils.getGoldenJar(), testFile); |
13249
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
54 |
List<String> cmdsList = new ArrayList<>(); |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
55 |
|
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
56 |
// case 1: |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
57 |
cmdsList.add(Utils.getPack200Cmd()); |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
58 |
cmdsList.add("--repack"); |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
59 |
cmdsList.add(testFile.getName()); |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
60 |
Utils.runExec(cmdsList); |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
61 |
|
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
62 |
// case 2: |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
63 |
File dstFile = new File("dst_tools.jar"); |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
64 |
cmdsList.clear(); |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
65 |
cmdsList.add(Utils.getPack200Cmd()); |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
66 |
cmdsList.add("--repack"); |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
67 |
cmdsList.add(dstFile.getName()); |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
68 |
cmdsList.add(testFile.getName()); |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
69 |
Utils.runExec(cmdsList); |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
70 |
|
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
71 |
// tidy up |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
72 |
testFile.delete(); |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
73 |
dstFile.delete(); |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
74 |
} |
9f4bd1ab7873
7184145: (pack200) pack200 --repack throws NullPointerException when JAR file specified without path
ksrini
parents:
diff
changeset
|
75 |
} |