test/jdk/tools/jpackage/linux/AppCategoryTest.java
branchJDK-8200758-branch
changeset 58036 f7f10023f7c0
child 58113 885b0543f6e4
equal deleted inserted replaced
57951:37e70d4679df 58036:f7f10023f7c0
       
     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.LinuxHelper;
       
    25 import jdk.jpackage.test.PackageTest;
       
    26 import jdk.jpackage.test.PackageType;
       
    27 import jdk.jpackage.test.Test;
       
    28 
       
    29 
       
    30 /**
       
    31  * Test --linux-app-category parameter. Output of the test should be
       
    32  * appcategorytest_1.0-1_amd64.deb or appcategorytest-1.0-1.amd64.rpm package
       
    33  * bundle. The output package should provide the same functionality as the
       
    34  * default package.
       
    35  *
       
    36  * deb:
       
    37  * Section property of the package should be set to Foo value.
       
    38  *
       
    39  * rpm:
       
    40  * Group property of the package should be set to Foo value.
       
    41  */
       
    42 
       
    43 
       
    44 /*
       
    45  * @test
       
    46  * @summary jpackage with --linux-app-category
       
    47  * @library ../helpers
       
    48  * @requires (os.family == "linux")
       
    49  * @modules jdk.jpackage/jdk.jpackage.internal
       
    50  * @run main/othervm/timeout=360 -Xmx512m AppCategoryTest
       
    51  */
       
    52 public class AppCategoryTest {
       
    53 
       
    54     public static void main(String[] args) throws Exception {
       
    55         final String CATEGORY = "Foo";
       
    56 
       
    57         new PackageTest().configureHelloApp().addInitializer(cmd -> {
       
    58             cmd.addArguments("--linux-app-category", CATEGORY);
       
    59         }).addBundleVerifier(cmd -> {
       
    60             final String field = "Section";
       
    61             String value = LinuxHelper.getDebBundleProperty(
       
    62                     cmd.outputBundle(), field);
       
    63             Test.assertEquals(CATEGORY, value,
       
    64                     String.format("Check value of %s field is [%s]",
       
    65                             field, CATEGORY));
       
    66         }, PackageType.LINUX_DEB).addBundleVerifier(cmd -> {
       
    67             final String field = "Group";
       
    68             String value = LinuxHelper.geRpmBundleProperty(
       
    69                     cmd.outputBundle(), field);
       
    70             Test.assertEquals(CATEGORY, value,
       
    71                     String.format("Check value of %s field is [%s]",
       
    72                             field, CATEGORY));
       
    73         }, PackageType.LINUX_RPM).run();
       
    74     }
       
    75 }