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
Sebb made changes - 08/Mar/08 10:12 AM
Field Original Value New Value
Attachment FTPTimestampParserImpl.patch [ 12377433 ]
Sebb made changes - 08/Mar/08 10:14 AM
Link This issue blocks NET-188 [ NET-188 ]
Rory Winston made changes - 08/Mar/08 05:24 PM
Resolution Fixed [ 1 ]
Fix Version/s 2.0 [ 12312040 ]
Fix Version/s 1.5 [ 12312041 ]
Status Open [ 1 ] Closed [ 6 ]
Sebb made changes - 09/Mar/08 04:52 PM
Status Closed [ 6 ] Reopened [ 4 ]
Resolution Fixed [ 1 ]
Sebb made changes - 09/Mar/08 04:55 PM
Attachment FTPTimestampParserImpl2.patch [ 12377485 ]
Rory Winston made changes - 09/Mar/08 05:35 PM
Resolution Fixed [ 1 ]
Status Reopened [ 4 ] Closed [ 6 ]
Sebb made changes - 09/Mar/08 07:22 PM
Link This issue is related to NET-83 [ NET-83 ]
Sebb made changes - 09/Mar/08 10:45 PM
Comment [ This is related to NET-83, which describes another instance where the FTP directory listing does not show the year.

Note that FreeBSD shows past and future dates without the year if the date is within 6 months of the current date, for example:

{code}
-rw-r--r-- 1 user Domain Users 0 Sep 9 2007 200709091234.tmp
-rw-r--r-- 1 user Domain Users 0 Sep 10 12:34 200709101234.tmp

-rw-r--r-- 1 user Domain Users 0 Sep 7 12:34 200809071234.tmp
-rw-r--r-- 1 user Domain Users 0 Sep 8 2008 200809081234.tmp

Sun Mar 9 15:05:09 EDT 2008 # date when listing was obtained
{code}

The file names show the actual timestamp used to "touch" the files. ]
Sebb made changes - 09/Mar/08 10:58 PM
Link This issue is related to NET-83 [ NET-83 ]