/*
* API coverage test for VTimeZone
*/
public void TestVTimeZoneCoverage() {
final String TZID = "Europe/Moscow";
BasicTimeZone otz = (BasicTimeZone)TimeZone.getTimeZone(TZID, TimeZone.TIMEZONE_ICU);
VTimeZone vtz = VTimeZone.create(TZID);
// getOffset(era, year, month, day, dayOfWeek, milliseconds)
int offset1 = otz.getOffset(GregorianCalendar.AD, 2007, Calendar.JULY, 1, Calendar.SUNDAY, 0);
int offset2 = vtz.getOffset(GregorianCalendar.AD, 2007, Calendar.JULY, 1, Calendar.SUNDAY, 0);
if (offset1 != offset2) {
errln("FAIL: getOffset(int,int,int,int,int,int) returned different results in VTimeZone and OlsonTimeZone");
}
// getOffset(date, local, offsets)
int[] offsets1 = new int[2];
int[] offsets2 = new int[2];
long t = System.currentTimeMillis();
otz.getOffset(t, false, offsets1);
vtz.getOffset(t, false, offsets2);
if (offsets1[0] != offsets2[0] || offsets1[1] != offsets2[1]) {
errln("FAIL: getOffset(long,boolean,int[]) returned different results in VTimeZone and OlsonTimeZone");
}
// getRawOffset
if (otz.getRawOffset() != vtz.getRawOffset()) {
errln("FAIL: getRawOffset returned different results in VTimeZone and OlsonTimeZone");
}
// inDaylightTime
Date d = new Date();
if (otz.inDaylightTime(d) != vtz.inDaylightTime(d)) {
errln("FAIL: inDaylightTime returned different results in VTimeZone and OlsonTimeZone");
}
// useDaylightTime
if (otz.useDaylightTime() != vtz.useDaylightTime()) {
errln("FAIL: useDaylightTime returned different results in VTimeZone and OlsonTimeZone");
}
// setRawOffset
final int RAW = -10*HOUR;
VTimeZone tmpvtz = (VTimeZone)vtz.clone();
tmpvtz.setRawOffset(RAW);
if (tmpvtz.getRawOffset() != RAW) {
logln("setRawOffset is implemented");
}
// hasSameRules
boolean bSame = otz.hasSameRules(vtz);
logln("OlsonTimeZone#hasSameRules(VTimeZone) should return false always for now - actual: " + bSame);
// getTZURL/setTZURL
final String TZURL = "http://icu-project.org/timezone";
String tzurl = vtz.getTZURL();
if (tzurl != null) {
errln("FAIL: getTZURL returned non-null value");
}
vtz.setTZURL(TZURL);
tzurl = vtz.getTZURL();
if (!TZURL.equals(tzurl)) {
errln("FAIL: URL returned by getTZURL does not match the one set by setTZURL");
}
// getLastModified/setLastModified
Date lastmod = vtz.getLastModified();
if (lastmod != null) {
errln("FAIL: getLastModified returned non-null value");
}
Date newdate = new Date();
vtz.setLastModified(newdate);
lastmod = vtz.getLastModified();
if (!newdate.equals(lastmod)) {
errln("FAIL: Date returned by getLastModified does not match the one set by setLastModified");
}
// getNextTransition/getPreviousTransition
long base = getUTCMillis(2007, Calendar.JULY, 1);
TimeZoneTransition tzt1 = otz.getNextTransition(base, true);
TimeZoneTransition tzt2 = vtz.getNextTransition(base, true);
if (tzt1.equals(tzt2)) {
errln("FAIL: getNextTransition returned different results in VTimeZone and OlsonTimeZone");
}
tzt1 = otz.getPreviousTransition(base, false);
tzt2 = vtz.getPreviousTransition(base, false);
if (tzt1.equals(tzt2)) {
errln("FAIL: getPreviousTransition returned different results in VTimeZone and OlsonTimeZone");
}