test/jdk/tools/jpackage/createimage/JPackageCreateImageBuildRootTest.java
author herrick
Fri, 01 Mar 2019 08:27:51 -0500
branchJDK-8200758-branch
changeset 57241 e11f3bf34083
parent 57150 fa68c2ab636d
permissions -rw-r--r--
8219889: Update jpackage tests for JDK-8219678 changes Submitten-by: almatvee Reviewed-by: kbr, herrick
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
57031
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
     1
/*
57106
ea870b9ce89a 8216492: Update copyright of all new jpackage fils to 2019
kcr
parents: 57096
diff changeset
     2
 * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
57031
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
     4
 *
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
     8
 *
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    13
 * accompanied this code).
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    14
 *
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    18
 *
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    21
 * questions.
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    22
 */
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    23
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    24
import java.io.File;
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    25
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    26
 /*
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    27
 * @test
57077
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57039
diff changeset
    28
 * @requires (os.family == "windows")
57039
98d3963b0b7b 8214051: rename jpackager tool to jpackage
herrick
parents: 57031
diff changeset
    29
 * @summary jpackage create image to test --build-root
57031
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    30
 * @library ../helpers
57039
98d3963b0b7b 8214051: rename jpackager tool to jpackage
herrick
parents: 57031
diff changeset
    31
 * @build JPackageHelper
98d3963b0b7b 8214051: rename jpackager tool to jpackage
herrick
parents: 57031
diff changeset
    32
 * @build JPackagePath
98d3963b0b7b 8214051: rename jpackager tool to jpackage
herrick
parents: 57031
diff changeset
    33
 * @modules jdk.jpackage
98d3963b0b7b 8214051: rename jpackager tool to jpackage
herrick
parents: 57031
diff changeset
    34
 * @run main/othervm -Xmx512m JPackageCreateImageBuildRootTest
57031
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    35
 */
57039
98d3963b0b7b 8214051: rename jpackager tool to jpackage
herrick
parents: 57031
diff changeset
    36
public class JPackageCreateImageBuildRootTest {
57241
e11f3bf34083 8219889: Update jpackage tests for JDK-8219678 changes
herrick
parents: 57150
diff changeset
    37
    private static final String OUTPUT = "output";
57031
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    38
    private static String buildRoot = null;
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    39
    private static final String BUILD_ROOT = "buildRoot";
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    40
    private static final String BUILD_ROOT_TB = "buildRootToolProvider";
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    41
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    42
    private static final String [] CMD = {
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    43
        "create-image",
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    44
        "--input", "input",
57241
e11f3bf34083 8219889: Update jpackage tests for JDK-8219678 changes
herrick
parents: 57150
diff changeset
    45
        "--output", OUTPUT,
e11f3bf34083 8219889: Update jpackage tests for JDK-8219678 changes
herrick
parents: 57150
diff changeset
    46
        "--name", "test",
e11f3bf34083 8219889: Update jpackage tests for JDK-8219678 changes
herrick
parents: 57150
diff changeset
    47
        "--main-jar", "hello.jar",
e11f3bf34083 8219889: Update jpackage tests for JDK-8219678 changes
herrick
parents: 57150
diff changeset
    48
        "--main-class", "Hello",
e11f3bf34083 8219889: Update jpackage tests for JDK-8219678 changes
herrick
parents: 57150
diff changeset
    49
        "--files", "hello.jar" };
e11f3bf34083 8219889: Update jpackage tests for JDK-8219678 changes
herrick
parents: 57150
diff changeset
    50
e11f3bf34083 8219889: Update jpackage tests for JDK-8219678 changes
herrick
parents: 57150
diff changeset
    51
    private static final String [] CMD_BUILD_ROOT = {
e11f3bf34083 8219889: Update jpackage tests for JDK-8219678 changes
herrick
parents: 57150
diff changeset
    52
        "create-image",
e11f3bf34083 8219889: Update jpackage tests for JDK-8219678 changes
herrick
parents: 57150
diff changeset
    53
        "--input", "input",
e11f3bf34083 8219889: Update jpackage tests for JDK-8219678 changes
herrick
parents: 57150
diff changeset
    54
        "--output", OUTPUT,
57031
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    55
        "--name", "test",
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    56
        "--main-jar", "hello.jar",
57150
fa68c2ab636d 8217894: jpackage CLI syntax changes
herrick
parents: 57106
diff changeset
    57
        "--main-class", "Hello",
57031
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    58
        "--files", "hello.jar",
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    59
        "--build-root", "TBD"};
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    60
57096
d06bec27f8c9 8215903: modify behavior of retaining temporary output dir
herrick
parents: 57079
diff changeset
    61
    private static void validate(boolean retain) throws Exception {
57031
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    62
        File br = new File(buildRoot);
57096
d06bec27f8c9 8215903: modify behavior of retaining temporary output dir
herrick
parents: 57079
diff changeset
    63
        if (retain) {
57031
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    64
            if (!br.exists()) {
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    65
                throw new AssertionError(br.getAbsolutePath() + " does not exist");
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    66
            }
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    67
        } else {
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    68
            if (br.exists()) {
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    69
                throw new AssertionError(br.getAbsolutePath() + " exist");
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    70
            }
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    71
        }
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    72
    }
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    73
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    74
    private static void init(boolean toolProvider) {
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    75
        if (toolProvider) {
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    76
            buildRoot = BUILD_ROOT_TB;
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    77
        } else {
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    78
            buildRoot = BUILD_ROOT;
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    79
        }
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    80
57096
d06bec27f8c9 8215903: modify behavior of retaining temporary output dir
herrick
parents: 57079
diff changeset
    81
        CMD_BUILD_ROOT[CMD_BUILD_ROOT.length - 1] = buildRoot;
57031
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    82
    }
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    83
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    84
    private static void testBuildRoot() throws Exception {
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    85
        init(false);
57039
98d3963b0b7b 8214051: rename jpackager tool to jpackage
herrick
parents: 57031
diff changeset
    86
        JPackageHelper.executeCLI(true, CMD);
57031
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    87
        validate(false);
57241
e11f3bf34083 8219889: Update jpackage tests for JDK-8219678 changes
herrick
parents: 57150
diff changeset
    88
        JPackageHelper.deleteOutputFolder(OUTPUT);
57096
d06bec27f8c9 8215903: modify behavior of retaining temporary output dir
herrick
parents: 57079
diff changeset
    89
        JPackageHelper.executeCLI(true, CMD_BUILD_ROOT);
57031
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    90
        validate(true);
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    91
    }
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    92
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    93
    private static void testBuildRootToolProvider() throws Exception {
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    94
        init(true);
57241
e11f3bf34083 8219889: Update jpackage tests for JDK-8219678 changes
herrick
parents: 57150
diff changeset
    95
        JPackageHelper.deleteOutputFolder(OUTPUT);
57039
98d3963b0b7b 8214051: rename jpackager tool to jpackage
herrick
parents: 57031
diff changeset
    96
        JPackageHelper.executeToolProvider(true, CMD);
57031
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
    97
        validate(false);
57241
e11f3bf34083 8219889: Update jpackage tests for JDK-8219678 changes
herrick
parents: 57150
diff changeset
    98
        JPackageHelper.deleteOutputFolder(OUTPUT);
57096
d06bec27f8c9 8215903: modify behavior of retaining temporary output dir
herrick
parents: 57079
diff changeset
    99
        JPackageHelper.executeToolProvider(true, CMD_BUILD_ROOT);
57031
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
   100
        validate(true);
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
   101
    }
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
   102
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
   103
    public static void main(String[] args) throws Exception {
57079
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents: 57077
diff changeset
   104
        JPackageHelper.createHelloImageJar();
57031
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
   105
        testBuildRoot();
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
   106
        testBuildRootToolProvider();
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
   107
    }
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
   108
ea4755429ed8 8214021: Create additional automated tests for jpackager
herrick
parents:
diff changeset
   109
}