test/jdk/tools/launcher/InfoStreams.java
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 42338 jdk/test/tools/launcher/InfoStreams.java@a60f280f803c
child 49538 707553fcca04
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
     1
/*
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
     4
 *
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
     8
 *
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    13
 * accompanied this code).
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    14
 *
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    18
 *
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    21
 * questions.
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    22
 */
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    23
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    24
/**
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    25
 * @test
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    26
 * @library /lib/testlibrary
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    27
 * @build InfoStreams jdk.testlibrary.ProcessTools
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    28
 * @run main InfoStreams
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    29
 * @summary Test that informational options use the correct streams
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    30
 */
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    31
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    32
import jdk.testlibrary.ProcessTools;
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    33
import jdk.testlibrary.OutputAnalyzer;
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    34
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    35
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    36
public class InfoStreams {
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    37
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    38
    public static OutputAnalyzer run(String ... opts) throws Exception {
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    39
        return ProcessTools.executeTestJava(opts).shouldHaveExitValue(0);
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    40
    }
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    41
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    42
    private static final String
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    43
        java_version = System.getProperty("java.version"),
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    44
        USAGE = "^Usage: java ",
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    45
        VERSION_ERR = "^(java|openjdk) version \"" + java_version + "\"",
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    46
        VERSION_OUT = "^(java|openjdk) " + java_version,
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    47
        FULLVERSION_ERR = "^(java|openjdk) full version \"" + java_version + ".*\"",
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    48
        FULLVERSION_OUT = "^(java|openjdk) " + java_version,
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    49
        NONSTD = ".*These extra options are subject to change";
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    50
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    51
    public static void main(String ... args) throws Exception {
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    52
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    53
        String classPath = System.getProperty("java.class.path");
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    54
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    55
        run("-help").stderrShouldMatch(USAGE).stdoutShouldNotMatch(".");
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    56
        run("--help").stdoutShouldMatch(USAGE).stderrShouldNotMatch(".");
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    57
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    58
        run("-version").stderrShouldMatch(VERSION_ERR).stdoutShouldNotMatch(".");
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    59
        run("--version").stdoutShouldMatch(VERSION_OUT).stderrShouldNotMatch(".");
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    60
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    61
        run("-showversion", "--dry-run", "-cp", classPath, "InfoStreams")
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    62
            .stderrShouldMatch(VERSION_ERR)
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    63
            .stdoutShouldNotMatch(".");
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    64
        run("--show-version", "--dry-run", "-cp", classPath, "InfoStreams")
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    65
            .stdoutShouldMatch(VERSION_OUT)
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    66
            .stderrShouldNotMatch(".");
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    67
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    68
        run("-fullversion").stderrShouldMatch(FULLVERSION_ERR)
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    69
            .stdoutShouldNotMatch(".");
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    70
        run("--full-version").stdoutShouldMatch(FULLVERSION_OUT)
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    71
            .stderrShouldNotMatch(".");
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    72
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    73
        run("-X").stderrShouldMatch(NONSTD).stdoutShouldNotMatch(".");
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    74
        run("--help-extra").stdoutShouldMatch(NONSTD).stderrShouldNotMatch(".");
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    75
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    76
    }
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    77
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents:
diff changeset
    78
}