001: /*
002: * Copyright 2005 The Apache Software Foundation
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.apache.commons.net.ftp.parser;
018:
019: import junit.framework.TestSuite;
020:
021: import org.apache.commons.net.ftp.FTPFile;
022: import org.apache.commons.net.ftp.FTPFileEntryParser;
023:
024: /**
025: * Created on Apr 6, 2005<br/>
026: * @author <a href="mailto:wnoto@openfinance.com">William Noto</a>
027: * @version $Id: NTFTPEntryParserTest.java,v 1.16 2005/01/02 03:17:50 scohen Exp $
028: */
029: public class MVSFTPEntryParserTest extends FTPParseTestFramework {
030: private static final String[] goodsamples = {
031: "Migrated file1.I",
032: "Migrated file2.I",
033: "PSMLC1 3390 2005/04/04 1 1 VB 27994 27998 PS file3.I",
034: "PSMLB9 3390 2005/04/04 1 1 VB 27994 27998 PS file4.I.BU",
035: "PSMLB6 3390 2005/04/05 1 1 VB 27994 27998 PS file3.I.BU",
036: "PSMLC6 3390 2005/04/05 1 1 VB 27994 27998 PS file6.I",
037: "Migrated file6.O",
038: "PSMLB7 3390 2005/04/04 1 1 VB 27994 27998 PS file7.O",
039: "PSMLC6 3390 2005/04/05 1 1 VB 27994 27998 PS file7.O.BU",
040: "FPFS42 3390 2004/06/23 1 1 FB 128 6144 PS INCOMING.RPTBM023.D061704",
041: "FPFS41 3390 2004/06/23 1 1 FB 128 6144 PS INCOMING.RPTBM056.D061704",
042: "FPFS25 3390 2004/06/23 1 1 FB 128 6144 PS INCOMING.WTM204.D061704", };
043:
044: private static final String[] badsamples = {
045: "MigratedP201.$FTXPBI1.$CF2ITB.$AAB0402.I",
046: "PSMLC133902005/04/041VB2799427998PSfile1.I", "file2.O", };
047:
048: /**
049: * @see junit.framework.TestCase#TestCase(String)
050: */
051: public MVSFTPEntryParserTest(String name) {
052: super (name);
053: }
054:
055: /* (non-Javadoc)
056: * @see org.apache.commons.net.ftp.parser.CompositeFTPParseTestFramework#getBadListings()
057: */
058: protected String[] getBadListing() {
059: return badsamples;
060: }
061:
062: /* (non-Javadoc)
063: * @see org.apache.commons.net.ftp.parser.CompositeFTPParseTestFramework#getGoodListings()
064: */
065: protected String[] getGoodListing() {
066: return goodsamples;
067: }
068:
069: /**
070: * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#getParser()
071: */
072: protected FTPFileEntryParser getParser() {
073: return new CompositeFileEntryParser(
074: new FTPFileEntryParser[] { new MVSFTPEntryParser(), });
075: }
076:
077: /**
078: * Method suite.
079: *
080: * @return TestSuite
081: */
082: public static TestSuite suite() {
083: return (new TestSuite(MVSFTPEntryParserTest.class));
084: }
085:
086: public void testParseFieldsOnDirectory() throws Exception {
087: // I don't really know how to test this because the MVS system that I
088: // connect with does not allow me to create directories.
089: }
090:
091: /* (non-Javadoc)
092: * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#testParseFieldsOnFile()
093: */
094: public void testParseFieldsOnFile() throws Exception {
095: FTPFile file = getParser()
096: .parseFTPEntry(
097: "Migrated file1.I");
098: assertNotNull("Could not parse entry.", file);
099: assertTrue("Should have been a file.", file.isFile());
100: assertEquals("file1.I", file.getName());
101:
102: FTPFile file2 = getParser()
103: .parseFTPEntry(
104: "PSMLC1 3390 2005/04/04 1 1 VB 27994 27998 PS file2.I");
105: assertNotNull("Could not parse entry.", file2);
106: assertTrue("Should have been a file.", file2.isFile());
107: assertEquals("file2.I", file2.getName());
108: }
109: }
|