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/net/src/test/org/apache/commons/net/ftp/parser VMSFTPEntryParserTest.java
Date Tue, 05 Aug 2003 18:56:42 GMT
brekke      2003/08/05 11:56:42

  Modified:    net/src/test/org/apache/commons/net/ftp/parser
                        VMSFTPEntryParserTest.java
  Log:
  The testBadListing/testGoodListing need not be overridden since the data
  and parser are what varies.  The changes to the array of listings reflected a
  full listing parse using the legacy interface.  Unfortunately the test cases
  weren't setup to support a full listing parse, but just a collection of
  bad entries and good entries.  I put the headers and trailer entries into
  the bad listing as they should fail to parse.
  
  Then I created a new test method to excersise the parseFileList() method.
  This may want to move into its own set of test cases similar to the entry
  parser tests.
  
  Revision  Changes    Path
  1.6       +29 -41    jakarta-commons/net/src/test/org/apache/commons/net/ftp/parser/VMSFTPEntryParserTest.java
  
  Index: VMSFTPEntryParserTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/net/src/test/org/apache/commons/net/ftp/parser/VMSFTPEntryParserTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- VMSFTPEntryParserTest.java	29 Jul 2003 02:35:35 -0000	1.5
  +++ VMSFTPEntryParserTest.java	5 Aug 2003 18:56:42 -0000	1.6
  @@ -55,6 +55,7 @@
    */
    
   import java.io.ByteArrayInputStream;
  +import java.io.IOException;
   
   import junit.framework.TestSuite;
   
  @@ -78,12 +79,13 @@
           "120196.TXT;1           118/126        14-APR-1997 12:45:27 PM  [GROUP,OWNER] 
  (RWED,,RWED,RE)", 
           "30CHARBAR.TXT;1         11/18          2-JUN-1998 08:38:42  [GROUP-1,OWNER]  
 (RWED,RWED,RWED,RE)", 
           "A.;2                    18/18          1-JUL-1998 08:43:20  [GROUP,OWNER]    (RWED2,RWED,RWED,RE)",

  -        "AA.;2                  152/153        13-FED-1997 08:13:43  [GROUP,OWNER]    (RWED,RWED,RWED,RE)"
  +        "AA.;2                  152/153        13-FED-1997 08:13:43  [GROUP,OWNER]    (RWED,RWED,RWED,RE)",
  +        "Directory USER1:[TEMP]\r\n\r\n",
  +        "\r\nTotal 14 files"
       };
       
       private static final String[] goodsamples = 
  -    {
  -		"Directory USER1:[TEMP]\r\n\r\n",
  +    {		
           "1-JUN.LIS;1              9/9           2-JUN-1998 07:32:04  [GROUP,OWNER]    (RWED,RWED,RWED,RE)",

           "1-JUN.LIS;3              9/9           2-JUN-1998 07:32:04  [GROUP,OWNER]    (RWED,RWED,RWED,)",

           "1-JUN.LIS;2              9/9           2-JUN-1998 07:32:04  [GROUP,OWNER]    (RWED,RWED,RWED,)",

  @@ -97,19 +99,36 @@
           "UNXMERGE.COM;15          1/15         20-AUG-1996 13:59:50  [POSTWARE,LP]    (RWE,RWE,RWE,RE)",
           "UNXTEMP.COM;7            1/15         15-AUG-1996 14:10:38  [POSTWARE,LP]    (RWE,RWE,RWE,RE)",
           "UNZIP_AND_ATTACH_FILES.COM;12\r\n                        14/15         24-JUL-2002
14:35:40  [TRANSLATED]    (RWE,RWE,RWE,RE)",
  -        "UNZIP_AND_ATTACH_FILES.SAV;1\r\n                        14/15         17-JAN-2002
11:13:53  [POSTWARE,LP]    (RWE,RWED,RWE,RE)",
  -		"\r\nTotal 14 files"        
  +        "UNZIP_AND_ATTACH_FILES.SAV;1\r\n                        14/15         17-JAN-2002
11:13:53  [POSTWARE,LP]    (RWE,RWED,RWE,RE)"        
       };
  -
  +    
  +    private static final String fullListing = "Directory USER1:[TEMP]\r\n\r\n"+
  +    "1-JUN.LIS;1              9/9           2-JUN-1998 07:32:04  [GROUP,OWNER]    (RWED,RWED,RWED,RE)\r\n"+

  +    "2-JUN.LIS;1              9/9           2-JUN-1998 07:32:04  [GROUP,OWNER]    (RWED,RWED,RWED,)\r\n"+

  +    "3-JUN.LIS;1              9/9           2-JUN-1998 07:32:04  [GROUP,OWNER]    (RWED,RWED,RWED,)\r\n"+
  +    "\r\nTotal 3 files"; 
  +    
       /**
        * @see junit.framework.TestCase#TestCase(String)
        */
       public VMSFTPEntryParserTest(String name)
       {
           super(name);
  -    }
  +    }  
   
  -    
  +    /**
  +     * Test the legacy interface for parsing file lists.
  +     * @throws IOException
  +     */
  +    public void testParseFileList() throws IOException
  +    {        
  +        VMSFTPEntryParser parser = new VMSFTPEntryParser();
  +        FTPFile[] files = parser.parseFileList(new ByteArrayInputStream(fullListing.getBytes()));
  +        assertEquals(3, files.length);
  +        assertEquals(files[0].getName(), "2-JUN.LIS", files[0].getName());
  +        assertEquals(files[1].getName(), "3-JUN.LIS", files[1].getName());
  +        assertEquals(files[2].getName(), "1-JUN.LIS", files[2].getName());        
  +    }
   
       /**
        * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#testParseFieldsOnDirectory()
  @@ -256,36 +275,5 @@
       public static TestSuite suite()
       {
           return(new TestSuite(VMSFTPEntryParserTest.class));
  -    }       
  -	
  -	public void testBadListing() throws Exception {
  -		super.testBadListing();
  -	}
  -
  -	public void testGoodListing() throws Exception {
  -		String[] goodsamples = getGoodListing();
  -        String listing = "";
  -           
  -        for (int i = 0; i < goodsamples.length; i++) {
  -            listing += goodsamples[i] + "\r\n";    
  -        }
  -        
  -        byte[] bytes = listing.getBytes();
  -        ByteArrayInputStream listingStream = new ByteArrayInputStream(bytes);
  -        
  -        FTPFile[] files = new VMSFTPEntryParser(true).parseFileList(listingStream);
  -
  -        System.out.println(files.length);
  -        for (int index = 0; index < files.length; index++) {
  -            System.out.println(files[index].getName());
  -        }
  -        
  -        listingStream.reset();
  -        files = new VMSFTPEntryParser(false).parseFileList(listingStream);
  -        
  -        System.out.println(files.length);
  -        for (int index = 0; index < files.length; index++) {
  -            System.out.println(files[index].getName());
  -        }
  -	}
  +    }
   }
  
  
  

Mime
View raw message