1 #
2 # Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
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 #
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.
22 #
23
24 #!/bin/ksh -p
25 #
26 # @test IOExceptionIfEncodedURLTest.sh
27 # @bug 6193279 6619458
28 # @summary REGRESSION: AppletViewer throws IOException when path is encoded URL
29 # @author Dmitry Cherepanov: area=appletviewer
30 # @modules java.base/sun.net.www
31 # java.desktop
32 # @run compile IOExceptionIfEncodedURLTest.java
33 # @run main IOExceptionIfEncodedURLTest
34 # @run shell IOExceptionIfEncodedURLTest.sh
35
36 # Beginning of subroutines:
37 status=1
38
39 #Call this from anywhere to fail the test with an error message
40 # usage: fail "reason why the test failed"
41 fail()
42 { echo "The test failed :-("
43 echo "$*" 1>&2
44 echo "exit status was $status"
45 exit $status
46 } #end of fail()
47
48 #Call this from anywhere to pass the test with a message
49 # usage: pass "reason why the test passed if applicable"
50 pass()
51 { echo "The test passed!!!"
52 echo "$*" 1>&2
53 exit 0
54 } #end of pass()
55
56 #Call this to run the test with a file name
57 test()
58 {
59 ${TESTJAVA}${FILESEP}bin${FILESEP}appletviewer -Xnosecurity ${URL} > err 2>&1 &
60 APPLET_ID=$!
61 sleep 15
62 kill -9 $APPLET_ID
63
64 # these exceptions will be thrown if the test fails
65 cat err | grep "I/O exception while reading"
66 exception=$?
67 if [ $exception = "0" ];
68 then fail "test failed for "${URL}", see err file and CRs #6193279,6329251,6376334"
69 fi
70
71 cat err | grep "java.lang.ClassNotFoundException"
72 exception=$?
73 if [ $exception = "0" ];
74 then fail "test failed for "${URL}", see err file and CRs #6193279,6329251,6376334"
75 fi
76
77 # the applet will log the same message
78 cat err | grep "the appletviewer started"
79 started=$?
117 VAR="A different value for MacOSX"
118 DEFAULT_JDK=/usr
119 FILESEP="/"
120 PATHSEP=":"
121 TMP="/tmp"
122 ;;
123
124 Windows* )
125 VAR="A different value for Win32"
126 DEFAULT_JDK="C:/Program Files/Java/jdk1.8.0"
127 FILESEP="\\"
128 PATHSEP=";"
129 TMP=`cd "${SystemRoot}/Temp"; echo ${PWD}`
130 ;;
131
132 CYGWIN* )
133 VAR="A different value for Cygwin"
134 DEFAULT_JDK="/cygdrive/c/Program\ Files/Java/jdk1.8.0"
135 FILESEP="/"
136 PATHSEP=";"
137 TMP=`cd "${SystemRoot}/Temp"; echo ${PWD}`
138 ;;
139
140 AIX )
141 VAR="A different value for AIX"
142 DEFAULT_JDK=/
143 FILESEP="/"
144 PATHSEP=":"
145 TMP="/tmp"
146 ;;
147
148 # catch all other OSs
149 * )
150 echo "Unrecognized system! $OS"
151 fail "Unrecognized system! $OS"
152 ;;
153 esac
154
155 # 6438730: Only a minimal set of env variables are set for shell tests.
156 # To guarantee that env variable holds correct value we need to set it ourselves.
157 if [ -z "${PWD}" ] ; then
158 PWD=`pwd`
159 fi
160
161 # check that some executable or other file you need is available, abort if not
162 # note that the name of the executable is in the fail string as well.
163 # this is how to check for presence of the compiler, etc.
164 #RESOURCE=`whence SomeProgramOrFileNeeded`
165 #if [ "${RESOURCE}" = "" ] ;
166 # then fail "Need SomeProgramOrFileNeeded to perform the test" ;
167 #fi
168
169 # Want this test to run standalone as well as in the harness, so do the
170 # following to copy the test's directory into the harness's scratch directory
171 # and set all appropriate variables:
172
173 if [ -z "${TESTJAVA}" ] ; then
174 # TESTJAVA is not set, so the test is running stand-alone.
223 # pass, you should be able to cut and paste it into here and it will
224 # run with the test harness.
225
226 # This is an example of running something -- test
227 # The stuff below catches the exit status of test then passes or fails
228 # this shell test as appropriate ( 0 status is considered a pass here )
229
230 # The test verifies that appletviewer correctly works with the different
231 # names of the files, including relative and absolute paths
232
233 # 6619458: exclude left brace from the name of the files managed by the VCS
234 NAME='test.html'
235
236 ENCODED='te%7Bst.html'
237 UNENCODED='te{st.html'
238
239 # Copy needed files into the harness's scratch directory
240 # or create a copy with the required name if the test is
241 # running as stand-alone
242 cp ${TESTSRC}${FILESEP}${NAME} ${UNENCODED}
243
244 # the encoded name, the path is absolute
245 URL="file:"${PWD}${FILESEP}${ENCODED}
246 test
247
248 # the encoded name, the path is relative
249 URL="file:"${ENCODED}
250 test
251
252 # the unencoded name, the path is absolute
253 URL="file:"${PWD}${FILESEP}${UNENCODED}
254 test
255
256 # the unencoded name, the path is relative
257 URL="file:"${UNENCODED}
258 test
259
260 # pick up our toys from the scratch directory
261 rm ${UNENCODED}
|
1 #
2 # Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
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 #
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.
22 #
23
24 #!/bin/ksh -p
25 #
26 # @test IOExceptionIfEncodedURLTest.sh
27 # @bug 6193279 6619458 8137087
28 # @summary REGRESSION: AppletViewer throws IOException when path is encoded URL
29 # @author Dmitry Cherepanov: area=appletviewer
30 # @modules java.base/sun.net.www
31 # java.desktop
32 # @run compile IOExceptionIfEncodedURLTest.java
33 # @run main IOExceptionIfEncodedURLTest
34 # @run shell IOExceptionIfEncodedURLTest.sh
35
36 # Beginning of subroutines:
37 status=1
38
39 #Call this from anywhere to fail the test with an error message
40 # usage: fail "reason why the test failed"
41 fail()
42 { echo "The test failed :-("
43 echo "$*" 1>&2
44 echo "exit status was $status"
45 exit $status
46 } #end of fail()
47
48 #Call this from anywhere to pass the test with a message
49 # usage: pass "reason why the test passed if applicable"
50 pass()
51 { echo "The test passed!!!"
52 echo "$*" 1>&2
53 exit 0
54 } #end of pass()
55
56 #Call this to run the test with a file name
57 test()
58 {
59 "${TESTJAVA}"${FILESEP}bin${FILESEP}appletviewer -Xnosecurity ${URL} > err 2>&1 &
60 APPLET_ID=$!
61 sleep 15
62 kill -9 $APPLET_ID
63
64 # these exceptions will be thrown if the test fails
65 cat err | grep "I/O exception while reading"
66 exception=$?
67 if [ $exception = "0" ];
68 then fail "test failed for "${URL}", see err file and CRs #6193279,6329251,6376334"
69 fi
70
71 cat err | grep "java.lang.ClassNotFoundException"
72 exception=$?
73 if [ $exception = "0" ];
74 then fail "test failed for "${URL}", see err file and CRs #6193279,6329251,6376334"
75 fi
76
77 # the applet will log the same message
78 cat err | grep "the appletviewer started"
79 started=$?
117 VAR="A different value for MacOSX"
118 DEFAULT_JDK=/usr
119 FILESEP="/"
120 PATHSEP=":"
121 TMP="/tmp"
122 ;;
123
124 Windows* )
125 VAR="A different value for Win32"
126 DEFAULT_JDK="C:/Program Files/Java/jdk1.8.0"
127 FILESEP="\\"
128 PATHSEP=";"
129 TMP=`cd "${SystemRoot}/Temp"; echo ${PWD}`
130 ;;
131
132 CYGWIN* )
133 VAR="A different value for Cygwin"
134 DEFAULT_JDK="/cygdrive/c/Program\ Files/Java/jdk1.8.0"
135 FILESEP="/"
136 PATHSEP=";"
137 TMP=`cd "${SYSTEMROOT}/Temp"; echo ${PWD}`
138 x="cygpath -m $PWD"
139 eval $x
140 PWD=$(eval $x)
141 ;;
142
143 AIX )
144 VAR="A different value for AIX"
145 DEFAULT_JDK=/
146 FILESEP="/"
147 PATHSEP=":"
148 TMP="/tmp"
149 ;;
150
151 # catch all other OSs
152 * )
153 echo "Unrecognized system! $OS"
154 fail "Unrecognized system! $OS"
155 ;;
156 esac
157
158
159 # 6438730: Only a minimal set of env variables are set for shell tests.
160 # To guarantee that env variable holds correct value we need to set it ourselves.
161 if [ -z "${PWD}" ] ; then
162 PWD=`pwd`
163 fi
164
165 # check that some executable or other file you need is available, abort if not
166 # note that the name of the executable is in the fail string as well.
167 # this is how to check for presence of the compiler, etc.
168 #RESOURCE=`whence SomeProgramOrFileNeeded`
169 #if [ "${RESOURCE}" = "" ] ;
170 # then fail "Need SomeProgramOrFileNeeded to perform the test" ;
171 #fi
172
173 # Want this test to run standalone as well as in the harness, so do the
174 # following to copy the test's directory into the harness's scratch directory
175 # and set all appropriate variables:
176
177 if [ -z "${TESTJAVA}" ] ; then
178 # TESTJAVA is not set, so the test is running stand-alone.
227 # pass, you should be able to cut and paste it into here and it will
228 # run with the test harness.
229
230 # This is an example of running something -- test
231 # The stuff below catches the exit status of test then passes or fails
232 # this shell test as appropriate ( 0 status is considered a pass here )
233
234 # The test verifies that appletviewer correctly works with the different
235 # names of the files, including relative and absolute paths
236
237 # 6619458: exclude left brace from the name of the files managed by the VCS
238 NAME='test.html'
239
240 ENCODED='te%7Bst.html'
241 UNENCODED='te{st.html'
242
243 # Copy needed files into the harness's scratch directory
244 # or create a copy with the required name if the test is
245 # running as stand-alone
246 cp ${TESTSRC}${FILESEP}${NAME} ${UNENCODED}
247
248
249 # the encoded name, the path is absolute
250 URL="file:"${PWD}${FILESEP}${ENCODED}
251 test
252
253 # the encoded name, the path is relative
254 URL="file:"${ENCODED}
255 test
256
257 # the unencoded name, the path is absolute
258 URL="file:"${PWD}${FILESEP}${UNENCODED}
259 test
260
261 # the unencoded name, the path is relative
262 URL="file:"${UNENCODED}
263 test
264
265 # pick up our toys from the scratch directory
266 rm ${UNENCODED}
|