1 # 
   2 # Copyright (c) 2007 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20 # CA 95054 USA or visit www.sun.com if you need additional information or
  21 # have any 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 echo "TESTJAVA=${TESTJAVA}"
  50 if [ "${TESTCLASSES}" = "" ]
  51 then
  52   echo "TESTCLASSES not set.  Test cannot execute.  Failed."
  53   exit 1
  54 fi
  55 echo "TESTCLASSES=${TESTCLASSES}"
  56 echo "CLASSPATH=${CLASSPATH}"
  57 
  58 # set platform-dependent variables
  59 OS=`uname -s`
  60 case "$OS" in
  61   SunOS | Linux )
  62     PS=":"
  63     FS="/"
  64     ;;
  65   Windows* )
  66     PS=";"
  67     FS="\\"
  68     ;;
  69   * )
  70     echo "Unrecognized system!"
  71     exit 1;
  72     ;;
  73 esac
  74 
  75 # set classpath and extension directory variables
  76 if [ -d ${TESTJAVA}${FS}lib${FS}ext ]
  77 then
  78     EXTDIRS="${TESTJAVA}${FS}lib${FS}ext${PS}${TESTCLASSES}"
  79 else
  80     EXTDIRS="${TESTJAVA}${FS}jre${FS}lib${FS}ext${PS}${TESTCLASSES}"
  81 fi
  82 
  83 case "$1" in 
  84   "foo" )
  85     cp ${TESTSRC}${FS}fooprovider.jar ${TESTCLASSES}
  86     CLASSPATHARG=".${PS}${TESTSRC}${PS}${TESTSRC}${FS}fooprovider.jar"
  87     ;;
  88   "bar" )
  89     cp ${TESTSRC}${FS}barprovider.jar ${TESTCLASSES}
  90     CLASSPATHARG=".${PS}${TESTSRC}${PS}${TESTSRC}${FS}barprovider.jar"
  91     ;;
  92   "foobar" )
  93     cp ${TESTSRC}${FS}fooprovider.jar ${TESTCLASSES}
  94     cp ${TESTSRC}${FS}barprovider.jar ${TESTCLASSES}
  95     CLASSPATHARG=".${PS}${TESTSRC}${PS}${TESTSRC}${FS}fooprovider.jar${PS}${TESTSRC}${PS}${TESTSRC}${FS}barprovider.jar"
  96     ;;
  97 esac
  98     
  99 # compile
 100 cp ${TESTSRC}${FS}ProviderTest.java .
 101 cp ${TESTSRC}${FS}$2.java .
 102 COMPILE="${TESTJAVA}${FS}bin${FS}javac -XDignore.symbol.file -d . -classpath ${CLASSPATHARG} $2.java"
 103 echo ${COMPILE}
 104 ${COMPILE}
 105 result=$?
 106 
 107 if [ $result -eq 0 ]
 108 then
 109   echo "Compilation of the test case was successful."
 110 else 
 111   echo "Compilation of the test case failed."
 112   # Cleanup
 113   rm -f ${TESTCLASSES}${FS}$2*.class
 114   rm -f ${TESTCLASSES}${FS}fooprovider.jar
 115   rm -f ${TESTCLASSES}${FS}barprovider.jar
 116   exit $result
 117 fi
 118 
 119 # run
 120 if [ "$3" = "true" ]
 121 then
 122   RUNCMD="${TESTJAVA}${FS}bin${FS}java -Djava.ext.dirs=${EXTDIRS} $2 "
 123 else
 124   RUNCMD="${TESTJAVA}${FS}bin${FS}java -classpath ${CLASSPATHARG} $2 "
 125 fi
 126 
 127 echo ${RUNCMD}
 128 ${RUNCMD}
 129 result=$?
 130 
 131 if [ $result -eq 0 ]
 132 then
 133   echo "Execution successful"
 134 else
 135   echo "Execution of the test case failed."
 136 fi
 137 
 138 # Cleanup
 139 rm -f ${TESTCLASSES}${FS}$2*.class
 140 rm -f ${TESTCLASSES}${FS}fooprovider.jar
 141 rm -f ${TESTCLASSES}${FS}barprovider.jar
 142 
 143 exit $result