Path: blob/master/test/jdk/tools/jpackage/share/MultiNameTwoPhaseTest.java
41149 views
/*1* Copyright (c) 2020, 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.io.IOException;25import jdk.jpackage.test.PackageTest;26import jdk.jpackage.test.PackageType;27import jdk.jpackage.test.TKit;28import jdk.jpackage.test.Annotations.Test;29import jdk.jpackage.test.Annotations.Parameter;30import jdk.jpackage.test.JPackageCommand;3132/**33* Test creation of packages in tho phases with different names.34* The first phase creates and app image, and the second phase uses that image.35* If the first phase has no --name, it will derive name from main-class.36* If the second phase has no --name, will derive it from the app-image content.37* The resulting name may differ, and all should still work38*/3940/*41* @test42* @summary Multiple names in two phases43* @library ../helpers44* @library /test/lib45* @key jpackagePlatformPackage46* @requires (jpackage.test.SQETest == null)47* @build jdk.jpackage.test.*48* @modules jdk.jpackage/jdk.jpackage.internal49* @compile MultiNameTwoPhaseTest.java50* @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main51* --jpt-run=MultiNameTwoPhaseTest52*/5354public class MultiNameTwoPhaseTest {5556@Test57@Parameter({"MultiNameTest", "MultiNameTest"})58@Parameter({"MultiNameTest", "MultiNameTestInstaller"})59@Parameter({"MultiNameTest", ""})60@Parameter({"", "MultiNameTestInstaller"})61@Parameter({"", ""})62public static void test(String... testArgs) throws IOException {63String appName = testArgs[0];64String installName = testArgs[1];6566Path appimageOutput = TKit.createTempDirectory("appimage");6768JPackageCommand appImageCmd = JPackageCommand.helloAppImage()69.setArgumentValue("--dest", appimageOutput)70.removeArgumentWithValue("--name");71if (!appName.isEmpty()) {72appImageCmd.addArguments("--name", appName);73}7475PackageTest packageTest = new PackageTest()76.addRunOnceInitializer(() -> appImageCmd.execute())77.addBundleDesktopIntegrationVerifier(true)78.addInitializer(cmd -> {79cmd.addArguments("--app-image", appImageCmd.outputBundle());80cmd.removeArgumentWithValue("--input");81cmd.removeArgumentWithValue("--name");82if (!installName.isEmpty()) {83cmd.addArguments("--name", installName);84}85})86.forTypes(PackageType.WINDOWS)87.addInitializer(cmd -> {88cmd.addArguments("--win-shortcut", "--win-menu",89"--win-menu-group", "MultiNameTwoPhaseTest");90})91.forTypes(PackageType.LINUX)92.addInitializer(cmd -> {93cmd.addArguments("--linux-shortcut");94});9596packageTest.run();97}98}99100101