Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@

import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -194,8 +195,14 @@ private static ApplicationLaunchers createLaunchers(
// mainParams), APP_NAME.fetchFrom(launcherParams)));
launcherParams.put(DESCRIPTION.getID(), DESCRIPTION.fetchFrom(mainParams));
}
return AddLauncherArguments.merge(mainParams, launcherParams, ICON.getID(), ADD_LAUNCHERS
.getID(), FILE_ASSOCIATIONS.getID());

var excludes = new ArrayList<String>(List.of(ICON.getID(), ADD_LAUNCHERS.getID()));
if (!NAME.findIn(mainParams).equals(NAME.findIn(launcherParams))) {
// This is the additional launcher. It shouldn't have FA.
excludes.add(FILE_ASSOCIATIONS.getID());
}

return AddLauncherArguments.merge(mainParams, launcherParams, excludes.toArray(String[]::new));
}

static final BundlerParamInfo<Application> APPLICATION = createApplicationBundlerParam(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,6 @@ static void withFileAssociationsTestRuns(FileAssociations fa,
PackageTest addHelloAppFileAssociationsVerifier(FileAssociations fa) {
Objects.requireNonNull(fa);

// Setup test app to have valid jpackage command line before running the check.
addHelloAppInitializer(null);

forTypes(LINUX, () -> {
LinuxHelper.addFileAssociationsVerifier(this, fa);
});
Expand Down
34 changes: 32 additions & 2 deletions test/jdk/tools/jpackage/share/FileAssociationsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@

import java.nio.file.Path;
import java.util.Map;
import jdk.jpackage.test.AdditionalLauncher;
import jdk.jpackage.test.Annotations.Parameter;
import jdk.jpackage.test.Annotations.Test;
import jdk.jpackage.test.FileAssociations;
import jdk.jpackage.test.JPackageCommand;
import jdk.jpackage.test.PackageTest;
import jdk.jpackage.test.PackageType;
import jdk.jpackage.test.RunnablePackageTest;
import jdk.jpackage.test.TKit;

/**
Expand Down Expand Up @@ -64,7 +66,7 @@
* @requires jpackage.test.SQETest == null
* @build jdk.jpackage.test.*
* @compile -Xlint:all -Werror FileAssociationsTest.java
* @run main/othervm/timeout=540 -Xmx512m jdk.jpackage.test.Main
* @run main/othervm/timeout=1080 -Xmx512m jdk.jpackage.test.Main
* --jpt-run=FileAssociationsTest
*/

Expand All @@ -85,7 +87,7 @@ public class FileAssociationsTest {
@Parameter("true")
@Parameter("false")
public static void test(boolean includeDescription) {
PackageTest packageTest = new PackageTest();
PackageTest packageTest = new PackageTest().configureHelloApp();

// Not supported
packageTest.excludeTypes(PackageType.MAC_DMG);
Expand Down Expand Up @@ -144,6 +146,34 @@ public static void testTooManyMimes() {
}).run();
}

@Test
@Parameter("true")
@Parameter("false")
public static void testFromAppImage(boolean withAdditionalLauncher) {

var appImageCmd = JPackageCommand.helloAppImage();

if (RunnablePackageTest.hasAction(RunnablePackageTest.Action.INSTALL)) {
// Ensure launchers are executable.
appImageCmd.ignoreFakeRuntime();
}

if (withAdditionalLauncher) {
new AdditionalLauncher("foo").applyTo(appImageCmd);
}

var test = new PackageTest().excludeTypes(PackageType.MAC_DMG)
.addRunOnceInitializer(appImageCmd::execute)
.addInitializer(cmd -> {
cmd.removeArgumentWithValue("--input");
cmd.setArgumentValue("--app-image", appImageCmd.outputBundle());
});

new FileAssociations("jptest3").applyTo(test);

test.run();
}

private static PackageTest initPackageTest() {
return new PackageTest()
.excludeTypes(PackageType.MAC)
Expand Down