1 #
   2 # Copyright (c) 2007, 2012, 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 #!/bin/sh
  24 #
  25 #
  26 #
  27 # This script is the actual launcher of each locale service provider test.
  28 # fooprovider.jar contains localized object providers and barprovider.jar
  29 # contains localized name providers.  This way, we can test providers that
  30 # can relate to each other (such as, DateFormatSymbolsProvider and
  31 # TimeZoneNameProvider) separately.
  32 #
  33 # Parameters:
  34 #    providersToTest: [foo|bar|foobar]
  35 #    java class name: <class name>
  36 #    providersInExtDir: [true|false]
  37 
  38 if [ "${TESTSRC}" = "" ]
  39 then
  40   echo "TESTSRC not set.  Test cannot execute.  Failed."
  41   exit 1
  42 fi
  43 echo "TESTSRC=${TESTSRC}"
  44 if [ "${TESTJAVA}" = "" ]
  45 then
  46   echo "TESTJAVA not set.  Test cannot execute.  Failed."
  47   exit 1
  48 fi
  49 if [ "${COMPILEJAVA}" = "" ]
  50 then
  51   COMPILEJAVA="${TESTJAVA}"
  52 fi
  53 echo "TESTJAVA=${TESTJAVA}"
  54 if [ "${TESTCLASSES}" = "" ]
  55 then
  56   echo "TESTCLASSES not set.  Test cannot execute.  Failed."
  57   exit 1
  58 fi
  59 echo "TESTCLASSES=${TESTCLASSES}"
  60 echo "CLASSPATH=${CLASSPATH}"
  61 
  62 # set platform-dependent variables
  63 OS=`uname -s`
  64 case "$OS" in
  65   SunOS | Linux | Darwin )
  66     PS=":"
  67     FS="/"
  68     ;;
  69   Windows* | CYGWIN* )
  70     PS=";"
  71     FS="\\"
  72     ;;
  73   * )
  74     echo "Unrecognized system!"
  75     exit 1;
  76     ;;
  77 esac
  78 
  79 # set classpath and extension directory variables
  80 if [ -d ${TESTJAVA}${FS}lib${FS}ext ]
  81 then
  82     EXTDIRS="${TESTJAVA}${FS}lib${FS}ext${PS}${TESTCLASSES}"
  83 else
  84     EXTDIRS="${TESTJAVA}${FS}jre${FS}lib${FS}ext${PS}${TESTCLASSES}"
  85 fi
  86 
  87 case "$1" in
  88   "foo" )
  89     cp ${TESTSRC}${FS}fooprovider.jar ${TESTCLASSES}
  90     CLASSPATHARG=".${PS}${TESTSRC}${PS}${TESTSRC}${FS}fooprovider.jar"
  91     ;;
  92   "bar" )
  93     cp ${TESTSRC}${FS}barprovider.jar ${TESTCLASSES}
  94     CLASSPATHARG=".${PS}${TESTSRC}${PS}${TESTSRC}${FS}barprovider.jar"
  95     ;;
  96   "foobar" )
  97     cp ${TESTSRC}${FS}fooprovider.jar ${TESTCLASSES}
  98     cp ${TESTSRC}${FS}barprovider.jar ${TESTCLASSES}
  99     CLASSPATHARG=".${PS}${TESTSRC}${PS}${TESTSRC}${FS}fooprovider.jar${PS}${TESTSRC}${PS}${TESTSRC}${FS}barprovider.jar"
 100     ;;
 101 esac
 102 
 103 # compile
 104 cp ${TESTSRC}${FS}ProviderTest.java .
 105 cp ${TESTSRC}${FS}$2.java .
 106 COMPILE="${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \
 107     -XDignore.symbol.file -d . -classpath ${CLASSPATHARG} $2.java"
 108 echo ${COMPILE}
 109 ${COMPILE}
 110 result=$?
 111 
 112 if [ $result -eq 0 ]
 113 then
 114   echo "Compilation of the test case was successful."
 115 else
 116   echo "Compilation of the test case failed."
 117   # Cleanup
 118   rm -f ${TESTCLASSES}${FS}$2*.class
 119   rm -f ${TESTCLASSES}${FS}fooprovider.jar
 120   rm -f ${TESTCLASSES}${FS}barprovider.jar
 121   exit $result
 122 fi
 123 
 124 # run
 125 if [ "$3" = "true" ]
 126 then
 127   RUNCMD="${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -Djava.ext.dirs=${EXTDIRS} $2 "
 128 else
 129   RUNCMD="${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -classpath ${CLASSPATHARG} $2 "
 130 fi
 131 
 132 echo ${RUNCMD}
 133 ${RUNCMD}
 134 result=$?
 135 
 136 if [ $result -eq 0 ]
 137 then
 138   echo "Execution successful"
 139 else
 140   echo "Execution of the test case failed."
 141 fi
 142 
 143 # Cleanup
 144 rm -f ${TESTCLASSES}${FS}$2*.class
 145 rm -f ${TESTCLASSES}${FS}fooprovider.jar
 146 rm -f ${TESTCLASSES}${FS}barprovider.jar
 147 
 148 exit $result