equal
deleted
inserted
replaced
29 import java.lang.invoke.MethodHandles; |
29 import java.lang.invoke.MethodHandles; |
30 import jdk.jpackage.test.HelloApp; |
30 import jdk.jpackage.test.HelloApp; |
31 import jdk.jpackage.test.PackageTest; |
31 import jdk.jpackage.test.PackageTest; |
32 import jdk.jpackage.test.PackageType; |
32 import jdk.jpackage.test.PackageType; |
33 import jdk.jpackage.test.FileAssociations; |
33 import jdk.jpackage.test.FileAssociations; |
34 import jdk.jpackage.test.Test; |
34 import jdk.jpackage.test.TKit; |
35 |
35 |
36 /** |
36 /** |
37 * Test --add-launcher parameter. Output of the test should be |
37 * Test --add-launcher parameter. Output of the test should be |
38 * additionallauncherstest*.* installer. The output installer should provide the |
38 * additionallauncherstest*.* installer. The output installer should provide the |
39 * same functionality as the default installer (see description of the default |
39 * same functionality as the default installer (see description of the default |
43 |
43 |
44 /* |
44 /* |
45 * @test |
45 * @test |
46 * @summary jpackage with --add-launcher |
46 * @summary jpackage with --add-launcher |
47 * @library ../helpers |
47 * @library ../helpers |
|
48 * @build jdk.jpackage.test.* |
48 * @modules jdk.jpackage/jdk.jpackage.internal |
49 * @modules jdk.jpackage/jdk.jpackage.internal |
49 * @run main/othervm/timeout=360 -Xmx512m AdditionalLaunchersTest |
50 * @run main/othervm/timeout=360 -Xmx512m AdditionalLaunchersTest |
50 */ |
51 */ |
51 public class AdditionalLaunchersTest { |
52 public class AdditionalLaunchersTest { |
52 |
53 |
53 public static void main(String[] args) { |
54 public static void main(String[] args) { |
54 Test.run(args, () -> { |
55 TKit.run(args, () -> { |
55 FileAssociations fa = new FileAssociations( |
56 FileAssociations fa = new FileAssociations( |
56 MethodHandles.lookup().lookupClass().getSimpleName()); |
57 MethodHandles.lookup().lookupClass().getSimpleName()); |
57 |
58 |
58 // Configure a bunch of additional launchers and also setup |
59 // Configure a bunch of additional launchers and also setup |
59 // file association to make sure it will be linked only to the main |
60 // file association to make sure it will be linked only to the main |
73 new AdditionalLauncher("foo").setArguments("yep!").applyTo(packageTest); |
74 new AdditionalLauncher("foo").setArguments("yep!").applyTo(packageTest); |
74 |
75 |
75 AdditionalLauncher barLauncher = new AdditionalLauncher("Bar").setArguments( |
76 AdditionalLauncher barLauncher = new AdditionalLauncher("Bar").setArguments( |
76 "one", "two", "three"); |
77 "one", "two", "three"); |
77 packageTest.forTypes(PackageType.LINUX).addInitializer(cmd -> { |
78 packageTest.forTypes(PackageType.LINUX).addInitializer(cmd -> { |
78 barLauncher.setIcon(Test.TEST_SRC_ROOT.resolve("apps/dukeplug.png")); |
79 barLauncher.setIcon(TKit.TEST_SRC_ROOT.resolve("apps/dukeplug.png")); |
79 }); |
80 }); |
80 barLauncher.applyTo(packageTest); |
81 barLauncher.applyTo(packageTest); |
81 |
82 |
82 packageTest.run(); |
83 packageTest.run(); |
83 }); |
84 }); |
107 icon = iconPath; |
108 icon = iconPath; |
108 return this; |
109 return this; |
109 } |
110 } |
110 |
111 |
111 void applyTo(PackageTest test) { |
112 void applyTo(PackageTest test) { |
112 final Path propsFile = Test.workDir().resolve(name + ".properties"); |
113 final Path propsFile = TKit.workDir().resolve(name + ".properties"); |
113 |
114 |
114 test.addInitializer(cmd -> { |
115 test.addInitializer(cmd -> { |
115 cmd.addArguments("--add-launcher", String.format("%s=%s", name, |
116 cmd.addArguments("--add-launcher", String.format("%s=%s", name, |
116 propsFile)); |
117 propsFile)); |
117 |
118 |
123 |
124 |
124 if (icon != null) { |
125 if (icon != null) { |
125 properties.put("icon", icon.toAbsolutePath().toString()); |
126 properties.put("icon", icon.toAbsolutePath().toString()); |
126 } |
127 } |
127 |
128 |
128 Test.createPropertiesFile(propsFile, properties); |
129 TKit.createPropertiesFile(propsFile, properties); |
129 }); |
130 }); |
130 test.addInstallVerifier(cmd -> { |
131 test.addInstallVerifier(cmd -> { |
131 Path launcherPath = replaceFileName( |
132 Path launcherPath = replaceFileName( |
132 cmd.launcherInstallationPath(), name); |
133 cmd.launcherInstallationPath(), name); |
133 |
134 |
134 Test.assertExecutableFileExists(launcherPath, true); |
135 TKit.assertExecutableFileExists(launcherPath); |
135 |
136 |
136 if (cmd.isFakeRuntimeInstalled(String.format( |
137 if (cmd.isFakeRuntimeInstalled(String.format( |
137 "Not running %s launcher", launcherPath))) { |
138 "Not running %s launcher", launcherPath))) { |
138 return; |
139 return; |
139 } |
140 } |
143 }); |
144 }); |
144 test.addUninstallVerifier(cmd -> { |
145 test.addUninstallVerifier(cmd -> { |
145 Path launcherPath = replaceFileName( |
146 Path launcherPath = replaceFileName( |
146 cmd.launcherInstallationPath(), name); |
147 cmd.launcherInstallationPath(), name); |
147 |
148 |
148 Test.assertExecutableFileExists(launcherPath, false); |
149 TKit.assertPathExists(launcherPath, false); |
149 }); |
150 }); |
150 } |
151 } |
151 |
152 |
152 private List<String> arguments; |
153 private List<String> arguments; |
153 private Path icon; |
154 private Path icon; |