FileDocCategorySizeDatePackage
VMSFTPEntryParserTest.javaAPI DocApache Commons NET 1.4.1 API12828Sat Dec 03 10:05:48 GMT 2005org.apache.commons.net.ftp.parser

VMSFTPEntryParserTest

public class VMSFTPEntryParserTest extends FTPParseTestFramework
author
Steve Cohen
author
Stephane ESTE-GRACIAS
version
$Id: VMSFTPEntryParserTest.java 155429 2005-02-26 13:13:04Z dirkv $

Fields Summary
private static final String[]
badsamples
private static final String[]
goodsamples
private static final String
fullListing
Constructors Summary
public VMSFTPEntryParserTest(String name)

see
junit.framework.TestCase#TestCase(String)


           
      
    
        super(name);
    
Methods Summary
public voidassertFileInListing(org.apache.commons.net.ftp.FTPFile[] listing, java.lang.String name)

        for (int i = 0; i < listing.length; i++) {
            if (name.equals(listing[i].getName())) {
                return;
            }
        }
        fail("File " + name + " not found in supplied listing");
    
public voidassertFileNotInListing(org.apache.commons.net.ftp.FTPFile[] listing, java.lang.String name)

        for (int i = 0; i < listing.length; i++) {
            if (name.equals(listing[i].getName())) {
                fail("Unexpected File " + name + " found in supplied listing");
            }
        }
    
private voidcheckPermisions(org.apache.commons.net.ftp.FTPFile dir)
Method checkPermisions. Verify that the VMS parser does NOT set the permissions.

param
dir

        assertTrue("Owner should not have read permission.",
                   !dir.hasPermission(FTPFile.USER_ACCESS,
                                      FTPFile.READ_PERMISSION));
        assertTrue("Owner should not have write permission.",
                   !dir.hasPermission(FTPFile.USER_ACCESS,
                                      FTPFile.WRITE_PERMISSION));
        assertTrue("Owner should not have execute permission.",
                   !dir.hasPermission(FTPFile.USER_ACCESS,
                                      FTPFile.EXECUTE_PERMISSION));
        assertTrue("Group should not have read permission.",
                   !dir.hasPermission(FTPFile.GROUP_ACCESS,
                                      FTPFile.READ_PERMISSION));
        assertTrue("Group should not have write permission.",
                   !dir.hasPermission(FTPFile.GROUP_ACCESS,
                                      FTPFile.WRITE_PERMISSION));
        assertTrue("Group should not have execute permission.",
                   !dir.hasPermission(FTPFile.GROUP_ACCESS,
                                      FTPFile.EXECUTE_PERMISSION));
        assertTrue("World should not have read permission.",
                   !dir.hasPermission(FTPFile.WORLD_ACCESS,
                                      FTPFile.READ_PERMISSION));
        assertTrue("World should not have write permission.",
                   !dir.hasPermission(FTPFile.WORLD_ACCESS,
                                      FTPFile.WRITE_PERMISSION));
        assertTrue("World should not have execute permission.",
                   !dir.hasPermission(FTPFile.WORLD_ACCESS,
                                      FTPFile.EXECUTE_PERMISSION));
    
protected java.lang.String[]getBadListing()

see
org.apache.commons.net.ftp.parser.FTPParseTestFramework#getBadListing()


        return (badsamples);
    
protected java.lang.String[]getGoodListing()

see
org.apache.commons.net.ftp.parser.FTPParseTestFramework#getGoodListing()


        return (goodsamples);
    
protected org.apache.commons.net.ftp.FTPFileEntryParsergetParser()

see
org.apache.commons.net.ftp.parser.FTPParseTestFramework#getParser()

        ConfigurableFTPFileEntryParserImpl parser =
            new VMSFTPEntryParser();
        parser.configure(null);
        return parser;
    
protected org.apache.commons.net.ftp.FTPFileEntryParsergetVersioningParser()

        ConfigurableFTPFileEntryParserImpl parser =
            new VMSVersioningFTPEntryParser();
        parser.configure(null);
        return parser;
    
public static junit.framework.TestSuitesuite()
Method suite.

return
TestSuite

        return(new TestSuite(VMSFTPEntryParserTest.class));
    
public voidtestParseFieldsOnDirectory()

see
org.apache.commons.net.ftp.parser.FTPParseTestFramework#testParseFieldsOnDirectory()


        FTPFile dir = getParser().parseFTPEntry("DATA.DIR;1               1/9           2-JUN-1998 07:32:04  [GROUP,OWNER]    (RWED,RWED,RWED,RE)");
        assertTrue("Should be a directory.",
                   dir.isDirectory());
        assertEquals("DATA.DIR",
                     dir.getName());
        assertEquals(512,
                     dir.getSize());
        assertEquals("Tue Jun 02 07:32:04 1998",
                     df.format(dir.getTimestamp().getTime()));
        assertEquals("GROUP",
                     dir.getGroup());
        assertEquals("OWNER",
                     dir.getUser());
        checkPermisions(dir);


        dir = getParser().parseFTPEntry("DATA.DIR;1               1/9           2-JUN-1998 07:32:04  [TRANSLATED]    (RWED,RWED,RWED,RE)");
        assertTrue("Should be a directory.",
                           dir.isDirectory());
        assertEquals("DATA.DIR",
                             dir.getName());
        assertEquals(512,
                             dir.getSize());
        assertEquals("Tue Jun 02 07:32:04 1998",
                             df.format(dir.getTimestamp().getTime()));
        assertEquals(null,
                     dir.getGroup());
        assertEquals("TRANSLATED",
                     dir.getUser());
        checkPermisions(dir);
    
public voidtestParseFieldsOnFile()

see
org.apache.commons.net.ftp.parser.FTPParseTestFramework#testParseFieldsOnFile()

        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.",
                   file.isFile());
        assertEquals("1-JUN.LIS",
                     file.getName());
        assertEquals(9 * 512,
                     file.getSize());
        assertEquals("Tue Jun 02 07:32:04 1998",
                     df.format(file.getTimestamp().getTime()));
        assertEquals("GROUP",
                     file.getGroup());
        assertEquals("OWNER",
                     file.getUser());
        checkPermisions(file);


        file = getParser().parseFTPEntry("1-JUN.LIS;1              9/9           2-JUN-1998 07:32:04  [TRANSLATED]    (RWED,RWED,RWED,RE)");
        assertTrue("Should be a file.",
                   file.isFile());
        assertEquals("1-JUN.LIS",
                     file.getName());
        assertEquals(9 * 512,
                     file.getSize());
        assertEquals("Tue Jun 02 07:32:04 1998",
                     df.format(file.getTimestamp().getTime()));
        assertEquals(null,
                     file.getGroup());
        assertEquals("TRANSLATED",
                     file.getUser());
        checkPermisions(file);
    
public voidtestWholeListParse()
Test the parsing of the whole list.

throws
IOException

        VMSFTPEntryParser parser = new VMSFTPEntryParser();
        parser.configure(null);
        FTPListParseEngine engine = new FTPListParseEngine(parser);
        engine.readServerList(
                new ByteArrayInputStream(fullListing.getBytes()));
        FTPFile[] files = engine.getFiles();
        assertEquals(6, files.length);
        assertFileInListing(files, "2-JUN.LIS");
        assertFileInListing(files, "3-JUN.LIS");
        assertFileInListing(files, "1-JUN.LIS");
        assertFileNotInListing(files, "1-JUN.LIS;1");

    
public voidtestWholeListParseWithVersioning()
Test the parsing of the whole list.

throws
IOException


        VMSFTPEntryParser parser = new VMSVersioningFTPEntryParser();
        parser.configure(null);
        FTPListParseEngine engine = new FTPListParseEngine(parser);
        engine.readServerList(
                new ByteArrayInputStream(fullListing.getBytes()));
        FTPFile[] files = engine.getFiles();
        assertEquals(3, files.length);
        assertFileInListing(files, "1-JUN.LIS;1");
        assertFileInListing(files, "2-JUN.LIS;1");
        assertFileInListing(files, "3-JUN.LIS;4");
        assertFileNotInListing(files, "3-JUN.LIS;1");
        assertFileNotInListing(files, "3-JUN.LIS");