Skip to content

Commit a1ed14f

Browse files
Add tests
1 parent abff73e commit a1ed14f

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PackageTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,6 @@ static void withFileAssociationsTestRuns(FileAssociations fa,
272272
PackageTest addHelloAppFileAssociationsVerifier(FileAssociations fa) {
273273
Objects.requireNonNull(fa);
274274

275-
// Setup test app to have valid jpackage command line before running the check.
276-
addHelloAppInitializer(null);
277-
278275
forTypes(LINUX, () -> {
279276
LinuxHelper.addFileAssociationsVerifier(this, fa);
280277
});
@@ -287,7 +284,7 @@ PackageTest addHelloAppFileAssociationsVerifier(FileAssociations fa) {
287284
}
288285

289286
addInstallVerifier(cmd -> {
290-
if (cmd.isFakeRuntime(noActionMsg) || cmd.isPackageUnpacked(noActionMsg)) {
287+
if (cmd.isPackageUnpacked(noActionMsg) || cmd.isFakeRuntime(noActionMsg)) {
291288
return;
292289
}
293290

test/jdk/tools/jpackage/share/FileAssociationsTest.java

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@
2525

2626
import java.nio.file.Path;
2727
import java.util.Map;
28+
import jdk.jpackage.test.AdditionalLauncher;
2829
import jdk.jpackage.test.Annotations.Parameter;
2930
import jdk.jpackage.test.Annotations.Test;
3031
import jdk.jpackage.test.FileAssociations;
3132
import jdk.jpackage.test.JPackageCommand;
3233
import jdk.jpackage.test.PackageTest;
3334
import jdk.jpackage.test.PackageType;
35+
import jdk.jpackage.test.RunnablePackageTest;
3436
import jdk.jpackage.test.TKit;
3537

3638
/**
@@ -85,7 +87,7 @@ public class FileAssociationsTest {
8587
@Parameter("true")
8688
@Parameter("false")
8789
public static void test(boolean includeDescription) {
88-
PackageTest packageTest = new PackageTest();
90+
PackageTest packageTest = new PackageTest().configureHelloApp();
8991

9092
// Not supported
9193
packageTest.excludeTypes(PackageType.MAC_DMG);
@@ -144,6 +146,34 @@ public static void testTooManyMimes() {
144146
}).run();
145147
}
146148

149+
@Test
150+
@Parameter("true")
151+
@Parameter("false")
152+
public static void testFromAppImage(boolean withAdditionalLauncher) {
153+
154+
var appImageCmd = JPackageCommand.helloAppImage();
155+
156+
if (RunnablePackageTest.hasAction(RunnablePackageTest.Action.INSTALL)) {
157+
// Ensure launchers are executable.
158+
appImageCmd.ignoreFakeRuntime();
159+
}
160+
161+
if (withAdditionalLauncher) {
162+
new AdditionalLauncher("foo").applyTo(appImageCmd);
163+
}
164+
165+
var test = new PackageTest().excludeTypes(PackageType.MAC_DMG)
166+
.addRunOnceInitializer(appImageCmd::execute)
167+
.addInitializer(cmd -> {
168+
cmd.removeArgumentWithValue("--input");
169+
cmd.setArgumentValue("--app-image", appImageCmd.outputBundle());
170+
});
171+
172+
new FileAssociations("jptest3").applyTo(test);
173+
174+
test.run();
175+
}
176+
147177
private static PackageTest initPackageTest() {
148178
return new PackageTest()
149179
.excludeTypes(PackageType.MAC)

0 commit comments

Comments
 (0)