KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > csdl > jblanket > ant > JBlanketTask


1 package csdl.jblanket.ant;
2
3 import java.util.Properties JavaDoc;
4
5 import org.apache.tools.ant.Project;
6 import org.apache.tools.ant.Task;
7 import org.apache.tools.ant.types.Environment;
8
9 /**
10  * Provides description for JBlanket related Apache Ant taskdefs.
11  *
12  * @author Joy M. Agustin
13  * @version $Id: JBlanketTask.java,v 1.1 2004/11/07 00:32:32 timshadel Exp $id
14  */

15 public abstract class JBlanketTask extends Task {
16
17   /** Describes if should execute JBlanket task */
18   protected boolean enable;
19   /** Describes if additional output should be sent to standard out */
20   protected boolean verbose;
21
22   /** Describes if one-line methods were excluded from coveage */
23   protected boolean excludeOneLineMethods;
24   /** Describes if constructors were excluded from coverage */
25   protected boolean excludeConstructors;
26   /** Describes if individual methods were excluded from coverage */
27   protected boolean excludeIndividualMethods;
28
29   /** Name of file for total methods */
30   protected String JavaDoc totalFile;
31   /** Name of file for methods containing only one line of source code */
32   protected String JavaDoc oneLineFile;
33   /** Name of file for constructors */
34   protected String JavaDoc constructorFile;
35   /** Name of file for individually excluded methods */
36   protected String JavaDoc excludedIndividualFile;
37
38   /**
39    * Constructs a new JBlanketTask object.
40    */

41   public JBlanketTask() {
42     super();
43     
44     this.enable = true;
45     this.verbose = false;
46
47     this.excludeOneLineMethods = false;
48     this.excludeConstructors = false;
49     this.excludeIndividualMethods = false;
50
51     this.totalFile = null;
52     this.oneLineFile = null;
53     this.constructorFile = null;
54     this.excludedIndividualFile = null;
55   }
56
57   /**
58    * Adds a system property. <code>systemProperty</code> contains the values in the
59    * &lt;sysproperty&gt; nested element and is added to the system properties.
60    *
61    * @param systemProperty the system property to add.
62    */

63   public void addConfiguredSysproperty(Environment.Variable systemProperty) {
64     
65     Properties JavaDoc properties = new Properties JavaDoc(System.getProperties());
66     properties.setProperty(systemProperty.getKey(), systemProperty.getValue());
67     System.setProperties(properties);
68   }
69
70   /**
71    * Describes whether the task should be enabled. Default value is <code>true</code>,
72    * i.e., execute JBlanket.
73    *
74    * @param enable <code>true</code>, <code>on</code>, or <code>yes</code> to execute the task, or
75    * <code>false</code>, <code>off</code>, or <code>no</code> to not execute the
76    * task.
77    */

78   public void setEnable(String JavaDoc enable) {
79     this.enable = Project.toBoolean(enable);
80   }
81
82   /**
83    * Describes whether additional output should be sent to standard out.
84    * Default value is <code>false</code>, i.e., do not operate in verbose mode.
85    *
86    * @param value <code>true</code>, <code>on</code>, or <code>yes</code> to operate in verbose
87    * mode, or <code>false</code>, <code>off</code>, or <code>no</code> to not operate
88    * in verbose mode.
89    */

90   public void setVerbose(String JavaDoc value) {
91     this.verbose = Project.toBoolean(value);
92   }
93
94   /**
95    * Describes whether one-line methods should be excluded from the coverage measurement.
96    * Default value is <code>false</code>, i.e., include one-line methods.
97    *
98    * @param excludeOneLineMethods <code>true</code>, <code>on</code>, or <code>yes</code> to
99    * exclude one-line methods, or <code>false</code>,
100    * <code>off</code>, or <code>no</code> to include one-line
101    * methods.
102    */

103   public void setExcludeonelinemethods(String JavaDoc excludeOneLineMethods) {
104     this.excludeOneLineMethods = Project.toBoolean(excludeOneLineMethods);
105   }
106
107   /**
108    * Describes whether constructors should be excluded from the coverage measurement.
109    * Default value is <code>false</code>, i.e., include constructors.
110    *
111    * @param excludeConstructors <code>true</code>, <code>on</code>, or <code>yes</code> to
112    * exclude constructors, or <code>false</code>, <code>off</code>, or
113    * <code>no</code> to include constructors.
114    */

115   public void setExcludeconstructors(String JavaDoc excludeConstructors) {
116     this.excludeConstructors = Project.toBoolean(excludeConstructors);
117   }
118
119   /**
120    * Describes whether individual methods should be excluded from the coverage measurement.
121    * Default value is <code>false</code>, i.e., do not individually exclude methods.
122    *
123    * @param excludeIndividualMethods <code>true</code>, <code>on</code>, or <code>yes</code> to
124    * individually exclude methods, or <code>false</code>,
125    * <code>off</code>, or <code>no</code> to not individually
126    * exclude methods.
127    */

128   public void setExcludeindividualmethods(String JavaDoc excludeIndividualMethods) {
129     this.excludeIndividualMethods = Project.toBoolean(excludeIndividualMethods);
130   }
131
132   /**
133    * Sets the name of the XML file for all methods in the system.
134    *
135    * @param totalFile the total file name.
136    */

137   public void setTotalfile(String JavaDoc totalFile) {
138     this.totalFile = totalFile;
139   }
140
141   /**
142    * Sets the name of the XML file for methods containing one line of source code.
143    *
144    * @param oneLineFile the one line file name.
145    */

146   public void setOnelinefile(String JavaDoc oneLineFile) {
147     this.oneLineFile = oneLineFile;
148   }
149
150   /**
151    * Sets the name of the XML file for constructors.
152    *
153    * @param constructorFile the constructor file name.
154    */

155   public void setConstructorfile(String JavaDoc constructorFile) {
156     this.constructorFile = constructorFile;
157   }
158
159   /**
160    * Sets the name of the XML file for individually excluded methods.
161    *
162    * @param excludedIndividualFile the exclude individual methods file name.
163    */

164   public void setExcludedindividualfile(String JavaDoc excludedIndividualFile) {
165     this.excludedIndividualFile = excludedIndividualFile;
166   }
167
168   /**
169    * Tells whether the task should print a short summary of the task -- not implemeneted.
170    * <p>
171    * NOTE: possible future addition. This is not needed unless execute JUnit tests
172    * inside of JBlanket system vs. currently executing tests outside with JUnit.
173    *
174    * @param value <code>true</code> to print a summary,
175    * <code>withOutAndErr</code> to include the test&apos;s output as well.
176    */

177   public void setPrintsummary(String JavaDoc value) { }
178
179   /**
180    * Tells whether a JVM should be forked for each testcase -- not implemented.
181    * <p>
182    * It avoids interference between testcases and possibly avoids hanging the build. This property
183    * is applied on all BatchTest (batchtest) and JUnitTest (test) however it can possibly be
184    * overridden by their own properties. (From Ant JUnitTask)
185    * <p>
186    * NOTE: possible future addition.
187    *
188    * @param value <code>true</code> if a JVM should be forked.
189    */

190   public void setFork(String JavaDoc value) { }
191 }
Popular Tags