test/jdk/tools/jpackage/share/AppImagePackageTest.java
branchJDK-8200758-branch
changeset 58301 e0efb29609bd
child 58415 73f8e557549a
equal deleted inserted replaced
58172:bf06a1d3aef6 58301:e0efb29609bd
       
     1 /*
       
     2  * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  */
       
    23 
       
    24 import java.nio.file.Path;
       
    25 import jdk.jpackage.test.Test;
       
    26 import jdk.jpackage.test.PackageTest;
       
    27 import jdk.jpackage.test.PackageType;
       
    28 import jdk.jpackage.test.JPackageCommand;
       
    29 
       
    30 /**
       
    31  * Test --app-image parameter. The output installer should provide the same
       
    32  * functionality as the default installer (see description of the default
       
    33  * installer in SimplePackageTest.java)
       
    34  */
       
    35 
       
    36 /*
       
    37  * @test
       
    38  * @summary jpackage with --app-image
       
    39  * @library ../helpers
       
    40  * @modules jdk.jpackage/jdk.jpackage.internal
       
    41  * @run main/othervm/timeout=360 -Xmx512m AppImagePackageTest
       
    42  */
       
    43 public class AppImagePackageTest {
       
    44 
       
    45     public static void main(String[] args) {
       
    46         Test.run(args, () -> {
       
    47             Path appimageOutput = Path.of("appimage");
       
    48 
       
    49             JPackageCommand appImageCmd = JPackageCommand.helloAppImage()
       
    50                     .setArgumentValue("--dest", appimageOutput)
       
    51                     .addArguments("--package-type", "app-image");
       
    52 
       
    53             PackageTest packageTest = new PackageTest();
       
    54             if (packageTest.getAction() == PackageTest.Action.CREATE) {
       
    55                 appImageCmd.execute();
       
    56             }
       
    57 
       
    58             packageTest.addInitializer(cmd -> {
       
    59                 Path appimageInput = appimageOutput.resolve(appImageCmd.name());
       
    60 
       
    61                 if (PackageType.MAC.contains(cmd.packageType())) {
       
    62                     // Why so complicated on macOS?
       
    63                     appimageInput = Path.of(appimageInput.toString() + ".app");
       
    64                     cmd.addArguments("--identifier", appImageCmd.name());
       
    65                 }
       
    66 
       
    67                 cmd.addArguments("--app-image", appimageInput);
       
    68                 cmd.removeArgument("--input");
       
    69             }).addBundleDesktopIntegrationVerifier(false).run();
       
    70         });
       
    71     }
       
    72 }