test/java/util/Locale/LocaleProviders.sh

Print this page
rev 5931 : imported patch 8000245.8000273.8000615


   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 # @test
  26 # @bug 6336885 7196799 7197573 7198834
  27 # @summary tests for "java.locale.providers" system property
  28 # @compile -XDignore.symbol.file LocaleProviders.java
  29 # @run shell/timeout=600 LocaleProviders.sh
  30 
  31 if [ "${TESTSRC}" = "" ]
  32 then
  33   echo "TESTSRC not set.  Test cannot execute.  Failed."
  34   exit 1
  35 fi
  36 echo "TESTSRC=${TESTSRC}"
  37 if [ "${TESTJAVA}" = "" ]
  38 then
  39   echo "TESTJAVA not set.  Test cannot execute.  Failed."
  40   exit 1
  41 fi
  42 echo "TESTJAVA=${TESTJAVA}"
  43 if [ "${TESTCLASSES}" = "" ]
  44 then
  45   echo "TESTCLASSES not set.  Test cannot execute.  Failed."
  46   exit 1


  48 echo "TESTCLASSES=${TESTCLASSES}"
  49 echo "CLASSPATH=${CLASSPATH}"
  50 
  51 # set platform-dependent variables
  52 OS=`uname -s`
  53 case "$OS" in
  54   SunOS | Linux | *BSD | Darwin )
  55     PS=":"
  56     FS="/"
  57     ;;
  58   Windows* | CYGWIN* )
  59     PS=";"
  60     FS="\\"
  61     ;;
  62   * )
  63     echo "Unrecognized system!"
  64     exit 1;
  65     ;;
  66 esac
  67 






























  68 # get the platform default locales
  69 PLATDEF=`${TESTJAVA}${FS}bin${FS}java -classpath ${TESTCLASSES} LocaleProviders getPlatformLocale display`
  70 DEFLANG=`echo ${PLATDEF} | sed -e "s/,.*//"`
  71 DEFCTRY=`echo ${PLATDEF} | sed -e "s/.*,//"`
  72 echo "DEFLANG=${DEFLANG}"
  73 echo "DEFCTRY=${DEFCTRY}"
  74 PLATDEF=`${TESTJAVA}${FS}bin${FS}java -classpath ${TESTCLASSES} LocaleProviders getPlatformLocale format`
  75 DEFFMTLANG=`echo ${PLATDEF} | sed -e "s/,.*//"`
  76 DEFFMTCTRY=`echo ${PLATDEF} | sed -e "s/.*,//"`
  77 echo "DEFFMTLANG=${DEFFMTLANG}"
  78 echo "DEFFMTCTRY=${DEFFMTCTRY}"
  79 
  80 runTest()
  81 {
  82     RUNCMD="${TESTJAVA}${FS}bin${FS}java -classpath ${TESTCLASSES} -Djava.locale.providers=$PREFLIST LocaleProviders $METHODNAME $PARAM1 $PARAM2 $PARAM3"
  83     echo ${RUNCMD}
  84     ${RUNCMD}
  85     result=$?
  86     if [ $result -eq 0 ]
  87     then


 180 PARAM2=en
 181 PARAM3=US
 182 runTest
 183 PREFLIST=FOO
 184 PARAM1=JRE
 185 PARAM2=en
 186 PARAM3=US
 187 runTest
 188 PREFLIST=BAR,SPI
 189 PARAM1=FALLBACK
 190 PARAM2=en
 191 PARAM3=US
 192 runTest
 193 
 194 # testing 7198834 fix. Only works on Windows Vista or upper.
 195 METHODNAME=bug7198834Test
 196 PREFLIST=HOST
 197 PARAM1=
 198 PARAM2=
 199 PARAM3=
















 200 runTest
 201 
 202 exit $result


   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 # @test
  26 # @bug 6336885 7196799 7197573 7198834 8000245 8000615
  27 # @summary tests for "java.locale.providers" system property
  28 # @compile -XDignore.symbol.file LocaleProviders.java
  29 # @run shell/timeout=600 LocaleProviders.sh
  30 
  31 if [ "${TESTSRC}" = "" ]
  32 then
  33   echo "TESTSRC not set.  Test cannot execute.  Failed."
  34   exit 1
  35 fi
  36 echo "TESTSRC=${TESTSRC}"
  37 if [ "${TESTJAVA}" = "" ]
  38 then
  39   echo "TESTJAVA not set.  Test cannot execute.  Failed."
  40   exit 1
  41 fi
  42 echo "TESTJAVA=${TESTJAVA}"
  43 if [ "${TESTCLASSES}" = "" ]
  44 then
  45   echo "TESTCLASSES not set.  Test cannot execute.  Failed."
  46   exit 1


  48 echo "TESTCLASSES=${TESTCLASSES}"
  49 echo "CLASSPATH=${CLASSPATH}"
  50 
  51 # set platform-dependent variables
  52 OS=`uname -s`
  53 case "$OS" in
  54   SunOS | Linux | *BSD | Darwin )
  55     PS=":"
  56     FS="/"
  57     ;;
  58   Windows* | CYGWIN* )
  59     PS=";"
  60     FS="\\"
  61     ;;
  62   * )
  63     echo "Unrecognized system!"
  64     exit 1;
  65     ;;
  66 esac
  67 
  68 # create an SPI implementation
  69 mk() {
  70   d=`dirname $1`
  71   if [ ! -d $d ]; then mkdir -p $d; fi
  72   cat - >$1
  73 }
  74 
  75 SPIDIR=${TESTCLASSES}${FS}spi
  76 rm -rf ${SPIDIR}
  77 mk ${SPIDIR}${FS}src${FS}tznp.java << EOF
  78 import java.util.spi.TimeZoneNameProvider;
  79 import java.util.Locale;
  80 
  81 public class tznp extends TimeZoneNameProvider {
  82     public String getDisplayName(String ID, boolean daylight, int style, Locale locale) {
  83         return "tznp";
  84     }
  85 
  86     public Locale[] getAvailableLocales() {
  87         Locale[] locales = {Locale.GERMAN, Locale.US, Locale.JAPANESE, Locale.CHINESE};
  88         return locales;
  89     }
  90 }
  91 EOF
  92 mk ${SPIDIR}${FS}dest${FS}META-INF${FS}services${FS}java.util.spi.TimeZoneNameProvider << EOF
  93 tznp
  94 EOF
  95 ${TESTJAVA}${FS}bin${FS}javac -d ${SPIDIR}${FS}dest ${SPIDIR}${FS}src${FS}tznp.java
  96 ${TESTJAVA}${FS}bin${FS}jar cvf ${SPIDIR}${FS}tznp.jar -C ${SPIDIR}${FS}dest .
  97 
  98 # get the platform default locales
  99 PLATDEF=`${TESTJAVA}${FS}bin${FS}java -classpath ${TESTCLASSES} LocaleProviders getPlatformLocale display`
 100 DEFLANG=`echo ${PLATDEF} | sed -e "s/,.*//"`
 101 DEFCTRY=`echo ${PLATDEF} | sed -e "s/.*,//"`
 102 echo "DEFLANG=${DEFLANG}"
 103 echo "DEFCTRY=${DEFCTRY}"
 104 PLATDEF=`${TESTJAVA}${FS}bin${FS}java -classpath ${TESTCLASSES} LocaleProviders getPlatformLocale format`
 105 DEFFMTLANG=`echo ${PLATDEF} | sed -e "s/,.*//"`
 106 DEFFMTCTRY=`echo ${PLATDEF} | sed -e "s/.*,//"`
 107 echo "DEFFMTLANG=${DEFFMTLANG}"
 108 echo "DEFFMTCTRY=${DEFFMTCTRY}"
 109 
 110 runTest()
 111 {
 112     RUNCMD="${TESTJAVA}${FS}bin${FS}java -classpath ${TESTCLASSES} -Djava.locale.providers=$PREFLIST LocaleProviders $METHODNAME $PARAM1 $PARAM2 $PARAM3"
 113     echo ${RUNCMD}
 114     ${RUNCMD}
 115     result=$?
 116     if [ $result -eq 0 ]
 117     then


 210 PARAM2=en
 211 PARAM3=US
 212 runTest
 213 PREFLIST=FOO
 214 PARAM1=JRE
 215 PARAM2=en
 216 PARAM3=US
 217 runTest
 218 PREFLIST=BAR,SPI
 219 PARAM1=FALLBACK
 220 PARAM2=en
 221 PARAM3=US
 222 runTest
 223 
 224 # testing 7198834 fix. Only works on Windows Vista or upper.
 225 METHODNAME=bug7198834Test
 226 PREFLIST=HOST
 227 PARAM1=
 228 PARAM2=
 229 PARAM3=
 230 runTest
 231 
 232 # testing 8000245 fix.
 233 METHODNAME=tzNameTest
 234 PREFLIST="JRE -Djava.ext.dirs=${SPIDIR}"
 235 PARAM1=Europe/Moscow
 236 PARAM2=
 237 PARAM3=
 238 runTest
 239 
 240 # testing 8000615 fix.
 241 METHODNAME=tzNameTest
 242 PREFLIST="JRE -Djava.ext.dirs=${SPIDIR}"
 243 PARAM1=America/Los_Angeles
 244 PARAM2=
 245 PARAM3=
 246 runTest
 247 
 248 exit $result