1 #!/bin/sh 2 3 # 4 # Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved. 5 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6 # 7 # This code is free software; you can redistribute it and/or modify it 8 # under the terms of the GNU General Public License version 2 only, as 9 # published by the Free Software Foundation. 10 # 11 # This code is distributed in the hope that it will be useful, but WITHOUT 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 # version 2 for more details (a copy is included in the LICENSE file that 15 # accompanied this code). 16 # 17 # You should have received a copy of the GNU General Public License version 18 # 2 along with this work; if not, write to the Free Software Foundation, 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 # 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 # or visit www.oracle.com if you need additional information or have any 23 # questions. 24 25 # @test 26 # @bug 8003228 27 # @summary Test the value of sun.jnu.encoding on Mac 28 # @author Brent Christian 29 # 30 # @run shell MacJNUEncoding.sh 31 32 # Only run test on Mac 33 OS=`uname -s` 34 case "$OS" in 35 Darwin ) ;; 36 * ) 37 exit 0 38 ;; 39 esac 40 41 if [ "${TESTJAVA}" = "" ] 42 then 43 echo "TESTJAVA not set. Test cannot execute. Failed." 44 exit 1 45 fi 46 47 if [ "${TESTSRC}" = "" ] 48 then 49 echo "TESTSRC not set. Test cannot execute. Failed." 50 exit 1 51 fi 52 53 if [ "${TESTCLASSES}" = "" ] 54 then 55 echo "TESTCLASSES not set. Test cannot execute. Failed." 56 exit 1 57 fi 58 59 JAVAC="${TESTJAVA}"/bin/javac 60 JAVA="${TESTJAVA}"/bin/java 61 62 echo "Building test classes..." 63 "$JAVAC" -d "${TESTCLASSES}" "${TESTSRC}"/ExpectedEncoding.java 64 65 echo "" 66 echo "Running test for C locale" 67 export LANG=C 68 export LC_ALL=C 69 "${JAVA}" ${TESTVMOPTS} -classpath "${TESTCLASSES}" ExpectedEncoding US-ASCII UTF-8 70 result1=$? 71 72 echo "" 73 echo "Running test for en_US.UTF-8 locale" 74 export LANG=en_US.UTF-8 75 export LC_ALL=en_US.UTF-8 76 "${JAVA}" ${TESTVMOPTS} -classpath "${TESTCLASSES}" ExpectedEncoding UTF-8 UTF-8 77 result2=$? 78 79 echo "" 80 echo "Cleanup" 81 rm ${TESTCLASSES}/ExpectedEncoding.class 82 83 if [ ${result1} -ne 0 ] ; then 84 echo "Test failed for C locale" 85 echo " LANG=\"${LANG}\"" 86 echo " LC_ALL=\"${LC_ALL}\"" 87 exit ${result1} 88 fi 89 if [ ${result2} -ne 0 ] ; then 90 echo "Test failed for en_US.UTF-8 locale" 91 echo " LANG=\"${LANG}\"" 92 echo " LC_ALL=\"${LC_ALL}\"" 93 exit ${result2} 94 fi 95 exit 0 96