Methods Summary |
---|
private void | runFailTest(int day, java.lang.String tz)Run a failure test. values should be invalid.
Day oDay = null;
try {
oDay = new Day(day, tz);
}
catch (Exception e) { // catch the validation exception
}
// object is not instantiated on bad data value
assertNull("validation restriction failed [ day=" + String.valueOf(day) +
",tz=" + tz + "]. did not restrict bad value.", oDay);
|
private void | runFailTest(java.lang.String source)
Day oDay = null;
try {
oDay = new Day(source);
}
catch (Exception e) { // catch the validation exception
}
// object is not instantiated on bad data value
assertNull("validation restriction failed [ " + source +
"]. did not restrict bad value.", oDay);
|
private void | runPassTest(int day, java.lang.String tz)Run a successful test. values should be valid.
Day oDay = null;
try {
oDay = new Day(day, tz);
}
catch (Exception e) { // catch the validation exception
assertTrue("Validation exception thrown on valid input", false);
}
assertEquals("Day day not equal", day, oDay.getDay());
assertEquals("Day timezone not equal", tz, oDay.getTimezone());
|
private void | runPassTest(java.lang.String source)
Day oDay = null;
try {
oDay = new Day(source);
}
catch (Exception e) { // catch the validation exception
assertTrue("Validation exception thrown on valid input", false);
}
assertEquals("Day.toString() not equal", source, oDay.toString());
|
public void | testBadDay()Test that a bad day fails
runFailTest(32, null);
|
public void | testBadDayString()
runFailTest("---32");
|
public void | testBadDayString2()
runFailTest("---1");
|
public void | testBadString()Test that badly formatted strings fail
runFailTest("13Z");
runFailTest("-13");
runFailTest("--13");
runFailTest("xxx13");
runFailTest("garbage");
|
public void | testBadTimezone()Test that a bad timezone fails
runFailTest( 31, "badzone");
|
public void | testBadTimezoneString()
runFailTest("---23+EDT");
|
public void | testNormal()Test that a normal date succeeeds
// test all days
for (int d=1; d < 32; d++) {
runPassTest(d, null);
}
|
public void | testNormalNegativeTimezone()
runPassTest("---11-11:00");
|
public void | testNormalPositiveTimezone()
runPassTest("---11+05:00");
|
public void | testNormalString()
// test all 31 days
// use NumberFormat to ensure leading zeros
NumberFormat nf = NumberFormat.getInstance();
nf.setMinimumIntegerDigits(2);
for (int d=1; d < 13; d++) {
String s = "---" + nf.format(d);
runPassTest(s);
}
|
public void | testNormalString2()
// check for leading zeros in toString().
runPassTest("---01");
|
public void | testNormalTimezone()
runPassTest("---01Z");
|