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 import java.nio.file.Files;
26
27 /*
28 * @test
29 * @summary jpackage create image to verify --icon
30 * @library ../helpers
31 * @build JPackageHelper
32 * @build JPackagePath
33 * @modules jdk.jpackage
34 * @run main/othervm -Xmx512m JPackageCreateImageIconTest
35 */
36 public class JPackageCreateImageIconTest {
37 private static final String app = JPackagePath.getApp();
38 private static final String appOutput = JPackagePath.getAppOutputFile();
39 private static final String appWorkingDir = JPackagePath.getAppWorkingDir();
40
41 private static final String[] CMD = {
42 "create-image",
43 "--input", "input",
44 "--name", "test",
45 "--main-jar", "hello.jar",
46 "--main-class", "Hello",
47 "--overwrite",
48 "--files", "hello.jar",
49 "--icon", getIconPath(),
50 "--output", "output"};
51
52 private static void validateResult(String[] result) throws Exception {
53 if (result.length != 2) {
54 throw new AssertionError(
55 "Unexpected number of lines: " + result.length);
56 }
57
58 if (!result[0].trim().equals("jpackage test application")) {
59 throw new AssertionError("Unexpected result[0]: " + result[0]);
60 }
61
62 if (!result[1].trim().equals("args.length: 0")) {
63 throw new AssertionError("Unexpected result[1]: " + result[1]);
64 }
65 }
66
67 private static void validate() throws Exception {
68 int retVal = JPackageHelper.execute(null, app);
69 if (retVal != 0) {
70 throw new AssertionError(
81 validateResult(result);
82 }
83
84 private static void validateIcon() throws Exception {
85 File origIcon = new File(getIconPath());
86 File icon = new File(JPackagePath.getAppIcon());
87 if (origIcon.length() != icon.length()) {
88 System.err.println("origIcon.length(): " + origIcon.length());
89 System.err.println("icon.length(): " + icon.length());
90 throw new AssertionError("Icons size does not match");
91 }
92 }
93
94 private static void testIcon() throws Exception {
95 JPackageHelper.executeCLI(true, CMD);
96 validate();
97 validateIcon();
98 }
99
100 private static void testIconToolProvider() throws Exception {
101 JPackageHelper.executeToolProvider(true, CMD);
102 validate();
103 validateIcon();
104 }
105
106 private static String getIconPath() {
107 String ext = ".ico";
108 if (JPackageHelper.isOSX()) {
109 ext = ".icns";
110 } else if (JPackageHelper.isLinux()) {
111 ext = ".png";
112 }
113
114 String path = JPackagePath.getTestSrcRoot() + File.separator + "resources"
115 + File.separator + "icon" + ext;
116
117 return path;
118 }
119
120 public static void main(String[] args) throws Exception {
|
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 import java.nio.file.Files;
26
27 /*
28 * @test
29 * @summary jpackage create image to verify --icon
30 * @library ../helpers
31 * @build JPackageHelper
32 * @build JPackagePath
33 * @modules jdk.jpackage
34 * @run main/othervm -Xmx512m JPackageCreateImageIconTest
35 */
36 public class JPackageCreateImageIconTest {
37 private static final String OUTPUT = "output";
38 private static final String app = JPackagePath.getApp();
39 private static final String appOutput = JPackagePath.getAppOutputFile();
40 private static final String appWorkingDir = JPackagePath.getAppWorkingDir();
41
42 private static final String[] CMD = {
43 "create-image",
44 "--input", "input",
45 "--name", "test",
46 "--main-jar", "hello.jar",
47 "--main-class", "Hello",
48 "--files", "hello.jar",
49 "--icon", getIconPath(),
50 "--output", OUTPUT};
51
52 private static void validateResult(String[] result) throws Exception {
53 if (result.length != 2) {
54 throw new AssertionError(
55 "Unexpected number of lines: " + result.length);
56 }
57
58 if (!result[0].trim().equals("jpackage test application")) {
59 throw new AssertionError("Unexpected result[0]: " + result[0]);
60 }
61
62 if (!result[1].trim().equals("args.length: 0")) {
63 throw new AssertionError("Unexpected result[1]: " + result[1]);
64 }
65 }
66
67 private static void validate() throws Exception {
68 int retVal = JPackageHelper.execute(null, app);
69 if (retVal != 0) {
70 throw new AssertionError(
81 validateResult(result);
82 }
83
84 private static void validateIcon() throws Exception {
85 File origIcon = new File(getIconPath());
86 File icon = new File(JPackagePath.getAppIcon());
87 if (origIcon.length() != icon.length()) {
88 System.err.println("origIcon.length(): " + origIcon.length());
89 System.err.println("icon.length(): " + icon.length());
90 throw new AssertionError("Icons size does not match");
91 }
92 }
93
94 private static void testIcon() throws Exception {
95 JPackageHelper.executeCLI(true, CMD);
96 validate();
97 validateIcon();
98 }
99
100 private static void testIconToolProvider() throws Exception {
101 JPackageHelper.deleteOutputFolder(OUTPUT);
102 JPackageHelper.executeToolProvider(true, CMD);
103 validate();
104 validateIcon();
105 }
106
107 private static String getIconPath() {
108 String ext = ".ico";
109 if (JPackageHelper.isOSX()) {
110 ext = ".icns";
111 } else if (JPackageHelper.isLinux()) {
112 ext = ".png";
113 }
114
115 String path = JPackagePath.getTestSrcRoot() + File.separator + "resources"
116 + File.separator + "icon" + ext;
117
118 return path;
119 }
120
121 public static void main(String[] args) throws Exception {
|