commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From britter <...@git.apache.org>
Subject [GitHub] commons-lang pull request #192: Lang 1255: Add DateUtils.toCalendar(Date, Ti...
Date Sat, 24 Sep 2016 10:11:15 GMT
Github user britter commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/192#discussion_r80358033
  
    --- Diff: src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java ---
    @@ -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");
    --- End diff --
    
    I don't understand this code. Why is a `NullPointerException` expected at this point?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message