1 18 19 package org.apache.tools.ant.taskdefs.optional.junit; 20 21 import java.util.Enumeration ; 22 import java.util.Hashtable ; 23 import java.util.Properties ; 24 import java.util.Vector ; 25 import org.apache.tools.ant.Project; 26 27 38 public class JUnitTest extends BaseTest implements Cloneable { 39 40 41 private String name = null; 42 43 44 private String outfile = null; 45 46 private long runs, failures, errors; 50 private long runTime; 51 52 private Properties props = null; 54 55 56 public JUnitTest() { 57 } 58 59 63 public JUnitTest(String name) { 64 this.name = name; 65 } 66 67 74 public JUnitTest(String name, boolean haltOnError, boolean haltOnFailure, 75 boolean filtertrace) { 76 this.name = name; 77 this.haltOnError = haltOnError; 78 this.haltOnFail = haltOnFailure; 79 this.filtertrace = filtertrace; 80 } 81 82 86 public void setName(String value) { 87 name = value; 88 } 89 90 94 public void setOutfile(String value) { 95 outfile = value; 96 } 97 98 102 public String getName() { 103 return name; 104 } 105 106 111 public String getOutfile() { 112 return outfile; 113 } 114 115 121 public void setCounts(long runs, long failures, long errors) { 122 this.runs = runs; 123 this.failures = failures; 124 this.errors = errors; 125 } 126 127 131 public void setRunTime(long runTime) { 132 this.runTime = runTime; 133 } 134 135 139 public long runCount() { 140 return runs; 141 } 142 143 147 public long failureCount() { 148 return failures; 149 } 150 151 155 public long errorCount() { 156 return errors; 157 } 158 159 163 public long getRunTime() { 164 return runTime; 165 } 166 167 171 public Properties getProperties() { 172 return props; 173 } 174 175 180 public void setProperties(Hashtable p) { 181 props = new Properties (); 182 for (Enumeration e = p.keys(); e.hasMoreElements();) { 183 Object key = e.nextElement(); 184 props.put(key, p.get(key)); 185 } 186 } 187 188 195 public boolean shouldRun(Project p) { 196 if (ifProperty != null && p.getProperty(ifProperty) == null) { 197 return false; 198 } else if (unlessProperty != null 199 && p.getProperty(unlessProperty) != null) { 200 return false; 201 } 202 203 return true; 204 } 205 206 210 public FormatterElement[] getFormatters() { 211 FormatterElement[] fes = new FormatterElement[formatters.size()]; 212 formatters.copyInto(fes); 213 return fes; 214 } 215 216 219 void addFormattersTo(Vector v) { 220 final int count = formatters.size(); 221 for (int i = 0; i < count; i++) { 222 v.addElement(formatters.elementAt(i)); 223 } 224 } 225 226 230 public Object clone() { 231 try { 232 JUnitTest t = (JUnitTest) super.clone(); 233 t.props = props == null ? null : (Properties ) props.clone(); 234 t.formatters = (Vector ) formatters.clone(); 235 return t; 236 } catch (CloneNotSupportedException e) { 237 return this; 239 } 240 } 241 } 242 | Popular Tags |