1 16 package org.apache.commons.net.ftp.parser; 17 18 import junit.framework.TestSuite; 19 20 import org.apache.commons.net.ftp.FTPFile; 21 import org.apache.commons.net.ftp.FTPFileEntryParser; 22 23 27 public class OS2FTPEntryParserTest extends FTPParseTestFramework 28 { 29 30 private static final String [] badsamples = 31 { 32 " DIR 12-30-97 12:32 jbrekke", 33 " 0 rsa DIR 11-25-97 09:42 junk", 34 " 0 dir 05-12-97 16:44 LANGUAGE", 35 " 0 DIR 13-05-97 25:49 MPTN", 36 "587823 RSA DIR Jan-08-97 13:58 OS2KRNL", 37 " 33280 A 1997-02-03 13:49 OS2LDR", 38 "12-05-96 05:03PM <DIR> absoft2", 39 "11-14-97 04:21PM 953 AUDITOR3.INI" 40 }; 41 private static final String [] goodsamples = 42 { 43 " 0 DIR 12-30-97 12:32 jbrekke", 44 " 0 DIR 11-25-97 09:42 junk", 45 " 0 DIR 05-12-97 16:44 LANGUAGE", 46 " 0 DIR 05-19-97 12:56 local", 47 " 0 DIR 05-12-97 16:52 Maintenance Desktop", 48 " 0 DIR 05-13-97 10:49 MPTN", 49 "587823 RSA DIR 01-08-97 13:58 OS2KRNL", 50 " 33280 A 02-09-97 13:49 OS2LDR", 51 " 0 DIR 11-28-97 09:42 PC", 52 "149473 A 11-17-98 16:07 POPUPLOG.OS2", 53 " 0 DIR 05-12-97 16:44 PSFONTS", 54 " 0 DIR 05-19-2000 12:56 local", 55 }; 56 57 60 public OS2FTPEntryParserTest(String name) 61 { 62 super(name); 63 } 64 65 69 public static TestSuite suite() 70 { 71 72 return (new TestSuite(OS2FTPEntryParserTest.class)); 73 } 74 75 78 public void testParseFieldsOnDirectory() throws Exception 79 { 80 FTPFile dir = getParser().parseFTPEntry(" 0 DIR 11-28-97 09:42 PC"); 81 assertNotNull("Could not parse entry.", dir); 82 assertTrue("Should have been a directory.", 83 dir.isDirectory()); 84 assertEquals(0,dir.getSize()); 85 assertEquals("PC", dir.getName()); 86 assertEquals("Fri Nov 28 09:42:00 1997", 87 df.format(dir.getTimestamp().getTime())); 88 } 89 90 93 public void testParseFieldsOnFile() throws Exception 94 { 95 FTPFile file = getParser().parseFTPEntry("5000000000 A 11-17-98 16:07 POPUPLOG.OS2"); 96 assertNotNull("Could not parse entry.", file); 97 assertTrue("Should have been a file.", 98 file.isFile()); 99 assertEquals(5000000000L, file.getSize()); 100 assertEquals("POPUPLOG.OS2", file.getName()); 101 assertEquals("Tue Nov 17 16:07:00 1998", 102 df.format(file.getTimestamp().getTime())); 103 } 104 105 108 protected String [] getBadListing() 109 { 110 111 return (badsamples); 112 } 113 114 117 protected String [] getGoodListing() 118 { 119 120 return (goodsamples); 121 } 122 123 126 protected FTPFileEntryParser getParser() 127 { 128 ConfigurableFTPFileEntryParserImpl parser = 129 new OS2FTPEntryParser(); 130 parser.configure(null); 131 return parser; 132 } 133 } 134 | Popular Tags |