test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageVerboseTest.java
author herrick
Tue, 09 Apr 2019 10:57:04 -0400
branchJDK-8200758-branch
changeset 57314 23da9e6f446f
parent 57307 4948a1944cf9
child 57414 6eda749d3117
permissions -rw-r--r--
8221641: Follow up code clean up for JDK-8221582 Reviewed-by: almatvee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
57307
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
     1
/*
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
     2
 * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
     4
 *
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
     7
 * published by the Free Software Foundation.
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
     8
 *
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    13
 * accompanied this code).
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    14
 *
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    18
 *
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    21
 * questions.
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    22
 */
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    23
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    24
/*
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    25
 * @test
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    26
 * @summary jpackage create image verbose test
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    27
 * @library ../helpers
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    28
 * @build JPackageHelper
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    29
 * @build JPackagePath
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    30
 * @modules jdk.jpackage
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    31
 * @run main/othervm -Xmx512m JPackageCreateAppImageVerboseTest
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    32
 */
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    33
public class JPackageCreateAppImageVerboseTest {
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    34
    private static final String OUTPUT = "output";
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    35
    private static final String[] CMD = {
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    36
        "create-app-image",
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    37
        "--input", "input",
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    38
        "--output", OUTPUT,
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    39
        "--name", "test",
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    40
        "--main-jar", "hello.jar",
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    41
        "--main-class", "Hello",
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    42
    };
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    43
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    44
    private static final String[] CMD_VERBOSE = {
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    45
        "create-app-image",
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    46
        "--input", "input",
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    47
        "--output", OUTPUT,
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    48
        "--name", "test",
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    49
        "--main-jar", "hello.jar",
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    50
        "--main-class", "Hello",
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    51
        "--verbose"};
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    52
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    53
    private static void validate(String result, String resultVerbose)
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    54
            throws Exception {
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    55
        String[] r = result.split("\n");
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    56
        String[] rv = resultVerbose.split("\n");
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    57
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    58
        if (r.length >= rv.length) {
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    59
            System.err.println("r.length: " + r.length);
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    60
            System.err.println(result);
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    61
            System.err.println("rv.length: " + rv.length);
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    62
            System.err.println(resultVerbose);
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    63
            throw new AssertionError(
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    64
                    "non-verbose output is less or equal to verbose output");
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    65
        }
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    66
    }
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    67
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    68
    private static void testCreateAppImage() throws Exception {
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    69
        String result = JPackageHelper.executeCLI(true, CMD);
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    70
        JPackageHelper.deleteOutputFolder(OUTPUT);
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    71
        String resultVerbose = JPackageHelper.executeCLI(true, CMD_VERBOSE);
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    72
        validate(result, resultVerbose);
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    73
    }
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    74
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    75
    private static void testCreateAppImageToolProvider() throws Exception {
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    76
        JPackageHelper.deleteOutputFolder(OUTPUT);
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    77
        String result = JPackageHelper.executeToolProvider(true, CMD);
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    78
        JPackageHelper.deleteOutputFolder(OUTPUT);
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    79
        String resultVerbose =
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    80
                JPackageHelper.executeToolProvider(true, CMD_VERBOSE);
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    81
        validate(result, resultVerbose);
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    82
    }
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    83
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    84
    public static void main(String[] args) throws Exception {
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    85
        JPackageHelper.createHelloImageJar();
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    86
        testCreateAppImage();
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    87
        testCreateAppImageToolProvider();
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    88
    }
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    89
4948a1944cf9 8221777: CLI changes from jpackage EA5 feedback
herrick
parents:
diff changeset
    90
}