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/05/21 01:48:51 UTC
svn commit: r658491 [3/3] - in /commons/proper/net/trunk/src:
java/examples/nntp/ java/examples/ntp/ java/org/apache/commons/net/ftp/
java/org/apache/commons/net/ftp/parser/ java/org/apache/commons/net/nntp/
java/org/apache/commons/net/ntp/ java/org/ap...
Modified: commons/proper/net/trunk/src/java/org/apache/commons/net/ntp/TimeStamp.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/java/org/apache/commons/net/ntp/TimeStamp.java?rev=658491&r1=658490&r2=658491&view=diff
==============================================================================
--- commons/proper/net/trunk/src/java/org/apache/commons/net/ntp/TimeStamp.java (original)
+++ commons/proper/net/trunk/src/java/org/apache/commons/net/ntp/TimeStamp.java Tue May 20 16:48:50 2008
@@ -188,8 +188,8 @@
*/
public static long getTime(long ntpTimeValue)
{
- long seconds = (ntpTimeValue >>> 32) & 0xffffffffL; // high-order 32-bits
- long fraction = ntpTimeValue & 0xffffffffL; // low-order 32-bits
+ long seconds = (ntpTimeValue >>> 32) & 0xffffffffL; // high-order 32-bits
+ long fraction = ntpTimeValue & 0xffffffffL; // low-order 32-bits
// Use round-off on fractional part to preserve going to lower precision
fraction = Math.round(1000D * fraction / 0x100000000L);
@@ -285,7 +285,7 @@
*/
protected static long toNtpTime(long t)
{
- boolean useBase1 = t < msb0baseTime; // time < Feb-2036
+ boolean useBase1 = t < msb0baseTime; // time < Feb-2036
long baseTime;
if (useBase1) {
baseTime = t - msb1baseTime; // dates <= Feb-2036
@@ -452,7 +452,7 @@
* is numerically less than the TimeStamp argument; and a
* value greater than <code>0</code> if this TimeStamp is
* numerically greater than the TimeStamp argument
- * (signed comparison).
+ * (signed comparison).
*/
public int compareTo(TimeStamp anotherTimeStamp)
{
@@ -469,13 +469,13 @@
*
* @param o the <code>Object</code> to be compared.
* @return the value <code>0</code> if the argument is a TimeStamp
- * numerically equal to this TimeStamp; a value less than
- * <code>0</code> if the argument is a TimeStamp numerically
- * greater than this TimeStamp; and a value greater than
- * <code>0</code> if the argument is a TimeStamp numerically
- * less than this TimeStamp.
+ * numerically equal to this TimeStamp; a value less than
+ * <code>0</code> if the argument is a TimeStamp numerically
+ * greater than this TimeStamp; and a value greater than
+ * <code>0</code> if the argument is a TimeStamp numerically
+ * less than this TimeStamp.
* @exception ClassCastException if the argument is not a
- * <code>TimeStamp</code>.
+ * <code>TimeStamp</code>.
* @see java.lang.Comparable
*/
public int compareTo(Object o)
Modified: commons/proper/net/trunk/src/java/org/apache/commons/net/telnet/TelnetInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/java/org/apache/commons/net/telnet/TelnetInputStream.java?rev=658491&r1=658490&r2=658491&view=diff
==============================================================================
--- commons/proper/net/trunk/src/java/org/apache/commons/net/telnet/TelnetInputStream.java (original)
+++ commons/proper/net/trunk/src/java/org/apache/commons/net/telnet/TelnetInputStream.java Tue May 20 16:48:50 2008
@@ -115,7 +115,7 @@
// If there is no more data AND we were told not to block, just return -2. (More efficient than exception.)
if(!mayBlock && super.available() == 0)
return -2;
-
+
// Otherwise, exit only when we reach end of stream.
if ((ch = super.read()) < 0)
return -1;
@@ -363,7 +363,7 @@
//__alreadyread = false;
__readIsWaiting = true;
int ch;
- boolean mayBlock = true; // block on the first read only
+ boolean mayBlock = true; // block on the first read only
do
{
@@ -427,11 +427,11 @@
--__bytesAvailable;
- // Need to explicitly notify() so available() works properly
- if(__bytesAvailable == 0 && __threaded) {
- __queue.notify();
- }
-
+ // Need to explicitly notify() so available() works properly
+ if(__bytesAvailable == 0 && __threaded) {
+ __queue.notify();
+ }
+
return ch;
}
}
Modified: commons/proper/net/trunk/src/java/org/apache/commons/net/tftp/TFTPClient.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/java/org/apache/commons/net/tftp/TFTPClient.java?rev=658491&r1=658490&r2=658491&view=diff
==============================================================================
--- commons/proper/net/trunk/src/java/org/apache/commons/net/tftp/TFTPClient.java (original)
+++ commons/proper/net/trunk/src/java/org/apache/commons/net/tftp/TFTPClient.java Tue May 20 16:48:50 2008
@@ -233,10 +233,10 @@
}
++block;
if (block > 65535)
- {
- // wrap the block number
- block = 0;
- }
+ {
+ // wrap the block number
+ block = 0;
+ }
break _receivePacket;
}
@@ -471,10 +471,10 @@
{
++block;
if (block > 65535)
- {
- // wrap the block number
- block = 0;
- }
+ {
+ // wrap the block number
+ block = 0;
+ }
if (lastAckWait) {
break _sendPacket;
Modified: commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/FTPClientConfigFunctionalTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/FTPClientConfigFunctionalTest.java?rev=658491&r1=658490&r2=658491&view=diff
==============================================================================
--- commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/FTPClientConfigFunctionalTest.java (original)
+++ commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/FTPClientConfigFunctionalTest.java Tue May 20 16:48:50 2008
@@ -60,16 +60,16 @@
public FTPClientConfigFunctionalTest() {
super();
- }
+ }
/*
* @throws java.lang.Exception
*/
protected void setUp() throws Exception {
super.setUp();
- FTPConf = new FTPClientConfig(FTPClientConfig.SYST_UNIX);
- FTPConf.setServerTimeZoneId("GMT");
- FTP.configure(FTPConf);
+ FTPConf = new FTPClientConfig(FTPClientConfig.SYST_UNIX);
+ FTPConf.setServerTimeZoneId("GMT");
+ FTP.configure(FTPConf);
try {
FTP.connect("tgftp.nws.noaa.gov");
FTP.login("anonymous","testing@apache.org");
@@ -95,7 +95,7 @@
super(arg0);
}
-
+
private TreeSet getSortedList(FTPFile[] files) {
// create a TreeSet which will sort each element
// as it is added.
@@ -111,10 +111,10 @@
for (int i=0; i < files.length; i++) {
- // The directory contains a few additional files at the beginning
- // which aren't in the series we want. The series we want consists
- // of files named sn.dddd. This adjusts the file list to get rid
- // of the uninteresting ones.
+ // The directory contains a few additional files at the beginning
+ // which aren't in the series we want. The series we want consists
+ // of files named sn.dddd. This adjusts the file list to get rid
+ // of the uninteresting ones.
if (files[i].getName().startsWith("sn")) {
sorted.add(files[i]);
}
@@ -122,7 +122,7 @@
return sorted;
}
-
+
public static void main(String[] args) {
FTPClientConfigFunctionalTest F = new FTPClientConfigFunctionalTest();
}
Modified: commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/FTPClientConfigTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/FTPClientConfigTest.java?rev=658491&r1=658490&r2=658491&view=diff
==============================================================================
--- commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/FTPClientConfigTest.java (original)
+++ commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/FTPClientConfigTest.java Tue May 20 16:48:50 2008
@@ -111,17 +111,17 @@
Date d2 = null;
Date d3 = null;
try {
- d1 = sdf1.parse("31 d\u00e9c 2004");
+ d1 = sdf1.parse("31 d\u00e9c 2004");
} catch (ParseException px) {
fail("failed.to.parse.french");
}
try {
- d2 = sdf2.parse("dhj 31, 2004");
+ d2 = sdf2.parse("dhj 31, 2004");
} catch (ParseException px) {
fail("failed.to.parse.albanian");
}
try {
- d3 = sdf3.parse("DEC 31, 2004");
+ d3 = sdf3.parse("DEC 31, 2004");
} catch (ParseException px) {
fail("failed.to.parse.'russian'");
}
@@ -163,12 +163,12 @@
Date d1 = null;
Date d2 = null;
try {
- d1 = sdf1.parse("dec 31, 2004");
+ d1 = sdf1.parse("dec 31, 2004");
} catch (ParseException px) {
fail("failed.to.parse.std");
}
try {
- d2 = sdf2.parse("hij 31, 2004");
+ d2 = sdf2.parse("hij 31, 2004");
} catch (ParseException px) {
fail("failed.to.parse.weird");
}
@@ -176,12 +176,12 @@
assertEquals("different.parser.same.date",d1, d2);
try {
- d2 = sdf1.parse("hij 31, 2004");
+ d2 = sdf1.parse("hij 31, 2004");
fail("should.have.failed.to.parse.weird");
} catch (ParseException px) {
}
try {
- d2 = sdf2.parse("dec 31, 2004");
+ d2 = sdf2.parse("dec 31, 2004");
fail("should.have.failed.to.parse.standard");
} catch (ParseException px) {
}
Modified: commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/EnterpriseUnixFTPEntryParserTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/EnterpriseUnixFTPEntryParserTest.java?rev=658491&r1=658490&r2=658491&view=diff
==============================================================================
--- commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/EnterpriseUnixFTPEntryParserTest.java (original)
+++ commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/EnterpriseUnixFTPEntryParserTest.java Tue May 20 16:48:50 2008
@@ -60,7 +60,7 @@
private static final String[] GOODSAMPLES =
{
"-C--E-----FTP B QUA1I1 18128 41 Aug 12 13:56 QUADTEST",
- "-C--E-----FTP A QUA1I1 18128 41 Aug 12 13:56 QUADTEST2"
+ "-C--E-----FTP A QUA1I1 18128 41 Aug 12 13:56 QUADTEST2"
};
/**
@@ -106,7 +106,7 @@
assertEquals("QUADTEST",
file.getName());
assertEquals(5000000000L,
- file.getSize());
+ file.getSize());
assertEquals("QUA1I1",
file.getUser());
assertEquals("18128",
Modified: commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/FTPConfigEntryParserTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/FTPConfigEntryParserTest.java?rev=658491&r1=658490&r2=658491&view=diff
==============================================================================
--- commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/FTPConfigEntryParserTest.java (original)
+++ commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/FTPConfigEntryParserTest.java Tue May 20 16:48:50 2008
@@ -35,130 +35,130 @@
* @version $Id$
*/
public class FTPConfigEntryParserTest extends TestCase {
-
- private SimpleDateFormat df = new SimpleDateFormat();
+
+ private SimpleDateFormat df = new SimpleDateFormat();
- public void testParseFieldsOnAIX() {
-
- // Set a date format for this server type
- FTPClientConfig config = new FTPClientConfig(FTPClientConfig.SYST_UNIX);
- config.setDefaultDateFormatStr("dd MMM HH:mm");
-
- UnixFTPEntryParser parser = new UnixFTPEntryParser();
- parser.configure(config);
-
- FTPFile f = parser.parseFTPEntry("-rw-r----- 1 ravensm sca 814 02 Mar 16:27 ZMIR2.m");
-
- assertNotNull("Could not parse entry.", f);
- assertFalse("Is not a directory.", f.isDirectory());
-
- assertTrue("Should have user read permission.", f.hasPermission(
- FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION));
- assertTrue("Should have user write permission.", f.hasPermission(
- FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION));
- assertFalse("Should NOT have user execute permission.", f
- .hasPermission(FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION));
- assertTrue("Should have group read permission.", f.hasPermission(
- FTPFile.GROUP_ACCESS, FTPFile.READ_PERMISSION));
- assertFalse("Should NOT have group write permission.", f
- .hasPermission(FTPFile.GROUP_ACCESS, FTPFile.WRITE_PERMISSION));
- assertFalse("Should NOT have group execute permission.",
- f.hasPermission(FTPFile.GROUP_ACCESS,
- FTPFile.EXECUTE_PERMISSION));
- assertFalse("Should NOT have world read permission.", f.hasPermission(
- FTPFile.WORLD_ACCESS, FTPFile.READ_PERMISSION));
- assertFalse("Should NOT have world write permission.", f
- .hasPermission(FTPFile.WORLD_ACCESS, FTPFile.WRITE_PERMISSION));
- assertFalse("Should NOT have world execute permission.",
- f.hasPermission(FTPFile.WORLD_ACCESS,
- FTPFile.EXECUTE_PERMISSION));
-
- assertEquals(1, f.getHardLinkCount());
-
- assertEquals("ravensm", f.getUser());
- assertEquals("sca", f.getGroup());
-
- assertEquals("ZMIR2.m", f.getName());
- assertEquals(814, f.getSize());
-
- Calendar cal = Calendar.getInstance();
-
- Date refDate = new Date();
-
- cal.set(Calendar.MONTH, Calendar.MARCH);
- cal.set(Calendar.DATE, 2);
- cal.set(Calendar.HOUR_OF_DAY, 16);
- cal.set(Calendar.MINUTE, 27);
- cal.set(Calendar.SECOND, 0);
-
- // With no year specified, it defaults to 1970
- // TODO this is probably a bug - it should default to the current year
- cal.set(Calendar.YEAR, 1970);
-
- assertEquals(df.format(cal.getTime()), df.format(f.getTimestamp()
- .getTime()));
- }
-
- /**
- * This is a new format reported on the mailing lists. Parsing this kind of
- * entry necessitated changing the regex in the parser.
- *
- */
- public void testParseEntryWithSymlink() {
-
- FTPClientConfig config = new FTPClientConfig(FTPClientConfig.SYST_UNIX);
- config.setDefaultDateFormatStr("yyyy-MM-dd HH:mm");
-
- UnixFTPEntryParser parser = new UnixFTPEntryParser();
- parser.configure(config);
-
- FTPFile f = parser.parseFTPEntry("lrwxrwxrwx 1 neeme neeme 23 2005-03-02 18:06 macros");
-
- assertNotNull("Could not parse entry.", f);
- assertFalse("Is not a directory.", f.isDirectory());
- assertTrue("Is a symbolic link", f.isSymbolicLink());
-
- assertTrue("Should have user read permission.", f.hasPermission(
- FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION));
- assertTrue("Should have user write permission.", f.hasPermission(
- FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION));
- assertTrue("Should have user execute permission.", f
- .hasPermission(FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION));
- assertTrue("Should have group read permission.", f.hasPermission(
- FTPFile.GROUP_ACCESS, FTPFile.READ_PERMISSION));
- assertTrue("Should have group write permission.", f
- .hasPermission(FTPFile.GROUP_ACCESS, FTPFile.WRITE_PERMISSION));
- assertTrue("Should have group execute permission.",
- f.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.EXECUTE_PERMISSION));
- assertTrue("Should have world read permission.", f.hasPermission(
- FTPFile.WORLD_ACCESS, FTPFile.READ_PERMISSION));
- assertTrue("Should have world write permission.", f
- .hasPermission(FTPFile.WORLD_ACCESS, FTPFile.WRITE_PERMISSION));
- assertTrue("Should have world execute permission.",
- f.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.EXECUTE_PERMISSION));
-
- assertEquals(1, f.getHardLinkCount());
-
- assertEquals("neeme", f.getUser());
- assertEquals("neeme", f.getGroup());
-
- assertEquals("macros", f.getName());
- assertEquals(23, f.getSize());
-
- Calendar cal = Calendar.getInstance();
-
- Date refDate = new Date();
-
- cal.set(Calendar.MONTH, Calendar.MARCH);
- cal.set(Calendar.DATE, 2);
- cal.set(Calendar.HOUR_OF_DAY, 18);
- cal.set(Calendar.MINUTE, 06);
- cal.set(Calendar.SECOND, 0);
- cal.set(Calendar.YEAR, 2005);
-
- assertEquals(df.format(cal.getTime()), df.format(f.getTimestamp()
- .getTime()));
-
- }
+ public void testParseFieldsOnAIX() {
+
+ // Set a date format for this server type
+ FTPClientConfig config = new FTPClientConfig(FTPClientConfig.SYST_UNIX);
+ config.setDefaultDateFormatStr("dd MMM HH:mm");
+
+ UnixFTPEntryParser parser = new UnixFTPEntryParser();
+ parser.configure(config);
+
+ FTPFile f = parser.parseFTPEntry("-rw-r----- 1 ravensm sca 814 02 Mar 16:27 ZMIR2.m");
+
+ assertNotNull("Could not parse entry.", f);
+ assertFalse("Is not a directory.", f.isDirectory());
+
+ assertTrue("Should have user read permission.", f.hasPermission(
+ FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION));
+ assertTrue("Should have user write permission.", f.hasPermission(
+ FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION));
+ assertFalse("Should NOT have user execute permission.", f
+ .hasPermission(FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION));
+ assertTrue("Should have group read permission.", f.hasPermission(
+ FTPFile.GROUP_ACCESS, FTPFile.READ_PERMISSION));
+ assertFalse("Should NOT have group write permission.", f
+ .hasPermission(FTPFile.GROUP_ACCESS, FTPFile.WRITE_PERMISSION));
+ assertFalse("Should NOT have group execute permission.",
+ f.hasPermission(FTPFile.GROUP_ACCESS,
+ FTPFile.EXECUTE_PERMISSION));
+ assertFalse("Should NOT have world read permission.", f.hasPermission(
+ FTPFile.WORLD_ACCESS, FTPFile.READ_PERMISSION));
+ assertFalse("Should NOT have world write permission.", f
+ .hasPermission(FTPFile.WORLD_ACCESS, FTPFile.WRITE_PERMISSION));
+ assertFalse("Should NOT have world execute permission.",
+ f.hasPermission(FTPFile.WORLD_ACCESS,
+ FTPFile.EXECUTE_PERMISSION));
+
+ assertEquals(1, f.getHardLinkCount());
+
+ assertEquals("ravensm", f.getUser());
+ assertEquals("sca", f.getGroup());
+
+ assertEquals("ZMIR2.m", f.getName());
+ assertEquals(814, f.getSize());
+
+ Calendar cal = Calendar.getInstance();
+
+ Date refDate = new Date();
+
+ cal.set(Calendar.MONTH, Calendar.MARCH);
+ cal.set(Calendar.DATE, 2);
+ cal.set(Calendar.HOUR_OF_DAY, 16);
+ cal.set(Calendar.MINUTE, 27);
+ cal.set(Calendar.SECOND, 0);
+
+ // With no year specified, it defaults to 1970
+ // TODO this is probably a bug - it should default to the current year
+ cal.set(Calendar.YEAR, 1970);
+
+ assertEquals(df.format(cal.getTime()), df.format(f.getTimestamp()
+ .getTime()));
+ }
+
+ /**
+ * This is a new format reported on the mailing lists. Parsing this kind of
+ * entry necessitated changing the regex in the parser.
+ *
+ */
+ public void testParseEntryWithSymlink() {
+
+ FTPClientConfig config = new FTPClientConfig(FTPClientConfig.SYST_UNIX);
+ config.setDefaultDateFormatStr("yyyy-MM-dd HH:mm");
+
+ UnixFTPEntryParser parser = new UnixFTPEntryParser();
+ parser.configure(config);
+
+ FTPFile f = parser.parseFTPEntry("lrwxrwxrwx 1 neeme neeme 23 2005-03-02 18:06 macros");
+
+ assertNotNull("Could not parse entry.", f);
+ assertFalse("Is not a directory.", f.isDirectory());
+ assertTrue("Is a symbolic link", f.isSymbolicLink());
+
+ assertTrue("Should have user read permission.", f.hasPermission(
+ FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION));
+ assertTrue("Should have user write permission.", f.hasPermission(
+ FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION));
+ assertTrue("Should have user execute permission.", f
+ .hasPermission(FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION));
+ assertTrue("Should have group read permission.", f.hasPermission(
+ FTPFile.GROUP_ACCESS, FTPFile.READ_PERMISSION));
+ assertTrue("Should have group write permission.", f
+ .hasPermission(FTPFile.GROUP_ACCESS, FTPFile.WRITE_PERMISSION));
+ assertTrue("Should have group execute permission.",
+ f.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.EXECUTE_PERMISSION));
+ assertTrue("Should have world read permission.", f.hasPermission(
+ FTPFile.WORLD_ACCESS, FTPFile.READ_PERMISSION));
+ assertTrue("Should have world write permission.", f
+ .hasPermission(FTPFile.WORLD_ACCESS, FTPFile.WRITE_PERMISSION));
+ assertTrue("Should have world execute permission.",
+ f.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.EXECUTE_PERMISSION));
+
+ assertEquals(1, f.getHardLinkCount());
+
+ assertEquals("neeme", f.getUser());
+ assertEquals("neeme", f.getGroup());
+
+ assertEquals("macros", f.getName());
+ assertEquals(23, f.getSize());
+
+ Calendar cal = Calendar.getInstance();
+
+ Date refDate = new Date();
+
+ cal.set(Calendar.MONTH, Calendar.MARCH);
+ cal.set(Calendar.DATE, 2);
+ cal.set(Calendar.HOUR_OF_DAY, 18);
+ cal.set(Calendar.MINUTE, 06);
+ cal.set(Calendar.SECOND, 0);
+ cal.set(Calendar.YEAR, 2005);
+
+ assertEquals(df.format(cal.getTime()), df.format(f.getTimestamp()
+ .getTime()));
+
+ }
}
Modified: commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java?rev=658491&r1=658490&r2=658491&view=diff
==============================================================================
--- commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java (original)
+++ commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java Tue May 20 16:48:50 2008
@@ -36,193 +36,193 @@
*
*/
public class FTPTimestampParserImplTest extends TestCase {
-
- private static final int TWO_HOURS_OF_MILLISECONDS = 2 * 60 * 60 * 1000;
+
+ private static final int TWO_HOURS_OF_MILLISECONDS = 2 * 60 * 60 * 1000;
+
+ public void testParseTimestamp() {
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.HOUR_OF_DAY, 1);
+ cal.set(Calendar.SECOND,0);
+ cal.set(Calendar.MILLISECOND,0);
+ Date anHourFromNow = cal.getTime();
+ FTPTimestampParserImpl parser = new FTPTimestampParserImpl();
+ SimpleDateFormat sdf =
+ new SimpleDateFormat(parser.getRecentDateFormatString());
+ String fmtTime = sdf.format(anHourFromNow);
+ try {
+ Calendar parsed = parser.parseTimestamp(fmtTime);
+ // since the timestamp is ahead of now (by one hour),
+ // this must mean the file's date refers to a year ago.
+ assertEquals("test.roll.back.year", 1, cal.get(Calendar.YEAR) - parsed.get(Calendar.YEAR));
+ } catch (ParseException e) {
+ fail("Unable to parse");
+ }
+ }
+
+ public void testParseTimestampWithSlop() {
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.HOUR_OF_DAY, 1);
+ cal.set(Calendar.SECOND,0);
+ cal.set(Calendar.MILLISECOND,0);
+ Date anHourFromNow = cal.getTime();
+ cal.add(Calendar.DATE, 1);
+ Date anHourFromNowTomorrow = cal.getTime();
+ cal.add(Calendar.DATE, -1);
+
+ FTPTimestampParserImpl parser = new FTPTimestampParserImpl();
+
+ // set the "slop" factor on
+ parser.setLenientFutureDates(true);
+
+ SimpleDateFormat sdf =
+ new SimpleDateFormat(parser.getRecentDateFormatString());
+ try {
+ String fmtTime = sdf.format(anHourFromNow);
+ Calendar parsed = parser.parseTimestamp(fmtTime);
+ // the timestamp is ahead of now (by one hour), but
+ // that's within range of the "slop" factor.
+ // so the date is still considered this year.
+ assertEquals("test.slop.no.roll.back.year", 0, cal.get(Calendar.YEAR) - parsed.get(Calendar.YEAR));
+
+ // add a day to get beyond the range of the slop factor.
+ // this must mean the file's date refers to a year ago.
+ fmtTime = sdf.format(anHourFromNowTomorrow);
+ parsed = parser.parseTimestamp(fmtTime);
+ assertEquals("test.slop.roll.back.year", 1, cal.get(Calendar.YEAR) - parsed.get(Calendar.YEAR));
+
+ } catch (ParseException e) {
+ fail("Unable to parse");
+ }
+ }
+
+ public void testParseTimestampAcrossTimeZones() {
+
+
+ Calendar cal = Calendar.getInstance();
+ cal.set(Calendar.SECOND,0);
+ cal.set(Calendar.MILLISECOND,0);
+
+ cal.add(Calendar.HOUR_OF_DAY, 1);
+ Date anHourFromNow = cal.getTime();
+
+ cal.add(Calendar.HOUR_OF_DAY, 2);
+ Date threeHoursFromNow = cal.getTime();
+ cal.add(Calendar.HOUR_OF_DAY, -2);
+
+ FTPTimestampParserImpl parser = new FTPTimestampParserImpl();
- public void testParseTimestamp() {
- Calendar cal = Calendar.getInstance();
- cal.add(Calendar.HOUR_OF_DAY, 1);
- cal.set(Calendar.SECOND,0);
- cal.set(Calendar.MILLISECOND,0);
- Date anHourFromNow = cal.getTime();
- FTPTimestampParserImpl parser = new FTPTimestampParserImpl();
- SimpleDateFormat sdf =
- new SimpleDateFormat(parser.getRecentDateFormatString());
- String fmtTime = sdf.format(anHourFromNow);
- try {
- Calendar parsed = parser.parseTimestamp(fmtTime);
- // since the timestamp is ahead of now (by one hour),
- // this must mean the file's date refers to a year ago.
- assertEquals("test.roll.back.year", 1, cal.get(Calendar.YEAR) - parsed.get(Calendar.YEAR));
- } catch (ParseException e) {
- fail("Unable to parse");
- }
- }
-
- public void testParseTimestampWithSlop() {
- Calendar cal = Calendar.getInstance();
- cal.add(Calendar.HOUR_OF_DAY, 1);
- cal.set(Calendar.SECOND,0);
- cal.set(Calendar.MILLISECOND,0);
- Date anHourFromNow = cal.getTime();
- cal.add(Calendar.DATE, 1);
- Date anHourFromNowTomorrow = cal.getTime();
- cal.add(Calendar.DATE, -1);
-
- FTPTimestampParserImpl parser = new FTPTimestampParserImpl();
-
- // set the "slop" factor on
- parser.setLenientFutureDates(true);
-
- SimpleDateFormat sdf =
- new SimpleDateFormat(parser.getRecentDateFormatString());
- try {
- String fmtTime = sdf.format(anHourFromNow);
- Calendar parsed = parser.parseTimestamp(fmtTime);
- // the timestamp is ahead of now (by one hour), but
- // that's within range of the "slop" factor.
- // so the date is still considered this year.
- assertEquals("test.slop.no.roll.back.year", 0, cal.get(Calendar.YEAR) - parsed.get(Calendar.YEAR));
-
- // add a day to get beyond the range of the slop factor.
- // this must mean the file's date refers to a year ago.
- fmtTime = sdf.format(anHourFromNowTomorrow);
- parsed = parser.parseTimestamp(fmtTime);
- assertEquals("test.slop.roll.back.year", 1, cal.get(Calendar.YEAR) - parsed.get(Calendar.YEAR));
-
- } catch (ParseException e) {
- fail("Unable to parse");
- }
- }
-
- public void testParseTimestampAcrossTimeZones() {
-
-
- Calendar cal = Calendar.getInstance();
- cal.set(Calendar.SECOND,0);
- cal.set(Calendar.MILLISECOND,0);
-
- cal.add(Calendar.HOUR_OF_DAY, 1);
- Date anHourFromNow = cal.getTime();
-
- cal.add(Calendar.HOUR_OF_DAY, 2);
- Date threeHoursFromNow = cal.getTime();
- cal.add(Calendar.HOUR_OF_DAY, -2);
-
- FTPTimestampParserImpl parser = new FTPTimestampParserImpl();
-
- // assume we are FTPing a server in Chicago, two hours ahead of
- // L. A.
- FTPClientConfig config =
- new FTPClientConfig(FTPClientConfig.SYST_UNIX);
- config.setDefaultDateFormatStr(FTPTimestampParser.DEFAULT_SDF);
- config.setRecentDateFormatStr(FTPTimestampParser.DEFAULT_RECENT_SDF);
- // 2 hours difference
- config.setServerTimeZoneId("America/Chicago");
- parser.configure(config);
-
- SimpleDateFormat sdf = (SimpleDateFormat)
- parser.getRecentDateFormat().clone();
-
- // assume we're in the US Pacific Time Zone
- TimeZone tzla = TimeZone.getTimeZone("America/Los_Angeles");
- sdf.setTimeZone(tzla);
-
- // get formatted versions of time in L.A.
- String fmtTimePlusOneHour = sdf.format(anHourFromNow);
- String fmtTimePlusThreeHours = sdf.format(threeHoursFromNow);
-
-
- try {
- Calendar parsed = parser.parseTimestamp(fmtTimePlusOneHour);
- // the only difference should be the two hours
- // difference, no rolling back a year should occur.
- assertEquals("no.rollback.because.of.time.zones",
- TWO_HOURS_OF_MILLISECONDS,
- cal.getTime().getTime() - parsed.getTime().getTime());
- } catch (ParseException e){
- fail("Unable to parse " + fmtTimePlusOneHour);
- }
-
- //but if the file's timestamp is THREE hours ahead of now, that should
- //cause a rollover even taking the time zone difference into account.
- //Since that time is still later than ours, it is parsed as occurring
- //on this date last year.
- try {
- Calendar parsed = parser.parseTimestamp(fmtTimePlusThreeHours);
- // rollback should occur here.
- assertEquals("rollback.even.with.time.zones",
- 1, cal.get(Calendar.YEAR) - parsed.get(Calendar.YEAR));
- } catch (ParseException e){
- fail("Unable to parse" + fmtTimePlusThreeHours);
- }
- }
-
-
- public void testParser() {
- FTPTimestampParserImpl parser = new FTPTimestampParserImpl();
- try {
- parser.parseTimestamp("feb 22 2002");
- } catch (ParseException e) {
- fail("failed.to.parse.default");
- }
- try {
- parser.parseTimestamp("f\u00e9v 22 2002");
- fail("should.have.failed.to.parse.default");
- } catch (ParseException e) {
- // this is the success case
- }
-
- FTPClientConfig config = new FTPClientConfig();
- config.setDefaultDateFormatStr("d MMM yyyy");
- config.setRecentDateFormatStr("d MMM HH:mm");
- config.setServerLanguageCode("fr");
- parser.configure(config);
- try {
- parser.parseTimestamp("d\u00e9c 22 2002");
- fail("incorrect.field.order");
- } catch (ParseException e) {
- // this is the success case
- }
- try {
- parser.parseTimestamp("22 d\u00e9c 2002");
- } catch (ParseException e) {
- fail("failed.to.parse.french");
- }
-
- try {
- parser.parseTimestamp("22 dec 2002");
- fail("incorrect.language");
- } catch (ParseException e) {
- // this is the success case
- }
- try {
- parser.parseTimestamp("29 f\u00e9v 2002");
- fail("nonexistent.date");
- } catch (ParseException e) {
- // this is the success case
- }
-
- try {
- parser.parseTimestamp("22 ao\u00fb 30:02");
- fail("bad.hour");
- } catch (ParseException e) {
- // this is the success case
- }
-
- try {
- parser.parseTimestamp("22 ao\u00fb 20:74");
- fail("bad.minute");
- } catch (ParseException e) {
- // this is the success case
- }
- try {
- parser.parseTimestamp("28 ao\u00fb 20:02");
- } catch (ParseException e) {
- fail("failed.to.parse.french.recent");
- }
- }
-
+ // assume we are FTPing a server in Chicago, two hours ahead of
+ // L. A.
+ FTPClientConfig config =
+ new FTPClientConfig(FTPClientConfig.SYST_UNIX);
+ config.setDefaultDateFormatStr(FTPTimestampParser.DEFAULT_SDF);
+ config.setRecentDateFormatStr(FTPTimestampParser.DEFAULT_RECENT_SDF);
+ // 2 hours difference
+ config.setServerTimeZoneId("America/Chicago");
+ parser.configure(config);
+
+ SimpleDateFormat sdf = (SimpleDateFormat)
+ parser.getRecentDateFormat().clone();
+
+ // assume we're in the US Pacific Time Zone
+ TimeZone tzla = TimeZone.getTimeZone("America/Los_Angeles");
+ sdf.setTimeZone(tzla);
+
+ // get formatted versions of time in L.A.
+ String fmtTimePlusOneHour = sdf.format(anHourFromNow);
+ String fmtTimePlusThreeHours = sdf.format(threeHoursFromNow);
+
+
+ try {
+ Calendar parsed = parser.parseTimestamp(fmtTimePlusOneHour);
+ // the only difference should be the two hours
+ // difference, no rolling back a year should occur.
+ assertEquals("no.rollback.because.of.time.zones",
+ TWO_HOURS_OF_MILLISECONDS,
+ cal.getTime().getTime() - parsed.getTime().getTime());
+ } catch (ParseException e){
+ fail("Unable to parse " + fmtTimePlusOneHour);
+ }
+
+ //but if the file's timestamp is THREE hours ahead of now, that should
+ //cause a rollover even taking the time zone difference into account.
+ //Since that time is still later than ours, it is parsed as occurring
+ //on this date last year.
+ try {
+ Calendar parsed = parser.parseTimestamp(fmtTimePlusThreeHours);
+ // rollback should occur here.
+ assertEquals("rollback.even.with.time.zones",
+ 1, cal.get(Calendar.YEAR) - parsed.get(Calendar.YEAR));
+ } catch (ParseException e){
+ fail("Unable to parse" + fmtTimePlusThreeHours);
+ }
+ }
+
+
+ public void testParser() {
+ FTPTimestampParserImpl parser = new FTPTimestampParserImpl();
+ try {
+ parser.parseTimestamp("feb 22 2002");
+ } catch (ParseException e) {
+ fail("failed.to.parse.default");
+ }
+ try {
+ parser.parseTimestamp("f\u00e9v 22 2002");
+ fail("should.have.failed.to.parse.default");
+ } catch (ParseException e) {
+ // this is the success case
+ }
+
+ FTPClientConfig config = new FTPClientConfig();
+ config.setDefaultDateFormatStr("d MMM yyyy");
+ config.setRecentDateFormatStr("d MMM HH:mm");
+ config.setServerLanguageCode("fr");
+ parser.configure(config);
+ try {
+ parser.parseTimestamp("d\u00e9c 22 2002");
+ fail("incorrect.field.order");
+ } catch (ParseException e) {
+ // this is the success case
+ }
+ try {
+ parser.parseTimestamp("22 d\u00e9c 2002");
+ } catch (ParseException e) {
+ fail("failed.to.parse.french");
+ }
+
+ try {
+ parser.parseTimestamp("22 dec 2002");
+ fail("incorrect.language");
+ } catch (ParseException e) {
+ // this is the success case
+ }
+ try {
+ parser.parseTimestamp("29 f\u00e9v 2002");
+ fail("nonexistent.date");
+ } catch (ParseException e) {
+ // this is the success case
+ }
+
+ try {
+ parser.parseTimestamp("22 ao\u00fb 30:02");
+ fail("bad.hour");
+ } catch (ParseException e) {
+ // this is the success case
+ }
+
+ try {
+ parser.parseTimestamp("22 ao\u00fb 20:74");
+ fail("bad.minute");
+ } catch (ParseException e) {
+ // this is the success case
+ }
+ try {
+ parser.parseTimestamp("28 ao\u00fb 20:02");
+ } catch (ParseException e) {
+ fail("failed.to.parse.french.recent");
+ }
+ }
+
/*
* Check how short date is interpreted at a given time.
* Check both with and without lenient future dates
Modified: commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/MVSFTPEntryParserTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/MVSFTPEntryParserTest.java?rev=658491&r1=658490&r2=658491&view=diff
==============================================================================
--- commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/MVSFTPEntryParserTest.java (original)
+++ commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/MVSFTPEntryParserTest.java Tue May 20 16:48:50 2008
@@ -40,9 +40,9 @@
"Migrated file6.O",
"PSMLB7 3390 2005/04/04 1 1 VB 27994 27998 PS file7.O",
"PSMLC6 3390 2005/04/05 1 1 VB 27994 27998 PS file7.O.BU",
- "FPFS42 3390 2004/06/23 1 1 FB 128 6144 PS INCOMING.RPTBM023.D061704",
- "FPFS41 3390 2004/06/23 1 1 FB 128 6144 PS INCOMING.RPTBM056.D061704",
- "FPFS25 3390 2004/06/23 1 1 FB 128 6144 PS INCOMING.WTM204.D061704",
+ "FPFS42 3390 2004/06/23 1 1 FB 128 6144 PS INCOMING.RPTBM023.D061704",
+ "FPFS41 3390 2004/06/23 1 1 FB 128 6144 PS INCOMING.RPTBM056.D061704",
+ "FPFS25 3390 2004/06/23 1 1 FB 128 6144 PS INCOMING.WTM204.D061704",
};
private static final String [] badsamples =
Modified: commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/NetwareFTPEntryParserTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/NetwareFTPEntryParserTest.java?rev=658491&r1=658490&r2=658491&view=diff
==============================================================================
--- commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/NetwareFTPEntryParserTest.java (original)
+++ commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/NetwareFTPEntryParserTest.java Tue May 20 16:48:50 2008
@@ -29,103 +29,103 @@
*/
public class NetwareFTPEntryParserTest extends FTPParseTestFramework {
- private static final String[] badsamples = {
- "a [-----F--] SCION_SYS 512 Apr 13 23:52 SYS",
- "d [----AF--] 0 512 10-04-2001 _ADMIN"
- };
-
- private static final String [] goodsamples = {
- "d [-----F--] SCION_SYS 512 Apr 13 23:52 SYS",
- "d [----AF--] 0 512 Feb 22 17:32 _ADMIN",
- "d [-W---F--] SCION_VOL2 512 Apr 13 23:12 VOL2",
- "- [RWCEAFMS] rwinston 19968 Mar 12 15:20 Executive Summary.doc",
- "d [RWCEAFMS] rwinston 512 Nov 24 2005 Favorites"
+ private static final String[] badsamples = {
+ "a [-----F--] SCION_SYS 512 Apr 13 23:52 SYS",
+ "d [----AF--] 0 512 10-04-2001 _ADMIN"
};
-
- /**
- * @see junit.framework.TestCase#TestCase(String)
- */
- public NetwareFTPEntryParserTest(String name) {
- super(name);
- }
-
- /**
- * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#getBadListing()
- */
- protected String[] getBadListing() {
- return (badsamples);
- }
-
- /**
- * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#getGoodListing()
- */
- protected String[] getGoodListing() {
- return (goodsamples);
- }
-
- /**
- * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#getParser()
- */
- protected FTPFileEntryParser getParser() {
- return (new NetwareFTPEntryParser());
- }
-
- /**
- * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#testParseFieldsOnDirectory()
- */
-
- public void testParseFieldsOnDirectory() throws Exception {
- String reply = "d [-W---F--] testUser 512 Apr 13 23:12 testFile";
- FTPFile f = getParser().parseFTPEntry(reply);
-
- assertNotNull("Could not parse file", f);
- assertEquals("testFile", f.getName());
- assertEquals(512L, f.getSize());
- assertEquals("testUser", f.getUser());
- assertTrue("Directory flag is not set!", f.isDirectory());
-
- Calendar cal = Calendar.getInstance();
- cal.set(Calendar.MONTH, 3);
- cal.set(Calendar.DAY_OF_MONTH, 13);
- cal.set(Calendar.HOUR_OF_DAY, 23);
- cal.set(Calendar.MINUTE, 12);
- cal.set(Calendar.SECOND, 0);
- cal.set(Calendar.MILLISECOND, 0);
- cal.set(Calendar.YEAR, f.getTimestamp().get(Calendar.YEAR));
-
- assertEquals(df.format(cal.getTime()), df.format(f.getTimestamp()
- .getTime()));
-
- }
-
-
- /**
- * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#testParseFieldsOnFile()
- */
- public void testParseFieldsOnFile() throws Exception {
- String reply = "- [R-CEAFMS] rwinston 19968 Mar 12 15:20 Document name with spaces.doc";
-
- FTPFile f = getParser().parseFTPEntry(reply);
-
- assertNotNull("Could not parse file", f);
- assertEquals("Document name with spaces.doc", f.getName());
- assertEquals(19968L, f.getSize());
- assertEquals("rwinston", f.getUser());
- assertTrue("File flag is not set!", f.isFile());
-
- assertTrue(f.hasPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION));
- assertFalse(f.hasPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION));
- }
-
-
- /**
- * Method suite.
- * @return TestSuite
- */
- public static TestSuite suite() {
- return (new TestSuite(NetwareFTPEntryParserTest.class));
- }
-
-
+
+ private static final String [] goodsamples = {
+ "d [-----F--] SCION_SYS 512 Apr 13 23:52 SYS",
+ "d [----AF--] 0 512 Feb 22 17:32 _ADMIN",
+ "d [-W---F--] SCION_VOL2 512 Apr 13 23:12 VOL2",
+ "- [RWCEAFMS] rwinston 19968 Mar 12 15:20 Executive Summary.doc",
+ "d [RWCEAFMS] rwinston 512 Nov 24 2005 Favorites"
+ };
+
+ /**
+ * @see junit.framework.TestCase#TestCase(String)
+ */
+ public NetwareFTPEntryParserTest(String name) {
+ super(name);
+ }
+
+ /**
+ * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#getBadListing()
+ */
+ protected String[] getBadListing() {
+ return (badsamples);
+ }
+
+ /**
+ * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#getGoodListing()
+ */
+ protected String[] getGoodListing() {
+ return (goodsamples);
+ }
+
+ /**
+ * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#getParser()
+ */
+ protected FTPFileEntryParser getParser() {
+ return (new NetwareFTPEntryParser());
+ }
+
+ /**
+ * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#testParseFieldsOnDirectory()
+ */
+
+ public void testParseFieldsOnDirectory() throws Exception {
+ String reply = "d [-W---F--] testUser 512 Apr 13 23:12 testFile";
+ FTPFile f = getParser().parseFTPEntry(reply);
+
+ assertNotNull("Could not parse file", f);
+ assertEquals("testFile", f.getName());
+ assertEquals(512L, f.getSize());
+ assertEquals("testUser", f.getUser());
+ assertTrue("Directory flag is not set!", f.isDirectory());
+
+ Calendar cal = Calendar.getInstance();
+ cal.set(Calendar.MONTH, 3);
+ cal.set(Calendar.DAY_OF_MONTH, 13);
+ cal.set(Calendar.HOUR_OF_DAY, 23);
+ cal.set(Calendar.MINUTE, 12);
+ cal.set(Calendar.SECOND, 0);
+ cal.set(Calendar.MILLISECOND, 0);
+ cal.set(Calendar.YEAR, f.getTimestamp().get(Calendar.YEAR));
+
+ assertEquals(df.format(cal.getTime()), df.format(f.getTimestamp()
+ .getTime()));
+
+ }
+
+
+ /**
+ * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#testParseFieldsOnFile()
+ */
+ public void testParseFieldsOnFile() throws Exception {
+ String reply = "- [R-CEAFMS] rwinston 19968 Mar 12 15:20 Document name with spaces.doc";
+
+ FTPFile f = getParser().parseFTPEntry(reply);
+
+ assertNotNull("Could not parse file", f);
+ assertEquals("Document name with spaces.doc", f.getName());
+ assertEquals(19968L, f.getSize());
+ assertEquals("rwinston", f.getUser());
+ assertTrue("File flag is not set!", f.isFile());
+
+ assertTrue(f.hasPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION));
+ assertFalse(f.hasPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION));
+ }
+
+
+ /**
+ * Method suite.
+ * @return TestSuite
+ */
+ public static TestSuite suite() {
+ return (new TestSuite(NetwareFTPEntryParserTest.class));
+ }
+
+
}
Modified: commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/UnixFTPEntryParserTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/UnixFTPEntryParserTest.java?rev=658491&r1=658490&r2=658491&view=diff
==============================================================================
--- commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/UnixFTPEntryParserTest.java (original)
+++ commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/UnixFTPEntryParserTest.java Tue May 20 16:48:50 2008
@@ -29,83 +29,83 @@
*/
public class UnixFTPEntryParserTest extends FTPParseTestFramework {
- private static final String[] badsamples = {
- "zrwxr-xr-x 2 root root 4096 Mar 2 15:13 zxbox",
- "dxrwr-xr-x 2 root root 4096 Aug 24 2001 zxjdbc",
- "drwxr-xr-x 2 root root 4096 Jam 4 00:03 zziplib",
- "drwxr-xr-x 2 root 99 4096 Feb 23 30:01 zzplayer",
- "drwxr-xr-x 2 root root 4096 Aug 36 2001 zztpp",
- "-rw-r--r-- 1 14 staff 80284 Aug 22 zxJDBC-1.2.3.tar.gz",
- "-rw-r--r-- 1 14 staff 119:26 Aug 22 2000 zxJDBC-1.2.3.zip",
- /*"-rw-r--r-- 1 ftp no group 83853 Jan 22 2001 zxJDBC-1.2.4.tar.gz",*/
- "-rw-r--r-- 1ftp nogroup 126552 Jan 22 2001 zxJDBC-1.2.4.zip",
- "-rw-r--r-- 1 root root 190144 2001-04-27 zxJDBC-2.0.1b1.zip",
- "-rw-r--r-- 1 root root 111325 Apr -7 18:79 zxJDBC-2.0.1b1.tar.gz" };
-
- private static final String[] goodsamples =
- {
- "-rw-r--r-- 1 500 500 21 Aug 8 14:14 JB3-TES1.gz",
- "-rwxr-xr-x 2 root root 4096 Mar 2 15:13 zxbox",
- "drwxr-xr-x 2 root root 4096 Aug 24 2001 zxjdbc",
- "drwxr-xr-x 2 root root 4096 Jan 4 00:03 zziplib",
- "drwxr-xr-x 2 root 99 4096 Feb 23 2001 zzplayer",
- "drwxr-xr-x 2 root root 4096 Aug 6 2001 zztpp",
- "drwxr-xr-x 1 usernameftp 512 Jan 29 23:32 prog",
- "lrw-r--r-- 1 14 14 80284 Aug 22 2000 zxJDBC-1.2.3.tar.gz",
- "frw-r--r-- 1 14 staff 119926 Aug 22 2000 zxJDBC-1.2.3.zip",
- "crw-r--r-- 1 ftp nogroup 83853 Jan 22 2001 zxJDBC-1.2.4.tar.gz",
- "brw-r--r-- 1 ftp nogroup 126552 Jan 22 2001 zxJDBC-1.2.4.zip",
- "-rw-r--r-- 1 root root 111325 Apr 27 2001 zxJDBC-2.0.1b1.tar.gz",
- "-rw-r--r-- 1 root root 190144 Apr 27 2001 zxJDBC-2.0.1b1.zip",
- "-rwxr-xr-x 2 500 500 166 Nov 2 2001 73131-testtes1.afp",
- "-rw-r--r-- 1 500 500 166 Nov 9 2001 73131-testtes1.AFP",
- "-rw-r--r-- 1 500 500 166 Nov 12 2001 73131-testtes2.afp",
- "-rw-r--r-- 1 500 500 166 Nov 12 2001 73131-testtes2.AFP",
- "-rw-r--r-- 1 500 500 2040000 Aug 5 07:35 testRemoteUPCopyNIX",
- "-rw-r--r-- 1 500 500 2040000 Aug 5 07:31 testRemoteUPDCopyNIX",
- "-rw-r--r-- 1 500 500 2040000 Aug 5 07:31 testRemoteUPVCopyNIX",
- "-rw-r--r-T 1 500 500 0 Mar 25 08:20 testSticky",
- "-rwxr-xr-t 1 500 500 0 Mar 25 08:21 testStickyExec",
- "-rwSr-Sr-- 1 500 500 0 Mar 25 08:22 testSuid",
- "-rwsr-sr-- 1 500 500 0 Mar 25 08:23 testSuidExec",
- "-rwsr-sr-- 1 500 500 0 Mar 25 0:23 testSuidExec2",
- "drwxrwx---+ 23 500 500 0 Jan 10 13:09 testACL",
- "-rw-r--r-- 1 1 3518644 May 25 12:12 std",
+ private static final String[] badsamples = {
+ "zrwxr-xr-x 2 root root 4096 Mar 2 15:13 zxbox",
+ "dxrwr-xr-x 2 root root 4096 Aug 24 2001 zxjdbc",
+ "drwxr-xr-x 2 root root 4096 Jam 4 00:03 zziplib",
+ "drwxr-xr-x 2 root 99 4096 Feb 23 30:01 zzplayer",
+ "drwxr-xr-x 2 root root 4096 Aug 36 2001 zztpp",
+ "-rw-r--r-- 1 14 staff 80284 Aug 22 zxJDBC-1.2.3.tar.gz",
+ "-rw-r--r-- 1 14 staff 119:26 Aug 22 2000 zxJDBC-1.2.3.zip",
+ /*"-rw-r--r-- 1 ftp no group 83853 Jan 22 2001 zxJDBC-1.2.4.tar.gz",*/
+ "-rw-r--r-- 1ftp nogroup 126552 Jan 22 2001 zxJDBC-1.2.4.zip",
+ "-rw-r--r-- 1 root root 190144 2001-04-27 zxJDBC-2.0.1b1.zip",
+ "-rw-r--r-- 1 root root 111325 Apr -7 18:79 zxJDBC-2.0.1b1.tar.gz" };
+
+ private static final String[] goodsamples =
+ {
+ "-rw-r--r-- 1 500 500 21 Aug 8 14:14 JB3-TES1.gz",
+ "-rwxr-xr-x 2 root root 4096 Mar 2 15:13 zxbox",
+ "drwxr-xr-x 2 root root 4096 Aug 24 2001 zxjdbc",
+ "drwxr-xr-x 2 root root 4096 Jan 4 00:03 zziplib",
+ "drwxr-xr-x 2 root 99 4096 Feb 23 2001 zzplayer",
+ "drwxr-xr-x 2 root root 4096 Aug 6 2001 zztpp",
+ "drwxr-xr-x 1 usernameftp 512 Jan 29 23:32 prog",
+ "lrw-r--r-- 1 14 14 80284 Aug 22 2000 zxJDBC-1.2.3.tar.gz",
+ "frw-r--r-- 1 14 staff 119926 Aug 22 2000 zxJDBC-1.2.3.zip",
+ "crw-r--r-- 1 ftp nogroup 83853 Jan 22 2001 zxJDBC-1.2.4.tar.gz",
+ "brw-r--r-- 1 ftp nogroup 126552 Jan 22 2001 zxJDBC-1.2.4.zip",
+ "-rw-r--r-- 1 root root 111325 Apr 27 2001 zxJDBC-2.0.1b1.tar.gz",
+ "-rw-r--r-- 1 root root 190144 Apr 27 2001 zxJDBC-2.0.1b1.zip",
+ "-rwxr-xr-x 2 500 500 166 Nov 2 2001 73131-testtes1.afp",
+ "-rw-r--r-- 1 500 500 166 Nov 9 2001 73131-testtes1.AFP",
+ "-rw-r--r-- 1 500 500 166 Nov 12 2001 73131-testtes2.afp",
+ "-rw-r--r-- 1 500 500 166 Nov 12 2001 73131-testtes2.AFP",
+ "-rw-r--r-- 1 500 500 2040000 Aug 5 07:35 testRemoteUPCopyNIX",
+ "-rw-r--r-- 1 500 500 2040000 Aug 5 07:31 testRemoteUPDCopyNIX",
+ "-rw-r--r-- 1 500 500 2040000 Aug 5 07:31 testRemoteUPVCopyNIX",
+ "-rw-r--r-T 1 500 500 0 Mar 25 08:20 testSticky",
+ "-rwxr-xr-t 1 500 500 0 Mar 25 08:21 testStickyExec",
+ "-rwSr-Sr-- 1 500 500 0 Mar 25 08:22 testSuid",
+ "-rwsr-sr-- 1 500 500 0 Mar 25 08:23 testSuidExec",
+ "-rwsr-sr-- 1 500 500 0 Mar 25 0:23 testSuidExec2",
+ "drwxrwx---+ 23 500 500 0 Jan 10 13:09 testACL",
+ "-rw-r--r-- 1 1 3518644 May 25 12:12 std",
"lrwxrwxrwx 1 neeme neeme 23 Mar 2 18:06 macros -> ./../../global/macros/.",
- "-rw-r--r-- 1 ftp group with spaces in it as allowed in cygwin see bug 38634 83853 Jan 22 2001 zxJDBC-1.2.4.tar.gz",
- "crw-r----- 1 root kmem 0, 27 Jan 30 11:42 kmem", //FreeBSD device
- "crw------- 1 root sys 109,767 Jul 2 2004 pci@1c,600000:devctl" //Solaris device
-
-
- };
-
- /**
- * @see junit.framework.TestCase#TestCase(String)
- */
- public UnixFTPEntryParserTest(String name) {
- super(name);
- }
-
- /**
- * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#getBadListing()
- */
- protected String[] getBadListing() {
- return (badsamples);
- }
-
- /**
- * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#getGoodListing()
- */
- protected String[] getGoodListing() {
- return (goodsamples);
- }
-
+ "-rw-r--r-- 1 ftp group with spaces in it as allowed in cygwin see bug 38634 83853 Jan 22 2001 zxJDBC-1.2.4.tar.gz",
+ "crw-r----- 1 root kmem 0, 27 Jan 30 11:42 kmem", //FreeBSD device
+ "crw------- 1 root sys 109,767 Jul 2 2004 pci@1c,600000:devctl" //Solaris device
+
+
+ };
+
+ /**
+ * @see junit.framework.TestCase#TestCase(String)
+ */
+ public UnixFTPEntryParserTest(String name) {
+ super(name);
+ }
+
+ /**
+ * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#getBadListing()
+ */
+ protected String[] getBadListing() {
+ return (badsamples);
+ }
+
+ /**
+ * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#getGoodListing()
+ */
+ protected String[] getGoodListing() {
+ return (goodsamples);
+ }
+
/**
*/
public void testNumericDateFormat()
{
String testNumericDF =
- "-rw-r----- 1 neeme neeme 346 2005-04-08 11:22 services.vsp";
+ "-rw-r----- 1 neeme neeme 346 2005-04-08 11:22 services.vsp";
String testNumericDF2 =
"lrwxrwxrwx 1 neeme neeme 23 2005-03-02 18:06 macros -> ./../../global/macros/.";
@@ -117,15 +117,15 @@
f);
- Calendar cal = Calendar.getInstance();
- cal.clear();
- cal.set(Calendar.YEAR, 2005);
- cal.set(Calendar.MONTH, Calendar.APRIL);
-
- cal.set(Calendar.DATE, 8);
- cal.set(Calendar.HOUR_OF_DAY, 11);
- cal.set(Calendar.MINUTE, 22);
- assertEquals(cal.getTime(), f.getTimestamp().getTime());
+ Calendar cal = Calendar.getInstance();
+ cal.clear();
+ cal.set(Calendar.YEAR, 2005);
+ cal.set(Calendar.MONTH, Calendar.APRIL);
+
+ cal.set(Calendar.DATE, 8);
+ cal.set(Calendar.HOUR_OF_DAY, 11);
+ cal.set(Calendar.MINUTE, 22);
+ assertEquals(cal.getTime(), f.getTimestamp().getTime());
FTPFile f2 = parser.parseFTPEntry(testNumericDF2);
assertNotNull("Failed to parse " + testNumericDF2,
@@ -135,114 +135,114 @@
}
- /**
- * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#getParser()
- */
- protected FTPFileEntryParser getParser() {
- return (new UnixFTPEntryParser());
- }
-
- /**
- * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#testParseFieldsOnDirectory()
- */
- public void testParseFieldsOnDirectory() throws Exception {
- FTPFile f = getParser().parseFTPEntry("drwxr-xr-x 2 user group 4096 Mar 2 15:13 zxbox");
- assertNotNull("Could not parse entry.", f);
- assertTrue("Should have been a directory.", f.isDirectory());
- checkPermissions(f);
- assertEquals(2, f.getHardLinkCount());
- assertEquals("user", f.getUser());
- assertEquals("group", f.getGroup());
- assertEquals("zxbox", f.getName());
- assertEquals(4096, f.getSize());
-
- Calendar cal = Calendar.getInstance();
- cal.set(Calendar.MONTH, Calendar.MARCH);
-
- cal.set(Calendar.DATE, 1);
- cal.set(Calendar.HOUR_OF_DAY, 0);
- cal.set(Calendar.MINUTE, 0);
- cal.set(Calendar.SECOND, 0);
- if (f.getTimestamp().getTime().before(cal.getTime())) {
- cal.add(Calendar.YEAR, -1);
- }
- cal.set(Calendar.DATE, 2);
- cal.set(Calendar.HOUR_OF_DAY, 15);
- cal.set(Calendar.MINUTE, 13);
-
- assertEquals(df.format(cal.getTime()), df.format(f.getTimestamp()
- .getTime()));
- }
-
-
- /**
- * Method checkPermissions.
- * Verify that the persmissions were properly set.
- * @param f
- */
- private void checkPermissions(FTPFile f) {
- assertTrue("Should have user read permission.", f.hasPermission(
- FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION));
- assertTrue("Should have user write permission.", f.hasPermission(
- FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION));
- assertTrue("Should have user execute permission.", f.hasPermission(
- FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION));
- assertTrue("Should have group read permission.", f.hasPermission(
- FTPFile.GROUP_ACCESS, FTPFile.READ_PERMISSION));
- assertTrue("Should NOT have group write permission.", !f.hasPermission(
- FTPFile.GROUP_ACCESS, FTPFile.WRITE_PERMISSION));
- assertTrue("Should have group execute permission.", f.hasPermission(
- FTPFile.GROUP_ACCESS, FTPFile.EXECUTE_PERMISSION));
- assertTrue("Should have world read permission.", f.hasPermission(
- FTPFile.WORLD_ACCESS, FTPFile.READ_PERMISSION));
- assertTrue("Should NOT have world write permission.", !f.hasPermission(
- FTPFile.WORLD_ACCESS, FTPFile.WRITE_PERMISSION));
- assertTrue("Should have world execute permission.", f.hasPermission(
- FTPFile.WORLD_ACCESS, FTPFile.EXECUTE_PERMISSION));
- }
-
- /**
- * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#testParseFieldsOnFile()
- */
- public void testParseFieldsOnFile() throws Exception {
- FTPFile f = getParser()
- .parseFTPEntry(
- "-rwxr-xr-x 2 user my group 500 5000000000 Mar 2 15:13 zxbox");
- assertNotNull("Could not parse entry.", f);
- assertTrue("Should have been a file.", f.isFile());
- checkPermissions(f);
- assertEquals(2, f.getHardLinkCount());
- assertEquals("user", f.getUser());
- assertEquals("my group 500", f.getGroup());
- assertEquals("zxbox", f.getName());
- assertEquals(5000000000L, f.getSize());
-
- Calendar cal = Calendar.getInstance();
- cal.set(Calendar.MONTH, Calendar.MARCH);
-
- cal.set(Calendar.DATE, 1);
- cal.set(Calendar.HOUR_OF_DAY, 0);
- cal.set(Calendar.MINUTE, 0);
- cal.set(Calendar.SECOND, 0);
- if (f.getTimestamp().getTime().before(cal.getTime())) {
- cal.add(Calendar.YEAR, -1);
- }
- cal.set(Calendar.DATE, 2);
- cal.set(Calendar.HOUR_OF_DAY, 15);
- cal.set(Calendar.MINUTE, 13);
- assertEquals(df.format(cal.getTime()), df.format(f.getTimestamp().getTime()));
- }
-
-
- /**
- * Method suite.
- * @return TestSuite
- */
- public static TestSuite suite() {
- return (new TestSuite(UnixFTPEntryParserTest.class));
- }
-
-
+ /**
+ * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#getParser()
+ */
+ protected FTPFileEntryParser getParser() {
+ return (new UnixFTPEntryParser());
+ }
+
+ /**
+ * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#testParseFieldsOnDirectory()
+ */
+ public void testParseFieldsOnDirectory() throws Exception {
+ FTPFile f = getParser().parseFTPEntry("drwxr-xr-x 2 user group 4096 Mar 2 15:13 zxbox");
+ assertNotNull("Could not parse entry.", f);
+ assertTrue("Should have been a directory.", f.isDirectory());
+ checkPermissions(f);
+ assertEquals(2, f.getHardLinkCount());
+ assertEquals("user", f.getUser());
+ assertEquals("group", f.getGroup());
+ assertEquals("zxbox", f.getName());
+ assertEquals(4096, f.getSize());
+
+ Calendar cal = Calendar.getInstance();
+ cal.set(Calendar.MONTH, Calendar.MARCH);
+
+ cal.set(Calendar.DATE, 1);
+ cal.set(Calendar.HOUR_OF_DAY, 0);
+ cal.set(Calendar.MINUTE, 0);
+ cal.set(Calendar.SECOND, 0);
+ if (f.getTimestamp().getTime().before(cal.getTime())) {
+ cal.add(Calendar.YEAR, -1);
+ }
+ cal.set(Calendar.DATE, 2);
+ cal.set(Calendar.HOUR_OF_DAY, 15);
+ cal.set(Calendar.MINUTE, 13);
+
+ assertEquals(df.format(cal.getTime()), df.format(f.getTimestamp()
+ .getTime()));
+ }
+
+
+ /**
+ * Method checkPermissions.
+ * Verify that the persmissions were properly set.
+ * @param f
+ */
+ private void checkPermissions(FTPFile f) {
+ assertTrue("Should have user read permission.", f.hasPermission(
+ FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION));
+ assertTrue("Should have user write permission.", f.hasPermission(
+ FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION));
+ assertTrue("Should have user execute permission.", f.hasPermission(
+ FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION));
+ assertTrue("Should have group read permission.", f.hasPermission(
+ FTPFile.GROUP_ACCESS, FTPFile.READ_PERMISSION));
+ assertTrue("Should NOT have group write permission.", !f.hasPermission(
+ FTPFile.GROUP_ACCESS, FTPFile.WRITE_PERMISSION));
+ assertTrue("Should have group execute permission.", f.hasPermission(
+ FTPFile.GROUP_ACCESS, FTPFile.EXECUTE_PERMISSION));
+ assertTrue("Should have world read permission.", f.hasPermission(
+ FTPFile.WORLD_ACCESS, FTPFile.READ_PERMISSION));
+ assertTrue("Should NOT have world write permission.", !f.hasPermission(
+ FTPFile.WORLD_ACCESS, FTPFile.WRITE_PERMISSION));
+ assertTrue("Should have world execute permission.", f.hasPermission(
+ FTPFile.WORLD_ACCESS, FTPFile.EXECUTE_PERMISSION));
+ }
+
+ /**
+ * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#testParseFieldsOnFile()
+ */
+ public void testParseFieldsOnFile() throws Exception {
+ FTPFile f = getParser()
+ .parseFTPEntry(
+ "-rwxr-xr-x 2 user my group 500 5000000000 Mar 2 15:13 zxbox");
+ assertNotNull("Could not parse entry.", f);
+ assertTrue("Should have been a file.", f.isFile());
+ checkPermissions(f);
+ assertEquals(2, f.getHardLinkCount());
+ assertEquals("user", f.getUser());
+ assertEquals("my group 500", f.getGroup());
+ assertEquals("zxbox", f.getName());
+ assertEquals(5000000000L, f.getSize());
+
+ Calendar cal = Calendar.getInstance();
+ cal.set(Calendar.MONTH, Calendar.MARCH);
+
+ cal.set(Calendar.DATE, 1);
+ cal.set(Calendar.HOUR_OF_DAY, 0);
+ cal.set(Calendar.MINUTE, 0);
+ cal.set(Calendar.SECOND, 0);
+ if (f.getTimestamp().getTime().before(cal.getTime())) {
+ cal.add(Calendar.YEAR, -1);
+ }
+ cal.set(Calendar.DATE, 2);
+ cal.set(Calendar.HOUR_OF_DAY, 15);
+ cal.set(Calendar.MINUTE, 13);
+ assertEquals(df.format(cal.getTime()), df.format(f.getTimestamp().getTime()));
+ }
+
+
+ /**
+ * Method suite.
+ * @return TestSuite
+ */
+ public static TestSuite suite() {
+ return (new TestSuite(UnixFTPEntryParserTest.class));
+ }
+
+
/*
* @param test
* @param f
@@ -277,10 +277,10 @@
}
for (int access = FTPFile.USER_ACCESS;
- access <= FTPFile.WORLD_ACCESS; access++)
+ access <= FTPFile.WORLD_ACCESS; access++)
{
for (int perm = FTPFile.READ_PERMISSION;
- perm <= FTPFile.EXECUTE_PERMISSION; perm++)
+ perm <= FTPFile.EXECUTE_PERMISSION; perm++)
{
int pos = 3*access + perm + 1;
char permchar = test.charAt(pos);
Modified: commons/proper/net/trunk/src/test/org/apache/commons/net/ntp/TimeStampTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/org/apache/commons/net/ntp/TimeStampTest.java?rev=658491&r1=658490&r2=658491&view=diff
==============================================================================
--- commons/proper/net/trunk/src/test/org/apache/commons/net/ntp/TimeStampTest.java (original)
+++ commons/proper/net/trunk/src/test/org/apache/commons/net/ntp/TimeStampTest.java Tue May 20 16:48:50 2008
@@ -42,10 +42,10 @@
public void testCompare() {
- TimeStamp ts1 = new TimeStamp(TIME1); // Tue, Dec 17 2002 14:07:24.810 UTC
+ TimeStamp ts1 = new TimeStamp(TIME1); // Tue, Dec 17 2002 14:07:24.810 UTC
TimeStamp ts2 = new TimeStamp(TIME1);
- TimeStamp ts3 = new TimeStamp(TIME2); // Tue, Dec 17 2002 14:07:24.810 UTC
- TimeStamp ts4 = new TimeStamp(TIME3); // Tue, Dec 17 2002 14:07:25.810 UTC
+ TimeStamp ts3 = new TimeStamp(TIME2); // Tue, Dec 17 2002 14:07:24.810 UTC
+ TimeStamp ts4 = new TimeStamp(TIME3); // Tue, Dec 17 2002 14:07:25.810 UTC
// do assertion tests on TimeStamp class
assertEquals("equals(1,2)", ts1, ts2);
@@ -54,9 +54,9 @@
assertEquals("hashCode(1,2)", ts1.hashCode(), ts2.hashCode());
assertEquals("ts1==ts1", ts1, ts1);
- // timestamps in ts1 (TIME1) and ts3 (TIME2) are only off by the smallest
- // fraction of a second (~200 picoseconds) so the times are not equal but
- // when converted to Java dates (in milliseconds) they will be equal.
+ // timestamps in ts1 (TIME1) and ts3 (TIME2) are only off by the smallest
+ // fraction of a second (~200 picoseconds) so the times are not equal but
+ // when converted to Java dates (in milliseconds) they will be equal.
assertTrue("ts1 != ts3", !ts1.equals(ts3));
assertTrue("compareTo(1,3)", ts1.compareTo(ts3) == -1);
assertEquals("seconds", ts1.getSeconds(), ts3.getSeconds());
@@ -72,20 +72,20 @@
}
public void testUTCString() {
- TimeStamp ts1 = new TimeStamp(TIME1); // Tue, Dec 17 2002 14:07:24.810 UTC
- String actual = ts1.toUTCString();
- assertEquals("Tue, Dec 17 2002 14:07:24.810 UTC", actual);
+ TimeStamp ts1 = new TimeStamp(TIME1); // Tue, Dec 17 2002 14:07:24.810 UTC
+ String actual = ts1.toUTCString();
+ assertEquals("Tue, Dec 17 2002 14:07:24.810 UTC", actual);
}
public void testDateConversion() {
- // convert current date to NtpTimeStamp then compare Java date
- // computed from NTP timestamp with original Java date.
- Calendar refCal = Calendar.getInstance(java.util.TimeZone.getTimeZone("UTC"));
- Date refDate = refCal.getTime();
- TimeStamp ts = new TimeStamp(refDate);
- assertEquals("refDate.getTime()", refDate.getTime(), ts.getTime());
- Date tsDate = ts.getDate();
- assertEquals(refDate, tsDate);
+ // convert current date to NtpTimeStamp then compare Java date
+ // computed from NTP timestamp with original Java date.
+ Calendar refCal = Calendar.getInstance(java.util.TimeZone.getTimeZone("UTC"));
+ Date refDate = refCal.getTime();
+ TimeStamp ts = new TimeStamp(refDate);
+ assertEquals("refDate.getTime()", refDate.getTime(), ts.getTime());
+ Date tsDate = ts.getDate();
+ assertEquals(refDate, tsDate);
}
}
Modified: commons/proper/net/trunk/src/test/org/apache/commons/net/pop3/AllTests.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/org/apache/commons/net/pop3/AllTests.java?rev=658491&r1=658490&r2=658491&view=diff
==============================================================================
--- commons/proper/net/trunk/src/test/org/apache/commons/net/pop3/AllTests.java (original)
+++ commons/proper/net/trunk/src/test/org/apache/commons/net/pop3/AllTests.java Tue May 20 16:48:50 2008
@@ -40,14 +40,14 @@
*/
public class AllTests {
- public static Test suite() {
- TestSuite suite =
- new TestSuite("Test for org.apache.commons.net.pop3");
- //$JUnit-BEGIN$
- suite.addTest(POP3ConstructorTest.suite());
- suite.addTest(POP3ClientTest.suite());
- suite.addTest(POP3ClientCommandsTest.suite());
- //$JUnit-END$
- return suite;
- }
+ public static Test suite() {
+ TestSuite suite =
+ new TestSuite("Test for org.apache.commons.net.pop3");
+ //$JUnit-BEGIN$
+ suite.addTest(POP3ConstructorTest.suite());
+ suite.addTest(POP3ClientTest.suite());
+ suite.addTest(POP3ClientCommandsTest.suite());
+ //$JUnit-END$
+ return suite;
+ }
}
Modified: commons/proper/net/trunk/src/test/org/apache/commons/net/pop3/TestSetupParameters.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/org/apache/commons/net/pop3/TestSetupParameters.java?rev=658491&r1=658490&r2=658491&view=diff
==============================================================================
--- commons/proper/net/trunk/src/test/org/apache/commons/net/pop3/TestSetupParameters.java (original)
+++ commons/proper/net/trunk/src/test/org/apache/commons/net/pop3/TestSetupParameters.java Tue May 20 16:48:50 2008
@@ -43,7 +43,7 @@
public static final String mailhost = "localhost";
- //Cannot be instantiated
+ //Cannot be instantiated
private TestSetupParameters()
{}
}
Modified: commons/proper/net/trunk/src/test/org/apache/commons/net/telnet/TelnetClientTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/org/apache/commons/net/telnet/TelnetClientTest.java?rev=658491&r1=658490&r2=658491&view=diff
==============================================================================
--- commons/proper/net/trunk/src/test/org/apache/commons/net/telnet/TelnetClientTest.java (original)
+++ commons/proper/net/trunk/src/test/org/apache/commons/net/telnet/TelnetClientTest.java Tue May 20 16:48:50 2008
@@ -91,13 +91,13 @@
try {
server = new TelnetTestSimpleServer(port);
switch (socket) {
- case 0:
- client = new TelnetClient();
+ case 0:
+ client = new TelnetClient();
// redundant but makes code clearer.
client.setReaderThread(true);
- break;
- case 1:
- client = new TelnetClient();
+ break;
+ case 1:
+ client = new TelnetClient();
TerminalTypeOptionHandler ttopt =
new TerminalTypeOptionHandler("VT100", false, false, true, false);
EchoOptionHandler echoopt =
@@ -108,30 +108,30 @@
client.addOptionHandler(ttopt);
client.addOptionHandler(echoopt);
client.addOptionHandler(gaopt);
- break;
- case 2:
+ break;
+ case 2:
client = new TelnetClient("ANSI");
- break;
- case 3:
+ break;
+ case 3:
client = new TelnetClient();
client.setReaderThread(false);
- break;
+ break;
}
client.connect("127.0.0.1", port);
switch (socket) {
- case 0:
- STANDARD = new TestConnection(server, client, port);
- break;
- case 1:
- OPTIONS = new TestConnection(server, client, port);
- break;
- case 2:
- ANSI = new TestConnection(server, client, port);
- break;
- case 3:
- NOREAD = new TestConnection(server, client, port);
- break;
-
+ case 0:
+ STANDARD = new TestConnection(server, client, port);
+ break;
+ case 1:
+ OPTIONS = new TestConnection(server, client, port);
+ break;
+ case 2:
+ ANSI = new TestConnection(server, client, port);
+ break;
+ case 3:
+ NOREAD = new TestConnection(server, client, port);
+ break;
+
}
// only increment socket number on success
@@ -702,9 +702,9 @@
boolean test2spy_ok = false;
boolean stopspy_ok = false;
byte expected1[] =
- { (byte) 't', (byte) 'e', (byte) 's', (byte) 't', (byte) '1' };
+ { (byte) 't', (byte) 'e', (byte) 's', (byte) 't', (byte) '1' };
byte expected2[] =
- { (byte) 't', (byte) 'e', (byte) 's', (byte) 't', (byte) '2' };
+ { (byte) 't', (byte) 'e', (byte) 's', (byte) 't', (byte) '2' };
PipedOutputStream po = new PipedOutputStream();
@@ -842,9 +842,9 @@
boolean result = true;
for(int ii=0; ii<a1.length; ii++)
{
-
+
if(a1[ii]!= a2[ii])
- result = false;
+ result = false;
}
return(result);
}
Modified: commons/proper/net/trunk/src/test/org/apache/commons/net/time/TimeTCPClientTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/org/apache/commons/net/time/TimeTCPClientTest.java?rev=658491&r1=658490&r2=658491&view=diff
==============================================================================
--- commons/proper/net/trunk/src/test/org/apache/commons/net/time/TimeTCPClientTest.java (original)
+++ commons/proper/net/trunk/src/test/org/apache/commons/net/time/TimeTCPClientTest.java Tue May 20 16:48:50 2008
@@ -43,16 +43,16 @@
***/
protected void openConnections() throws Exception
{
- try {
+ try {
server1 = new TimeTestSimpleServer(_port);
server1.connect();
- } catch (IOException ioe)
- {
- // try again on another port
- _port = 4000;
+ } catch (IOException ioe)
+ {
+ // try again on another port
+ _port = 4000;
server1 = new TimeTestSimpleServer(_port);
server1.connect();
- }
+ }
server1.start();
}
Modified: commons/proper/net/trunk/src/test/org/apache/commons/net/time/TimeTestSimpleServer.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/org/apache/commons/net/time/TimeTestSimpleServer.java?rev=658491&r1=658490&r2=658491&view=diff
==============================================================================
--- commons/proper/net/trunk/src/test/org/apache/commons/net/time/TimeTestSimpleServer.java (original)
+++ commons/proper/net/trunk/src/test/org/apache/commons/net/time/TimeTestSimpleServer.java Tue May 20 16:48:50 2008
@@ -94,14 +94,14 @@
public void start() throws IOException
{
if (server == null)
- {
+ {
connect();
- }
- if (!running)
- {
- running = true;
- new Thread(this).start();
- }
+ }
+ if (!running)
+ {
+ running = true;
+ new Thread(this).start();
+ }
}
public void run()