commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sco...@apache.org
Subject cvs commit: jakarta-commons/net/src/test/org/apache/commons/net/ftp/parser NTFTPEntryParserTest.java
Date Sat, 17 Jan 2004 21:04:21 GMT
scohen      2004/01/17 13:04:21

  Modified:    net/src/java/org/apache/commons/net/ftp/parser
                        NTFTPEntryParser.java
               net/src/test/org/apache/commons/net/ftp/parser
                        NTFTPEntryParserTest.java
  Log:
  fix bug 20259 (NT directories with name beginning with number).  Beef up test
  case to catch bug and fix, according to reporter's suggestion.
  
  Revision  Changes    Path
  1.10      +2 -2      jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser/NTFTPEntryParser.java
  
  Index: NTFTPEntryParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser/NTFTPEntryParser.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- NTFTPEntryParser.java	10 Jan 2004 16:01:48 -0000	1.9
  +++ NTFTPEntryParser.java	17 Jan 2004 21:04:21 -0000	1.10
  @@ -79,7 +79,7 @@
           + "([0-5]\\d)\\s*" 
           + "([AP])M\\s*" 
           + "(<DIR>)?\\s*" 
  -        + "([0-9]+)?\\s*" 
  +        + "([0-9]+)?\\s+" 
           + "(\\S.*)";
   
       /**
  
  
  
  1.6       +41 -2     jakarta-commons/net/src/test/org/apache/commons/net/ftp/parser/NTFTPEntryParserTest.java
  
  Index: NTFTPEntryParserTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/net/src/test/org/apache/commons/net/ftp/parser/NTFTPEntryParserTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- NTFTPEntryParserTest.java	2 Jan 2004 03:39:07 -0000	1.5
  +++ NTFTPEntryParserTest.java	17 Jan 2004 21:04:21 -0000	1.6
  @@ -75,7 +75,8 @@
                   "01-22-98  01:52PM                  795 AUTOEXEC.BAT",
                   "05-13-97  01:46PM                  828 AUTOEXEC.DOS",
                   "12-03-96  06:38AM                  403 AUTOTOOL.LOG",
  -                "01-20-97  03:48PM       <DIR>          bin",
  +                "12-03-96  06:38AM       <DIR>          123xyz",
  +				"01-20-97  03:48PM       <DIR>          bin",
   
               };
   
  @@ -88,6 +89,9 @@
                   "     0           DIR   05-12-97   16:52  Maintenance Desktop",
   
               };
  +    private static final String directoryBeginningWithNumber =
  +    	"12-03-96  06:38AM       <DIR>          123xyz";
  +	
   
       /**
        * @see junit.framework.TestCase#TestCase(String)
  @@ -159,4 +163,39 @@
           assertEquals("AUTOEXEC.BAK", f.getName());
           assertEquals(828, f.getSize());   
       }
  +
  +    /* (non-Javadoc)
  +	 * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#testGoodListing()
  +	 */
  +	public void testGoodListing() throws Exception {
  +		String[] goodsamples = getGoodListing();
  +		for (int i = 0; i < goodsamples.length; i++)
  +		{
  +
  +			String test = goodsamples[i];
  +			FTPFile f = getParser().parseFTPEntry(test);
  +			assertNotNull("Failed to parse " + test, 
  +					f);
  +			if (test.indexOf("<DIR>") >= 0) {
  +				assertEquals("directory.type", 
  +						FTPFile.DIRECTORY_TYPE, f.getType());
  +			} else {
  +				assertEquals("file.type", 
  +						FTPFile.FILE_TYPE, f.getType());
  +			}
  +		}
  +		
  +	}
  +	
  +
  +	/**
  +	 * test condition reported as bug 20259.
  +	 * directory with name beginning with a numeric character
  +	 * was not parsing correctly
  +	 * @throws Exception
  +	 */
  +	public void testDirectoryBeginningWithNumber() throws Exception {
  +		FTPFile f = getParser().parseFTPEntry(directoryBeginningWithNumber);
  +		assertEquals("name", "123xyz", f.getName());
  +	}
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message