use of java.util.SimpleTimeZone in project robovm by robovm.
the class SimpleTimeZoneTest method test_useDaylightTime.
/**
* java.util.SimpleTimeZone#useDaylightTime()
*/
public void test_useDaylightTime() {
// Test for method boolean java.util.SimpleTimeZone.useDaylightTime()
SimpleTimeZone st = new SimpleTimeZone(1000, "Test_TZ");
assertTrue("useDaylightTime returned incorrect value", !st.useDaylightTime());
// Spec indicates that both end and start must be set or result is
// undefined
st.setStartRule(Calendar.NOVEMBER, 1, Calendar.SUNDAY, 0);
st.setEndRule(Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0);
assertTrue("useDaylightTime returned incorrect value", st.useDaylightTime());
}
use of java.util.SimpleTimeZone in project robovm by robovm.
the class SimpleTimeZoneTest method test_setDSTSavingsI.
/**
* java.util.SimpleTimeZone#setDSTSavings(int)
*/
public void test_setDSTSavingsI() {
// Test for method void java.util.SimpleTimeZone.setDSTSavings(int)
SimpleTimeZone st = new SimpleTimeZone(1000, "Test_TZ");
st.setStartRule(0, 1, 1, 1);
st.setEndRule(11, 1, 1, 1);
st.setDSTSavings(1);
assertEquals(1, st.getDSTSavings());
try {
st.setDSTSavings(0);
fail();
} catch (IllegalArgumentException expected) {
}
try {
st.setDSTSavings(-1);
fail();
} catch (IllegalArgumentException expected) {
}
}
use of java.util.SimpleTimeZone in project robovm by robovm.
the class SimpleTimeZoneTest method test_setStartRuleIIII.
/**
* java.util.SimpleTimeZone#setStartRule(int, int, int, int)
*/
public void test_setStartRuleIIII() {
// Test for method void java.util.SimpleTimeZone.setStartRule(int, int,
// int, int)
SimpleTimeZone st = new SimpleTimeZone(1000, "Test_TZ");
// Spec indicates that both end and start must be set or result is
// undefined
st.setStartRule(Calendar.NOVEMBER, 1, Calendar.SUNDAY, 0);
st.setEndRule(Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0);
assertTrue("StartRule improperly set1", st.useDaylightTime());
assertTrue("StartRule improperly set2", st.inDaylightTime((new GregorianCalendar(1998, Calendar.NOVEMBER, 13).getTime())));
assertTrue("StartRule improperly set3", !(st.inDaylightTime(new GregorianCalendar(1998, Calendar.OCTOBER, 13).getTime())));
try {
st.setStartRule(12, -1, Calendar.SUNDAY, 0);
fail("IllegalArgumentException is not thrown.");
} catch (IllegalArgumentException iae) {
//expected
}
try {
st.setStartRule(Calendar.NOVEMBER, 10, Calendar.SUNDAY, 0);
fail("IllegalArgumentException is not thrown.");
} catch (IllegalArgumentException iae) {
//expected
}
try {
st.setStartRule(Calendar.NOVEMBER, -1, 8, 0);
fail("IllegalArgumentException is not thrown.");
} catch (IllegalArgumentException iae) {
//expected
}
try {
st.setStartRule(Calendar.NOVEMBER, -1, Calendar.SUNDAY, -10);
fail("IllegalArgumentException is not thrown.");
} catch (IllegalArgumentException iae) {
//expected
}
}
use of java.util.SimpleTimeZone in project robovm by robovm.
the class SimpleTimeZoneTest method test_clone.
/**
* java.util.SimpleTimeZone#clone()
*/
public void test_clone() {
// Test for method java.lang.Object java.util.SimpleTimeZone.clone()
SimpleTimeZone st1 = new SimpleTimeZone(1000, "TEST", Calendar.NOVEMBER, 1, Calendar.SUNDAY, 0, Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0);
SimpleTimeZone stA = new SimpleTimeZone(1, "Gah");
assertTrue("Clone resulted in same reference", st1.clone() != st1);
assertTrue("Clone resulted in unequal object", ((SimpleTimeZone) st1.clone()).equals(st1));
assertTrue("Clone resulted in same reference", stA.clone() != stA);
assertTrue("Clone resulted in unequal object", ((SimpleTimeZone) stA.clone()).equals(stA));
}
use of java.util.SimpleTimeZone in project robovm by robovm.
the class SimpleTimeZoneTest method test_ConstructorILjava_lang_StringIIIIIIIII.
/**
* java.util.SimpleTimeZone#SimpleTimeZone(int, java.lang.String,
* int, int, int, int, int, int, int, int, int)
*/
public void test_ConstructorILjava_lang_StringIIIIIIIII() {
// Test for method java.util.SimpleTimeZone(int, java.lang.String, int,
// int, int, int, int, int, int, int, int)
SimpleTimeZone st = new SimpleTimeZone(1000, "TEST", Calendar.NOVEMBER, 1, Calendar.SUNDAY, 0, Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0, 1000 * 60 * 60);
assertTrue("Incorrect TZ constructed", st.inDaylightTime(new GregorianCalendar(1998, Calendar.NOVEMBER, 13).getTime()));
assertTrue("Incorrect TZ constructed", !(st.inDaylightTime(new GregorianCalendar(1998, Calendar.OCTOBER, 13).getTime())));
assertEquals("Incorrect TZ constructed", "TEST", st.getID());
assertEquals("Incorrect TZ constructed", 1000, st.getRawOffset());
assertTrue("Incorrect TZ constructed", st.useDaylightTime());
assertTrue("Incorrect TZ constructed", st.getDSTSavings() == 1000 * 60 * 60);
try {
new SimpleTimeZone(1000, "TEST", 12, 1, Calendar.SUNDAY, 0, Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0, 1000 * 60 * 60);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException e) {
//expected
}
try {
new SimpleTimeZone(1000, "TEST", Calendar.NOVEMBER, 10, Calendar.SUNDAY, 0, Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0, 1000 * 60 * 60);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException e) {
//expected
}
try {
new SimpleTimeZone(1000, "TEST", Calendar.NOVEMBER, 1, 10, 0, Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0, 1000 * 60 * 60);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException e) {
//expected
}
try {
new SimpleTimeZone(1000, "TEST", Calendar.DECEMBER, 1, Calendar.SUNDAY, 0, Calendar.NOVEMBER, -10, Calendar.SUNDAY, 0, 1000 * 60 * 60);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException e) {
//expected
}
}
Aggregations