alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*
 * Copyright 2001-2004 The Apache Software Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.commons.net.ftp.parser;
import junit.framework.TestSuite;

import org.apache.commons.net.ftp.FTPFile;
import org.apache.commons.net.ftp.FTPFileEntryParser;

/**
 * @author Steve Cohen
 * @version $Id: OS2FTPEntryParserTest.java,v 1.7 2004/04/21 23:30:33 scohen Exp $
 */
public class OS2FTPEntryParserTest extends FTPParseTestFramework
{

    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                 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()
    {

        return (new TestSuite(OS2FTPEntryParserTest.class));
    }

    /**
     * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#testParseFieldsOnDirectory()
     */
    public void testParseFieldsOnDirectory() throws Exception
    {
        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 1997",
                     df.format(dir.getTimestamp().getTime()));
    }

    /**
     * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#testParseFieldsOnFile()
     */
    public void testParseFieldsOnFile() throws Exception
    {
        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 1998",
                     df.format(file.getTimestamp().getTime()));
    }

    /**
     * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#getBadListing()
     */
    protected String[] getBadListing()
    {

        return (badsamples);
    }

    /**
     * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#getGoodListing()
     */
    protected String[] getGoodListing()
    {

        return (goodsamples);
    }

    /**
     * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#getParser()
     */
    protected FTPFileEntryParser getParser()
    {

        return (new OS2FTPEntryParser());
    }
}
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.