author | mfang |
Wed, 17 Aug 2011 14:18:26 -0700 | |
changeset 10294 | 8fcdae2a7ec7 |
parent 5506 | 202f599c92aa |
child 46151 | 5fa789776f7d |
permissions | -rw-r--r-- |
434
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
1 |
/* |
5506 | 2 |
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. |
434
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
4 |
* |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
8 |
* |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
13 |
* accompanied this code). |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
14 |
* |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
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. |
|
434
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
22 |
*/ |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
23 |
|
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
24 |
/* |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
25 |
test |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
26 |
@bug 6193279 |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
27 |
@summary REGRESSION: AppletViewer throws IOException when path is encoded URL |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
28 |
@author Dmitry Cherepanov: area=appletviewer |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
29 |
@run compile IOExceptionIfEncodedURLTest.java |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
30 |
@run main IOExceptionIfEncodedURLTest |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
31 |
@run shell IOExceptionIfEncodedURLTest.sh |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
32 |
*/ |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
33 |
|
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
34 |
import java.applet.Applet; |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
35 |
import sun.net.www.ParseUtil; |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
36 |
import java.io.File; |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
37 |
import java.net.MalformedURLException; |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
38 |
|
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
39 |
public class IOExceptionIfEncodedURLTest extends Applet{ |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
40 |
public void init(){ |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
41 |
} |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
42 |
|
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
43 |
public void start(){ |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
44 |
// We check that appletviewer writes this message to log file |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
45 |
System.err.println("the appletviewer started"); |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
46 |
} |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
47 |
|
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
48 |
// We expect that sun.net.www.ParseUtil.fileToEncodedURL works like following |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
49 |
// if relative file URL, like this "file:index.html" is processed |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
50 |
static String url = "file:IOExceptionIfEncodedURLTest.java"; |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
51 |
public static final void main(String args[]) |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
52 |
throws MalformedURLException{ |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
53 |
System.err.println("prior checking..."); |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
54 |
String prefix = "file:"; |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
55 |
String path = ParseUtil.fileToEncodedURL(new File(System.getProperty("user.dir"))).getPath(); |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
56 |
String filename = url.substring(prefix.length()); |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
57 |
System.err.println("url="+url+" -> path="+path+",filename="+filename); |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
58 |
|
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
59 |
if (!path.endsWith("/") && !filename.startsWith("/")) { |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
60 |
throw new RuntimeException("Incorrect '/' processing"); |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
61 |
} |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
62 |
} |
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
63 |
|
acc4487b3f1b
6619458: testcase depends on a file with the name te{st.html
dcherepanov
parents:
diff
changeset
|
64 |
} |