1 #
   2 # Copyright (c) 2014, 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 # @test
  25 # @bug 6760902
  26 # @summary Empty path on bootclasspath is not default to current working
  27 #          directory for both class lookup and resource lookup
  28 #
  29 # @run shell GetResource.sh
  30 
  31 if [ "${TESTSRC}" = "" ] ; then
  32     TESTSRC=`pwd`
  33 fi
  34 if [ "${TESTCLASSES}" = "" ] ; then
  35     TESTCLASSES=`pwd`
  36 fi
  37 
  38 if [ "${TESTJAVA}" = "" ] ; then
  39     echo "TESTJAVA not set.  Test cannot execute."
  40     echo "FAILED!!!"
  41     exit 1
  42 fi
  43 
  44 if [ "${COMPILEJAVA}" = "" ] ; then
  45     COMPILEJAVA="${TESTJAVA}"
  46 fi
  47 
  48 # set platform-specific variables
  49 OS=`uname -s`
  50 case "$OS" in
  51   SunOS )
  52     PS=":"
  53     ;;
  54   Linux )
  55     PS=":"
  56     ;;
  57   Darwin )
  58     PS=":"
  59     ;;
  60   Windows*)
  61     PS=";"
  62     ;;
  63   CYGWIN* )
  64     PS=";"
  65     TESTCLASSES=`/usr/bin/cygpath -a -s -m ${TESTCLASSES}`
  66     ;;
  67 esac
  68 
  69 echo TESTSRC=${TESTSRC}
  70 echo TESTCLASSES=${TESTCLASSES}
  71 echo TESTJAVA=${TESTJAVA}
  72 echo ""
  73 
  74 ${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \
  75         -d ${TESTCLASSES} \
  76         ${TESTSRC}/GetResource.java  || exit 10
  77 
  78 setup() {
  79     dest=${TESTCLASSES}/$1
  80     rm -rf $dest
  81     mkdir $dest
  82     cp ${TESTSRC}/test.properties $dest
  83     cp ${TESTCLASSES}/GetResource.class $dest
  84 }
  85 
  86 # run test
  87 setup "a"
  88 setup "b"
  89 
  90 cd ${TESTCLASSES}
  91 DIR=`pwd`
  92 
  93 echo "1. Test -Xbootclasspath/p:a"
  94 ${TESTJAVA}/bin/java ${TESTVMOPTS} "-Xbootclasspath/p:a" \
  95         GetResource "a"   || exit 1
  96 
  97 echo "2. Test -Xbootclasspath/p:b"
  98 ${TESTJAVA}/bin/java ${TESTVMOPTS} "-Xbootclasspath/p:b" \
  99         GetResource "b"   || exit 2
 100 
 101 echo "3. Test -Xbootclasspath/p:a${PS}b"
 102 ${TESTJAVA}/bin/java ${TESTVMOPTS} "-Xbootclasspath/p:a${PS}b" \
 103         GetResource "a"   || exit 3
 104 
 105 echo "4. Test -Xbootclasspath/p:b${PS}a"
 106 ${TESTJAVA}/bin/java ${TESTVMOPTS} "-Xbootclasspath/p:b${PS}a" \
 107         GetResource "b"   || exit 4
 108 
 109 cd ${DIR}/a
 110 echo "5. Test -Xbootclasspath/p:."
 111 ${TESTJAVA}/bin/java ${TESTVMOPTS} "-Xbootclasspath/p:." \
 112         GetResource "a"   || exit 5
 113 
 114 echo "6. Test -Xbootclasspath/p:../b"
 115 ${TESTJAVA}/bin/java ${TESTVMOPTS} "-Xbootclasspath/p:../b" \
 116         GetResource "b"   || exit 6
 117 
 118 # Test empty path in bootclasspath not default to current working directory
 119 echo "7. Test -Xbootclasspath/p:${PS}../b"
 120 ${TESTJAVA}/bin/java ${TESTVMOPTS} "-Xbootclasspath/p:${PS}../b" \
 121         GetResource "b"   || exit 7