1 16 package org.apache.commons.net.ftp.parser; 17 18 import org.apache.commons.net.ftp.FTPFile; 19 import org.apache.commons.net.ftp.FTPFileEntryParser; 20 21 25 public abstract class CompositeFTPParseTestFramework extends FTPParseTestFramework 26 { 27 30 public CompositeFTPParseTestFramework(String name) 31 { 32 super(name); 33 } 34 35 38 protected String [] getGoodListing() 39 { 40 return (getGoodListings()[0]); 41 } 42 43 50 protected abstract String [][] getBadListings(); 51 52 59 protected abstract String [][] getGoodListings(); 60 61 64 protected String [] getBadListing() 65 { 66 return (getBadListings()[0]); 67 } 68 69 72 public void testConsistentListing() throws Exception 73 { 74 String goodsamples[][] = getGoodListings(); 75 76 for (int i = 0; i < goodsamples.length; i++) 77 { 78 FTPFileEntryParser parser = getParser(); 79 for (int j = 0; j < goodsamples[i].length; j++) 80 { 81 String test = goodsamples[i][j]; 82 FTPFile f = parser.parseFTPEntry(test); 83 assertNotNull("Failed to parse " + test, 84 f); 85 86 doAdditionalGoodTests(test, f); 87 } 88 } 89 } 90 91 94 public void testBadListing() throws Exception 95 { 96 String badsamples[][] = getBadListings(); 97 98 for (int i = 0; i < badsamples.length; i++) 99 { 100 FTPFileEntryParser parser = getParser(); 101 for (int j = 0; j < badsamples[i].length; j++) 102 { 103 String test = badsamples[i][j]; 104 FTPFile f = parser.parseFTPEntry(test); 105 assertNull("Should have Failed to parse " + test, 106 f); 107 108 doAdditionalBadTests(test, f); 109 } 110 } 111 } 112 113 public void testInconsistentListing() throws Exception 117 { 118 String goodsamples[][] = getGoodListings(); 119 120 FTPFileEntryParser parser = getParser(); 121 122 for (int i = 0; i < goodsamples.length; i++) 123 { 124 String test = goodsamples[i][0]; 125 FTPFile f = parser.parseFTPEntry(test); 126 127 switch (i) 128 { 129 case 0: 130 assertNotNull("Failed to parse " + test, f); 131 break; 132 case 1: 133 assertNull("Should have failed to parse " + test, f); 134 break; 135 } 136 } 137 } 138 } 139 | Popular Tags |