jdk/test/java/util/ResourceBundle/Control/ExpirationTest.sh
author rupashka
Mon, 17 May 2010 17:23:18 +0400
changeset 5581 9c2282c6f080
parent 4662 49b8cbe45e6a
child 5506 202f599c92aa
permissions -rw-r--r--
6938481: 4906607 is not fixed for NIMBUS L&F Reviewed-by: alexp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
# 
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
# 
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
# published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
# 
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
# This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
# version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
# accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
# 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
# You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
# 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
# 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
# CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
# have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
# @test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
# @bug 4212439 5102289 6272156
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
# @summary Tests for expiration control and reloading expired resource bundles.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
# @build ExpirationTest
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
# @run shell/timeout=300 ExpirationTest.sh
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
# Timings of the test sequence
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
# 0         5    7      10             20             40  [seconds]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
# +---------+----+------+------//------+------//------+--
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
# g         X    g      X              U              g   [event]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#  0 g - java starts; the first getBundle call gets "German";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#        sleep for 7 sec
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#  5 X - the bundle expires (every 5 seconds)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#  7 g - java wakes up; the second getBundle call still gets "German";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#        sleep for 33 sec
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
# 10 X - the bundle expires in the cache
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
# 20 U - shell script updates DE and add AT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
# 40 g - java wakes up; third getBundle call; gets "Deutsch"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
# event: g - getBundle, X - eXpire, U - Update
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
# ExpirationTest.java uses 3 exit values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
#  0 - passed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
#  1 - failed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
#  2 - can't proceed due to slow platform
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
# Check environment variables
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
if [ "x$TESTJAVA" = "x" ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    1>&2 echo "No TESTJAVA defined. exiting..."
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    exit 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
# Make sure that this test is run in C locale
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
LANG=C
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
export LANG
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
LC_ALL=
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
export LC_ALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
: ${TESTCLASSES:=.}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
# YES if the platform has %s support in date
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
HAS_S=NO
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
case "`uname`" in
4662
49b8cbe45e6a 6911108: These tests do not work with CYGWIN: java/util
ohair
parents: 2
diff changeset
    72
Windows* | CYGWIN* )
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    DEL=";"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    ;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
SunOS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    DEL=":"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    ;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
Linux)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    DEL=":"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    HAS_S=YES
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    ;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
esac
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
# Interval until resources are updated
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
INTERVAL=20
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
DATA=ExpirationData
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
ROOT=${DATA}.properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
JA=${DATA}_ja.properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
DE=${DATA}_de.properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
AT=${DATA}_de_AT.properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
JARFILE=data.jar
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
createProperties() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    rm -f ${DATA}*.properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    echo "data: English" > $ROOT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    (echo "data: Japanese"; echo "january: 1gatsu") > $JA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    (echo "data: German"; echo "january: Januar") > $DE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    echo "Properties files have been created at `date +%T`"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
createJar() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    if [ "$FORMAT" = "properties" ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
	createProperties
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
	F="${DATA}*.properties"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
	createClasses
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
	F="-C classes ${ROOT}.class -C classes ${JA}.class -C classes ${DE}.class"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    ${TESTJAVA}/bin/jar cf $JARFILE $F
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    ${TESTJAVA}/bin/jar tvf $JARFILE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    rm -f ${DATA}*.properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    echo "Jar created at `date +%T`"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
createClasses() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    rm -f ${DATA}*.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    rm -rf classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    mkdir classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    createJava $ROOT English
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    createJava $JA Japanese
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    createJava $DE German Januar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    ${TESTJAVA}/bin/javac -d classes ${ROOT}.java ${JA}.java ${DE}.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    echo "Created" classes/*.class "at `date +%T`"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
createJava() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    (echo "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
public class $1 extends ListResourceBundle {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    public Object[][] getContents() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
	return new Object[][] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
	    { \"data\", \"$2\" },"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    if [ "x$3" != "x" ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
	echo "	    { \"january\", \"$3\" },"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
echo "	};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
}") >$1.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
updateDEaddAT() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    rm -f $DE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    (echo "data=Deutsch"; echo "january=Januar") > $DE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    # add de_AT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    echo "january=J\u00e4nner" > $AT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    echo "Updated '"${DE}"' and added '"${AT}"' at `date +%T`"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
updateClassDEaddClassAT() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    rm -f $DE.java classes/$DE.class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    createJava $DE Deutsch Januar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    ${TESTJAVA}/bin/javac -d classes ${DE}.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    createJava $AT Deutsch "J\\u00e4nner"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    ${TESTJAVA}/bin/javac -d classes ${AT}.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    echo "Updated '"${DE}"' class and added '"${AT}"' class at `date +%T`"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
updateJar() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    if [ "$FORMAT" = "properties" ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
	updateDEaddAT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
	F="$DE $AT"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
	updateClassDEaddClassAT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
	F="-C classes ${DE}.class -C classes ${AT}.class"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    ${TESTJAVA}/bin/jar uf $JARFILE $F
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    rm -f $DE $AT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    echo "Updated '"${JARFILE}"' at `date +%T`"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    ${TESTJAVA}/bin/jar tvf $JARFILE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
getSeconds() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    if [ "$HAS_S" = "YES" ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
	date '+%s'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
	# Returns an approximation of the offset from the Epoch in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
	# seconds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
	date -u '+%Y %j %H %M %S' | \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
	awk '{d=($1-1970)*365.2425; print int(((((((d+$2-1)*24)+$3)*60)+$3)*60)+$5);}'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
# Execute $1 and check how long it takes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
timedExec() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    S=`getSeconds`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    eval $1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    E=`getSeconds`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    D=`expr $E - $S`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    #
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    # If this machine is too slow, give up the further testing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    #
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    if [ "$D" -gt $2 ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
	1>&2 echo "This machine took $D seconds to prepare test data," \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
		  "which is too slow to proceed. Exiting..."
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
	exit 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    unset S
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    unset E
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    unset D
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
checkStatus() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    if [ $1 = 0 ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
	echo "$2: PASSED"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    elif [ $1 != 2 ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
	echo "$2: FAILED"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
	exit 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
	# Just we should't proceed to avoid timing issues.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
	exit 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
# Before starting tests, check the latency with Thread.sleep().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
${TESTJAVA}/bin/java -cp "${TESTCLASSES}${DEL}." ExpirationTest -latency
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
STATUS=$?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
if [ $STATUS = 2 ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    exit 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
# Tests for properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
FORMAT=properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
# Test with plain files (properties)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
echo "Starting test with properties files at `date +%T`"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
# Creates properties files
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
timedExec createProperties 10
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
# Execute a child process which will update files in $INTERVAL seconds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
(sleep $INTERVAL; updateDEaddAT; exit 0) &
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
${TESTJAVA}/bin/java -cp "${TESTCLASSES}${DEL}." ExpirationTest properties file
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
STATUS=$?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
wait
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
checkStatus $STATUS "Test with properties files"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
# Test with jar file if jar is available (properties)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
if [ -x ${TESTJAVA}/bin/jar ] || [ -x ${TESTJAVA}/bin/jar.exe ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    HASJAR=YES
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    HASJAR=NO
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
if [ $HASJAR = YES  ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    echo ""
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    echo "Starting test with a jar file (properties) at `date +%T`"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    #
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    # Create a jar files with properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    #
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    timedExec createJar 10
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    (sleep $INTERVAL; updateJar; exit 0) &
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    ${TESTJAVA}/bin/java -cp "${TESTCLASSES}${DEL}${JARFILE}" ExpirationTest properties jar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    STATUS=$?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    wait
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    checkStatus $STATUS "Test with a jar file (properties)"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
# Test for classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
# Note: class-based resource bundles can't be reloaded due to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
# cache support in class loaders. So the results of the test cases
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
# below are not checked. (Test cases always pass.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
# If there's no javac available, then give up the test with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
# class-based properties.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
if [ ! -x ${TESTJAVA}/bin/javac ] && [ ! -x ${TESTJAVA}/bin/javac.exe ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    exit 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
rm -f ${DATA}*.properties $JARFILE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
FORMAT=class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
ROOT=`basename $ROOT .properties`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
JA=`basename $JA .properties`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
DE=`basename $DE .properties`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
AT=`basename $AT .properties`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
echo ""
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
echo "Starting test with class files at `date +%T`"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
# Create class files
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
timedExec createClasses 10
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
(sleep $INTERVAL; updateClassDEaddClassAT; exit 0) &
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
${TESTJAVA}/bin/java -cp "${TESTCLASSES}${DEL}classes" ExpirationTest class file
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
STATUS=$?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
wait
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
checkStatus $STATUS "Test with class files"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
if [ $HASJAR = YES ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    echo ""
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    echo "Starting test with a jar file (class) at `date +%T`"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    #
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    # Create a jar file with class files
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    #
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    timedExec createJar 10
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    (sleep $INTERVAL; updateJar; exit 0) &
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    ${TESTJAVA}/bin/java -cp "${TESTCLASSES}${DEL}${JARFILE}" ExpirationTest class jar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    STATUS=$?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    wait
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    checkStatus $STATUS "Test with a jar file (class)"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
exit 0