test/sun/net/InetAddress/nameservice/dns/cname.sh

Print this page




  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=www-proxy.us.oracle.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 ${TESTVMOPTS} 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 ${TESTVMOPTS} $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 #


  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=www-proxy.us.oracle.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 ${TESTVMOPTS} ${TESTJAVAOPTS} 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 ${TESTVMOPTS} ${TESTJAVAOPTS} $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 #