Add unit tests for DateUtils.toCalendar(Date, TimeZone)
This commit is contained in:
parent
1eecfc948b
commit
ac5a216f76
|
@ -693,6 +693,43 @@ public void testToCalendar() {
|
|||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Test
|
||||
public void testToCalendarWithDate() {
|
||||
assertEquals("Convert Date and TimeZone to a Calendar, but failed to get the Date back", date1, DateUtils.toCalendar(date1, zone).getTime());
|
||||
try {
|
||||
DateUtils.toCalendar(null, zone);
|
||||
fail("Expected NullPointerException to be thrown");
|
||||
} catch(final NullPointerException npe) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Test
|
||||
public void testToCalendarWithTimeZone() {
|
||||
assertEquals("Convert Date and TimeZone to a Calendar, but failed to get the TimeZone back", zone, DateUtils.toCalendar(date1, zone).getTimeZone());
|
||||
try {
|
||||
DateUtils.toCalendar(date1, null);
|
||||
fail("Expected NullPointerException to be thrown");
|
||||
} catch(final NullPointerException npe) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Test
|
||||
public void testToCalendarWithDateAndTimeZone() {
|
||||
try {
|
||||
Calendar c = DateUtils.toCalendar(date2, defaultZone);
|
||||
assertEquals("Convert Date and TimeZone to a Calendar, but failed to get the Date back", date2, c.getTime());
|
||||
assertEquals("Convert Date and TimeZone to a Calendar, but failed to get the TimeZone back", defaultZone, c.getTimeZone());
|
||||
// expected
|
||||
} catch(final NullPointerException npe) {
|
||||
fail("Expected NullPointerException to be thrown");
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue