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

EnterpriseUnixFTPEntryParserTest

public class EnterpriseUnixFTPEntryParserTest extends FTPParseTestFramework
Tests the EnterpriseUnixFTPEntryParser
version
$Id: EnterpriseUnixFTPEntryParserTest.java 165675 2005-05-02 20:09:55Z rwinston $
author
Winston Ojeda

Fields Summary
private static final String[]
BADSAMPLES
private static final String[]
GOODSAMPLES
Constructors Summary
public EnterpriseUnixFTPEntryParserTest(String name)
Creates a new EnterpriseUnixFTPEntryParserTest object.

param
name Test name.


                  
      
    
        super(name);
    
Methods Summary
private voidcheckPermisions(org.apache.commons.net.ftp.FTPFile dir)
Method checkPermisions. Verify that the 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()


        return (new EnterpriseUnixFTPEntryParser());
    
public static junit.framework.TestSuitesuite()
Method suite.

return
TestSuite


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

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

        // Everything is a File for now.
    
public voidtestParseFieldsOnFile()

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

        FTPFile file = getParser().parseFTPEntry("-C--E-----FTP B QUA1I1      18128       5000000000 Aug 12 13:56 QUADTEST");
        Calendar today  = Calendar.getInstance();
        int year        = today.get(Calendar.YEAR);

        assertTrue("Should be a file.",
                   file.isFile());
        assertEquals("QUADTEST",
                     file.getName());
        assertEquals(5000000000L, 
        			 file.getSize());
        assertEquals("QUA1I1",
                     file.getUser());
        assertEquals("18128",
                     file.getGroup());

        if(today.get(Calendar.MONTH) < Calendar.AUGUST)
            --year;

        Calendar timestamp = file.getTimestamp();
        assertEquals(year, timestamp.get(Calendar.YEAR));
        assertEquals(Calendar.AUGUST, timestamp.get(Calendar.MONTH));
        assertEquals(12, timestamp.get(Calendar.DAY_OF_MONTH));
        assertEquals(13, timestamp.get(Calendar.HOUR_OF_DAY));
        assertEquals(56, timestamp.get(Calendar.MINUTE));
        assertEquals(0, timestamp.get(Calendar.SECOND));

        checkPermisions(file);