Path: blob/master/test/jdk/tools/jpackage/macosx/MacAppStoreRuntimeTest.java
66644 views
/*1* Copyright (c) 2022, 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.Files;24import java.nio.file.Path;25import java.io.IOException;26import java.util.ArrayList;27import java.util.List;2829import jdk.jpackage.test.JPackageCommand;30import jdk.jpackage.test.Executor;31import jdk.jpackage.test.TKit;32import jdk.jpackage.test.JavaTool;33import jdk.jpackage.test.Annotations.Test;34import jdk.jpackage.test.Annotations.Parameter;353637/**38* Tests generation of app image with --mac-app-store and --runtime-image. jpackage should able39* to generate app image if runtime image does not have "bin" folder and fail otherwise.40*/4142/*43* @test44* @summary jpackage with --mac-app-store and --runtime-image45* @library ../helpers46* @library /test/lib47* @build jdk.jpackage.test.*48* @build MacAppStoreRuntimeTest49* @modules jdk.jpackage/jdk.jpackage.internal50* @requires (os.family == "mac")51* @run main/othervm -Xmx512m jdk.jpackage.test.Main52* --jpt-run=MacAppStoreRuntimeTest53*/54public class MacAppStoreRuntimeTest {5556private static String getRuntimeImage(boolean stripNativeCommands) throws IOException {57final Path workDir = TKit.createTempDirectory("runtime").resolve("data");58final Path jlinkOutputDir = workDir.resolve("temp.runtime");59Files.createDirectories(jlinkOutputDir.getParent());6061// List of modules required for test app.62final var modules = new String[] {63"java.base",64"java.desktop"65};6667List<String> jlinkArgs = new ArrayList<>();68jlinkArgs.add("--output");69jlinkArgs.add(jlinkOutputDir.toString());70jlinkArgs.add("--add-modules");71jlinkArgs.add(String.join(",", modules));72jlinkArgs.add("--strip-debug");73jlinkArgs.add("--no-header-files");74jlinkArgs.add("--no-man-pages");75if (stripNativeCommands) {76jlinkArgs.add("--strip-native-commands");77}7879new Executor()80.setToolProvider(JavaTool.JLINK)81.dumpOutput()82.addArguments(jlinkArgs)83.execute();8485return jlinkOutputDir.toString();86}8788@Test89@Parameter("true")90@Parameter("false")91public static void test(boolean stripNativeCommands) throws Exception {92JPackageCommand cmd = JPackageCommand.helloAppImage();93cmd.addArguments("--mac-app-store", "--runtime-image", getRuntimeImage(stripNativeCommands));9495if (stripNativeCommands) {96cmd.executeAndAssertHelloAppImageCreated();97} else {98cmd.execute(1);99}100}101}102103104