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 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 locale 69 PLATDEF=`${TESTJAVA}${FS}bin${FS}java -classpath ${TESTCLASSES} LocaleProviders` 70 DEFLANG=`echo ${PLATDEF} | sed -e "s/,.*//"` 71 DEFCTRY=`echo ${PLATDEF} | sed -e "s/.*,//"` 72 echo "DEFLANG=${DEFLANG}" 73 echo "DEFCTRY=${DEFCTRY}" 74 75 runTest() 76 { 77 RUNCMD="${TESTJAVA}${FS}bin${FS}java -classpath ${TESTCLASSES} -Djava.locale.providers=$PREFLIST LocaleProviders $EXPECTED $TESTLANG $TESTCTRY" 78 echo ${RUNCMD} 79 ${RUNCMD} 80 result=$? 81 if [ $result -eq 0 ] 82 then 83 echo "Execution successful" 84 else 85 echo "Execution of the test case failed." 86 exit $result 87 fi 88 } 89 90 # testing HOST is selected for the default locale, if specified on Windows or MacOSX 91 PREFLIST=HOST,JRE 92 case "$OS" in 93 Windows_NT* ) 94 WINVER=`uname -r` 95 if [ "${WINVER}" = "5" ] 96 then 97 EXPECTED=JRE 98 else 99 EXPECTED=HOST 100 fi 101 ;; 102 CYGWIN_NT-6* | Darwin ) 103 EXPECTED=HOST 104 ;; 105 * ) 106 EXPECTED=JRE 107 ;; 108 esac 109 TESTLANG=${DEFLANG} 110 TESTCTRY=${DEFCTRY} 111 runTest 112 113 # testing HOST is NOT selected for the non-default locale, if specified 114 PREFLIST=HOST,JRE 115 EXPECTED=JRE 116 if [ "${DEFLANG}" = "en" ] 117 then 118 TESTLANG=ja 119 TESTCTRY=JP 120 else 121 TESTLANG=en 122 TESTCTRY=US 123 fi 124 runTest 125 126 # testing SPI is NOT selected, as there is none. 127 PREFLIST=SPI,JRE 128 EXPECTED=JRE 129 TESTLANG=en 130 TESTCTRY=US 131 runTest 132 133 # testing the order, variaton #1. This assumes en_GB DateFormat data are available both in JRE & CLDR 134 PREFLIST=CLDR,JRE 135 EXPECTED=CLDR 136 TESTLANG=en 137 TESTCTRY=GB 138 runTest 139 140 # testing the order, variaton #2. This assumes en_GB DateFormat data are available both in JRE & CLDR 141 PREFLIST=JRE,CLDR 142 EXPECTED=JRE 143 TESTLANG=en 144 TESTCTRY=GB 145 runTest 146 147 # testing the order, variaton #3 for non-existent locale in JRE assuming "haw" is not in JRE. 148 PREFLIST=JRE,CLDR 149 EXPECTED=CLDR 150 TESTLANG=haw 151 TESTCTRY=GB 152 runTest 153 154 # testing the order, variaton #4 for the bug 7196799. CLDR's "zh" data should be used in "zh_CN" 155 PREFLIST=CLDR 156 EXPECTED=CLDR 157 TESTLANG=zh 158 TESTCTRY=CN 159 runTest 160 161 exit $result