You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2008/03/10 13:07:16 UTC
svn commit: r635537 -
/commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java
Author: sebb
Date: Mon Mar 10 05:07:15 2008
New Revision: 635537
URL: http://svn.apache.org/viewvc?rev=635537&view=rev
Log:
Fix non-leap year test
Modified:
commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java
Modified: commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java?rev=635537&r1=635536&r2=635537&view=diff
==============================================================================
--- commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java (original)
+++ commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java Mon Mar 10 05:07:15 2008
@@ -226,7 +226,7 @@
/*
* Check how short date is interpreted at a given time
*/
- private void checkShortParse(String msg, Calendar now, Calendar input) throws Exception {
+ private void checkShortParse(String msg, Calendar now, Calendar input) throws ParseException {
FTPTimestampParserImpl parser = new FTPTimestampParserImpl();
Format shortFormat = parser.getRecentDateFormat(); // It's expecting this format
Format longFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm");
@@ -286,15 +286,19 @@
// Test Feb 29 for a known leap year
public void testFeb29LeapYear() throws Exception{
int year = 2000; // Use same year for current and short date
- GregorianCalendar now = new GregorianCalendar(year, Calendar.APRIL, 1);
+ GregorianCalendar now = new GregorianCalendar(year, Calendar.APRIL, 1, 12, 0);
checkShortParse("Feb 29th 2000",now,new GregorianCalendar(year, Calendar.FEBRUARY,29));
}
- // Test Feb 29 for a known non-leap year
- public void testFeb29NonLeapYear() throws Exception{
- int year = 1999;// Use same year for current and short date
- GregorianCalendar now = new GregorianCalendar(year, Calendar.APRIL, 1);
- checkShortParse("Feb 29th 1900",now,new GregorianCalendar(year, Calendar.FEBRUARY,29));
+ // Test Feb 29 for a known non-leap year - should fail
+ public void testFeb29NonLeapYear(){
+ GregorianCalendar now = new GregorianCalendar(1999, Calendar.APRIL, 1, 12, 0);
+ // Note: we use a known leap year for the target date to avoid rounding up
+ try {
+ checkShortParse("Feb 29th 1999",now,new GregorianCalendar(2000, Calendar.FEBRUARY,29));
+ fail("Should have failed to parse Feb 29th 1999");
+ } catch (ParseException expected) {
+ }
}
/**