commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bre...@apache.org
Subject cvs commit: jakarta-commons-sandbox/net/src/test/org/apache/commons/net/ftp/ftp2/parser FTPParseTestFramework.java NTFTPEntryParserTest.java OS2FTPEntryParserTest.java UnixFTPEntryParserTest.java VMSFTPEntryParserTest.java
Date Wed, 07 Aug 2002 18:26:19 GMT
brekke      2002/08/07 11:26:19

  Modified:    net/src/java/org/apache/commons/net/ftp/ftp2/parser
                        NTFTPEntryParser.java OS2FTPEntryParser.java
               net/src/test/org/apache/commons/net/ftp/ftp2/parser
                        FTPParseTestFramework.java
                        NTFTPEntryParserTest.java
                        OS2FTPEntryParserTest.java
                        UnixFTPEntryParserTest.java
                        VMSFTPEntryParserTest.java
  Log:
  o Added abstract test methods for the file and dir tests.
  o Added some javadocs to the parser tests.
  o Fixed NT and OS2 parsers.
  
  Revision  Changes    Path
  1.4       +4 -4      jakarta-commons-sandbox/net/src/java/org/apache/commons/net/ftp/ftp2/parser/NTFTPEntryParser.java
  
  Index: NTFTPEntryParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/net/src/java/org/apache/commons/net/ftp/ftp2/parser/NTFTPEntryParser.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- NTFTPEntryParser.java	3 May 2002 14:52:30 -0000	1.3
  +++ NTFTPEntryParser.java	7 Aug 2002 18:26:18 -0000	1.4
  @@ -112,7 +112,7 @@
           "((?:0[1-9])|(?:1[012])):" +
           "([0-5]\\d)\\s*" +
           "([AP])M\\s*" +
  -        "(<DIR>\\s*)?" +
  +        "(<DIR>)?\\s*" +
           "([0-9]+)?\\s*" +
           "(\\S.*)";
   
  @@ -164,9 +164,9 @@
               }
               f.setName(name);
               //convert all the calendar stuff to ints
  -            int month = new Integer(mo).intValue();
  +            int month = new Integer(mo).intValue()-1;
               int day = new Integer(da).intValue();
  -            int year = new Integer(yr).intValue() + 2000;
  +            int year = new Integer(yr).intValue()+2000;
               int hour = new Integer(hr).intValue();
               int minutes = new Integer(min).intValue();
   
  
  
  
  1.4       +2 -2      jakarta-commons-sandbox/net/src/java/org/apache/commons/net/ftp/ftp2/parser/OS2FTPEntryParser.java
  
  Index: OS2FTPEntryParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/net/src/java/org/apache/commons/net/ftp/ftp2/parser/OS2FTPEntryParser.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- OS2FTPEntryParser.java	3 May 2002 14:52:30 -0000	1.3
  +++ OS2FTPEntryParser.java	7 Aug 2002 18:26:18 -0000	1.4
  @@ -170,7 +170,7 @@
   
   
               //convert all the calendar stuff to ints
  -            int month = new Integer(mo).intValue();
  +            int month = new Integer(mo).intValue()-1;
               int day = new Integer(da).intValue();
               int year = new Integer(yr).intValue() + 2000;
               int hour = new Integer(hr).intValue();
  
  
  
  1.3       +49 -3     jakarta-commons-sandbox/net/src/test/org/apache/commons/net/ftp/ftp2/parser/FTPParseTestFramework.java
  
  Index: FTPParseTestFramework.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/net/src/test/org/apache/commons/net/ftp/ftp2/parser/FTPParseTestFramework.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FTPParseTestFramework.java	6 Aug 2002 20:32:04 -0000	1.2
  +++ FTPParseTestFramework.java	7 Aug 2002 18:26:19 -0000	1.3
  @@ -64,14 +64,21 @@
    */
   public abstract class FTPParseTestFramework extends TestCase
   {
  -
       private FTPFileEntryParser parser = null;
   
  +    /**
  +     * @see junit.framework.TestCase#TestCase(String)
  +     */
       public FTPParseTestFramework(String name)
       {
           super(name);
       }
   
  +    /**
  +     * Method testBadListing.
  +     * Tests that parser provided failures actually fail.
  +     * @throws Exception
  +     */
       public void testBadListing() throws Exception
       {
   
  @@ -86,6 +93,11 @@
           }
       }
   
  +    /**
  +     * Method testGoodListing.
  +     * Test that parser provided listings pass.
  +     * @throws Exception
  +     */
       public void testGoodListing() throws Exception
       {
   
  @@ -100,10 +112,44 @@
           }
       }
   
  +    /**
  +     * Method getBadListing.
  +     * Implementors must provide a listing that contains failures.
  +     * @return String[]
  +     */
       protected abstract String[] getBadListing();
  +
  +    /**
  +     * Method getGoodListing.
  +     * Implementors must provide a listing that passes.
  +     * @return String[]
  +     */
       protected abstract String[] getGoodListing();
  -    protected abstract FTPFileEntryParser getParser();
   
  +    /**
  +     * Method getParser.
  +     * Provide the parser to use for testing.
  +     * @return FTPFileEntryParser
  +     */
  +    protected abstract FTPFileEntryParser getParser();
  +    
  +    /**
  +     * Method testParseFieldsOnDirectory.
  +     * Provide a test to show that fields on a directory entry are parsed correctly.
  +     * @throws Exception
  +     */
  +    public abstract void testParseFieldsOnDirectory() throws Exception;
  +    
  +    /**
  +     * Method testParseFieldsOnFile.
  +     * Provide a test to show that fields on a file entry are parsed correctly.
  +     * @throws Exception
  +     */
  +    public abstract void testParseFieldsOnFile() throws Exception;
  +
  +    /**
  +     * @see junit.framework.TestCase#setUp()
  +     */
       protected void setUp() throws Exception
       {
           super.setUp();
  
  
  
  1.3       +48 -1     jakarta-commons-sandbox/net/src/test/org/apache/commons/net/ftp/ftp2/parser/NTFTPEntryParserTest.java
  
  Index: NTFTPEntryParserTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/net/src/test/org/apache/commons/net/ftp/ftp2/parser/NTFTPEntryParserTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- NTFTPEntryParserTest.java	6 Aug 2002 20:32:04 -0000	1.2
  +++ NTFTPEntryParserTest.java	7 Aug 2002 18:26:19 -0000	1.3
  @@ -54,6 +54,7 @@
    * <http://www.apache.org/>.
    */
   
  +import org.apache.commons.net.ftp.FTPFile;
   import org.apache.commons.net.ftp.ftp2.FTPFileEntryParser;
   
   import junit.framework.TestSuite;
  @@ -88,28 +89,74 @@
   
               };
   
  +    /**
  +     * @see junit.framework.TestCase#TestCase(String)
  +     */
       public NTFTPEntryParserTest (String name)
       {
           super(name);
       }
   
  +    /**
  +     * @see org.apache.commons.net.ftp.ftp2.parser.FTPParseTestFramework#getGoodListing()
  +     */
       protected String[] getGoodListing()
       {
           return(goodsamples);
       }
       
  +    /**
  +     * @see org.apache.commons.net.ftp.ftp2.parser.FTPParseTestFramework#getBadListing()
  +     */
       protected String[] getBadListing()
       {
           return(badsamples);
       }
   
  +    /**
  +     * @see org.apache.commons.net.ftp.ftp2.parser.FTPParseTestFramework#getParser()
  +     */
       protected FTPFileEntryParser getParser()
       {
           return(new NTFTPEntryParser());
       }
       
  +    /**
  +     * Method suite.
  +     * @return TestSuite
  +     */
       public static TestSuite suite()
       {
           return(new TestSuite(NTFTPEntryParserTest.class));
  +    }
  +    
  +    /**
  +     * @see org.apache.commons.net.ftp.ftp2.parser.FTPParseTestFramework#testParseFieldsOnDirectory()
  +     */
  +    public void testParseFieldsOnDirectory() throws Exception
  +    {
  +        FTPFile dir = getParser().parseFTPEntry("12-05-96  05:03PM       <DIR>  
       absoft2");
  +        assertNotNull("Could not parse entry.", dir);
  +        assertEquals("Thu Dec 05 17:03:00 CST 1996", 
  +                     dir.getTimestamp().getTime().toString());
  +        assertTrue("Should have been a directory.", 
  +                   dir.isDirectory());
  +        assertEquals("absoft2", dir.getName());
  +        assertEquals(0, dir.getSize());       
  +    }
  +
  +    /**
  +     * @see org.apache.commons.net.ftp.ftp2.parser.FTPParseTestFramework#testParseFieldsOnFile()
  +     */
  +    public void testParseFieldsOnFile() throws Exception
  +    {
  +        FTPFile f = getParser().parseFTPEntry("05-22-97  08:08AM                  828 AUTOEXEC.BAK");
  +        assertNotNull("Could not parse entry.", f);
  +        assertEquals("Thu May 22 08:08:00 CDT 1997", 
  +                     f.getTimestamp().getTime().toString());
  +        assertTrue("Should have been a file.", 
  +                   f.isFile());
  +        assertEquals("AUTOEXEC.BAK", f.getName());
  +        assertEquals(828, f.getSize());   
       }
   }
  
  
  
  1.3       +90 -42    jakarta-commons-sandbox/net/src/test/org/apache/commons/net/ftp/ftp2/parser/OS2FTPEntryParserTest.java
  
  Index: OS2FTPEntryParserTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/net/src/test/org/apache/commons/net/ftp/ftp2/parser/OS2FTPEntryParserTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- OS2FTPEntryParserTest.java	6 Aug 2002 20:32:04 -0000	1.2
  +++ OS2FTPEntryParserTest.java	7 Aug 2002 18:26:19 -0000	1.3
  @@ -53,9 +53,9 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    */
  -
   import junit.framework.TestSuite;
   
  +import org.apache.commons.net.ftp.FTPFile;
   import org.apache.commons.net.ftp.ftp2.FTPFileEntryParser;
   
   /**
  @@ -65,57 +65,105 @@
   public class OS2FTPEntryParserTest extends FTPParseTestFramework
   {
   
  -    private static final String [] goodsamples = {
  -                "     0           DIR   12-30-97   12:32  jbrekke",
  -                "     0           DIR   11-25-97   09:42  junk",
  -                "     0           DIR   05-12-97   16:44  LANGUAGE",
  -                "     0           DIR   05-19-97   12:56  local",
  -                "     0           DIR   05-12-97   16:52  Maintenance Desktop",
  -                "     0           DIR   05-13-97   10:49  MPTN",
  -                "587823    RSA    DIR   01-08-97   13:58  OS2KRNL",
  -                " 33280      A          02-09-97   13:49  OS2LDR",
  -                "     0           DIR   11-28-97   09:42  PC",
  -                "149473      A          11-17-98   16:07  POPUPLOG.OS2",
  -                "     0           DIR   05-12-97   16:44  PSFONTS"
  -
  -            };
  -
  -    private static final String [] badsamples = {
  -                "                 DIR   12-30-97   12:32  jbrekke",
  -                "     0    rsa    DIR   11-25-97   09:42  junk",
  -                "     0           dir   05-12-97   16:44  LANGUAGE",
  -                "     0           DIR   05-19-2000 12:56  local",
  -                "     0           DIR   13-05-97   25:49  MPTN",
  -                "587823    RSA    DIR   Jan-08-97   13:58  OS2KRNL",
  -                " 33280      A          1997-02-03  13:49  OS2LDR",
  -                "12-05-96  05:03PM       <DIR>          absoft2",
  -                "11-14-97  04:21PM                  953 AUDITOR3.INI",
  -            };
  +    private static final String[] badsamples = 
  +    {
  +        "                 DIR   12-30-97   12:32  jbrekke", 
  +        "     0    rsa    DIR   11-25-97   09:42  junk", 
  +        "     0           dir   05-12-97   16:44  LANGUAGE", 
  +        "     0           DIR   05-19-2000 12:56  local", 
  +        "     0           DIR   13-05-97   25:49  MPTN", 
  +        "587823    RSA    DIR   Jan-08-97   13:58  OS2KRNL", 
  +        " 33280      A          1997-02-03  13:49  OS2LDR", 
  +        "12-05-96  05:03PM       <DIR>          absoft2", 
  +        "11-14-97  04:21PM                  953 AUDITOR3.INI"
  +    };
  +    private static final String[] goodsamples = 
  +    {
  +        "     0           DIR   12-30-97   12:32  jbrekke", 
  +        "     0           DIR   11-25-97   09:42  junk", 
  +        "     0           DIR   05-12-97   16:44  LANGUAGE", 
  +        "     0           DIR   05-19-97   12:56  local", 
  +        "     0           DIR   05-12-97   16:52  Maintenance Desktop", 
  +        "     0           DIR   05-13-97   10:49  MPTN", 
  +        "587823    RSA    DIR   01-08-97   13:58  OS2KRNL", 
  +        " 33280      A          02-09-97   13:49  OS2LDR", 
  +        "     0           DIR   11-28-97   09:42  PC", 
  +        "149473      A          11-17-98   16:07  POPUPLOG.OS2", 
  +        "     0           DIR   05-12-97   16:44  PSFONTS"
  +    };
  +
  +    /**
  +     * @see junit.framework.TestCase#TestCase(String)
  +     */
  +    public OS2FTPEntryParserTest(String name)
  +    {
  +        super(name);
  +    }
   
  +    /**
  +     * Method suite.
  +     * @return TestSuite
  +     */
  +    public static TestSuite suite()
  +    {
   
  -    public OS2FTPEntryParserTest (String name)
  +        return (new TestSuite(OS2FTPEntryParserTest.class));
  +    }
  +
  +    /**
  +     * @see org.apache.commons.net.ftp.ftp2.parser.FTPParseTestFramework#testParseFieldsOnDirectory()
  +     */
  +    public void testParseFieldsOnDirectory() throws Exception    
       {
  -        super(name);
  +        FTPFile dir = getParser().parseFTPEntry("     0           DIR   11-28-97   09:42
 PC");
  +        assertNotNull("Could not parse entry.", dir);
  +        assertTrue("Should have been a directory.", 
  +                   dir.isDirectory());
  +        assertEquals(0,dir.getSize());
  +        assertEquals("PC", dir.getName());
  +        assertEquals("Fri Nov 28 09:42:00 CST 1997", 
  +                     dir.getTimestamp().getTime().toString());
       }
   
  -    protected String[] getGoodListing()
  +    /**
  +     * @see org.apache.commons.net.ftp.ftp2.parser.FTPParseTestFramework#testParseFieldsOnFile()
  +     */
  +    public void testParseFieldsOnFile() throws Exception 
       {
  -        return(goodsamples);
  +        FTPFile file = getParser().parseFTPEntry("149473      A          11-17-98   16:07
 POPUPLOG.OS2");
  +        assertNotNull("Could not parse entry.", file);
  +        assertTrue("Should have been a file.", 
  +                   file.isFile());
  +        assertEquals(149473,file.getSize());
  +        assertEquals("POPUPLOG.OS2", file.getName());
  +        assertEquals("Tue Nov 17 16:07:00 CST 1998", 
  +                     file.getTimestamp().getTime().toString());           
       }
  -    
  +
  +    /**
  +     * @see org.apache.commons.net.ftp.ftp2.parser.FTPParseTestFramework#getBadListing()
  +     */
       protected String[] getBadListing()
       {
  -        return(badsamples);
  +
  +        return (badsamples);
       }
  -    
  -    protected FTPFileEntryParser getParser()
  +
  +    /**
  +     * @see org.apache.commons.net.ftp.ftp2.parser.FTPParseTestFramework#getGoodListing()
  +     */
  +    protected String[] getGoodListing()
       {
  -        return(new OS2FTPEntryParser());
  +
  +        return (goodsamples);
       }
  -    
  -    public static TestSuite suite()
  +
  +    /**
  +     * @see org.apache.commons.net.ftp.ftp2.parser.FTPParseTestFramework#getParser()
  +     */
  +    protected FTPFileEntryParser getParser()
       {
  -        return(new TestSuite(OS2FTPEntryParserTest.class));
  +
  +        return (new OS2FTPEntryParser());
       }
  -    
  -}
  +}
  \ No newline at end of file
  
  
  
  1.3       +28 -1     jakarta-commons-sandbox/net/src/test/org/apache/commons/net/ftp/ftp2/parser/UnixFTPEntryParserTest.java
  
  Index: UnixFTPEntryParserTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/net/src/test/org/apache/commons/net/ftp/ftp2/parser/UnixFTPEntryParserTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- UnixFTPEntryParserTest.java	6 Aug 2002 20:32:05 -0000	1.2
  +++ UnixFTPEntryParserTest.java	7 Aug 2002 18:26:19 -0000	1.3
  @@ -102,26 +102,41 @@
           "-rw-r--r--   1 500      500       2040000 Aug  5 07:31 testRemoteUPVCopyNIX" 
     
       };
   
  +    /**
  +     * @see junit.framework.TestCase#TestCase(String)
  +     */
       public UnixFTPEntryParserTest(String name)
       {
           super(name);
       }
   
  +    /**
  +     * @see org.apache.commons.net.ftp.ftp2.parser.FTPParseTestFramework#getBadListing()
  +     */
       protected String[] getBadListing()
       {
           return(badsamples);
       }
       
  +    /**
  +     * @see org.apache.commons.net.ftp.ftp2.parser.FTPParseTestFramework#getGoodListing()
  +     */
       protected String[] getGoodListing()
       {
           return(goodsamples);
       }
       
  +    /**
  +     * @see org.apache.commons.net.ftp.ftp2.parser.FTPParseTestFramework#getParser()
  +     */
       protected FTPFileEntryParser getParser() 
       {
           return(new UnixFTPEntryParser());
       }
       
  +    /**
  +     * @see org.apache.commons.net.ftp.ftp2.parser.FTPParseTestFramework#testParseFieldsOnDirectory()
  +     */
       public void testParseFieldsOnDirectory() throws Exception
       {
           FTPFile f = getParser().parseFTPEntry("drwxr-xr-x   2 user     group         4096
Mar  2 15:13 zxbox");
  @@ -144,6 +159,11 @@
                        f.getTimestamp().getTime().toString());
       }
   
  +    /**
  +     * Method checkPermissions.
  +     * Verify that the persmissions were properly set.
  +     * @param f
  +     */
       private void checkPermissions(FTPFile f)
       {
           assertTrue("Should have user read permission.", 
  @@ -175,6 +195,9 @@
                                      FTPFile.EXECUTE_PERMISSION));
       }
   
  +    /**
  +     * @see org.apache.commons.net.ftp.ftp2.parser.FTPParseTestFramework#testParseFieldsOnFile()
  +     */
       public void testParseFieldsOnFile() throws Exception
       {
           FTPFile f = getParser().parseFTPEntry("-rwxr-xr-x   2 user     group         4096
Mar  2 15:13 zxbox");
  @@ -197,6 +220,10 @@
                        f.getTimestamp().getTime().toString());
       }
       
  +    /**
  +     * Method suite.
  +     * @return TestSuite
  +     */
       public static TestSuite suite()
       {
           return(new TestSuite(UnixFTPEntryParserTest.class));
  
  
  
  1.3       +30 -3     jakarta-commons-sandbox/net/src/test/org/apache/commons/net/ftp/ftp2/parser/VMSFTPEntryParserTest.java
  
  Index: VMSFTPEntryParserTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/net/src/test/org/apache/commons/net/ftp/ftp2/parser/VMSFTPEntryParserTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- VMSFTPEntryParserTest.java	6 Aug 2002 20:32:05 -0000	1.2
  +++ VMSFTPEntryParserTest.java	7 Aug 2002 18:26:19 -0000	1.3
  @@ -91,12 +91,18 @@
           "AA.;2                  152/153        13-FEB-1997 08:13:43  [GROUP,OWNER]    (RWED,RWED,RWED,RE)"
       };
   
  +    /**
  +     * @see junit.framework.TestCase#TestCase(String)
  +     */
       public VMSFTPEntryParserTest(String name)
       {
           super(name);
       }
   
  -    public void testParseFieldsOnDirecotry()
  +    /**
  +     * @see org.apache.commons.net.ftp.ftp2.parser.FTPParseTestFramework#testParseFieldsOnDirectory()
  +     */
  +    public void testParseFieldsOnDirectory() throws Exception
       {
   
           FTPFile dir = getParser().parseFTPEntry("DATA.DIR;1               1/9         
 2-JUN-1998 07:32:04  [GROUP,OWNER]    (RWED,RWED,RWED,RE)");
  @@ -115,7 +121,10 @@
           checkPermisions(dir);
       }
   
  -    public void testParseFieldsOnFile()
  +    /**
  +     * @see org.apache.commons.net.ftp.ftp2.parser.FTPParseTestFramework#testParseFieldsOnFile()
  +     */
  +    public void testParseFieldsOnFile() throws Exception
       {
           FTPFile file = getParser().parseFTPEntry("1-JUN.LIS;1              9/9        
  2-JUN-1998 07:32:04  [GROUP,OWNER]    (RWED,RWED,RWED,RE)");
           assertTrue("Should be a file.", 
  @@ -133,24 +142,38 @@
           checkPermisions(file);
       }
   
  +    /**
  +     * @see org.apache.commons.net.ftp.ftp2.parser.FTPParseTestFramework#getBadListing()
  +     */
       protected String[] getBadListing()
       {
   
           return (badsamples);
       }
   
  +    /**
  +     * @see org.apache.commons.net.ftp.ftp2.parser.FTPParseTestFramework#getGoodListing()
  +     */
       protected String[] getGoodListing()
       {
   
           return (goodsamples);
       }
   
  +    /**
  +     * @see org.apache.commons.net.ftp.ftp2.parser.FTPParseTestFramework#getParser()
  +     */
       protected FTPFileEntryParser getParser()
       {
   
           return (new VMSFTPEntryParser());
       }
   
  +    /**
  +     * Method checkPermisions.
  +     * Verify that the VMS parser does NOT  set the permissions.
  +     * @param dir
  +     */
       private void checkPermisions(FTPFile dir)
       {
           assertTrue("Owner should not have read permission.", 
  @@ -182,6 +205,10 @@
                                         FTPFile.EXECUTE_PERMISSION));
       }
       
  +    /**
  +     * Method suite.
  +     * @return TestSuite
  +     */
       public static TestSuite suite()
       {
           return(new TestSuite(VMSFTPEntryParserTest.class));
  
  
  

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


Mime
View raw message