35 36 public class InfoStreams { 37 38 public static OutputAnalyzer run(String ... opts) throws Exception { 39 return ProcessTools.executeTestJava(opts).shouldHaveExitValue(0); 40 } 41 42 private static final String 43 java_version = System.getProperty("java.version"), 44 USAGE = "^Usage: java ", 45 VERSION_ERR = "^(java|openjdk) version \"" + java_version + "\"", 46 VERSION_OUT = "^(java|openjdk) " + java_version, 47 FULLVERSION_ERR = "^(java|openjdk) full version \"" + java_version + ".*\"", 48 FULLVERSION_OUT = "^(java|openjdk) " + java_version, 49 NONSTD = ".*These extra options are subject to change"; 50 51 public static void main(String ... args) throws Exception { 52 53 String classPath = System.getProperty("java.class.path"); 54 55 run("-help").stderrShouldMatch(USAGE).stdoutShouldNotMatch("."); 56 run("--help").stdoutShouldMatch(USAGE).stderrShouldNotMatch("."); 57 58 run("-version").stderrShouldMatch(VERSION_ERR).stdoutShouldNotMatch("."); 59 run("--version").stdoutShouldMatch(VERSION_OUT).stderrShouldNotMatch("."); 60 61 run("-showversion", "--dry-run", "-cp", classPath, "InfoStreams") 62 .stderrShouldMatch(VERSION_ERR) 63 .stdoutShouldNotMatch("."); 64 run("--show-version", "--dry-run", "-cp", classPath, "InfoStreams") 65 .stdoutShouldMatch(VERSION_OUT) 66 .stderrShouldNotMatch("."); 67 68 run("-fullversion").stderrShouldMatch(FULLVERSION_ERR) 69 .stdoutShouldNotMatch("."); 70 run("--full-version").stdoutShouldMatch(FULLVERSION_OUT) 71 .stderrShouldNotMatch("."); 72 73 run("-X").stderrShouldMatch(NONSTD).stdoutShouldNotMatch("."); 74 run("--help-extra").stdoutShouldMatch(NONSTD).stderrShouldNotMatch("."); 75 76 } 77 78 } | 35 36 public class InfoStreams { 37 38 public static OutputAnalyzer run(String ... opts) throws Exception { 39 return ProcessTools.executeTestJava(opts).shouldHaveExitValue(0); 40 } 41 42 private static final String 43 java_version = System.getProperty("java.version"), 44 USAGE = "^Usage: java ", 45 VERSION_ERR = "^(java|openjdk) version \"" + java_version + "\"", 46 VERSION_OUT = "^(java|openjdk) " + java_version, 47 FULLVERSION_ERR = "^(java|openjdk) full version \"" + java_version + ".*\"", 48 FULLVERSION_OUT = "^(java|openjdk) " + java_version, 49 NONSTD = ".*These extra options are subject to change"; 50 51 public static void main(String ... args) throws Exception { 52 53 String classPath = System.getProperty("java.class.path"); 54 55 run("-help").stderrShouldMatch(USAGE).stdoutShouldNotMatch(USAGE); 56 run("--help").stdoutShouldMatch(USAGE).stderrShouldNotMatch(USAGE); 57 58 run("-version").stderrShouldMatch(VERSION_ERR) 59 .stdoutShouldNotMatch(VERSION_ERR) 60 .stdoutShouldNotMatch(VERSION_OUT); 61 run("--version").stdoutShouldMatch(VERSION_OUT) 62 .stderrShouldNotMatch(VERSION_OUT) 63 .stderrShouldNotMatch(VERSION_ERR); 64 65 run("-showversion", "--dry-run", "-cp", classPath, "InfoStreams") 66 .stderrShouldMatch(VERSION_ERR) 67 .stdoutShouldNotMatch(VERSION_ERR) 68 .stdoutShouldNotMatch(VERSION_OUT); 69 run("--show-version", "--dry-run", "-cp", classPath, "InfoStreams") 70 .stdoutShouldMatch(VERSION_OUT) 71 .stderrShouldNotMatch(VERSION_OUT) 72 .stderrShouldNotMatch(VERSION_ERR); 73 74 run("-fullversion").stderrShouldMatch(FULLVERSION_ERR) 75 .stdoutShouldNotMatch(FULLVERSION_ERR) 76 .stdoutShouldNotMatch(FULLVERSION_OUT); 77 run("--full-version").stdoutShouldMatch(FULLVERSION_OUT) 78 .stderrShouldNotMatch(FULLVERSION_OUT) 79 .stderrShouldNotMatch(FULLVERSION_ERR); 80 81 run("-X").stderrShouldMatch(NONSTD).stdoutShouldNotMatch(NONSTD); 82 run("--help-extra").stdoutShouldMatch(NONSTD).stderrShouldNotMatch(NONSTD); 83 } 84 } |