1 16 package org.apache.commons.net.ftp.parser; 17 import junit.framework.TestCase; 18 19 import java.text.SimpleDateFormat ; 20 import java.util.Locale ; 21 import org.apache.commons.net.ftp.FTPFile; 22 import org.apache.commons.net.ftp.FTPFileEntryParser; 23 24 28 public abstract class FTPParseTestFramework extends TestCase 29 { 30 private FTPFileEntryParser parser = null; 31 protected SimpleDateFormat df = null; 32 33 36 public FTPParseTestFramework(String name) 37 { 38 super(name); 39 } 40 41 46 public void testBadListing() throws Exception 47 { 48 49 String [] badsamples = getBadListing(); 50 for (int i = 0; i < badsamples.length; i++) 51 { 52 53 String test = badsamples[i]; 54 FTPFile f = parser.parseFTPEntry(test); 55 assertNull("Should have Failed to parse " + test, 56 f); 57 58 doAdditionalBadTests(test, f); 59 } 60 } 61 62 67 public void testGoodListing() throws Exception 68 { 69 70 String [] goodsamples = getGoodListing(); 71 for (int i = 0; i < goodsamples.length; i++) 72 { 73 74 String test = goodsamples[i]; 75 FTPFile f = parser.parseFTPEntry(test); 76 assertNotNull("Failed to parse " + test, 77 f); 78 79 doAdditionalGoodTests(test, f); 80 } 81 } 82 83 89 protected void doAdditionalGoodTests(String test, FTPFile f) 90 { 91 } 92 93 99 protected void doAdditionalBadTests(String test, FTPFile f) 100 { 101 } 102 103 108 protected abstract String [] getBadListing(); 109 110 115 protected abstract String [] getGoodListing(); 116 117 122 protected abstract FTPFileEntryParser getParser(); 123 124 129 public abstract void testParseFieldsOnDirectory() throws Exception ; 130 131 136 public abstract void testParseFieldsOnFile() throws Exception ; 137 138 141 protected void setUp() throws Exception 142 { 143 super.setUp(); 144 parser = getParser(); 145 df = new SimpleDateFormat ("EEE MMM dd HH:mm:ss yyyy", Locale.US); 146 } 147 } 148 | Popular Tags |