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

NTFTPEntryParserTest

public class NTFTPEntryParserTest extends CompositeFTPParseTestFramework
author
Steve Cohen
version
$Id: NTFTPEntryParserTest.java 155429 2005-02-26 13:13:04Z dirkv $

Fields Summary
private static final String[]
goodsamples
private static final String[]
badsamples
private static final String
directoryBeginningWithNumber
Constructors Summary
public NTFTPEntryParserTest(String name)

see
junit.framework.TestCase#TestCase(String)



           
       
    
        super(name);
    
Methods Summary
protected voiddoAdditionalGoodTests(java.lang.String test, org.apache.commons.net.ftp.FTPFile f)

        if (test.indexOf("<DIR>") >= 0)
        {
                    assertEquals("directory.type",
                            FTPFile.DIRECTORY_TYPE, f.getType());
                }
    
protected java.lang.String[][]getBadListings()

see
org.apache.commons.net.ftp.parser.CompositeFTPParseTestFramework#getBadListings()

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

see
org.apache.commons.net.ftp.parser.CompositeFTPParseTestFramework#getGoodListings()

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

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

       return new CompositeFileEntryParser(new FTPFileEntryParser[]
        {
            new NTFTPEntryParser(),
            new UnixFTPEntryParser()

        });
    
public static junit.framework.TestSuitesuite()
Method suite.

return
TestSuite

        return(new TestSuite(NTFTPEntryParserTest.class));
    
public voidtestDirectoryBeginningWithNumber()
test condition reported as bug 20259. directory with name beginning with a numeric character was not parsing correctly

throws
Exception

        FTPFile f = getParser().parseFTPEntry(directoryBeginningWithNumber);
        assertEquals("name", "123xyz", f.getName());
    
public voidtestParseFieldsOnDirectory()

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

        FTPFile dir = getParser().parseFTPEntry("12-05-96  05:03PM       <DIR>          absoft2");
        assertNotNull("Could not parse entry.", dir);
        assertEquals("Thu Dec 05 17:03:00 1996",
                     df.format(dir.getTimestamp().getTime()));
        assertTrue("Should have been a directory.",
                   dir.isDirectory());
        assertEquals("absoft2", dir.getName());
        assertEquals(0, dir.getSize());

        dir = getParser().parseFTPEntry("12-03-96  06:38AM       <DIR>          123456");
        assertNotNull("Could not parse entry.", dir);
        assertTrue("Should have been a directory.",
                dir.isDirectory());
        assertEquals("123456", dir.getName());
        assertEquals(0, dir.getSize());

    
public voidtestParseFieldsOnFile()

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

        FTPFile f = getParser().parseFTPEntry("05-22-97  12:08AM                  5000000000 AUTOEXEC.BAK");
        assertNotNull("Could not parse entry.", f);
        assertEquals("Thu May 22 00:08:00 1997",
                     df.format(f.getTimestamp().getTime()));
        assertTrue("Should have been a file.",
                   f.isFile());
        assertEquals("AUTOEXEC.BAK", f.getName());
        assertEquals(5000000000L, f.getSize());

        // test an NT-unix style listing that does NOT have a leading zero
        // on the hour.

        f = getParser().parseFTPEntry(
                "-rw-rw-r--   1 mqm        mqm          17707 Mar 12  3:33 killmq.sh.log");
        assertNotNull("Could not parse entry.", f);
        Calendar cal = Calendar.getInstance();
        cal.setTime(f.getTimestamp().getTime());
        assertEquals("hour", 3, cal.get(Calendar.HOUR));
        assertTrue("Should have been a file.",
                f.isFile());
        assertEquals(17707, f.getSize());