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