Path: blob/master/test/jdk/tools/jpackage/share/AppImagePackageTest.java
41149 views
/*1* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import java.nio.file.Path;24import java.nio.file.Files;25import java.io.IOException;26import java.util.List;27import jdk.jpackage.test.Annotations.Parameter;28import jdk.jpackage.test.TKit;29import jdk.jpackage.test.JPackageCommand;30import jdk.jpackage.test.PackageTest;31import jdk.jpackage.test.RunnablePackageTest.Action;32import jdk.jpackage.test.Annotations.Test;3334/**35* Test --app-image parameter. The output installer should provide the same36* functionality as the default installer (see description of the default37* installer in SimplePackageTest.java)38*/3940/*41* @test42* @summary jpackage with --app-image43* @key jpackagePlatformPackage44* @library ../helpers45* @requires (jpackage.test.SQETest == null)46* @build jdk.jpackage.test.*47* @modules jdk.jpackage/jdk.jpackage.internal48* @compile AppImagePackageTest.java49* @run main/othervm/timeout=540 -Xmx512m jdk.jpackage.test.Main50* --jpt-run=AppImagePackageTest51*/52public class AppImagePackageTest {5354@Test55public static void test() {56Path appimageOutput = TKit.workDir().resolve("appimage");5758JPackageCommand appImageCmd = JPackageCommand.helloAppImage()59.setArgumentValue("--dest", appimageOutput);6061new PackageTest()62.addRunOnceInitializer(() -> appImageCmd.execute())63.addInitializer(cmd -> {64cmd.addArguments("--app-image", appImageCmd.outputBundle());65cmd.removeArgumentWithValue("--input");66}).addBundleDesktopIntegrationVerifier(false).run();67}6869@Test70@Parameter("true")71@Parameter("false")72public static void testEmpty(boolean withIcon) throws IOException {73final String name = "EmptyAppImagePackageTest";74final String imageName = name + (TKit.isOSX() ? ".app" : "");75Path appImageDir = TKit.createTempDirectory(null).resolve(imageName);7677Files.createDirectories(appImageDir.resolve("bin"));78Path libDir = Files.createDirectories(appImageDir.resolve("lib"));79TKit.createTextFile(libDir.resolve("README"),80List.of("This is some arbitrary text for the README file\n"));8182new PackageTest()83.addInitializer(cmd -> {84cmd.addArguments("--app-image", appImageDir);85if (withIcon) {86cmd.addArguments("--icon", iconPath("icon"));87}88cmd.removeArgumentWithValue("--input");8990// on mac, with --app-image and without --mac-package-identifier,91// will try to infer it from the image, so foreign image needs it.92if (TKit.isOSX()) {93cmd.addArguments("--mac-package-identifier", name);94}95}).run(Action.CREATE, Action.UNPACK);96// default: {CREATE, UNPACK, VERIFY}, but we can't verify foreign image97}9899private static Path iconPath(String name) {100return TKit.TEST_SRC_ROOT.resolve(Path.of("resources", name101+ TKit.ICON_SUFFIX));102}103}104105106