57307
|
1 |
/*
|
|
2 |
* Copyright (c) 2018, 2019, 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 |
*/
|
|
23 |
|
|
24 |
import java.io.File;
|
|
25 |
|
|
26 |
/*
|
|
27 |
* @test
|
|
28 |
* @requires (os.family == "windows")
|
|
29 |
* @summary jpackage create image to test --temp-root
|
|
30 |
* @library ../helpers
|
|
31 |
* @build JPackageHelper
|
|
32 |
* @build JPackagePath
|
|
33 |
* @modules jdk.jpackage
|
|
34 |
* @run main/othervm -Xmx512m JPackageCreateAppImageTempRootTest
|
|
35 |
*/
|
|
36 |
public class JPackageCreateAppImageTempRootTest {
|
|
37 |
private static final String OUTPUT = "output";
|
|
38 |
private static String buildRoot = null;
|
|
39 |
private static final String BUILD_ROOT = "buildRoot";
|
|
40 |
private static final String BUILD_ROOT_TB = "buildRootToolProvider";
|
|
41 |
|
|
42 |
private static final String [] CMD = {
|
|
43 |
"--input", "input",
|
|
44 |
"--output", OUTPUT,
|
|
45 |
"--name", "test",
|
|
46 |
"--main-jar", "hello.jar",
|
|
47 |
"--main-class", "Hello",
|
|
48 |
};
|
|
49 |
|
|
50 |
private static final String [] CMD_BUILD_ROOT = {
|
|
51 |
"--input", "input",
|
|
52 |
"--output", OUTPUT,
|
|
53 |
"--name", "test",
|
|
54 |
"--main-jar", "hello.jar",
|
|
55 |
"--main-class", "Hello",
|
|
56 |
"--temp-root", "TBD"};
|
|
57 |
|
|
58 |
private static void validate(boolean retain) throws Exception {
|
|
59 |
File br = new File(buildRoot);
|
|
60 |
if (retain) {
|
|
61 |
if (!br.exists()) {
|
|
62 |
throw new AssertionError(br.getAbsolutePath() + " does not exist");
|
|
63 |
}
|
|
64 |
} else {
|
|
65 |
if (br.exists()) {
|
|
66 |
throw new AssertionError(br.getAbsolutePath() + " exist");
|
|
67 |
}
|
|
68 |
}
|
|
69 |
}
|
|
70 |
|
|
71 |
private static void init(boolean toolProvider) {
|
|
72 |
if (toolProvider) {
|
|
73 |
buildRoot = BUILD_ROOT_TB;
|
|
74 |
} else {
|
|
75 |
buildRoot = BUILD_ROOT;
|
|
76 |
}
|
|
77 |
|
|
78 |
CMD_BUILD_ROOT[CMD_BUILD_ROOT.length - 1] = buildRoot;
|
|
79 |
}
|
|
80 |
|
|
81 |
private static void testTempRoot() throws Exception {
|
|
82 |
init(false);
|
|
83 |
JPackageHelper.executeCLI(true, CMD);
|
|
84 |
validate(false);
|
|
85 |
JPackageHelper.deleteOutputFolder(OUTPUT);
|
|
86 |
JPackageHelper.executeCLI(true, CMD_BUILD_ROOT);
|
|
87 |
validate(true);
|
|
88 |
}
|
|
89 |
|
|
90 |
private static void testTempRootToolProvider() throws Exception {
|
|
91 |
init(true);
|
|
92 |
JPackageHelper.deleteOutputFolder(OUTPUT);
|
|
93 |
JPackageHelper.executeToolProvider(true, CMD);
|
|
94 |
validate(false);
|
|
95 |
JPackageHelper.deleteOutputFolder(OUTPUT);
|
|
96 |
JPackageHelper.executeToolProvider(true, CMD_BUILD_ROOT);
|
|
97 |
validate(true);
|
|
98 |
}
|
|
99 |
|
|
100 |
public static void main(String[] args) throws Exception {
|
|
101 |
JPackageHelper.createHelloImageJar();
|
|
102 |
testTempRoot();
|
|
103 |
testTempRootToolProvider();
|
|
104 |
}
|
|
105 |
|
|
106 |
}
|