Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-111

[Lang] time unit tests fail on Sundays

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0
    • 2.0
    • None
    • None
    • Operating System: other
      Platform: Other

    • 19364

    Description

      The time unit tests fail when run on a Sunday:

      test.time:
      [echo] Running time package tests ...
      [java] ...F.F................
      [java] Time: 4.394
      [java] There were 2 failures:
      [java] 1)
      testParse(org.apache.commons.lang.time.CalendarUtilsTest)junit.framework.AssertionFailedError:
      parse last Sunday expected Sun Apr 27 06:39:17 MST 2003 but got Sun Apr 20
      06:39:17 MST 2003
      [java] at
      org.apache.commons.lang.time.CalendarUtilsTest.assertEquals(CalendarUtilsTest.java:373)
      [java] at
      org.apache.commons.lang.time.CalendarUtilsTest.testParse(CalendarUtilsTest.java:243)
      [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [java] at
      sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      [java] at
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      [java] 2)
      testWeekIterator(org.apache.commons.lang.time.CalendarUtilsTest)junit.framework.AssertionFailedError:
      expected Mon Apr 28 00:00:00 MST 2003 but got Mon Apr 21 00:00:00 MST 2003
      [java] at
      org.apache.commons.lang.time.CalendarUtilsTest.assertEquals(CalendarUtilsTest.java:373)
      [java] at
      org.apache.commons.lang.time.CalendarUtilsTest.assertWeekIterator(CalendarUtilsTest.java:346)
      [java] at
      org.apache.commons.lang.time.CalendarUtilsTest.assertWeekIterator(CalendarUtilsTest.java:324)
      [java] at
      org.apache.commons.lang.time.CalendarUtilsTest.testWeekIterator(CalendarUtilsTest.java:284)
      [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [java] at
      sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      [java] at
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

      Looks to me like the unit test code is checking the value of Calendar.DATE, when
      it should be looking at Calendar.DAY_OF_WEEK (at line 237 and below) to decide
      whether to make adjustments for today==Sunday.

      When I fix this, testParse succeeds but testWeekIterator hangs at the statement
      it = CalendarUtils.getCalendarIterator(now, CalendarUtils.RANGE_WEEK_RELATIVE);

      Attachments

        Activity

          People

            Unassigned Unassigned
            phil@steitz.com Phil Steitz
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: