annotate test/java/util/Currency/PropertiesTest.sh @ 8830:3e8ecdbce883

8003846: Override mechanism for currency data should not require creating currency.properties in java.home Reviewed-by: naoto
author andrew
date Mon, 15 Apr 2019 19:24:25 +0100
parents e5c39738ce1f
children 29c82a80efd2
rev   line source
duke@0 1 #!/bin/sh
andrew@8830 2
andrew@8830 3 # Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
andrew@8830 4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 5 #
andrew@8830 6 # This code is free software; you can redistribute it and/or modify it
andrew@8830 7 # under the terms of the GNU General Public License version 2 only, as
andrew@8830 8 # published by the Free Software Foundation.
andrew@8830 9 #
andrew@8830 10 # This code is distributed in the hope that it will be useful, but WITHOUT
andrew@8830 11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
andrew@8830 12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
andrew@8830 13 # version 2 for more details (a copy is included in the LICENSE file that
andrew@8830 14 # accompanied this code).
andrew@8830 15 #
andrew@8830 16 # You should have received a copy of the GNU General Public License version
andrew@8830 17 # 2 along with this work; if not, write to the Free Software Foundation,
andrew@8830 18 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
andrew@8830 19 #
andrew@8830 20 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
andrew@8830 21 # or visit www.oracle.com if you need additional information or have any
andrew@8830 22 # questions.
andrew@8830 23 #
andrew@8830 24
duke@0 25 # @test
andrew@8830 26 # @bug 6332666 8003846
duke@0 27 # @summary tests the capability of replacing the currency data with user
duke@0 28 # specified currency properties file
duke@0 29 # @build PropertiesTest
duke@0 30 # @run shell/timeout=600 PropertiesTest.sh
duke@0 31
duke@0 32 if [ "${TESTSRC}" = "" ]
duke@0 33 then
duke@0 34 echo "TESTSRC not set. Test cannot execute. Failed."
duke@0 35 exit 1
duke@0 36 fi
duke@0 37 echo "TESTSRC=${TESTSRC}"
duke@0 38 if [ "${TESTJAVA}" = "" ]
duke@0 39 then
duke@0 40 echo "TESTJAVA not set. Test cannot execute. Failed."
duke@0 41 exit 1
duke@0 42 fi
duke@0 43 echo "TESTJAVA=${TESTJAVA}"
duke@0 44 if [ "${TESTCLASSES}" = "" ]
duke@0 45 then
duke@0 46 echo "TESTCLASSES not set. Test cannot execute. Failed."
duke@0 47 exit 1
duke@0 48 fi
duke@0 49 echo "TESTCLASSES=${TESTCLASSES}"
duke@0 50 echo "CLASSPATH=${CLASSPATH}"
duke@0 51
duke@0 52 # set platform-dependent variables
duke@0 53 OS=`uname -s`
duke@0 54 case "$OS" in
simonis@8153 55 SunOS | Linux | Darwin | AIX )
duke@0 56 PS=":"
duke@0 57 FS="/"
duke@0 58 ;;
ohair@2077 59 Windows* | CYGWIN* )
duke@0 60 PS=";"
andrew@8830 61 FS="/"
duke@0 62 ;;
duke@0 63 * )
duke@0 64 echo "Unrecognized system!"
duke@0 65 exit 1;
duke@0 66 ;;
duke@0 67 esac
duke@0 68
andrew@8830 69 failures=0
duke@0 70
duke@0 71 # run
andrew@8830 72 run() {
andrew@8830 73 echo ''
andrew@8830 74 sh -xc "${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -cp ${TESTCLASSES} $*" 2>&1
andrew@8830 75 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
andrew@8830 76 }
duke@0 77
andrew@8830 78 PROPS=${TESTSRC}${FS}currency.properties
duke@0 79
duke@0 80
andrew@8830 81 # Dump built-in currency data
andrew@8830 82
andrew@8830 83 run PropertiesTest -d dump1
andrew@8830 84
andrew@8830 85
andrew@8830 86 # Dump built-in currency data + overrides in properties file specified
andrew@8830 87 # by system property.
andrew@8830 88
andrew@8830 89 run -Djava.util.currency.data=${PROPS} PropertiesTest -d dump2
andrew@8830 90 run PropertiesTest -c dump1 dump2 ${PROPS}
andrew@8830 91
andrew@8830 92
andrew@8830 93 # Dump built-in currency data + overrides in properties file copied into
andrew@8830 94 # JRE image.
duke@0 95
duke@0 96 # copy the test properties file
duke@0 97 COPIED=0
duke@0 98 if [ -w $TESTJAVA ]
michaelm@4638 99 then
duke@0 100 WRITABLEJDK=$TESTJAVA
duke@0 101 else
michaelm@4638 102 WRITABLEJDK=.${FS}testjava
duke@0 103 cp -r $TESTJAVA $WRITABLEJDK
duke@0 104 COPIED=1
duke@0 105 fi
duke@0 106
duke@0 107 if [ -d ${WRITABLEJDK}${FS}jre ]
duke@0 108 then
duke@0 109 PROPLOCATION=${WRITABLEJDK}${FS}jre${FS}lib
duke@0 110 else
duke@0 111 PROPLOCATION=${WRITABLEJDK}${FS}lib
duke@0 112 fi
andrew@8830 113 cp ${PROPS} $PROPLOCATION
duke@0 114
duke@0 115 # run
andrew@8830 116 echo ''
andrew@8830 117 sh -xc "${WRITABLEJDK}${FS}bin${FS}java ${TESTVMOPTS} -cp ${TESTCLASSES} PropertiesTest -d dump3"
andrew@8830 118 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
duke@0 119
duke@0 120 # Cleanup
duke@0 121 rm -f ${PROPLOCATION}${FS}currency.properties
duke@0 122 if [ $COPIED -eq 1 ]
duke@0 123 then
duke@0 124 rm -rf $WRITABLEJDK
duke@0 125 fi
duke@0 126
andrew@8830 127 # compare the two dump files
andrew@8830 128 run PropertiesTest -c dump1 dump3 ${PROPS}
andrew@8830 129
andrew@8830 130
andrew@8830 131 # Results
andrew@8830 132 echo ''
andrew@8830 133 if [ $failures -gt 0 ];
andrew@8830 134 then echo "$failures tests failed";
andrew@8830 135 else echo "All tests passed"; fi
andrew@8830 136 exit $failures