Skip to content

Commit

Permalink
Add org.apache.commons.net.ftp.parser.FTPTimestampParserImplTest.test…
Browse files Browse the repository at this point in the history
…Net710()
  • Loading branch information
garydgregory committed May 4, 2024
1 parent 544e3db commit 68919ac
Showing 1 changed file with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,6 @@ private void checkShortParse(final String msg, final Calendar servertime, final
}
}

// This test currently fails, because we assume that short dates are +-6months when parsing Feb 29
@Test
@Disabled
public void testNET446() throws Exception {
final GregorianCalendar server = new GregorianCalendar(2001, Calendar.JANUARY, 1, 12, 0);
// Note: we use a known leap year for the target date to avoid rounding up
final GregorianCalendar input = new GregorianCalendar(2000, Calendar.FEBRUARY, 29);
final GregorianCalendar expected = new GregorianCalendar(2000, Calendar.FEBRUARY, 29);
checkShortParse("Feb 29th 2000", server, input, expected);
}

// Test leap year if current year is a leap year
@Test
public void testFeb29IfLeapYear() throws Exception {
Expand Down Expand Up @@ -166,8 +155,6 @@ public void testFeb29NonLeapYear() {
assertThrows(ParseException.class, () -> checkShortParse("Feb 29th 1999", server, input, expected, false));
}

// Lenient mode allows for dates up to 1 day in the future

@Test
public void testNET444() throws Exception {
final FTPTimestampParserImpl parser = new FTPTimestampParserImpl();
Expand All @@ -188,6 +175,27 @@ public void testNET444() throws Exception {
assertEquals(nowplus25.get(Calendar.YEAR) - 1, parsed25.get(Calendar.YEAR));
}

// Lenient mode allows for dates up to 1 day in the future

// This test currently fails, because we assume that short dates are +-6months when parsing Feb 29
@Test
@Disabled
public void testNET446() throws Exception {
final GregorianCalendar server = new GregorianCalendar(2001, Calendar.JANUARY, 1, 12, 0);
// Note: we use a known leap year for the target date to avoid rounding up
final GregorianCalendar input = new GregorianCalendar(2000, Calendar.FEBRUARY, 29);
final GregorianCalendar expected = new GregorianCalendar(2000, Calendar.FEBRUARY, 29);
checkShortParse("Feb 29th 2000", server, input, expected);
}

@Test
@Disabled
public void testNet710() throws ParseException {
Calendar serverTime = Calendar.getInstance(TimeZone.getTimeZone("EDT"), Locale.US);
serverTime.set(2022, 2, 16, 14, 0);
new FTPTimestampParserImpl().parseTimestamp("Mar 13 02:33", serverTime);
}

@Test
public void testParseDec31Lenient() throws Exception {
final GregorianCalendar now = new GregorianCalendar(2007, Calendar.DECEMBER, 30, 12, 0);
Expand Down

0 comments on commit 68919ac

Please sign in to comment.