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 jdk.jpackage.test.PackageTest;
  25 import jdk.jpackage.test.PackageType;
  26 
  27 
  28 /**
  29  * Test --linux-package-deps parameter. Output of the test should be
  30  * apackagedepstestprereq_1.0-1_amd64.deb and packagedepstest_1.0-1_amd64.deb or
  31  * apackagedepstestprereq-1.0-1.amd64.rpm and packagedepstest-1.0-1.amd64.rpm
  32  * package bundles. The output packages should provide the same functionality as
  33  * the default package.
  34  *
  35  * deb: Value of Depends property of packagedepstest package should contain
  36  * apackagedepstestprereq word.
  37  *
  38  * rpm: Value of Requires property of packagedepstest package should contain
  39  * apackagedepstestprereq word.
  40  */
  41 
  42 
  43 /*
  44  * @test
  45  * @summary jpackage with --linux-package-deps
  46  * @library ../helpers
  47  * @requires (os.family == "linux")
  48  * @modules jdk.jpackage/jdk.jpackage.internal
  49  * @run main/othervm/timeout=360 -Xmx512m PackageDepsTest
  50  */
  51 public class PackageDepsTest {
  52 
  53     // Pick the name of prerequisite package to be alphabetically
  54     // preceeding the main package name.
  55     // This is needed to make Bash script batch installing/uninstalling packages
  56     // produced by jtreg tests install/uninstall packages in the right order.
  57     static class APackageDepsTestPrereq {
  58 
  59         public static void main(String[] args) throws Exception {
  60             new PackageTest().forTypes(PackageType.LINUX).configureHelloApp().run();
  61         }
  62     }
  63 
  64     public static void main(String[] args) throws Exception {
  65         final String PREREQ_PACKAGE_NAME = "apackagedepstestprereq";
  66 
  67         APackageDepsTestPrereq.main(args);
  68 
  69         new PackageTest()
  70         .forTypes(PackageType.LINUX)
  71         .configureHelloApp()
  72         .addInitializer(cmd -> {
  73             cmd.addArguments("--linux-package-deps", PREREQ_PACKAGE_NAME);
  74         })
  75         .forTypes(PackageType.LINUX_DEB)
  76         .addBundlePropertyVerifier("Depends", PREREQ_PACKAGE_NAME)
  77         .forTypes(PackageType.LINUX_RPM)
  78         .addBundlePropertyVerifier("Requires", PREREQ_PACKAGE_NAME)
  79         .run();
  80     }
  81 }