1 # 2 # Copyright (c) 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 # @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 47 fi 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 88 echo "Execution successful" 89 else 90 echo "Execution of the test case failed." 91 exit $result 92 fi 93 } 94 95 # testing HOST is selected for the default locale, if specified on Windows or MacOSX 96 METHODNAME=adapterTest 97 PREFLIST=HOST,JRE 98 case "$OS" in 99 Windows_NT* ) 100 WINVER=`uname -r` 101 if [ "${WINVER}" = "5" ] 102 then 103 PARAM1=JRE 104 else 105 PARAM1=HOST 106 fi 107 ;; 108 CYGWIN_NT-6* | Darwin ) 109 PARAM1=HOST 110 ;; 111 * ) 112 PARAM1=JRE 113 ;; 114 esac 115 PARAM2=${DEFLANG} 116 PARAM3=${DEFCTRY} 117 runTest 118 119 # testing HOST is NOT selected for the non-default locale, if specified 120 METHODNAME=adapterTest 121 PREFLIST=HOST,JRE 122 PARAM1=JRE 123 # Try to find the locale JRE supports which is not the platform default (HOST supports that one) 124 if [ "${DEFLANG}" != "en" ] && [ "${DEFFMTLANG}" != "en" ]; then 125 PARAM2=en 126 PARAM3=US 127 elif [ "${DEFLANG}" != "ja" ] && [ "${DEFFMTLANG}" != "ja" ]; then 128 PARAM2=ja 129 PARAM3=JP 130 else 131 PARAM2=zh 132 PARAM3=CN 133 fi 134 runTest 135 136 # testing SPI is NOT selected, as there is none. 137 METHODNAME=adapterTest 138 PREFLIST=SPI,JRE 139 PARAM1=JRE 140 PARAM2=en 141 PARAM3=US 142 runTest 143 144 # testing the order, variaton #1. This assumes en_GB DateFormat data are available both in JRE & CLDR 145 METHODNAME=adapterTest 146 PREFLIST=CLDR,JRE 147 PARAM1=CLDR 148 PARAM2=en 149 PARAM3=GB 150 runTest 151 152 # testing the order, variaton #2. This assumes en_GB DateFormat data are available both in JRE & CLDR 153 METHODNAME=adapterTest 154 PREFLIST=JRE,CLDR 155 PARAM1=JRE 156 PARAM2=en 157 PARAM3=GB 158 runTest 159 160 # testing the order, variaton #3 for non-existent locale in JRE assuming "haw" is not in JRE. 161 METHODNAME=adapterTest 162 PREFLIST=JRE,CLDR 163 PARAM1=CLDR 164 PARAM2=haw 165 PARAM3=GB 166 runTest 167 168 # testing the order, variaton #4 for the bug 7196799. CLDR's "zh" data should be used in "zh_CN" 169 METHODNAME=adapterTest 170 PREFLIST=CLDR 171 PARAM1=CLDR 172 PARAM2=zh 173 PARAM3=CN 174 runTest 175 176 # testing FALLBACK provider. SPI and invalid one cases. 177 METHODNAME=adapterTest 178 PREFLIST=SPI 179 PARAM1=FALLBACK 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