KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > taskdefs > optional > junit > BaseTest


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */

18
19 package org.apache.tools.ant.taskdefs.optional.junit;
20
21 import java.io.File JavaDoc;
22 import java.util.Vector JavaDoc;
23
24 /**
25  * Baseclass for BatchTest and JUnitTest.
26  *
27  */

28 public abstract class BaseTest {
29     // CheckStyle:VisibilityModifier OFF - bc
30
protected boolean haltOnError = false;
31     protected boolean haltOnFail = false;
32     protected boolean filtertrace = true;
33     protected boolean fork = false;
34     protected String JavaDoc ifProperty = null;
35     protected String JavaDoc unlessProperty = null;
36     protected Vector JavaDoc formatters = new Vector JavaDoc();
37     /** destination directory */
38     protected File JavaDoc destDir = null;
39
40     protected String JavaDoc failureProperty;
41     protected String JavaDoc errorProperty;
42     // CheckStyle:VisibilityModifier ON
43

44     /**
45      * Set the filtertrace attribute.
46      * @param value a <code>boolean</code> value.
47      */

48     public void setFiltertrace(boolean value) {
49         filtertrace = value;
50     }
51
52     /**
53      * Get the filtertrace attribute.
54      * @return the attribute.
55      */

56     public boolean getFiltertrace() {
57         return filtertrace;
58     }
59
60     /**
61      * Set the fork attribute.
62      * @param value a <code>boolean</code> value.
63      */

64     public void setFork(boolean value) {
65         fork = value;
66     }
67
68     /**
69      * Get the fork attribute.
70      * @return the attribute.
71      */

72     public boolean getFork() {
73         return fork;
74     }
75
76     /**
77      * Set the haltonerror attribute.
78      * @param value a <code>boolean</code> value.
79      */

80     public void setHaltonerror(boolean value) {
81         haltOnError = value;
82     }
83
84     /**
85      * Set the haltonfailure attribute.
86      * @param value a <code>boolean</code> value.
87      */

88     public void setHaltonfailure(boolean value) {
89         haltOnFail = value;
90     }
91
92     /**
93      * Get the haltonerror attribute.
94      * @return the attribute.
95      */

96     public boolean getHaltonerror() {
97         return haltOnError;
98     }
99
100     /**
101      * Get the haltonfailure attribute.
102      * @return the attribute.
103      */

104     public boolean getHaltonfailure() {
105         return haltOnFail;
106     }
107
108     /**
109      * Set the if attribute.
110      * If this property is present in project,
111      * the test will be run.
112      * @param propertyName the name of the property to look for.
113      */

114     public void setIf(String JavaDoc propertyName) {
115         ifProperty = propertyName;
116     }
117
118     /**
119      * Set the unless attribute.
120      * If this property is present in project,
121      * the test will *not* be run.
122      * @param propertyName the name of the property to look for.
123      */

124     public void setUnless(String JavaDoc propertyName) {
125         unlessProperty = propertyName;
126     }
127
128     /**
129      * Allow a formatter nested element.
130      * @param elem a formatter nested element.
131      */

132     public void addFormatter(FormatterElement elem) {
133         formatters.addElement(elem);
134     }
135
136     /**
137      * Sets the destination directory.
138      * @param destDir the destination directory.
139      */

140     public void setTodir(File JavaDoc destDir) {
141         this.destDir = destDir;
142     }
143
144     /**
145      * Get the destination directory.
146      * @return the destination directory as an absolute path if it exists
147      * otherwise return <tt>null</tt>
148      */

149     public String JavaDoc getTodir() {
150         if (destDir != null) {
151             return destDir.getAbsolutePath();
152         }
153         return null;
154     }
155
156     /**
157      * Get the failure property name.
158      * @return the name of the property to set on failure.
159      */

160     public String JavaDoc getFailureProperty() {
161         return failureProperty;
162     }
163
164     /**
165      * Set the name of the failure property.
166      * @param failureProperty the name of the property to set if
167      * the test fails.
168      */

169     public void setFailureProperty(String JavaDoc failureProperty) {
170         this.failureProperty = failureProperty;
171     }
172
173     /**
174      * Get the failure property name.
175      * @return the name of the property to set on failure.
176      */

177     public String JavaDoc getErrorProperty() {
178         return errorProperty;
179     }
180
181     /**
182      * Set the name of the error property.
183      * @param errorProperty the name of the property to set if
184      * the test has an error.
185      */

186     public void setErrorProperty(String JavaDoc errorProperty) {
187         this.errorProperty = errorProperty;
188     }
189 }
190
Popular Tags