1 26 27 29 package de.nava.informa.utils; 30 31 import java.io.File ; 32 import java.util.Iterator ; 33 34 import junit.framework.TestCase; 35 36 import org.apache.commons.logging.Log; 37 import org.apache.commons.logging.LogFactory; 38 39 import de.nava.informa.core.ChannelIF; 40 import de.nava.informa.core.ItemIF; 41 42 48 public class InformaTestCase extends TestCase { 49 50 private static Log logger = LogFactory.getLog(InformaTestCase.class); 51 52 protected final static String FS = System.getProperty("file.separator"); 53 protected static String dataDir; 54 protected static String indexDir; 55 protected static String outputDir; 56 protected static String baselineDir; 57 58 protected String testcase_name; 59 protected String method_name; 60 61 static { 62 String baseDir = System.getProperty("INFORMA_HOME"); 64 logger.debug("retrieving property INFORMA_HOME: " + baseDir); 65 if (baseDir == null) { 66 baseDir = System.getProperty("basedir"); 67 logger.debug("retrieving property basedir: " + baseDir); 68 } 69 if (baseDir == null) { 70 baseDir = System.getProperty("user.dir"); 71 logger.debug("retrieving property user.dir: " + baseDir); 72 } 73 String writeDir = baseDir + FS + "build" + FS + "test" + FS + "data"; 75 indexDir = writeDir + FS + "index"; 76 outputDir = writeDir + FS + "out"; 77 File out = new File (outputDir); 80 if (!out.exists()) { 81 out.mkdirs(); 82 } 83 String refDir = baseDir + FS + "test"; 85 dataDir = refDir + FS + "data"; 86 baselineDir = refDir + FS + "baseline"; 87 } 88 89 90 97 public InformaTestCase(String testcase_name, String method_name) { 98 super(method_name); 99 this.method_name = method_name; 100 this.testcase_name = testcase_name; 101 } 102 103 106 public static String getDataDir() { 107 return dataDir; 108 } 109 110 113 public static String getIndexDir() { 114 return indexDir; 115 } 116 117 121 public static String getOutputDir() { 122 return outputDir; 123 } 124 125 129 public static String getBaselineDir() { 130 return baselineDir; 131 } 132 133 136 public String getName() { 137 return testcase_name + "." + method_name; 138 } 139 140 144 protected ItemIF searchForItem(ChannelIF chn, String itmTitle) { 145 ItemIF lookup_item = null; 146 Iterator it = chn.getItems().iterator(); 147 while (it.hasNext()) { 148 ItemIF item = (ItemIF) it.next(); 149 assertNotNull("Item has no title", item.getTitle()); 150 assertNotNull("Item has no link", item.getLink()); 151 if (item.getTitle().startsWith(itmTitle)) { 153 lookup_item = item; 154 break; 155 } 156 } 157 return lookup_item; 158 } 159 160 } 161 | Popular Tags |