author | jlaskey |
Tue, 19 Feb 2013 09:47:02 -0400 | |
changeset 16248 | e4bcc4b4f897 |
parent 15523 | cc0ee864bfb5 |
child 17714 | 04271182b2c1 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
15523
cc0ee864bfb5
8006536: [launcher] removes trailing slashes on arguments
ksrini
parents:
14763
diff
changeset
|
2 |
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5506 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
2 | 22 |
*/ |
23 |
||
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
24 |
/** |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
25 |
* @test |
6005 | 26 |
* @bug 5030233 6214916 6356475 6571029 6684582 6742159 4459600 6758881 6753938 |
13416
9732a77088fe
7189944: (launcher) test/tools/launcher/Arrrrghs.java needs a couple of minor fixes
ksrini
parents:
13411
diff
changeset
|
27 |
* 6894719 6968053 7151434 7146424 |
1343
ecc86134ee4c
6758881: (launcher) needs to throw NoClassDefFoundError instead of JavaRuntimeException
ksrini
parents:
1329
diff
changeset
|
28 |
* @summary Argument parsing validation. |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
29 |
* @compile -XDignore.symbol.file Arrrghs.java |
14763
c16fa130fa23
8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents:
13416
diff
changeset
|
30 |
* @run main/othervm Arrrghs |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
31 |
*/ |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
32 |
|
399 | 33 |
import java.io.BufferedReader; |
34 |
import java.io.File; |
|
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
35 |
import java.io.FileNotFoundException; |
399 | 36 |
import java.io.IOException; |
37 |
import java.io.InputStream; |
|
38 |
import java.io.InputStreamReader; |
|
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
39 |
import java.util.ArrayList; |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
40 |
import java.util.Arrays; |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
41 |
import java.util.HashMap; |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
42 |
import java.util.List; |
399 | 43 |
import java.util.Map; |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
44 |
import java.util.regex.Matcher; |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
45 |
import java.util.regex.Pattern; |
2 | 46 |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
47 |
public class Arrrghs extends TestHelper { |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
48 |
private Arrrghs(){} |
2 | 49 |
/** |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
50 |
* This class provides various tests for arguments processing. |
2 | 51 |
* A group of tests to ensure that arguments are passed correctly to |
52 |
* a child java process upon a re-exec, this typically happens when |
|
53 |
* a version other than the one being executed is requested by the user. |
|
54 |
* |
|
55 |
* History: these set of tests were part of Arrrghs.sh. The MKS shell |
|
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
56 |
* implementations were notoriously buggy. Implementing these tests purely |
2 | 57 |
* in Java is not only portable but also robust. |
58 |
* |
|
59 |
*/ |
|
60 |
||
61 |
// The version string to force a re-exec |
|
62 |
final static String VersionStr = "-version:1.1+"; |
|
63 |
||
64 |
// The Cookie or the pattern we match in the debug output. |
|
65 |
final static String Cookie = "ReExec Args: "; |
|
66 |
||
67 |
/* |
|
68 |
* SIGH, On Windows all strings are quoted, we need to unwrap it |
|
69 |
*/ |
|
70 |
private static String removeExtraQuotes(String in) { |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
71 |
if (isWindows) { |
2 | 72 |
// Trim the string and remove the enclosed quotes if any. |
73 |
in = in.trim(); |
|
74 |
if (in.startsWith("\"") && in.endsWith("\"")) { |
|
75 |
return in.substring(1, in.length()-1); |
|
76 |
} |
|
77 |
} |
|
78 |
return in; |
|
79 |
} |
|
80 |
||
81 |
/* |
|
82 |
* This method detects the cookie in the output stream of the process. |
|
83 |
*/ |
|
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
84 |
private boolean detectCookie(InputStream istream, |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
85 |
String expectedArguments) throws IOException { |
2 | 86 |
BufferedReader rd = new BufferedReader(new InputStreamReader(istream)); |
87 |
boolean retval = false; |
|
88 |
||
89 |
String in = rd.readLine(); |
|
90 |
while (in != null) { |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
91 |
if (debug) System.out.println(in); |
2 | 92 |
if (in.startsWith(Cookie)) { |
93 |
String detectedArgument = removeExtraQuotes(in.substring(Cookie.length())); |
|
94 |
if (expectedArguments.equals(detectedArgument)) { |
|
95 |
retval = true; |
|
96 |
} else { |
|
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
97 |
System.out.println("Error: Expected Arguments\t:'" + |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
98 |
expectedArguments + "'"); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
99 |
System.out.println(" Detected Arguments\t:'" + |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
100 |
detectedArgument + "'"); |
2 | 101 |
} |
102 |
// Return the value asap if not in debug mode. |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
103 |
if (!debug) { |
2 | 104 |
rd.close(); |
105 |
istream.close(); |
|
106 |
return retval; |
|
107 |
} |
|
108 |
} |
|
109 |
in = rd.readLine(); |
|
110 |
} |
|
111 |
return retval; |
|
112 |
} |
|
113 |
||
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
114 |
private boolean doReExecTest0(ProcessBuilder pb, String expectedArguments) { |
2 | 115 |
boolean retval = false; |
116 |
try { |
|
399 | 117 |
pb.redirectErrorStream(true); |
2 | 118 |
Process p = pb.start(); |
119 |
retval = detectCookie(p.getInputStream(), expectedArguments); |
|
120 |
p.waitFor(); |
|
121 |
p.destroy(); |
|
122 |
} catch (Exception ex) { |
|
123 |
ex.printStackTrace(); |
|
124 |
throw new RuntimeException(ex.getMessage()); |
|
125 |
} |
|
126 |
return retval; |
|
127 |
} |
|
128 |
||
129 |
/** |
|
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
130 |
* This method returns true if the expected and detected arguments are the same. |
2 | 131 |
* Quoting could cause dissimilar testArguments and expected arguments. |
132 |
*/ |
|
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
133 |
int doReExecTest(String testArguments, String expectedPattern) { |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
134 |
ProcessBuilder pb = new ProcessBuilder(javaCmd, |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
135 |
VersionStr, testArguments); |
2 | 136 |
|
137 |
Map<String, String> env = pb.environment(); |
|
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
138 |
env.put(JLDEBUG_KEY, "true"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
139 |
return doReExecTest0(pb, testArguments) ? 0 : 1; |
2 | 140 |
} |
141 |
||
142 |
/** |
|
143 |
* A convenience method for identical test pattern and expected arguments |
|
144 |
*/ |
|
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
145 |
int doReExecTest(String testPattern) { |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
146 |
return doReExecTest(testPattern, testPattern); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
147 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
148 |
|
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
149 |
@Test |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
150 |
void testQuoteParsingThroughReExec() { |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
151 |
/* |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
152 |
* Tests for 6214916 |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
153 |
* These tests require that a JVM (any JVM) be installed in the system registry. |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
154 |
* If none is installed, skip this test. |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
155 |
*/ |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
156 |
TestResult tr = doExec(javaCmd, VersionStr, "-version"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
157 |
if (!tr.isOK()) { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
158 |
System.err.println("Warning:Argument Passing Tests were skipped, " + |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
159 |
"no java found in system registry."); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
160 |
return; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
161 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
162 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
163 |
// Basic test |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
164 |
testExitValue += doReExecTest("-a -b -c -d"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
165 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
166 |
// Basic test with many spaces |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
167 |
testExitValue += doReExecTest("-a -b -c -d"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
168 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
169 |
// Quoted whitespace does matter ? |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
170 |
testExitValue += doReExecTest("-a \"\"-b -c\"\" -d"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
171 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
172 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
173 |
// Escaped quotes outside of quotes as literals |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
174 |
testExitValue += doReExecTest("-a \\\"-b -c\\\" -d"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
175 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
176 |
// Check for escaped quotes inside of quotes as literal |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
177 |
testExitValue += doReExecTest("-a \"-b \\\"stuff\\\"\" -c -d"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
178 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
179 |
// A quote preceeded by an odd number of slashes is a literal quote |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
180 |
testExitValue += doReExecTest("-a -b\\\\\\\" -c -d"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
181 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
182 |
// A quote preceeded by an even number of slashes is a literal quote |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
183 |
// see 6214916. |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
184 |
testExitValue += doReExecTest("-a -b\\\\\\\\\" -c -d"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
185 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
186 |
// Make sure that whitespace doesn't interfere with the removal of the |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
187 |
// appropriate tokens. (space-tab-space preceeds -jre-restict-search). |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
188 |
testExitValue += doReExecTest("-a -b \t -jre-restrict-search -c -d", "-a -b -c -d"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
189 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
190 |
// Make sure that the mJRE tokens being stripped, aren't stripped if |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
191 |
// they happen to appear as arguments to the main class. |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
192 |
testExitValue += doReExecTest("foo -version:1.1+"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
193 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
194 |
System.out.println("Completed arguments quoting tests with " |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
195 |
+ testExitValue + " errors"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
196 |
} |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
197 |
// the pattern we hope to see in the output |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
198 |
static final Pattern ArgPattern = Pattern.compile("\\s*argv\\[[0-9]*\\].*=.*"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
199 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
200 |
void checkArgumentParsing(String inArgs, String... expArgs) throws IOException { |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
201 |
List<String> scratchpad = new ArrayList<>(); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
202 |
scratchpad.add("set " + JLDEBUG_KEY + "=true"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
203 |
// GAK, -version needs to be added so that windows can flush its stderr |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
204 |
// exiting the process prematurely can terminate the stderr. |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
205 |
scratchpad.add(javaCmd + " -version " + inArgs); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
206 |
File batFile = new File("atest.bat"); |
14763
c16fa130fa23
8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents:
13416
diff
changeset
|
207 |
createAFile(batFile, scratchpad); |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
208 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
209 |
TestResult tr = doExec(batFile.getName()); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
210 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
211 |
ArrayList<String> expList = new ArrayList<>(); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
212 |
expList.add(javaCmd); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
213 |
expList.add("-version"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
214 |
expList.addAll(Arrays.asList(expArgs)); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
215 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
216 |
List<String> gotList = new ArrayList<>(); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
217 |
for (String x : tr.testOutput) { |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
218 |
Matcher m = ArgPattern.matcher(x); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
219 |
if (m.matches()) { |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
220 |
String a[] = x.split("="); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
221 |
gotList.add(a[a.length - 1].trim()); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
222 |
} |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
223 |
} |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
224 |
if (!gotList.equals(expList)) { |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
225 |
System.out.println(tr); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
226 |
System.out.println("Expected args:"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
227 |
System.out.println(expList); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
228 |
System.out.println("Obtained args:"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
229 |
System.out.println(gotList); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
230 |
throw new RuntimeException("Error: args do not match"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
231 |
} |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
232 |
System.out.println("\'" + inArgs + "\'" + " - Test passed"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
233 |
} |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
234 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
235 |
/* |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
236 |
* This tests general quoting and are specific to Windows, *nixes |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
237 |
* need not worry about this, these have been tested with Windows |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
238 |
* implementation and those that are known to work are used against |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
239 |
* the java implementation. Note that the ProcessBuilder gets in the |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
240 |
* way when testing some of these arguments, therefore we need to |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
241 |
* create and execute a .bat file containing the arguments. |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
242 |
*/ |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
243 |
@Test |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
244 |
void testArgumentParsing() throws IOException { |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
245 |
if (!isWindows) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
246 |
return; |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
247 |
// no quotes |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
248 |
checkArgumentParsing("a b c d", "a", "b", "c", "d"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
249 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
250 |
// single quotes |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
251 |
checkArgumentParsing("\"a b c d\"", "a b c d"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
252 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
253 |
//double quotes |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
254 |
checkArgumentParsing("\"\"a b c d\"\"", "a", "b", "c", "d"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
255 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
256 |
// triple quotes |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
257 |
checkArgumentParsing("\"\"\"a b c d\"\"\"", "\"a b c d\""); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
258 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
259 |
// a literal within single quotes |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
260 |
checkArgumentParsing("\"a\"b c d\"e\"", "ab", "c", "de"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
261 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
262 |
// a literal within double quotes |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
263 |
checkArgumentParsing("\"\"a\"b c d\"e\"\"", "ab c de"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
264 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
265 |
// a literal quote |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
266 |
checkArgumentParsing("a\\\"b", "a\"b"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
267 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
268 |
// double back-slash |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
269 |
checkArgumentParsing("\"a b c d\\\\\"", "a b c d\\"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
270 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
271 |
// triple back-slash |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
272 |
checkArgumentParsing("a\\\\\\\"b", "a\\\"b"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
273 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
274 |
// dangling quote |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
275 |
checkArgumentParsing("\"a b c\"\"", "a b c\""); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
276 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
277 |
// expansions of white space separators |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
278 |
checkArgumentParsing("a b", "a", "b"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
279 |
checkArgumentParsing("a\tb", "a", "b"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
280 |
checkArgumentParsing("a \t b", "a", "b"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
281 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
282 |
checkArgumentParsing("\"C:\\TEST A\\\\\"", "C:\\TEST A\\"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
283 |
checkArgumentParsing("\"\"C:\\TEST A\\\\\"\"", "C:\\TEST", "A\\"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
284 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
285 |
// MS Windows tests |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
286 |
// triple back-slash |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
287 |
checkArgumentParsing("a\\\\\\d", "a\\\\\\d"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
288 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
289 |
// triple back-slash in quotes |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
290 |
checkArgumentParsing("\"a\\\\\\d\"", "a\\\\\\d"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
291 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
292 |
// slashes separating characters |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
293 |
checkArgumentParsing("X\\Y\\Z", "X\\Y\\Z"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
294 |
checkArgumentParsing("\\X\\Y\\Z", "\\X\\Y\\Z"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
295 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
296 |
// literals within dangling quotes, etc. |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
297 |
checkArgumentParsing("\"a b c\" d e", "a b c", "d", "e"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
298 |
checkArgumentParsing("\"ab\\\"c\" \"\\\\\" d", "ab\"c", "\\", "d"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
299 |
checkArgumentParsing("a\\\\\\c d\"e f\"g h", "a\\\\\\c", "de fg", "h"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
300 |
checkArgumentParsing("a\\\\\\\"b c d", "a\\\"b", "c", "d"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
301 |
checkArgumentParsing("a\\\\\\\\\"g c\" d e", "a\\\\g c", "d", "e"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
302 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
303 |
// treatment of back-slashes |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
304 |
checkArgumentParsing("*\\", "*\\"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
305 |
checkArgumentParsing("*/", "*/"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
306 |
checkArgumentParsing(".\\*", ".\\*"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
307 |
checkArgumentParsing("./*", "./*"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
308 |
checkArgumentParsing("..\\..\\*", "..\\..\\*"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
309 |
checkArgumentParsing("../../*", "../../*"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
310 |
checkArgumentParsing("..\\..\\", "..\\..\\"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
311 |
checkArgumentParsing("../../", "../../"); |
15523
cc0ee864bfb5
8006536: [launcher] removes trailing slashes on arguments
ksrini
parents:
14763
diff
changeset
|
312 |
checkArgumentParsing("a b\\ c", "a", "b\\", "c"); |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
313 |
} |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
314 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
315 |
private void initEmptyDir(File emptyDir) throws IOException { |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
316 |
if (emptyDir.exists()) { |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
317 |
recursiveDelete(emptyDir); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
318 |
} |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
319 |
emptyDir.mkdir(); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
320 |
} |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
321 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
322 |
private void initDirWithJavaFiles(File libDir) throws IOException { |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
323 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
324 |
if (libDir.exists()) { |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
325 |
recursiveDelete(libDir); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
326 |
} |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
327 |
libDir.mkdirs(); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
328 |
ArrayList<String> scratchpad = new ArrayList<>(); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
329 |
scratchpad.add("package lib;"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
330 |
scratchpad.add("public class Fbo {"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
331 |
scratchpad.add("public static void main(String... args){Foo.f();}"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
332 |
scratchpad.add("public static void f(){}"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
333 |
scratchpad.add("}"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
334 |
createFile(new File(libDir, "Fbo.java"), scratchpad); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
335 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
336 |
scratchpad.clear(); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
337 |
scratchpad.add("package lib;"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
338 |
scratchpad.add("public class Foo {"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
339 |
scratchpad.add("public static void main(String... args){"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
340 |
scratchpad.add("for (String x : args) {"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
341 |
scratchpad.add("System.out.println(x);"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
342 |
scratchpad.add("}"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
343 |
scratchpad.add("Fbo.f();"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
344 |
scratchpad.add("}"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
345 |
scratchpad.add("public static void f(){}"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
346 |
scratchpad.add("}"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
347 |
createFile(new File(libDir, "Foo.java"), scratchpad); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
348 |
} |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
349 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
350 |
void checkArgumentWildcard(String inArgs, String... expArgs) throws IOException { |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
351 |
String[] in = {inArgs}; |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
352 |
checkArgumentWildcard(in, expArgs); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
353 |
|
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
354 |
// now add arbitrary arguments before and after |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
355 |
String[] outInArgs = { "-Q", inArgs, "-R"}; |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
356 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
357 |
String[] outExpArgs = new String[expArgs.length + 2]; |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
358 |
outExpArgs[0] = "-Q"; |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
359 |
System.arraycopy(expArgs, 0, outExpArgs, 1, expArgs.length); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
360 |
outExpArgs[expArgs.length + 1] = "-R"; |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
361 |
checkArgumentWildcard(outInArgs, outExpArgs); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
362 |
} |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
363 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
364 |
void checkArgumentWildcard(String[] inArgs, String[] expArgs) throws IOException { |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
365 |
ArrayList<String> argList = new ArrayList<>(); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
366 |
argList.add(javaCmd); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
367 |
argList.add("-cp"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
368 |
argList.add("lib" + File.separator + "*"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
369 |
argList.add("lib.Foo"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
370 |
argList.addAll(Arrays.asList(inArgs)); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
371 |
String[] cmds = new String[argList.size()]; |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
372 |
argList.toArray(cmds); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
373 |
TestResult tr = doExec(cmds); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
374 |
if (!tr.isOK()) { |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
375 |
System.out.println(tr); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
376 |
throw new RuntimeException("Error: classpath single entry wildcard entry"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
377 |
} |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
378 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
379 |
ArrayList<String> expList = new ArrayList<>(); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
380 |
expList.addAll(Arrays.asList(expArgs)); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
381 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
382 |
List<String> gotList = new ArrayList<>(); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
383 |
for (String x : tr.testOutput) { |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
384 |
gotList.add(x.trim()); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
385 |
} |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
386 |
if (!gotList.equals(expList)) { |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
387 |
System.out.println(tr); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
388 |
System.out.println("Expected args:"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
389 |
System.out.println(expList); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
390 |
System.out.println("Obtained args:"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
391 |
System.out.println(gotList); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
392 |
throw new RuntimeException("Error: args do not match"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
393 |
} |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
394 |
System.out.print("\'"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
395 |
for (String x : inArgs) { |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
396 |
System.out.print(x + " "); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
397 |
} |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
398 |
System.out.println("\'" + " - Test passed"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
399 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
400 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
401 |
/* |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
402 |
* These tests are not expected to work on *nixes, and are ignored. |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
403 |
*/ |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
404 |
@Test |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
405 |
void testWildCardArgumentProcessing() throws IOException { |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
406 |
if (!isWindows) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
407 |
return; |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
408 |
File cwd = new File("."); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
409 |
File libDir = new File(cwd, "lib"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
410 |
initDirWithJavaFiles(libDir); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
411 |
initEmptyDir(new File(cwd, "empty")); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
412 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
413 |
// test if javac (the command) can compile *.java |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
414 |
TestResult tr = doExec(javacCmd, libDir.getName() + File.separator + "*.java"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
415 |
if (!tr.isOK()) { |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
416 |
System.out.println(tr); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
417 |
throw new RuntimeException("Error: compiling java wildcards"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
418 |
} |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
419 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
420 |
// use the jar cmd to create jars using the ? wildcard |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
421 |
File jarFoo = new File(libDir, "Foo.jar"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
422 |
tr = doExec(jarCmd, "cvf", jarFoo.getAbsolutePath(), "lib" + File.separator + "F?o.class"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
423 |
if (!tr.isOK()) { |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
424 |
System.out.println(tr); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
425 |
throw new RuntimeException("Error: creating jar with wildcards"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
426 |
} |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
427 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
428 |
// now the litmus test!, this should work |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
429 |
checkArgumentWildcard("a", "a"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
430 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
431 |
// test for basic expansion |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
432 |
checkArgumentWildcard("lib\\F*java", "lib\\Fbo.java", "lib\\Foo.java"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
433 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
434 |
// basic expansion in quotes |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
435 |
checkArgumentWildcard("\"lib\\F*java\"", "lib\\F*java"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
436 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
437 |
checkArgumentWildcard("lib\\**", "lib\\Fbo.class", "lib\\Fbo.java", |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
438 |
"lib\\Foo.class", "lib\\Foo.jar", "lib\\Foo.java"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
439 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
440 |
checkArgumentWildcard("lib\\*?", "lib\\Fbo.class", "lib\\Fbo.java", |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
441 |
"lib\\Foo.class", "lib\\Foo.jar", "lib\\Foo.java"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
442 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
443 |
checkArgumentWildcard("lib\\?*", "lib\\Fbo.class", "lib\\Fbo.java", |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
444 |
"lib\\Foo.class", "lib\\Foo.jar", "lib\\Foo.java"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
445 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
446 |
checkArgumentWildcard("lib\\?", "lib\\?"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
447 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
448 |
// test for basic expansion |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
449 |
checkArgumentWildcard("lib\\*java", "lib\\Fbo.java", "lib\\Foo.java"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
450 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
451 |
// basic expansion in quotes |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
452 |
checkArgumentWildcard("\"lib\\*.java\"", "lib\\*.java"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
453 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
454 |
// suffix expansion |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
455 |
checkArgumentWildcard("lib\\*.class", "lib\\Fbo.class", "lib\\Foo.class"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
456 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
457 |
// suffix expansion in quotes |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
458 |
checkArgumentWildcard("\"lib\\*.class\"", "lib\\*.class"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
459 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
460 |
// check for ? expansion now |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
461 |
checkArgumentWildcard("lib\\F?o.java", "lib\\Fbo.java", "lib\\Foo.java"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
462 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
463 |
// check ? in quotes |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
464 |
checkArgumentWildcard("\"lib\\F?o.java\"", "lib\\F?o.java"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
465 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
466 |
// check ? as suffixes |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
467 |
checkArgumentWildcard("lib\\F?o.????", "lib\\Fbo.java", "lib\\Foo.java"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
468 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
469 |
// check ? in a leading role |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
470 |
checkArgumentWildcard("lib\\???.java", "lib\\Fbo.java", "lib\\Foo.java"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
471 |
checkArgumentWildcard("\"lib\\???.java\"", "lib\\???.java"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
472 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
473 |
// check ? prefixed with - |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
474 |
checkArgumentWildcard("-?", "-?"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
475 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
476 |
// check * prefixed with - |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
477 |
checkArgumentWildcard("-*", "-*"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
478 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
479 |
// check on empty directory |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
480 |
checkArgumentWildcard("empty\\*", "empty\\*"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
481 |
checkArgumentWildcard("empty\\**", "empty\\**"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
482 |
checkArgumentWildcard("empty\\?", "empty\\?"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
483 |
checkArgumentWildcard("empty\\??", "empty\\??"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
484 |
checkArgumentWildcard("empty\\*?", "empty\\*?"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
485 |
checkArgumentWildcard("empty\\?*", "empty\\?*"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
486 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
487 |
} |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
488 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
489 |
void doArgumentCheck(String inArgs, String... expArgs) { |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
490 |
Map<String, String> env = new HashMap<>(); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
491 |
env.put(JLDEBUG_KEY, "true"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
492 |
TestResult tr = doExec(env, javaCmd, inArgs); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
493 |
System.out.println(tr); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
494 |
int sindex = tr.testOutput.indexOf("Command line args:"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
495 |
if (sindex < 0) { |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
496 |
System.out.println(tr); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
497 |
throw new RuntimeException("Error: no output"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
498 |
} |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
499 |
sindex++; // skip over the tag |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
500 |
List<String> gotList = new ArrayList<>(); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
501 |
for (String x : tr.testOutput.subList(sindex, sindex + expArgs.length)) { |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
502 |
String a[] = x.split("="); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
503 |
gotList.add(a[a.length - 1].trim()); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
504 |
} |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
505 |
List<String> expList = Arrays.asList(expArgs); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
506 |
if (!gotList.equals(expList)) { |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
507 |
System.out.println(tr); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
508 |
System.out.println("Expected args:"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
509 |
System.out.println(expList); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
510 |
System.out.println("Obtained args:"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
511 |
System.out.println(gotList); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
512 |
throw new RuntimeException("Error: args do not match"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
513 |
} |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
514 |
} |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
515 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
516 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
517 |
/* |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
518 |
* These tests are usually run on non-existent targets to check error results |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
519 |
*/ |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
520 |
@Test |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
521 |
void testBasicErrorMessages() { |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
522 |
// Tests for 5030233 |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
523 |
TestResult tr = doExec(javaCmd, "-cp"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
524 |
tr.checkNegative(); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
525 |
tr.isNotZeroOutput(); |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
526 |
if (!tr.testStatus) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
527 |
System.out.println(tr); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
528 |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
529 |
tr = doExec(javaCmd, "-classpath"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
530 |
tr.checkNegative(); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
531 |
tr.isNotZeroOutput(); |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
532 |
if (!tr.testStatus) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
533 |
System.out.println(tr); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
534 |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
535 |
tr = doExec(javaCmd, "-jar"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
536 |
tr.checkNegative(); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
537 |
tr.isNotZeroOutput(); |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
538 |
if (!tr.testStatus) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
539 |
System.out.println(tr); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
540 |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
541 |
tr = doExec(javacCmd, "-cp"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
542 |
tr.checkNegative(); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
543 |
tr.isNotZeroOutput(); |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
544 |
if (!tr.testStatus) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
545 |
System.out.println(tr); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
546 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
547 |
// Test for 6356475 "REGRESSION:"java -X" from cmdline fails" |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
548 |
tr = doExec(javaCmd, "-X"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
549 |
tr.checkPositive(); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
550 |
tr.isNotZeroOutput(); |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
551 |
if (!tr.testStatus) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
552 |
System.out.println(tr); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
553 |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
554 |
tr = doExec(javaCmd, "-help"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
555 |
tr.checkPositive(); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
556 |
tr.isNotZeroOutput(); |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
557 |
if (!tr.testStatus) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
558 |
System.out.println(tr); |
6005 | 559 |
|
560 |
// 6753938, test for non-negative exit value for an incorrectly formed |
|
561 |
// command line, '% java' |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
562 |
tr = doExec(javaCmd); |
6005 | 563 |
tr.checkNegative(); |
564 |
tr.isNotZeroOutput(); |
|
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
565 |
if (!tr.testStatus) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
566 |
System.out.println(tr); |
6005 | 567 |
|
568 |
// 6753938, test for non-negative exit value for an incorrectly formed |
|
569 |
// command line, '% java -Xcomp' |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
570 |
tr = doExec(javaCmd, "-Xcomp"); |
6005 | 571 |
tr.checkNegative(); |
572 |
tr.isNotZeroOutput(); |
|
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
573 |
if (!tr.testStatus) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
574 |
System.out.println(tr); |
12550 | 575 |
|
12703
c5ebefaa2f9f
7170087: tools/launcher/Arrghs.java test has wrong bugID for 7151434
ksrini
parents:
12550
diff
changeset
|
576 |
// 7151434, test for non-negative exit value for an incorrectly formed |
12550 | 577 |
// command line, '% java -jar -W', note the bogus -W |
578 |
tr = doExec(javaCmd, "-jar", "-W"); |
|
579 |
tr.checkNegative(); |
|
580 |
tr.contains("Unrecognized option: -W"); |
|
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
581 |
if (!tr.testStatus) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
582 |
System.out.println(tr); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
583 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
584 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
585 |
/* |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
586 |
* Tests various dispositions of the main method, these tests are limited |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
587 |
* to English locales as they check for error messages that are localized. |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
588 |
*/ |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
589 |
@Test |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
590 |
void testMainMethod() throws FileNotFoundException { |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
591 |
if (!isEnglishLocale()) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
592 |
return; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
593 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
594 |
|
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
595 |
TestResult tr = null; |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
596 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
597 |
// a missing class |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
598 |
createJar("MIA", new File("some.jar"), new File("Foo"), |
1329
ce13b59a8401
4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents:
1323
diff
changeset
|
599 |
(String[])null); |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
600 |
tr = doExec(javaCmd, "-jar", "some.jar"); |
8174
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
6888
diff
changeset
|
601 |
tr.contains("Error: Could not find or load main class MIA"); |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
602 |
if (!tr.testStatus) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
603 |
System.out.println(tr); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
604 |
// use classpath to check |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
605 |
tr = doExec(javaCmd, "-cp", "some.jar", "MIA"); |
8174
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
6888
diff
changeset
|
606 |
tr.contains("Error: Could not find or load main class MIA"); |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
607 |
if (!tr.testStatus) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
608 |
System.out.println(tr); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
609 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
610 |
// incorrect method access |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
611 |
createJar(new File("some.jar"), new File("Foo"), |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
612 |
"private static void main(String[] args){}"); |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
613 |
tr = doExec(javaCmd, "-jar", "some.jar"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
614 |
tr.contains("Error: Main method not found in class Foo"); |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
615 |
if (!tr.testStatus) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
616 |
System.out.println(tr); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
617 |
// use classpath to check |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
618 |
tr = doExec(javaCmd, "-cp", "some.jar", "Foo"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
619 |
tr.contains("Error: Main method not found in class Foo"); |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
620 |
if (!tr.testStatus) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
621 |
System.out.println(tr); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
622 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
623 |
// incorrect return type |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
624 |
createJar(new File("some.jar"), new File("Foo"), |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
625 |
"public static int main(String[] args){return 1;}"); |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
626 |
tr = doExec(javaCmd, "-jar", "some.jar"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
627 |
tr.contains("Error: Main method must return a value of type void in class Foo"); |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
628 |
if (!tr.testStatus) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
629 |
System.out.println(tr); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
630 |
// use classpath to check |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
631 |
tr = doExec(javaCmd, "-cp", "some.jar", "Foo"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
632 |
tr.contains("Error: Main method must return a value of type void in class Foo"); |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
633 |
if (!tr.testStatus) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
634 |
System.out.println(tr); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
635 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
636 |
// incorrect parameter type |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
637 |
createJar(new File("some.jar"), new File("Foo"), |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
638 |
"public static void main(Object[] args){}"); |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
639 |
tr = doExec(javaCmd, "-jar", "some.jar"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
640 |
tr.contains("Error: Main method not found in class Foo"); |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
641 |
if (!tr.testStatus) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
642 |
System.out.println(tr); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
643 |
// use classpath to check |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
644 |
tr = doExec(javaCmd, "-cp", "some.jar", "Foo"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
645 |
tr.contains("Error: Main method not found in class Foo"); |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
646 |
if (!tr.testStatus) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
647 |
System.out.println(tr); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
648 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
649 |
// incorrect method type - non-static |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
650 |
createJar(new File("some.jar"), new File("Foo"), |
1329
ce13b59a8401
4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents:
1323
diff
changeset
|
651 |
"public void main(String[] args){}"); |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
652 |
tr = doExec(javaCmd, "-jar", "some.jar"); |
1329
ce13b59a8401
4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents:
1323
diff
changeset
|
653 |
tr.contains("Error: Main method is not static in class Foo"); |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
654 |
if (!tr.testStatus) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
655 |
System.out.println(tr); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
656 |
// use classpath to check |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
657 |
tr = doExec(javaCmd, "-cp", "some.jar", "Foo"); |
1329
ce13b59a8401
4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents:
1323
diff
changeset
|
658 |
tr.contains("Error: Main method is not static in class Foo"); |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
659 |
if (!tr.testStatus) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
660 |
System.out.println(tr); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
661 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
662 |
// amongst a potpourri of kindred main methods, is the right one chosen ? |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
663 |
createJar(new File("some.jar"), new File("Foo"), |
8174
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
6888
diff
changeset
|
664 |
"void main(Object[] args){}", |
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
6888
diff
changeset
|
665 |
"int main(Float[] args){return 1;}", |
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
6888
diff
changeset
|
666 |
"private void main() {}", |
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
6888
diff
changeset
|
667 |
"private static void main(int x) {}", |
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
6888
diff
changeset
|
668 |
"public int main(int argc, String[] argv) {return 1;}", |
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
6888
diff
changeset
|
669 |
"public static void main(String[] args) {System.out.println(\"THE_CHOSEN_ONE\");}"); |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
670 |
tr = doExec(javaCmd, "-jar", "some.jar"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
671 |
tr.contains("THE_CHOSEN_ONE"); |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
672 |
if (!tr.testStatus) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
673 |
System.out.println(tr); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
674 |
// use classpath to check |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
675 |
tr = doExec(javaCmd, "-cp", "some.jar", "Foo"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
676 |
tr.contains("THE_CHOSEN_ONE"); |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
677 |
if (!tr.testStatus) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
678 |
System.out.println(tr); |
1329
ce13b59a8401
4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents:
1323
diff
changeset
|
679 |
|
ce13b59a8401
4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents:
1323
diff
changeset
|
680 |
// test for extraneous whitespace in the Main-Class attribute |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
681 |
createJar(" Foo ", new File("some.jar"), new File("Foo"), |
1329
ce13b59a8401
4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents:
1323
diff
changeset
|
682 |
"public static void main(String... args){}"); |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
683 |
tr = doExec(javaCmd, "-jar", "some.jar"); |
1329
ce13b59a8401
4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents:
1323
diff
changeset
|
684 |
tr.checkPositive(); |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
685 |
if (!tr.testStatus) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
686 |
System.out.println(tr); |
2 | 687 |
} |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
688 |
/* |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
689 |
* tests 6968053, ie. we turn on the -Xdiag (for now) flag and check if |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
690 |
* the suppressed stack traces are exposed, ignore these tests for localized |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
691 |
* locales, limiting to English only. |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
692 |
*/ |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
693 |
@Test |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
694 |
void testDiagOptions() throws FileNotFoundException { |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
695 |
if (!isEnglishLocale()) { // only english version |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
696 |
return; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
697 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
698 |
TestResult tr = null; |
8174
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
6888
diff
changeset
|
699 |
// a missing class |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
700 |
createJar("MIA", new File("some.jar"), new File("Foo"), |
8174
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
6888
diff
changeset
|
701 |
(String[])null); |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
702 |
tr = doExec(javaCmd, "-Xdiag", "-jar", "some.jar"); |
8174
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
6888
diff
changeset
|
703 |
tr.contains("Error: Could not find or load main class MIA"); |
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
6888
diff
changeset
|
704 |
tr.contains("java.lang.ClassNotFoundException: MIA"); |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
705 |
if (!tr.testStatus) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
706 |
System.out.println(tr); |
8174
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
6888
diff
changeset
|
707 |
|
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
6888
diff
changeset
|
708 |
// use classpath to check |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
709 |
tr = doExec(javaCmd, "-Xdiag", "-cp", "some.jar", "MIA"); |
8174
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
6888
diff
changeset
|
710 |
tr.contains("Error: Could not find or load main class MIA"); |
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
6888
diff
changeset
|
711 |
tr.contains("java.lang.ClassNotFoundException: MIA"); |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
712 |
if (!tr.testStatus) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
713 |
System.out.println(tr); |
8174
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
6888
diff
changeset
|
714 |
|
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
6888
diff
changeset
|
715 |
// a missing class on the classpath |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
716 |
tr = doExec(javaCmd, "-Xdiag", "NonExistentClass"); |
8174
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
6888
diff
changeset
|
717 |
tr.contains("Error: Could not find or load main class NonExistentClass"); |
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
6888
diff
changeset
|
718 |
tr.contains("java.lang.ClassNotFoundException: NonExistentClass"); |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
719 |
if (!tr.testStatus) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
720 |
System.out.println(tr); |
8174
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
6888
diff
changeset
|
721 |
} |
2 | 722 |
|
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
723 |
@Test |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
724 |
static void testJreRestrictSearchFlag() { |
6888
83b7b1e3301c
6894719: (launcher)The option -no-jre-restrict-search is expected when -jre-no-restrict-search is documented.
ksrini
parents:
6005
diff
changeset
|
725 |
// test both arguments to ensure they exist |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
726 |
TestResult tr = null; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
727 |
tr = doExec(javaCmd, |
6888
83b7b1e3301c
6894719: (launcher)The option -no-jre-restrict-search is expected when -jre-no-restrict-search is documented.
ksrini
parents:
6005
diff
changeset
|
728 |
"-no-jre-restrict-search", "-version"); |
83b7b1e3301c
6894719: (launcher)The option -no-jre-restrict-search is expected when -jre-no-restrict-search is documented.
ksrini
parents:
6005
diff
changeset
|
729 |
tr.checkPositive(); |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
730 |
if (!tr.testStatus) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
731 |
System.out.println(tr); |
6888
83b7b1e3301c
6894719: (launcher)The option -no-jre-restrict-search is expected when -jre-no-restrict-search is documented.
ksrini
parents:
6005
diff
changeset
|
732 |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
733 |
tr = doExec(javaCmd, |
6888
83b7b1e3301c
6894719: (launcher)The option -no-jre-restrict-search is expected when -jre-no-restrict-search is documented.
ksrini
parents:
6005
diff
changeset
|
734 |
"-jre-restrict-search", "-version"); |
83b7b1e3301c
6894719: (launcher)The option -no-jre-restrict-search is expected when -jre-no-restrict-search is documented.
ksrini
parents:
6005
diff
changeset
|
735 |
tr.checkPositive(); |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
736 |
if (!tr.testStatus) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
737 |
System.out.println(tr); |
6888
83b7b1e3301c
6894719: (launcher)The option -no-jre-restrict-search is expected when -jre-no-restrict-search is documented.
ksrini
parents:
6005
diff
changeset
|
738 |
} |
10126
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9035
diff
changeset
|
739 |
|
2 | 740 |
/** |
741 |
* @param args the command line arguments |
|
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
399
diff
changeset
|
742 |
* @throws java.io.FileNotFoundException |
2 | 743 |
*/ |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
744 |
public static void main(String[] args) throws Exception { |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
745 |
if (debug) { |
6888
83b7b1e3301c
6894719: (launcher)The option -no-jre-restrict-search is expected when -jre-no-restrict-search is documented.
ksrini
parents:
6005
diff
changeset
|
746 |
System.out.println("Starting Arrrghs tests"); |
83b7b1e3301c
6894719: (launcher)The option -no-jre-restrict-search is expected when -jre-no-restrict-search is documented.
ksrini
parents:
6005
diff
changeset
|
747 |
} |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
748 |
Arrrghs a = new Arrrghs(); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12703
diff
changeset
|
749 |
a.run(args); |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
750 |
if (testExitValue > 0) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
10126
diff
changeset
|
751 |
System.out.println("Total of " + testExitValue + " failed"); |
6888
83b7b1e3301c
6894719: (launcher)The option -no-jre-restrict-search is expected when -jre-no-restrict-search is documented.
ksrini
parents:
6005
diff
changeset
|
752 |
System.exit(1); |
83b7b1e3301c
6894719: (launcher)The option -no-jre-restrict-search is expected when -jre-no-restrict-search is documented.
ksrini
parents:
6005
diff
changeset
|
753 |
} else { |
83b7b1e3301c
6894719: (launcher)The option -no-jre-restrict-search is expected when -jre-no-restrict-search is documented.
ksrini
parents:
6005
diff
changeset
|
754 |
System.out.println("All tests pass"); |
2 | 755 |
} |
756 |
} |
|
6888
83b7b1e3301c
6894719: (launcher)The option -no-jre-restrict-search is expected when -jre-no-restrict-search is documented.
ksrini
parents:
6005
diff
changeset
|
757 |
} |