Methods Summary |
---|
private void | runFailTest(int month, java.lang.String tz)Run a failure test. values should be invalid.
Month oMonth = null;
try {
oMonth = new Month(month, tz);
}
catch (Exception e) { // catch the validation exception
}
// object is not instantiated on bad data value
assertNull("validation restriction failed [ month=" + String.valueOf(month) +
",tz=" + tz + "]. did not restrict bad value.", oMonth);
|
private void | runFailTest(java.lang.String source)
Month oMonth = null;
try {
oMonth = new Month(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.", oMonth);
|
private void | runPassTest(int month, java.lang.String tz)Run a successful test. values should be valid.
Month oMonth = null;
try {
oMonth = new Month(month, tz);
}
catch (Exception e) { // catch the validation exception
assertTrue("Validation exception thrown on valid input", false);
}
assertEquals("Month month not equal", month, oMonth.getMonth());
assertEquals("Month timezone not equal", tz, oMonth.getTimezone());
|
private void | runPassTest(java.lang.String source)
Month oMonth = null;
try {
oMonth = new Month(source);
}
catch (Exception e) { // catch the validation exception
assertTrue("Validation exception thrown on valid input", false);
}
assertEquals("Month.toString() not equal", source, oMonth.toString());
|
public void | testBadMonth()Test that a bad month fails
runFailTest(13, null);
|
public void | testBadMonthString()
runFailTest("--13--");
|
public void | testBadMonthString2()
runFailTest("--1--");
|
public void | testBadString()Test that badly formatted strings fail
runFailTest("11--");
runFailTest("-11--");
runFailTest("--11-");
runFailTest("--11");
runFailTest("xx07-13");
runFailTest("garbage");
|
public void | testBadTimezone()Test that a bad timezone fails
runFailTest(7, "badzone");
|
public void | testBadTimezoneString()
runFailTest("--07--+EDT");
|
public void | testNormal()Test that a normal date succeeeds
// test all twelve months
for (int m=1; m < 13; m++) {
runPassTest(m, null);
}
|
public void | testNormalNegativeTimezone()
runPassTest("--11---11:00");
|
public void | testNormalPositiveTimezone()
runPassTest("--11--+05:00");
|
public void | testNormalString()
// test all twelve months
// use NumberFormat to ensure leading zeros
NumberFormat nf = NumberFormat.getInstance();
nf.setMinimumIntegerDigits(2);
for (int m=1; m < 13; m++) {
String s = "--" + nf.format(m) + "--";
runPassTest(s);
}
|
public void | testNormalTimezone()
runPassTest("--01--Z");
|