commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwins...@apache.org
Subject svn commit: r756232 - in /commons/proper/net/branches/NET_2_0/src: main/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParser.java test/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParserTest.java
Date Thu, 19 Mar 2009 22:00:46 GMT
Author: rwinston
Date: Thu Mar 19 22:00:45 2009
New Revision: 756232

URL: http://svn.apache.org/viewvc?rev=756232&view=rev
Log:
NET-265: Fix edge case in group name parsing

Modified:
    commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParser.java
    commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParserTest.java

Modified: commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParser.java
URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParser.java?rev=756232&r1=756231&r2=756232&view=diff
==============================================================================
--- commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParser.java
(original)
+++ commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParser.java
Thu Mar 19 22:00:45 2009
@@ -88,12 +88,10 @@
         + "(?:(\\S+(?:\\s\\S+)*?)\\s+)?"                // owner name (optional spaces)
         + "(?:(\\S+(?:\\s\\S+)*)\\s+)?"                 // group name (optional spaces)
         + "(\\d+(?:,\\s*\\d+)?)\\s+"
-        
         /*
           numeric or standard format date
         */
-        + "((?:\\d+[-/]\\d+[-/]\\d+)|(?:\\S+\\s+\\S+))\\s+"
-        
+        + "((?:\\d+[-/]\\d+[-/]\\d+)|(?:[a-zA-Z]+\\s+\\S+))\\s+"
         /* 
            year (for non-recent standard format) 
            or time (for numeric or recent standard format  

Modified: commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParserTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParserTest.java?rev=756232&r1=756231&r2=756232&view=diff
==============================================================================
--- commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParserTest.java
(original)
+++ commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParserTest.java
Thu Mar 19 22:00:45 2009
@@ -186,6 +186,26 @@
 		assertEquals(f.getGroup(), "chrism");
 		assertEquals(f.getHardLinkCount(), 1464);
 	}
+	
+	public void testCorrectGroupNameParsing() {
+		FTPFile f = getParser().parseFTPEntry("-rw-r--r--   1 ftpuser  ftpusers 12414535 Mar 17
11:07 test 1999 abc.pdf");
+		assertNotNull(f);
+		assertEquals(f.getHardLinkCount(), 1);
+		assertEquals(f.getUser(), "ftpuser");
+		assertEquals(f.getGroup(), "ftpusers");
+		assertEquals(f.getSize(), 12414535);
+		assertEquals(f.getName(), "test 1999 abc.pdf");
+
+
+		Calendar cal = Calendar.getInstance();
+		cal.set(Calendar.MONTH, Calendar.MARCH);
+		cal.set(Calendar.DAY_OF_MONTH, 17);
+		cal.set(Calendar.HOUR_OF_DAY, 11);
+		cal.set(Calendar.MINUTE, 7);
+		cal.set(Calendar.SECOND, 0);
+		cal.set(Calendar.MILLISECOND, 0);
+		assertEquals(cal.getTime(), f.getTimestamp().getTime());
+	}
 
     /**
      * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#testParseFieldsOnDirectory()



Mime
View raw message