test/jdk/tools/jpackager/JPackagerHelper.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.File;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    25
import java.io.PrintWriter;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    26
import java.io.StringWriter;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    27
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    28
import java.nio.file.Files;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    29
import java.nio.file.Path;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    30
import java.util.List;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    31
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    32
import java.util.spi.ToolProvider;
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 class JPackagerHelper {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    35
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    36
    private static final boolean VERBOSE = false;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    37
    private static final String OS =
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    38
            System.getProperty("os.name").toLowerCase();
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    39
    private static final String JAVA_HOME = System.getProperty("java.home");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    40
    private static final String TEST_SRC = System.getProperty("test.src");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    41
    private static final Path BIN_DIR = Path.of(JAVA_HOME, "bin");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    42
    private static final Path JPACKAGER;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    43
    private static final Path JAVAC;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    44
    private static final Path JAR;
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
    static {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    47
        if (OS.startsWith("win")) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    48
            JPACKAGER = BIN_DIR.resolve("jpackager.exe");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    49
            JAVAC = BIN_DIR.resolve("javac.exe");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    50
            JAR = BIN_DIR.resolve("jar.exe");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    51
        } else {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    52
            JPACKAGER = BIN_DIR.resolve("jpackager");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    53
            JAVAC = BIN_DIR.resolve("javac");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    54
            JAR = BIN_DIR.resolve("jar");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    55
        }
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
    static final ToolProvider JPACKAGER_TOOL =
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    59
            ToolProvider.findFirst("jpackager").orElseThrow(
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    60
            () -> new RuntimeException("jpackager tool not found"));
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
    public static int execute(File out, String... command) throws Exception {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    63
        if (VERBOSE) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    64
            System.out.print("Execute command: ");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    65
            for (String c : command) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    66
                System.out.print(c);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    67
                System.out.print(" ");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    68
            }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    69
            System.out.println();
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    70
        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    71
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    72
        ProcessBuilder builder = new ProcessBuilder(command);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    73
        if (out != null) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    74
            builder.redirectErrorStream(true);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    75
            builder.redirectOutput(out);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    76
        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    77
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    78
        Process process = builder.start();
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    79
        return process.waitFor();
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    80
    }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    81
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    82
    private static String[] getCommand(String... args) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    83
        String[] command;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    84
        if (args == null) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    85
            command = new String[1];
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    86
        } else {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    87
            command = new String[args.length + 1];
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    88
        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    89
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    90
        int index = 0;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    91
        command[index] = JPACKAGER.toString();
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    92
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    93
        if (args != null) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    94
            for (String arg : args) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    95
                index++;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    96
                command[index] = arg;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    97
            }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    98
        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    99
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   100
        return command;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   101
    }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   102
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   103
    public static String executeCLI(boolean retValZero, String... args)
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   104
            throws Exception {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   105
        int retVal;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   106
        File outfile = new File("output.log");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   107
        try {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   108
            String[] command = getCommand(args);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   109
            retVal = execute(outfile, command);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   110
        } catch (Exception ex) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   111
            if (outfile.exists()) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   112
                System.err.println(Files.readString(outfile.toPath()));
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   113
            }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   114
            throw ex;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   115
        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   116
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   117
        String output = Files.readString(outfile.toPath());
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   118
        if (retValZero) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   119
            if (retVal != 0) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   120
                System.err.println(output);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   121
                throw new AssertionError("jpackager exited with error: "
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   122
                        + retVal);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   123
            }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   124
        } else {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   125
            if (retVal == 0) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   126
                System.err.println(output);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   127
                throw new AssertionError("jpackager exited without error: "
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   128
                        + retVal);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   129
            }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   130
        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   131
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   132
        if (VERBOSE) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   133
            System.out.println("output =");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   134
            System.out.println(output);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   135
        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   136
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   137
        return output;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   138
    }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   139
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   140
    public static String executeToolProvider(
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   141
           boolean retValZero, String... args) throws Exception {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   142
        StringWriter writer = new StringWriter();
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   143
        PrintWriter pw = new PrintWriter(writer);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   144
        int retVal = JPACKAGER_TOOL.run(pw, pw, args);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   145
        String output = writer.toString();
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   146
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   147
        if (retValZero) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   148
            if (retVal != 0) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   149
                System.err.println(output);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   150
                throw new AssertionError("jpackager exited with error: "
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   151
                        + retVal);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   152
            }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   153
        } else {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   154
            if (retVal == 0) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   155
                System.err.println(output);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   156
                throw new AssertionError("jpackager exited without error");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   157
            }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   158
        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   159
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   160
        if (VERBOSE) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   161
            System.out.println("output =");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   162
            System.out.println(output);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   163
        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   164
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   165
        return output;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   166
    }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   167
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   168
    public static boolean isWindows() {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   169
        return (OS.contains("win"));
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   170
    }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   171
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   172
    public static boolean isOSX() {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   173
        return (OS.contains("mac"));
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   174
    }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   175
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   176
    public static boolean isLinux() {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   177
        return ((OS.contains("nix") || OS.contains("nux")));
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   178
    }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   179
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   180
    public static void createHelloJar() throws Exception {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   181
        int retVal;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   182
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   183
        File input = new File("input");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   184
        if (!input.exists()) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   185
            input.mkdir();
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   186
        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   187
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   188
        Files.copy(Path.of(TEST_SRC + File.separator + "Hello.java"),
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   189
                Path.of("Hello.java"));
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   190
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   191
        File javacLog = new File("javac.log");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   192
        try {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   193
            retVal = execute(javacLog, JAVAC.toString(), "Hello.java");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   194
        } catch (Exception ex) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   195
            if (javacLog.exists()) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   196
                System.err.println(Files.readString(javacLog.toPath()));
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   197
            }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   198
            throw ex;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   199
        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   200
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   201
        if (retVal != 0) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   202
            if (javacLog.exists()) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   203
                System.err.println(Files.readString(javacLog.toPath()));
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   204
            }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   205
            throw new AssertionError("javac exited with error: " + retVal);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   206
        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   207
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   208
        File jarLog = new File("jar.log");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   209
        try {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   210
            retVal = execute(null, JAR.toString(), "cvf",
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   211
                    "input" + File.separator + "hello.jar", "Hello.class");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   212
        } catch (Exception ex) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   213
            if (jarLog.exists()) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   214
                System.err.println(Files.readString(jarLog.toPath()));
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   215
            }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   216
            throw ex;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   217
        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   218
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   219
        if (retVal != 0) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   220
            if (jarLog.exists()) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   221
                System.err.println(Files.readString(jarLog.toPath()));
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   222
            }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   223
            throw new AssertionError("jar exited with error: " + retVal);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   224
        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   225
    }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   226
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   227
    public static String listToArgumentsMap(List<String> arguments,
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   228
            boolean toolProvider) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   229
        if (arguments.isEmpty()) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   230
            return "";
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   231
        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   232
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   233
        String argsStr = "";
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   234
        for (int i = 0; i < arguments.size(); i++) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   235
            String arg = arguments.get(i);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   236
            argsStr += quote(arg, toolProvider);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   237
            if ((i + 1) != arguments.size()) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   238
                argsStr += " ";
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   239
            }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   240
        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   241
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   242
        if (!toolProvider && isWindows()) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   243
            if (argsStr.contains(" ")) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   244
                if (argsStr.contains("\"")) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   245
                    argsStr = escapeQuote(argsStr, toolProvider);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   246
                }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   247
                argsStr = "\"" + argsStr + "\"";
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   248
            }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   249
        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   250
        return argsStr;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   251
    }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   252
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   253
    private static String quote(String in, boolean toolProvider) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   254
        if (in == null) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   255
            return null;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   256
        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   257
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   258
        if (in.isEmpty()) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   259
            return "";
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   260
        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   261
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   262
        if (!in.contains("=")) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   263
            // Not a property
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   264
            if (in.contains(" ")) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   265
                in = escapeQuote(in, toolProvider);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   266
                return "\"" + in + "\"";
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   267
            }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   268
            return in;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   269
        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   270
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   271
        if (!in.contains(" ")) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   272
            return in; // No need to quote
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   273
        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   274
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   275
        int paramIndex = in.indexOf("=");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   276
        if (paramIndex <= 0) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   277
            return in; // Something wrong, just skip quoting
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   278
        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   279
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   280
        String param = in.substring(0, paramIndex);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   281
        String value = in.substring(paramIndex + 1);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   282
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   283
        if (value.length() == 0) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   284
            return in; // No need to quote
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   285
        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   286
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   287
        value = escapeQuote(value, toolProvider);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   288
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   289
        return param + "=" + "\"" + value + "\"";
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   290
    }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   291
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   292
    private static String escapeQuote(String in, boolean toolProvider) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   293
        if (in == null) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   294
            return null;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   295
        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   296
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   297
        if (in.isEmpty()) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   298
            return "";
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   299
        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   300
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   301
        if (in.contains("\"")) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   302
            // Use code points to preserve non-ASCII chars
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   303
            StringBuilder sb = new StringBuilder();
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   304
            int codeLen = in.codePointCount(0, in.length());
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   305
            for (int i = 0; i < codeLen; i++) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   306
                int code = in.codePointAt(i);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   307
                // Note: No need to escape '\' on Linux or OS X
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   308
                // jpackager expects us to pass arguments and properties with
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   309
                // quotes and spaces as a map
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   310
                // with quotes being escaped with additional \ for
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   311
                // internal quotes.
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   312
                // So if we want two properties below:
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   313
                // -Djnlp.Prop1=Some "Value" 1
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   314
                // -Djnlp.Prop2=Some Value 2
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   315
                // jpackager will need:
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   316
                // "-Djnlp.Prop1=\"Some \\"Value\\" 1\" -Djnlp.Prop2=\"Some Value 2\""
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   317
                // but since we using ProcessBuilder to run jpackager we will need to escape
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   318
                // our escape symbols as well, so we will need to pass string below to ProcessBuilder:
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   319
                // "-Djnlp.Prop1=\\\"Some \\\\\\\"Value\\\\\\\" 1\\\" -Djnlp.Prop2=\\\"Some Value 2\\\""
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   320
                switch (code) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   321
                    case '"':
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   322
                        // " -> \" -> \\\"
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   323
                        if (i == 0 || in.codePointAt(i - 1) != '\\') {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   324
                            if (!toolProvider && isWindows()) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   325
                                sb.appendCodePoint('\\');
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   326
                                sb.appendCodePoint('\\');
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   327
                            }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   328
                            sb.appendCodePoint('\\');
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   329
                            sb.appendCodePoint(code);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   330
                        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   331
                        break;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   332
                    case '\\':
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   333
                        // We need to escape already escaped symbols as well
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   334
                        if ((i + 1) < codeLen) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   335
                            int nextCode = in.codePointAt(i + 1);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   336
                            if (nextCode == '"') {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   337
                                // \" -> \\\"
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   338
                                sb.appendCodePoint('\\');
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   339
                                sb.appendCodePoint('\\');
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   340
                                sb.appendCodePoint('\\');
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   341
                                sb.appendCodePoint(nextCode);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   342
                            } else {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   343
                                sb.appendCodePoint('\\');
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   344
                                sb.appendCodePoint(code);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   345
                            }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   346
                        } else {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   347
                            if (isWindows()) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   348
                                sb.appendCodePoint('\\');
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   349
                            }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   350
                            sb.appendCodePoint(code);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   351
                        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   352
                        break;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   353
                    default:
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   354
                        sb.appendCodePoint(code);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   355
                        break;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   356
                }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   357
            }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   358
            return sb.toString();
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   359
        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   360
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   361
        return in;
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   362
    }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   363
}