2
|
1 |
#!/bin/sh
|
|
2 |
|
|
3 |
#
|
5506
|
4 |
# Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
|
2
|
5 |
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
6 |
#
|
|
7 |
# This code is free software; you can redistribute it and/or modify it
|
|
8 |
# under the terms of the GNU General Public License version 2 only, as
|
|
9 |
# published by the Free Software Foundation.
|
|
10 |
#
|
|
11 |
# This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
# version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
# accompanied this code).
|
|
16 |
#
|
|
17 |
# You should have received a copy of the GNU General Public License version
|
|
18 |
# 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
#
|
5506
|
21 |
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
22 |
# or visit www.oracle.com if you need additional information or have any
|
|
23 |
# questions.
|
2
|
24 |
#
|
|
25 |
|
|
26 |
|
|
27 |
# @test
|
|
28 |
# @bug 4763315
|
|
29 |
# @build CanonicalName Lookup
|
|
30 |
# @run shell/timeout=120 cname.sh
|
|
31 |
# @summary Test DNS provider's handling of CNAME records
|
|
32 |
|
|
33 |
|
|
34 |
# The host that we try to resolve
|
|
35 |
|
|
36 |
HOST=webcache.sfbay.sun.com
|
|
37 |
|
|
38 |
# fail gracefully if DNS is not configured or there
|
|
39 |
# isn't a CNAME record.
|
|
40 |
|
|
41 |
CLASSPATH=${TESTCLASSES}
|
|
42 |
export CLASSPATH
|
|
43 |
JAVA="${TESTJAVA}/bin/java"
|
|
44 |
|
|
45 |
sh -xc "$JAVA CanonicalName $HOST" 2>&1
|
|
46 |
if [ $? != 0 ]; then
|
|
47 |
echo "DNS not configured or host doesn't resolve to CNAME record"
|
|
48 |
exit 0
|
|
49 |
fi
|
|
50 |
|
|
51 |
failures=0
|
|
52 |
|
|
53 |
go() {
|
|
54 |
echo ''
|
|
55 |
sh -xc "$JAVA $1 Lookup $2" 2>&1
|
|
56 |
if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
|
|
57 |
}
|
|
58 |
|
|
59 |
# Tests - with & without security manager
|
|
60 |
|
|
61 |
POLICY=java.policy
|
|
62 |
echo "grant {" > ${POLICY}
|
|
63 |
echo " permission java.net.SocketPermission \"${HOST}\", \"resolve\";" >> ${POLICY}
|
|
64 |
echo "};" >> ${POLICY}
|
|
65 |
|
|
66 |
np="-Dsun.net.spi.nameservice.provider.1=dns,sun"
|
|
67 |
sm="-Djava.security.manager -Djava.security.policy=${POLICY}"
|
|
68 |
|
|
69 |
go "$np" "$HOST"
|
|
70 |
go "$np $sm" "$HOST"
|
|
71 |
|
|
72 |
|
|
73 |
#
|
|
74 |
# Results
|
|
75 |
#
|
|
76 |
echo ''
|
|
77 |
if [ $failures -gt 0 ];
|
|
78 |
then echo "$failures test(s) failed";
|
|
79 |
else echo "All test(s) passed"; fi
|
|
80 |
exit $failures
|