001: package csdl.jblanket.ant;
002:
003: import java.util.Properties;
004:
005: import org.apache.tools.ant.Project;
006: import org.apache.tools.ant.Task;
007: import org.apache.tools.ant.types.Environment;
008:
009: /**
010: * Provides description for JBlanket related Apache Ant taskdefs.
011: *
012: * @author Joy M. Agustin
013: * @version $Id: JBlanketTask.java,v 1.1 2004/11/07 00:32:32 timshadel Exp $id
014: */
015: public abstract class JBlanketTask extends Task {
016:
017: /** Describes if should execute JBlanket task */
018: protected boolean enable;
019: /** Describes if additional output should be sent to standard out */
020: protected boolean verbose;
021:
022: /** Describes if one-line methods were excluded from coveage */
023: protected boolean excludeOneLineMethods;
024: /** Describes if constructors were excluded from coverage */
025: protected boolean excludeConstructors;
026: /** Describes if individual methods were excluded from coverage */
027: protected boolean excludeIndividualMethods;
028:
029: /** Name of file for total methods */
030: protected String totalFile;
031: /** Name of file for methods containing only one line of source code */
032: protected String oneLineFile;
033: /** Name of file for constructors */
034: protected String constructorFile;
035: /** Name of file for individually excluded methods */
036: protected String excludedIndividualFile;
037:
038: /**
039: * Constructs a new JBlanketTask object.
040: */
041: public JBlanketTask() {
042: super ();
043:
044: this .enable = true;
045: this .verbose = false;
046:
047: this .excludeOneLineMethods = false;
048: this .excludeConstructors = false;
049: this .excludeIndividualMethods = false;
050:
051: this .totalFile = null;
052: this .oneLineFile = null;
053: this .constructorFile = null;
054: this .excludedIndividualFile = null;
055: }
056:
057: /**
058: * Adds a system property. <code>systemProperty</code> contains the values in the
059: * <sysproperty> nested element and is added to the system properties.
060: *
061: * @param systemProperty the system property to add.
062: */
063: public void addConfiguredSysproperty(
064: Environment.Variable systemProperty) {
065:
066: Properties properties = new Properties(System.getProperties());
067: properties.setProperty(systemProperty.getKey(), systemProperty
068: .getValue());
069: System.setProperties(properties);
070: }
071:
072: /**
073: * Describes whether the task should be enabled. Default value is <code>true</code>,
074: * i.e., execute JBlanket.
075: *
076: * @param enable <code>true</code>, <code>on</code>, or <code>yes</code> to execute the task, or
077: * <code>false</code>, <code>off</code>, or <code>no</code> to not execute the
078: * task.
079: */
080: public void setEnable(String enable) {
081: this .enable = Project.toBoolean(enable);
082: }
083:
084: /**
085: * Describes whether additional output should be sent to standard out.
086: * Default value is <code>false</code>, i.e., do not operate in verbose mode.
087: *
088: * @param value <code>true</code>, <code>on</code>, or <code>yes</code> to operate in verbose
089: * mode, or <code>false</code>, <code>off</code>, or <code>no</code> to not operate
090: * in verbose mode.
091: */
092: public void setVerbose(String value) {
093: this .verbose = Project.toBoolean(value);
094: }
095:
096: /**
097: * Describes whether one-line methods should be excluded from the coverage measurement.
098: * Default value is <code>false</code>, i.e., include one-line methods.
099: *
100: * @param excludeOneLineMethods <code>true</code>, <code>on</code>, or <code>yes</code> to
101: * exclude one-line methods, or <code>false</code>,
102: * <code>off</code>, or <code>no</code> to include one-line
103: * methods.
104: */
105: public void setExcludeonelinemethods(String excludeOneLineMethods) {
106: this .excludeOneLineMethods = Project
107: .toBoolean(excludeOneLineMethods);
108: }
109:
110: /**
111: * Describes whether constructors should be excluded from the coverage measurement.
112: * Default value is <code>false</code>, i.e., include constructors.
113: *
114: * @param excludeConstructors <code>true</code>, <code>on</code>, or <code>yes</code> to
115: * exclude constructors, or <code>false</code>, <code>off</code>, or
116: * <code>no</code> to include constructors.
117: */
118: public void setExcludeconstructors(String excludeConstructors) {
119: this .excludeConstructors = Project
120: .toBoolean(excludeConstructors);
121: }
122:
123: /**
124: * Describes whether individual methods should be excluded from the coverage measurement.
125: * Default value is <code>false</code>, i.e., do not individually exclude methods.
126: *
127: * @param excludeIndividualMethods <code>true</code>, <code>on</code>, or <code>yes</code> to
128: * individually exclude methods, or <code>false</code>,
129: * <code>off</code>, or <code>no</code> to not individually
130: * exclude methods.
131: */
132: public void setExcludeindividualmethods(
133: String excludeIndividualMethods) {
134: this .excludeIndividualMethods = Project
135: .toBoolean(excludeIndividualMethods);
136: }
137:
138: /**
139: * Sets the name of the XML file for all methods in the system.
140: *
141: * @param totalFile the total file name.
142: */
143: public void setTotalfile(String totalFile) {
144: this .totalFile = totalFile;
145: }
146:
147: /**
148: * Sets the name of the XML file for methods containing one line of source code.
149: *
150: * @param oneLineFile the one line file name.
151: */
152: public void setOnelinefile(String oneLineFile) {
153: this .oneLineFile = oneLineFile;
154: }
155:
156: /**
157: * Sets the name of the XML file for constructors.
158: *
159: * @param constructorFile the constructor file name.
160: */
161: public void setConstructorfile(String constructorFile) {
162: this .constructorFile = constructorFile;
163: }
164:
165: /**
166: * Sets the name of the XML file for individually excluded methods.
167: *
168: * @param excludedIndividualFile the exclude individual methods file name.
169: */
170: public void setExcludedindividualfile(String excludedIndividualFile) {
171: this .excludedIndividualFile = excludedIndividualFile;
172: }
173:
174: /**
175: * Tells whether the task should print a short summary of the task -- not implemeneted.
176: * <p>
177: * NOTE: possible future addition. This is not needed unless execute JUnit tests
178: * inside of JBlanket system vs. currently executing tests outside with JUnit.
179: *
180: * @param value <code>true</code> to print a summary,
181: * <code>withOutAndErr</code> to include the test's output as well.
182: */
183: public void setPrintsummary(String value) {
184: }
185:
186: /**
187: * Tells whether a JVM should be forked for each testcase -- not implemented.
188: * <p>
189: * It avoids interference between testcases and possibly avoids hanging the build. This property
190: * is applied on all BatchTest (batchtest) and JUnitTest (test) however it can possibly be
191: * overridden by their own properties. (From Ant JUnitTask)
192: * <p>
193: * NOTE: possible future addition.
194: *
195: * @param value <code>true</code> if a JVM should be forked.
196: */
197: public void setFork(String value) {
198: }
199: }
|