1 /*
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
33 * @author ksrini
34 */
35 public class RepackTest {
36
37 public static void main(String... args) throws Exception {
38 testRepack();
39 Utils.cleanup();
40 }
41
42 /*
43 * there are two cases we need to test, where the file in question is
44 * orpaned, ie. without a parent ie. not qualified by a parent path
45 * relative nor absolute
46 * case 1: src and dest are the same
47 * case 2: src and dest are different
48 */
49 static void testRepack() throws IOException {
50
51 // make a copy of the test specimen to local directory
52 File testFile = new File("src_tools.jar");
53 Utils.copyFile(Utils.locateJar("golden.jar"), testFile);
54 List<String> cmdsList = new ArrayList<>();
55
56 // case 1:
57 cmdsList.add(Utils.getPack200Cmd());
58 cmdsList.add("--repack");
59 cmdsList.add(testFile.getName());
60 Utils.runExec(cmdsList);
61
62 // case 2:
63 File dstFile = new File("dst_tools.jar");
64 cmdsList.clear();
65 cmdsList.add(Utils.getPack200Cmd());
66 cmdsList.add("--repack");
67 cmdsList.add(dstFile.getName());
68 cmdsList.add(testFile.getName());
69 Utils.runExec(cmdsList);
70
71 // tidy up
72 testFile.delete();
73 dstFile.delete();
|
1 /*
2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
33 * @author ksrini
34 */
35 public class RepackTest {
36
37 public static void main(String... args) throws Exception {
38 testRepack();
39 Utils.cleanup();
40 }
41
42 /*
43 * there are two cases we need to test, where the file in question is
44 * orpaned, ie. without a parent ie. not qualified by a parent path
45 * relative nor absolute
46 * case 1: src and dest are the same
47 * case 2: src and dest are different
48 */
49 static void testRepack() throws IOException {
50
51 // make a copy of the test specimen to local directory
52 File testFile = new File("src_tools.jar");
53 Utils.copyFile(Utils.getGoldenJar(), testFile);
54 List<String> cmdsList = new ArrayList<>();
55
56 // case 1:
57 cmdsList.add(Utils.getPack200Cmd());
58 cmdsList.add("--repack");
59 cmdsList.add(testFile.getName());
60 Utils.runExec(cmdsList);
61
62 // case 2:
63 File dstFile = new File("dst_tools.jar");
64 cmdsList.clear();
65 cmdsList.add(Utils.getPack200Cmd());
66 cmdsList.add("--repack");
67 cmdsList.add(dstFile.getName());
68 cmdsList.add(testFile.getName());
69 Utils.runExec(cmdsList);
70
71 // tidy up
72 testFile.delete();
73 dstFile.delete();
|