author | alanb |
Fri, 11 Jan 2013 20:19:55 +0000 | |
changeset 15254 | 3997a6f357cb |
parent 14786 | a9f61e0cbe61 |
child 22602 | 0d9a07b0d7e9 |
permissions | -rw-r--r-- |
2 | 1 |
# |
14342
8435a30053c1
7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents:
14191
diff
changeset
|
2 |
# Copyright (c) 2005, 2012, 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 |
||
24 |
# @test |
|
14191
01f4a54604a6
7198496: (sl) ServiceLoader.load(Class, null) behavior differs from spec
psandoz
parents:
12047
diff
changeset
|
25 |
# @bug 4640520 6354623 7198496 |
2 | 26 |
# @summary Unit test for java.util.ServiceLoader |
27 |
# |
|
28 |
# @build Basic Load FooService FooProvider1 FooProvider2 FooProvider3 |
|
29 |
# @run shell basic.sh |
|
30 |
||
31 |
# Command-line usage: sh basic.sh /path/to/build |
|
32 |
||
33 |
if [ -z "$TESTJAVA" ]; then |
|
34 |
if [ $# -lt 1 ]; then exit 1; fi |
|
35 |
TESTJAVA="$1"; shift |
|
15254
3997a6f357cb
8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents:
14786
diff
changeset
|
36 |
COMPILEJAVA="${TESTJAVA}" |
2 | 37 |
TESTSRC="`pwd`" |
38 |
TESTCLASSES="`pwd`" |
|
39 |
fi |
|
40 |
||
41 |
JAVA="$TESTJAVA/bin/java" |
|
15254
3997a6f357cb
8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents:
14786
diff
changeset
|
42 |
JAR="$COMPILEJAVA/bin/jar" |
2 | 43 |
|
44 |
OS=`uname -s` |
|
45 |
case "$OS" in |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
7668
diff
changeset
|
46 |
SunOS | Darwin ) |
2 | 47 |
SEP=':' ;; |
48 |
Linux ) |
|
49 |
SEP=':' ;; |
|
50 |
* ) |
|
51 |
SEP='\;' ;; |
|
52 |
esac |
|
53 |
||
4662
49b8cbe45e6a
6911108: These tests do not work with CYGWIN: java/util
ohair
parents:
2
diff
changeset
|
54 |
JARD=x.jar |
49b8cbe45e6a
6911108: These tests do not work with CYGWIN: java/util
ohair
parents:
2
diff
changeset
|
55 |
EXTD=x.ext |
49b8cbe45e6a
6911108: These tests do not work with CYGWIN: java/util
ohair
parents:
2
diff
changeset
|
56 |
TESTD=x.test |
2 | 57 |
|
58 |
if [ \! -d $EXTD ]; then |
|
59 |
# Initialize |
|
60 |
echo Initializing... |
|
61 |
rm -rf $JARD $EXTD $TESTD |
|
62 |
mkdir -p $JARD $EXTD $TESTD |
|
63 |
||
64 |
for n in 2 3; do |
|
65 |
rm -rf $JARD/*; mkdir -p $JARD/META-INF/services |
|
66 |
echo FooProvider$n \ |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
7668
diff
changeset
|
67 |
>$JARD/META-INF/services/FooService |
2 | 68 |
cp $TESTCLASSES/FooProvider$n.class $JARD |
69 |
if [ $n = 3 ]; then |
|
70 |
cp $TESTCLASSES/FooService.class $JARD |
|
71 |
fi |
|
15254
3997a6f357cb
8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents:
14786
diff
changeset
|
72 |
(cd $JARD; "$JAR" ${TESTTOOLVMOPTS} -cf ../p$n.jar *) |
2 | 73 |
done |
74 |
||
75 |
mv p3.jar $EXTD |
|
76 |
||
77 |
cp $TESTCLASSES/Load.class $TESTD |
|
78 |
cp $TESTCLASSES/FooService.class $TESTD |
|
79 |
cp $TESTCLASSES/FooProvider1.class $TESTD |
|
80 |
mkdir -p $TESTD/META-INF/services |
|
81 |
echo FooProvider1 \ |
|
82 |
>$TESTD/META-INF/services/FooService |
|
83 |
||
84 |
# This gives us: |
|
85 |
# $TESTD: FooProvider1 |
|
86 |
# . : FooProvider2, in p2.jar |
|
87 |
# $EXTD: FooProvider3, in p3.jar |
|
88 |
||
89 |
fi |
|
90 |
||
91 |
failures=0 |
|
92 |
||
93 |
go() { |
|
94 |
echo '' |
|
95 |
cp="$1"; shift |
|
96 |
if [ -z "$cp" ]; then cp="$TESTCLASSES"; else cp="$TESTCLASSES$SEP$cp"; fi |
|
97 |
vmargs="$1"; shift |
|
14786
a9f61e0cbe61
8003890: corelibs test scripts should pass TESTVMOPTS
chegar
parents:
14342
diff
changeset
|
98 |
sh -xc "'$JAVA' ${TESTVMOPTS} -cp $cp $vmargs $T $*" 2>&1 |
2 | 99 |
if [ $? != 0 ]; then failures=`expr $failures + 1`; fi |
100 |
} |
|
101 |
||
102 |
||
103 |
# Java-level tests |
|
104 |
||
105 |
T=Basic |
|
106 |
go ".${SEP}$TESTD${SEP}p2.jar" "-Djava.ext.dirs=$EXTD" |
|
107 |
||
108 |
||
109 |
# Success cases |
|
110 |
||
111 |
T=Load |
|
112 |
||
113 |
go "$TESTD" "" FooProvider1 |
|
114 |
||
115 |
go ".${SEP}p2.jar" "" FooProvider2 |
|
116 |
||
117 |
go "" "-Djava.ext.dirs=$EXTD" FooProvider3 |
|
118 |
||
119 |
go "$TESTD${SEP}p2.jar" "" FooProvider1 FooProvider2 |
|
120 |
||
121 |
go "$TESTD" "-Djava.ext.dirs=$EXTD" FooProvider3 FooProvider1 |
|
122 |
||
123 |
go "$TESTD${SEP}p2.jar" "-Djava.ext.dirs=$EXTD" \ |
|
124 |
FooProvider3 FooProvider1 FooProvider2 |
|
125 |
||
126 |
# Should only find the installed provider |
|
127 |
go "$TESTD${SEP}p2.jar" "-Djava.ext.dirs=$EXTD" -i FooProvider3 |
|
128 |
||
129 |
||
130 |
# Failure cases |
|
131 |
||
132 |
mkdir -p x.meta/META-INF/services |
|
133 |
||
134 |
# Simple failures |
|
135 |
for p in FooProvider42 'blah blah' 9234 'X!' java.lang.Object; do |
|
136 |
echo $p >x.meta/META-INF/services/FooService |
|
137 |
go ".${SEP}x.meta" "" fail |
|
138 |
done |
|
139 |
||
140 |
# Failures followed by successes |
|
141 |
echo FooProvider42 >x.meta/META-INF/services/FooService |
|
142 |
go "$TESTD${SEP}x.meta" "" FooProvider1 fail |
|
143 |
go "x.meta${SEP}$TESTD" "" fail FooProvider1 |
|
144 |
go "$TESTD${SEP}x.meta${SEP}${SEP}p2.jar" "-Djava.ext.dirs=$EXTD" \ |
|
145 |
FooProvider3 FooProvider1 fail FooProvider2 |
|
146 |
||
147 |
||
148 |
# Summary |
|
149 |
||
150 |
echo '' |
|
151 |
if [ $failures -gt 0 ]; |
|
152 |
then echo "$failures case(s) failed"; |
|
153 |
else echo "All cases passed"; fi |
|
154 |
exit $failures |