test/jdk/tools/jpackage/macosx/MacPropertiesTest.java
branchJDK-8200758-branch
changeset 58648 3bf53ffa9ae7
child 58994 b09ba68c6a19
equal deleted inserted replaced
58647:2c43b89b1679 58648:3bf53ffa9ae7
       
     1 /*
       
     2  * Copyright (c) 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 jdk.jpackage.test.TKit;
       
    25 import jdk.jpackage.test.MacHelper;
       
    26 import jdk.jpackage.test.JPackageCommand;
       
    27 import jdk.jpackage.test.Annotations.Test;
       
    28 import jdk.jpackage.test.Annotations.Parameter;
       
    29 
       
    30 
       
    31 /**
       
    32  * Test --mac-package-name, --mac-package-identifier parameters.
       
    33  */
       
    34 
       
    35 /*
       
    36  * @test
       
    37  * @summary jpackage with --mac-package-name, --mac-package-identifier
       
    38  * @library ../helpers
       
    39  * @build jdk.jpackage.test.*
       
    40  * @requires (os.family == "mac")
       
    41  * @modules jdk.jpackage/jdk.jpackage.internal
       
    42  * @compile MacPropertiesTest.java
       
    43  * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main
       
    44  *  --jpt-run=MacPropertiesTest
       
    45  */
       
    46 public class MacPropertiesTest {
       
    47     @Test
       
    48     @Parameter("MacPackageNameTest")
       
    49     public void testPackageName(String packageName) {
       
    50         testParameterInAppImage("--mac-package-name", "CFBundleName",
       
    51                 packageName);
       
    52     }
       
    53 
       
    54     @Test
       
    55     @Parameter("Foo")
       
    56     public void testPackageIdetifier(String packageId) {
       
    57         testParameterInAppImage("--mac-package-identifier", "CFBundleIdentifier",
       
    58                 packageId);
       
    59     }
       
    60 
       
    61     private static void testParameterInAppImage(String jpackageParameterName,
       
    62             String plistKeyName, String value) {
       
    63         JPackageCommand cmd = JPackageCommand.helloAppImage()
       
    64                 .addArguments(jpackageParameterName, value);
       
    65 
       
    66         cmd.executeAndAssertHelloAppImageCreated();
       
    67 
       
    68         var plist = MacHelper.readPListFromAppImage(cmd.outputBundle());
       
    69 
       
    70         TKit.assertEquals(value, plist.queryValue(plistKeyName), String.format(
       
    71                 "Check value of %s plist key", plistKeyName));
       
    72     }
       
    73 }