Issue Details (XML | Word | Printable)

Key: NET-198
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Sebb
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Commons Net

FTPTimestampParserImpl#parseTimeStamp() is not fully testable

Created: 08/Mar/08 10:09 AM   Updated: 09/Mar/08 10:58 PM
Return to search
Component/s: None
Affects Version/s: None
Fix Version/s: 2.0, 1.5

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works FTPTimestampParserImpl.patch 2008-03-08 10:12 AM Sebb 0.9 kB
Text File Licensed for inclusion in ASF works FTPTimestampParserImpl2.patch 2008-03-09 04:55 PM Sebb 1 kB
Issue Links:
Blocker
 

Resolution Date: 09/Mar/08 05:35 PM


 Description  « Hide
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.



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
No work has yet been logged on this issue.