author | kcr |
Thu, 10 Jan 2019 11:30:09 -0800 | |
branch | JDK-8200758-branch |
changeset 57106 | ea870b9ce89a |
parent 57079 | c53a2eca0f57 |
child 57150 | fa68c2ab636d |
permissions | -rw-r--r-- |
57079
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
1 |
/* |
57106
ea870b9ce89a
8216492: Update copyright of all new jpackage fils to 2019
kcr
parents:
57079
diff
changeset
|
2 |
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. |
57079
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
4 |
* |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
8 |
* |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
13 |
* accompanied this code). |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
14 |
* |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
18 |
* |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
21 |
* questions. |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
22 |
*/ |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
23 |
|
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
24 |
import java.io.File; |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
25 |
import java.util.ArrayList; |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
26 |
import java.util.List; |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
27 |
|
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
28 |
public class JPackageCreateInstallerBase { |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
29 |
|
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
30 |
private static String TEST_NAME; |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
31 |
private static String EXT; |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
32 |
private static String OUTPUT; |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
33 |
private static String[] CMD; |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
34 |
|
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
35 |
private static void copyResults() throws Exception { |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
36 |
List<String> files = new ArrayList<>(); |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
37 |
files.add(OUTPUT); |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
38 |
JPackageInstallerHelper.copyTestResults(files); |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
39 |
} |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
40 |
|
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
41 |
private static void testCreateInstaller() throws Exception { |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
42 |
JPackageHelper.executeCLI(true, CMD); |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
43 |
JPackageInstallerHelper.validateOutput(OUTPUT); |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
44 |
copyResults(); |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
45 |
} |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
46 |
|
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
47 |
private static void verifyInstall() throws Exception { |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
48 |
String app = JPackagePath.getOSXInstalledApp(TEST_NAME); |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
49 |
JPackageInstallerHelper.validateApp(app); |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
50 |
} |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
51 |
|
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
52 |
private static void verifyUnInstall() throws Exception { |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
53 |
// Not needed on OS X, since we just deleting installed application |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
54 |
// without using generated installer. We keeping this for consistnency |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
55 |
// between platforms. |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
56 |
} |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
57 |
|
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
58 |
private static void init(String name, String ext) { |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
59 |
TEST_NAME = name; |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
60 |
EXT = ext; |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
61 |
OUTPUT = "output" + File.separator + TEST_NAME + "-1.0." + EXT; |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
62 |
CMD = new String[]{ |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
63 |
"create-installer", |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
64 |
EXT, |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
65 |
"--input", "input", |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
66 |
"--output", "output", |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
67 |
"--name", TEST_NAME, |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
68 |
"--main-jar", "hello.jar", |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
69 |
"--class", "Hello", |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
70 |
"--force", |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
71 |
"--files", "hello.jar"}; |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
72 |
} |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
73 |
|
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
74 |
public static void run(String name, String ext) throws Exception { |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
75 |
init(name, ext); |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
76 |
|
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
77 |
if (JPackageInstallerHelper.isVerifyInstall()) { |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
78 |
verifyInstall(); |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
79 |
} else if (JPackageInstallerHelper.isVerifyUnInstall()) { |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
80 |
verifyUnInstall(); |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
81 |
} else { |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
82 |
JPackageHelper.createHelloInstallerJar(); |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
83 |
testCreateInstaller(); |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
84 |
} |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
85 |
} |
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff
changeset
|
86 |
} |