Uploaded image for project: 'Commons Net'
  1. Commons Net
  2. NET-198

FTPTimestampParserImpl#parseTimeStamp() is not fully testable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.5, 2.0
    • Component/s: None
    • Labels:
      None

      Description

      The FTPTimestampParserImpl#parseTimeStamp() method is not fully testable, because it unconditionally creates Calendar items using the current time.

      In order to test for leap years and DST, the test code needs to be able to set arbitrary times.

      I suggest adding a package-private method that takes an additional Calendar parameter, as follows:

      Calendar parseTimestamp(String timestampStr, Calendar now) throws ParseException {
      // etc

      This would replace the original code; the public interface would delegate to the package-private method:

      public Calendar parseTimestamp(String timestampStr) throws ParseException

      { Calendar now = Calendar.getInstance(); return parseTimestamp(timestampStr, now); }

      Patch to follow.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                sebb@apache.org Sebb
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: