0N/A#!/bin/sh
0N/A
0N/A#
4009N/A# Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
0N/A# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A#
0N/A# This code is free software; you can redistribute it and/or modify it
0N/A# under the terms of the GNU General Public License version 2 only, as
0N/A# published by the Free Software Foundation.
0N/A#
0N/A# This code is distributed in the hope that it will be useful, but WITHOUT
0N/A# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A# version 2 for more details (a copy is included in the LICENSE file that
0N/A# accompanied this code).
0N/A#
0N/A# You should have received a copy of the GNU General Public License version
0N/A# 2 along with this work; if not, write to the Free Software Foundation,
0N/A# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A#
2362N/A# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A# or visit www.oracle.com if you need additional information or have any
2362N/A# questions.
0N/A#
0N/A
0N/A
0N/A# @test
0N/A# @bug 4763315
4009N/A# @build CanonicalName Lookup
0N/A# @run shell/timeout=120 cname.sh
0N/A# @summary Test DNS provider's handling of CNAME records
0N/A
0N/A
0N/A# The host that we try to resolve
0N/A
4009N/AHOST=www-proxy.us.oracle.com
0N/A
4009N/A# fail gracefully if DNS is not configured or there
0N/A# isn't a CNAME record.
0N/A
0N/ACLASSPATH=${TESTCLASSES}
0N/Aexport CLASSPATH
0N/AJAVA="${TESTJAVA}/bin/java"
0N/A
0N/Ash -xc "$JAVA CanonicalName $HOST" 2>&1
4009N/Aif [ $? != 0 ]; then
0N/A echo "DNS not configured or host doesn't resolve to CNAME record"
0N/A exit 0
0N/Afi
0N/A
0N/Afailures=0
0N/A
0N/Ago() {
0N/A echo ''
0N/A sh -xc "$JAVA $1 Lookup $2" 2>&1
0N/A if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
0N/A}
0N/A
0N/A# Tests - with & without security manager
0N/A
0N/APOLICY=java.policy
0N/Aecho "grant {" > ${POLICY}
0N/Aecho " permission java.net.SocketPermission \"${HOST}\", \"resolve\";" >> ${POLICY}
0N/Aecho "};" >> ${POLICY}
0N/A
0N/Anp="-Dsun.net.spi.nameservice.provider.1=dns,sun"
0N/Asm="-Djava.security.manager -Djava.security.policy=${POLICY}"
0N/A
0N/Ago "$np" "$HOST"
0N/Ago "$np $sm" "$HOST"
0N/A
0N/A
4009N/A#
0N/A# Results
0N/A#
0N/Aecho ''
0N/Aif [ $failures -gt 0 ];
0N/A then echo "$failures test(s) failed";
0N/A else echo "All test(s) passed"; fi
0N/Aexit $failures