test/jdk/tools/jpackager/Hello.java
author herrick
Thu, 08 Nov 2018 19:07:57 -0500
branchJDK-8200758-branch
changeset 57023 8bf89434f0a5
permissions -rw-r--r--
8213332: Create minimal automated tests for jpackager Submitten-by: almatvee Reviewed-by: herrick. kcr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
57023
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
     1
/*
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
     4
 *
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
     7
 * published by the Free Software Foundation.
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
     8
 *
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    13
 * accompanied this code).
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    14
 *
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    18
 *
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    21
 * questions.
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    22
 */
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    23
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    24
import java.io.BufferedWriter;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    25
import java.io.File;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    26
import java.io.FileWriter;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    27
import java.io.PrintWriter;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    28
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    29
public class Hello {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    30
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    31
    private static final String MSG = "jpackager test application";
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    32
    private static final int EXPECTED_NUM_OF_PARAMS = 3; // Starts at 1
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    33
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    34
    public static void main(String[] args) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    35
        String outputFile = "appOutput.txt";
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    36
        File file = new File(outputFile);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    37
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    38
        try (PrintWriter out =
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    39
                new PrintWriter(new BufferedWriter(new FileWriter(file)))) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    40
            System.out.println(MSG);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    41
            out.println(MSG);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    42
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    43
            System.out.println("args.length: " + args.length);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    44
            out.println("args.length: " + args.length);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    45
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    46
            for (String arg : args) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    47
                System.out.println(arg);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    48
                out.println(arg);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    49
            }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    50
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    51
            for (int index = 1; index <= EXPECTED_NUM_OF_PARAMS; index++) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    52
                String value = System.getProperty("param" + index);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    53
                if (value != null) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    54
                    System.out.println("-Dparam" + index + "=" + value);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    55
                    out.println("-Dparam" + index + "=" + value);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    56
                }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    57
            }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    58
        } catch (Exception ex) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    59
            System.err.println(ex.toString());
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    60
        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    61
    }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    62
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    63
}