2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2012-01-28 18:46:46 +00:00
|
|
|
* Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
|
2007-12-01 00:00:00 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
2010-05-25 22:58:33 +00:00
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
2007-12-01 00:00:00 +00:00
|
|
|
*/
|
|
|
|
|
2008-09-24 22:07:41 +00:00
|
|
|
/**
|
|
|
|
* @test
|
2010-07-09 18:04:34 +00:00
|
|
|
* @bug 5030233 6214916 6356475 6571029 6684582 6742159 4459600 6758881 6753938
|
2012-02-02 23:37:22 +00:00
|
|
|
* 6894719 6968053
|
2008-09-24 22:07:41 +00:00
|
|
|
* @summary Argument parsing validation.
|
2012-01-28 18:46:46 +00:00
|
|
|
* @compile -XDignore.symbol.file Arrrghs.java
|
2008-10-14 20:02:30 +00:00
|
|
|
* @run main Arrrghs
|
2008-09-24 22:07:41 +00:00
|
|
|
*/
|
|
|
|
|
2008-04-10 16:02:22 +00:00
|
|
|
import java.io.BufferedReader;
|
|
|
|
import java.io.File;
|
2008-09-24 22:07:41 +00:00
|
|
|
import java.io.FileNotFoundException;
|
2008-04-10 16:02:22 +00:00
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
import java.util.Map;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2012-01-28 18:46:46 +00:00
|
|
|
public class Arrrghs extends TestHelper {
|
2008-09-24 22:07:41 +00:00
|
|
|
private Arrrghs(){}
|
2007-12-01 00:00:00 +00:00
|
|
|
/**
|
2008-09-24 22:07:41 +00:00
|
|
|
* This class provides various tests for arguments processing.
|
2007-12-01 00:00:00 +00:00
|
|
|
* A group of tests to ensure that arguments are passed correctly to
|
|
|
|
* a child java process upon a re-exec, this typically happens when
|
|
|
|
* a version other than the one being executed is requested by the user.
|
|
|
|
*
|
|
|
|
* History: these set of tests were part of Arrrghs.sh. The MKS shell
|
2008-09-24 22:07:41 +00:00
|
|
|
* implementations were notoriously buggy. Implementing these tests purely
|
2007-12-01 00:00:00 +00:00
|
|
|
* in Java is not only portable but also robust.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
// The version string to force a re-exec
|
|
|
|
final static String VersionStr = "-version:1.1+";
|
|
|
|
|
|
|
|
// The Cookie or the pattern we match in the debug output.
|
|
|
|
final static String Cookie = "ReExec Args: ";
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SIGH, On Windows all strings are quoted, we need to unwrap it
|
|
|
|
*/
|
|
|
|
private static String removeExtraQuotes(String in) {
|
2012-01-28 18:46:46 +00:00
|
|
|
if (isWindows) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// Trim the string and remove the enclosed quotes if any.
|
|
|
|
in = in.trim();
|
|
|
|
if (in.startsWith("\"") && in.endsWith("\"")) {
|
|
|
|
return in.substring(1, in.length()-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return in;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This method detects the cookie in the output stream of the process.
|
|
|
|
*/
|
2008-09-24 22:07:41 +00:00
|
|
|
private static boolean detectCookie(InputStream istream,
|
|
|
|
String expectedArguments) throws IOException {
|
2007-12-01 00:00:00 +00:00
|
|
|
BufferedReader rd = new BufferedReader(new InputStreamReader(istream));
|
|
|
|
boolean retval = false;
|
|
|
|
|
|
|
|
String in = rd.readLine();
|
|
|
|
while (in != null) {
|
2012-01-28 18:46:46 +00:00
|
|
|
if (debug) System.out.println(in);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (in.startsWith(Cookie)) {
|
|
|
|
String detectedArgument = removeExtraQuotes(in.substring(Cookie.length()));
|
|
|
|
if (expectedArguments.equals(detectedArgument)) {
|
|
|
|
retval = true;
|
|
|
|
} else {
|
2008-09-24 22:07:41 +00:00
|
|
|
System.out.println("Error: Expected Arguments\t:'" +
|
|
|
|
expectedArguments + "'");
|
|
|
|
System.out.println(" Detected Arguments\t:'" +
|
|
|
|
detectedArgument + "'");
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
// Return the value asap if not in debug mode.
|
2012-01-28 18:46:46 +00:00
|
|
|
if (!debug) {
|
2007-12-01 00:00:00 +00:00
|
|
|
rd.close();
|
|
|
|
istream.close();
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
in = rd.readLine();
|
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2008-09-24 22:07:41 +00:00
|
|
|
private static boolean doTest0(ProcessBuilder pb, String expectedArguments) {
|
2007-12-01 00:00:00 +00:00
|
|
|
boolean retval = false;
|
|
|
|
try {
|
2008-04-10 16:02:22 +00:00
|
|
|
pb.redirectErrorStream(true);
|
2007-12-01 00:00:00 +00:00
|
|
|
Process p = pb.start();
|
|
|
|
retval = detectCookie(p.getInputStream(), expectedArguments);
|
|
|
|
p.waitFor();
|
|
|
|
p.destroy();
|
|
|
|
} catch (Exception ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
throw new RuntimeException(ex.getMessage());
|
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This method return true if the expected and detected arguments are the same.
|
|
|
|
* Quoting could cause dissimilar testArguments and expected arguments.
|
|
|
|
*/
|
2008-09-24 22:07:41 +00:00
|
|
|
static int doTest(String testArguments, String expectedPattern) {
|
2012-01-28 18:46:46 +00:00
|
|
|
ProcessBuilder pb = new ProcessBuilder(javaCmd,
|
2008-09-24 22:07:41 +00:00
|
|
|
VersionStr, testArguments);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
Map<String, String> env = pb.environment();
|
|
|
|
env.put("_JAVA_LAUNCHER_DEBUG", "true");
|
2008-09-24 22:07:41 +00:00
|
|
|
return doTest0(pb, testArguments) ? 0 : 1;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A convenience method for identical test pattern and expected arguments
|
|
|
|
*/
|
2008-09-24 22:07:41 +00:00
|
|
|
static int doTest(String testPattern) {
|
|
|
|
return doTest(testPattern, testPattern);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2008-09-24 22:07:41 +00:00
|
|
|
static void quoteParsingTests() {
|
|
|
|
/*
|
|
|
|
* Tests for 6214916
|
|
|
|
* These tests require that a JVM (any JVM) be installed in the system registry.
|
|
|
|
* If none is installed, skip this test.
|
|
|
|
*/
|
2012-01-28 18:46:46 +00:00
|
|
|
TestResult tr = doExec(javaCmd, VersionStr, "-version");
|
2008-09-24 22:07:41 +00:00
|
|
|
if (!tr.isOK()) {
|
|
|
|
System.err.println("Warning:Argument Passing Tests were skipped, " +
|
|
|
|
"no java found in system registry.");
|
|
|
|
return;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Basic test
|
2012-01-28 18:46:46 +00:00
|
|
|
testExitValue += doTest("-a -b -c -d");
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Basic test with many spaces
|
2012-01-28 18:46:46 +00:00
|
|
|
testExitValue += doTest("-a -b -c -d");
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Quoted whitespace does matter ?
|
2012-01-28 18:46:46 +00:00
|
|
|
testExitValue += doTest("-a \"\"-b -c\"\" -d");
|
2008-09-24 22:07:41 +00:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Escaped quotes outside of quotes as literals
|
2012-01-28 18:46:46 +00:00
|
|
|
testExitValue += doTest("-a \\\"-b -c\\\" -d");
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Check for escaped quotes inside of quotes as literal
|
2012-01-28 18:46:46 +00:00
|
|
|
testExitValue += doTest("-a \"-b \\\"stuff\\\"\" -c -d");
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// A quote preceeded by an odd number of slashes is a literal quote
|
2012-01-28 18:46:46 +00:00
|
|
|
testExitValue += doTest("-a -b\\\\\\\" -c -d");
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// A quote preceeded by an even number of slashes is a literal quote
|
|
|
|
// see 6214916.
|
2012-01-28 18:46:46 +00:00
|
|
|
testExitValue += doTest("-a -b\\\\\\\\\" -c -d");
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Make sure that whitespace doesn't interfere with the removal of the
|
|
|
|
// appropriate tokens. (space-tab-space preceeds -jre-restict-search).
|
2012-01-28 18:46:46 +00:00
|
|
|
testExitValue += doTest("-a -b \t -jre-restrict-search -c -d","-a -b -c -d");
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Make sure that the mJRE tokens being stripped, aren't stripped if
|
|
|
|
// they happen to appear as arguments to the main class.
|
2012-01-28 18:46:46 +00:00
|
|
|
testExitValue += doTest("foo -version:1.1+");
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2008-09-24 22:07:41 +00:00
|
|
|
System.out.println("Completed arguments quoting tests with " +
|
2012-01-28 18:46:46 +00:00
|
|
|
testExitValue + " errors");
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2008-09-24 22:07:41 +00:00
|
|
|
/*
|
|
|
|
* These tests are usually run on non-existent targets to check error results
|
|
|
|
*/
|
|
|
|
static void runBasicErrorMessageTests() {
|
|
|
|
// Tests for 5030233
|
2012-01-28 18:46:46 +00:00
|
|
|
TestResult tr = doExec(javaCmd, "-cp");
|
2008-09-24 22:07:41 +00:00
|
|
|
tr.checkNegative();
|
|
|
|
tr.isNotZeroOutput();
|
|
|
|
System.out.println(tr);
|
|
|
|
|
2012-01-28 18:46:46 +00:00
|
|
|
tr = doExec(javaCmd, "-classpath");
|
2008-09-24 22:07:41 +00:00
|
|
|
tr.checkNegative();
|
|
|
|
tr.isNotZeroOutput();
|
|
|
|
System.out.println(tr);
|
|
|
|
|
2012-01-28 18:46:46 +00:00
|
|
|
tr = doExec(javaCmd, "-jar");
|
2008-09-24 22:07:41 +00:00
|
|
|
tr.checkNegative();
|
|
|
|
tr.isNotZeroOutput();
|
|
|
|
System.out.println(tr);
|
|
|
|
|
2012-01-28 18:46:46 +00:00
|
|
|
tr = doExec(javacCmd, "-cp");
|
2008-09-24 22:07:41 +00:00
|
|
|
tr.checkNegative();
|
|
|
|
tr.isNotZeroOutput();
|
|
|
|
System.out.println(tr);
|
|
|
|
|
|
|
|
// Test for 6356475 "REGRESSION:"java -X" from cmdline fails"
|
2012-01-28 18:46:46 +00:00
|
|
|
tr = doExec(javaCmd, "-X");
|
2008-09-24 22:07:41 +00:00
|
|
|
tr.checkPositive();
|
|
|
|
tr.isNotZeroOutput();
|
|
|
|
System.out.println(tr);
|
|
|
|
|
2012-01-28 18:46:46 +00:00
|
|
|
tr = doExec(javaCmd, "-help");
|
2008-09-24 22:07:41 +00:00
|
|
|
tr.checkPositive();
|
|
|
|
tr.isNotZeroOutput();
|
|
|
|
System.out.println(tr);
|
2010-07-09 18:04:34 +00:00
|
|
|
|
|
|
|
// 6753938, test for non-negative exit value for an incorrectly formed
|
|
|
|
// command line, '% java'
|
2012-01-28 18:46:46 +00:00
|
|
|
tr = doExec(javaCmd);
|
2010-07-09 18:04:34 +00:00
|
|
|
tr.checkNegative();
|
|
|
|
tr.isNotZeroOutput();
|
|
|
|
System.out.println(tr);
|
|
|
|
|
|
|
|
// 6753938, test for non-negative exit value for an incorrectly formed
|
|
|
|
// command line, '% java -Xcomp'
|
2012-01-28 18:46:46 +00:00
|
|
|
tr = doExec(javaCmd, "-Xcomp");
|
2010-07-09 18:04:34 +00:00
|
|
|
tr.checkNegative();
|
|
|
|
tr.isNotZeroOutput();
|
|
|
|
System.out.println(tr);
|
2008-09-24 22:07:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-01-28 18:46:46 +00:00
|
|
|
* Tests various dispositions of the main method, these tests are limited
|
|
|
|
* to English locales as they check for error messages that are localized.
|
2008-09-24 22:07:41 +00:00
|
|
|
*/
|
|
|
|
static void runMainMethodTests() throws FileNotFoundException {
|
2012-01-28 18:46:46 +00:00
|
|
|
if (!isEnglishLocale()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
TestResult tr = null;
|
2008-09-24 22:07:41 +00:00
|
|
|
|
|
|
|
// a missing class
|
2012-01-28 18:46:46 +00:00
|
|
|
createJar("MIA", new File("some.jar"), new File("Foo"),
|
2008-10-01 16:04:42 +00:00
|
|
|
(String[])null);
|
2012-01-28 18:46:46 +00:00
|
|
|
tr = doExec(javaCmd, "-jar", "some.jar");
|
2011-02-03 23:41:23 +00:00
|
|
|
tr.contains("Error: Could not find or load main class MIA");
|
2008-09-24 22:07:41 +00:00
|
|
|
System.out.println(tr);
|
|
|
|
// use classpath to check
|
2012-01-28 18:46:46 +00:00
|
|
|
tr = doExec(javaCmd, "-cp", "some.jar", "MIA");
|
2011-02-03 23:41:23 +00:00
|
|
|
tr.contains("Error: Could not find or load main class MIA");
|
2008-09-24 22:07:41 +00:00
|
|
|
System.out.println(tr);
|
|
|
|
|
|
|
|
// incorrect method access
|
2012-01-28 18:46:46 +00:00
|
|
|
createJar(new File("some.jar"), new File("Foo"),
|
2008-09-24 22:07:41 +00:00
|
|
|
"private static void main(String[] args){}");
|
2012-01-28 18:46:46 +00:00
|
|
|
tr = doExec(javaCmd, "-jar", "some.jar");
|
2008-09-24 22:07:41 +00:00
|
|
|
tr.contains("Error: Main method not found in class Foo");
|
|
|
|
System.out.println(tr);
|
|
|
|
// use classpath to check
|
2012-01-28 18:46:46 +00:00
|
|
|
tr = doExec(javaCmd, "-cp", "some.jar", "Foo");
|
2008-09-24 22:07:41 +00:00
|
|
|
tr.contains("Error: Main method not found in class Foo");
|
|
|
|
System.out.println(tr);
|
|
|
|
|
|
|
|
// incorrect return type
|
2012-01-28 18:46:46 +00:00
|
|
|
createJar(new File("some.jar"), new File("Foo"),
|
2008-09-24 22:07:41 +00:00
|
|
|
"public static int main(String[] args){return 1;}");
|
2012-01-28 18:46:46 +00:00
|
|
|
tr = doExec(javaCmd, "-jar", "some.jar");
|
2008-09-24 22:07:41 +00:00
|
|
|
tr.contains("Error: Main method must return a value of type void in class Foo");
|
|
|
|
System.out.println(tr);
|
|
|
|
// use classpath to check
|
2012-01-28 18:46:46 +00:00
|
|
|
tr = doExec(javaCmd, "-cp", "some.jar", "Foo");
|
2008-09-24 22:07:41 +00:00
|
|
|
tr.contains("Error: Main method must return a value of type void in class Foo");
|
|
|
|
System.out.println(tr);
|
|
|
|
|
|
|
|
// incorrect parameter type
|
2012-01-28 18:46:46 +00:00
|
|
|
createJar(new File("some.jar"), new File("Foo"),
|
2008-09-24 22:07:41 +00:00
|
|
|
"public static void main(Object[] args){}");
|
2012-01-28 18:46:46 +00:00
|
|
|
tr = doExec(javaCmd, "-jar", "some.jar");
|
2008-09-24 22:07:41 +00:00
|
|
|
tr.contains("Error: Main method not found in class Foo");
|
|
|
|
System.out.println(tr);
|
|
|
|
// use classpath to check
|
2012-01-28 18:46:46 +00:00
|
|
|
tr = doExec(javaCmd, "-cp", "some.jar", "Foo");
|
2008-09-24 22:07:41 +00:00
|
|
|
tr.contains("Error: Main method not found in class Foo");
|
|
|
|
System.out.println(tr);
|
|
|
|
|
|
|
|
// incorrect method type - non-static
|
2012-01-28 18:46:46 +00:00
|
|
|
createJar(new File("some.jar"), new File("Foo"),
|
2008-10-01 16:04:42 +00:00
|
|
|
"public void main(String[] args){}");
|
2012-01-28 18:46:46 +00:00
|
|
|
tr = doExec(javaCmd, "-jar", "some.jar");
|
2008-10-01 16:04:42 +00:00
|
|
|
tr.contains("Error: Main method is not static in class Foo");
|
2008-09-24 22:07:41 +00:00
|
|
|
System.out.println(tr);
|
|
|
|
// use classpath to check
|
2012-01-28 18:46:46 +00:00
|
|
|
tr = doExec(javaCmd, "-cp", "some.jar", "Foo");
|
2008-10-01 16:04:42 +00:00
|
|
|
tr.contains("Error: Main method is not static in class Foo");
|
2008-09-24 22:07:41 +00:00
|
|
|
System.out.println(tr);
|
|
|
|
|
|
|
|
// amongst a potpourri of kindred main methods, is the right one chosen ?
|
2012-01-28 18:46:46 +00:00
|
|
|
createJar(new File("some.jar"), new File("Foo"),
|
2011-02-03 23:41:23 +00:00
|
|
|
"void main(Object[] args){}",
|
|
|
|
"int main(Float[] args){return 1;}",
|
|
|
|
"private void main() {}",
|
|
|
|
"private static void main(int x) {}",
|
|
|
|
"public int main(int argc, String[] argv) {return 1;}",
|
|
|
|
"public static void main(String[] args) {System.out.println(\"THE_CHOSEN_ONE\");}");
|
2012-01-28 18:46:46 +00:00
|
|
|
tr = doExec(javaCmd, "-jar", "some.jar");
|
2008-09-24 22:07:41 +00:00
|
|
|
tr.contains("THE_CHOSEN_ONE");
|
|
|
|
System.out.println(tr);
|
|
|
|
// use classpath to check
|
2012-01-28 18:46:46 +00:00
|
|
|
tr = doExec(javaCmd, "-cp", "some.jar", "Foo");
|
2008-09-24 22:07:41 +00:00
|
|
|
tr.contains("THE_CHOSEN_ONE");
|
|
|
|
System.out.println(tr);
|
2008-10-01 16:04:42 +00:00
|
|
|
|
|
|
|
// test for extraneous whitespace in the Main-Class attribute
|
2012-01-28 18:46:46 +00:00
|
|
|
createJar(" Foo ", new File("some.jar"), new File("Foo"),
|
2008-10-01 16:04:42 +00:00
|
|
|
"public static void main(String... args){}");
|
2012-01-28 18:46:46 +00:00
|
|
|
tr = doExec(javaCmd, "-jar", "some.jar");
|
2008-10-01 16:04:42 +00:00
|
|
|
tr.checkPositive();
|
|
|
|
System.out.println(tr);
|
2008-09-24 22:07:41 +00:00
|
|
|
}
|
2012-01-28 18:46:46 +00:00
|
|
|
/*
|
|
|
|
* tests 6968053, ie. we turn on the -Xdiag (for now) flag and check if
|
|
|
|
* the suppressed stack traces are exposed, ignore these tests for localized
|
|
|
|
* locales, limiting to English only.
|
|
|
|
*/
|
2011-02-03 23:41:23 +00:00
|
|
|
static void runDiagOptionTests() throws FileNotFoundException {
|
2012-01-28 18:46:46 +00:00
|
|
|
if (!isEnglishLocale()) { // only english version
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
TestResult tr = null;
|
2011-02-03 23:41:23 +00:00
|
|
|
// a missing class
|
2012-01-28 18:46:46 +00:00
|
|
|
createJar("MIA", new File("some.jar"), new File("Foo"),
|
2011-02-03 23:41:23 +00:00
|
|
|
(String[])null);
|
2012-01-28 18:46:46 +00:00
|
|
|
tr = doExec(javaCmd, "-Xdiag", "-jar", "some.jar");
|
2011-02-03 23:41:23 +00:00
|
|
|
tr.contains("Error: Could not find or load main class MIA");
|
|
|
|
tr.contains("java.lang.ClassNotFoundException: MIA");
|
|
|
|
System.out.println(tr);
|
|
|
|
|
|
|
|
// use classpath to check
|
2012-01-28 18:46:46 +00:00
|
|
|
tr = doExec(javaCmd, "-Xdiag", "-cp", "some.jar", "MIA");
|
2011-02-03 23:41:23 +00:00
|
|
|
tr.contains("Error: Could not find or load main class MIA");
|
|
|
|
tr.contains("java.lang.ClassNotFoundException: MIA");
|
|
|
|
System.out.println(tr);
|
|
|
|
|
|
|
|
// a missing class on the classpath
|
2012-01-28 18:46:46 +00:00
|
|
|
tr = doExec(javaCmd, "-Xdiag", "NonExistentClass");
|
2011-02-03 23:41:23 +00:00
|
|
|
tr.contains("Error: Could not find or load main class NonExistentClass");
|
|
|
|
tr.contains("java.lang.ClassNotFoundException: NonExistentClass");
|
|
|
|
System.out.println(tr);
|
|
|
|
}
|
2008-09-24 22:07:41 +00:00
|
|
|
|
2010-10-07 21:35:14 +00:00
|
|
|
static void test6894719() {
|
|
|
|
// test both arguments to ensure they exist
|
2012-01-28 18:46:46 +00:00
|
|
|
TestResult tr = null;
|
|
|
|
tr = doExec(javaCmd,
|
2010-10-07 21:35:14 +00:00
|
|
|
"-no-jre-restrict-search", "-version");
|
|
|
|
tr.checkPositive();
|
|
|
|
System.out.println(tr);
|
|
|
|
|
2012-01-28 18:46:46 +00:00
|
|
|
tr = doExec(javaCmd,
|
2010-10-07 21:35:14 +00:00
|
|
|
"-jre-restrict-search", "-version");
|
|
|
|
tr.checkPositive();
|
|
|
|
System.out.println(tr);
|
|
|
|
}
|
2011-07-19 17:58:50 +00:00
|
|
|
|
2008-09-24 22:07:41 +00:00
|
|
|
/**
|
|
|
|
* @param args the command line arguments
|
|
|
|
* @throws java.io.FileNotFoundException
|
|
|
|
*/
|
|
|
|
public static void main(String[] args) throws FileNotFoundException {
|
2012-01-28 18:46:46 +00:00
|
|
|
if (debug) {
|
2010-10-07 21:35:14 +00:00
|
|
|
System.out.println("Starting Arrrghs tests");
|
|
|
|
}
|
|
|
|
quoteParsingTests();
|
|
|
|
runBasicErrorMessageTests();
|
|
|
|
runMainMethodTests();
|
|
|
|
test6894719();
|
2011-02-03 23:41:23 +00:00
|
|
|
runDiagOptionTests();
|
2012-01-28 18:46:46 +00:00
|
|
|
if (testExitValue > 0) {
|
|
|
|
System.out.println("Total of " + testExitValue + " failed");
|
2010-10-07 21:35:14 +00:00
|
|
|
System.exit(1);
|
|
|
|
} else {
|
|
|
|
System.out.println("All tests pass");
|
2008-09-24 22:07:41 +00:00
|
|
|
}
|
|
|
|
}
|
2010-10-07 21:35:14 +00:00
|
|
|
}
|