test/jdk/tools/jpackage/createinstaller/macosx/base/JPMacLicenseBase.java
branchJDK-8200758-branch
changeset 57438 4a31db8d42bd
parent 57414 6eda749d3117
equal deleted inserted replaced
57421:0410ee319681 57438:4a31db8d42bd
       
     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.io.File;
       
    25 import java.util.ArrayList;
       
    26 import java.util.List;
       
    27 
       
    28 public class JPMacLicenseBase {
       
    29 
       
    30     private static String TEST_NAME;
       
    31     private static String EXT;
       
    32     private static String OUTPUT;
       
    33     private static String[] CMD;
       
    34 
       
    35     private static void copyResults() throws Exception {
       
    36         List<String> files = new ArrayList<>();
       
    37         files.add(OUTPUT);
       
    38         JPackageInstallerHelper.copyTestResults(files);
       
    39     }
       
    40 
       
    41     private static void testCreateInstaller() throws Exception {
       
    42         JPackageHelper.executeCLI(true, CMD);
       
    43         JPackageInstallerHelper.validateOutput(OUTPUT);
       
    44         copyResults();
       
    45     }
       
    46 
       
    47     private static void verifyInstall() throws Exception {
       
    48         String app = JPackagePath.getOSXInstalledApp(TEST_NAME);
       
    49         JPackageInstallerHelper.validateApp(app);
       
    50 
       
    51     }
       
    52 
       
    53     private static void verifyUnInstall() throws Exception {
       
    54         // Not needed on OS X, since we just deleting installed application
       
    55         // without using generated installer. We keeping this for consistnency
       
    56         // between platforms.
       
    57     }
       
    58 
       
    59     private static void init(String name, String ext) {
       
    60         TEST_NAME = name;
       
    61         EXT = ext;
       
    62         OUTPUT = "output" + File.separator + TEST_NAME + "-1.0." + EXT;
       
    63         CMD = new String [] {
       
    64         "--package-type", EXT,
       
    65         "--input", "input",
       
    66         "--output", "output",
       
    67         "--name", TEST_NAME,
       
    68         "--main-jar", "hello.jar",
       
    69         "--main-class", "Hello",
       
    70         "--license-file", JPackagePath.getLicenseFilePath()};
       
    71     }
       
    72 
       
    73     public static void run(String name, String ext) throws Exception {
       
    74         init(name, ext);
       
    75 
       
    76         if (JPackageInstallerHelper.isVerifyInstall()) {
       
    77             verifyInstall();
       
    78         } else if (JPackageInstallerHelper.isVerifyUnInstall()) {
       
    79             verifyUnInstall();
       
    80         } else {
       
    81             JPackageHelper.createHelloInstallerJar();
       
    82             testCreateInstaller();
       
    83         }
       
    84     }
       
    85 }