001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018:
019: package org.apache.tools.ant.taskdefs.optional.junit;
020:
021: import java.io.File;
022: import java.util.Vector;
023:
024: /**
025: * Baseclass for BatchTest and JUnitTest.
026: *
027: */
028: public abstract class BaseTest {
029: // CheckStyle:VisibilityModifier OFF - bc
030: protected boolean haltOnError = false;
031: protected boolean haltOnFail = false;
032: protected boolean filtertrace = true;
033: protected boolean fork = false;
034: protected String ifProperty = null;
035: protected String unlessProperty = null;
036: protected Vector formatters = new Vector();
037: /** destination directory */
038: protected File destDir = null;
039:
040: protected String failureProperty;
041: protected String errorProperty;
042:
043: // CheckStyle:VisibilityModifier ON
044:
045: /**
046: * Set the filtertrace attribute.
047: * @param value a <code>boolean</code> value.
048: */
049: public void setFiltertrace(boolean value) {
050: filtertrace = value;
051: }
052:
053: /**
054: * Get the filtertrace attribute.
055: * @return the attribute.
056: */
057: public boolean getFiltertrace() {
058: return filtertrace;
059: }
060:
061: /**
062: * Set the fork attribute.
063: * @param value a <code>boolean</code> value.
064: */
065: public void setFork(boolean value) {
066: fork = value;
067: }
068:
069: /**
070: * Get the fork attribute.
071: * @return the attribute.
072: */
073: public boolean getFork() {
074: return fork;
075: }
076:
077: /**
078: * Set the haltonerror attribute.
079: * @param value a <code>boolean</code> value.
080: */
081: public void setHaltonerror(boolean value) {
082: haltOnError = value;
083: }
084:
085: /**
086: * Set the haltonfailure attribute.
087: * @param value a <code>boolean</code> value.
088: */
089: public void setHaltonfailure(boolean value) {
090: haltOnFail = value;
091: }
092:
093: /**
094: * Get the haltonerror attribute.
095: * @return the attribute.
096: */
097: public boolean getHaltonerror() {
098: return haltOnError;
099: }
100:
101: /**
102: * Get the haltonfailure attribute.
103: * @return the attribute.
104: */
105: public boolean getHaltonfailure() {
106: return haltOnFail;
107: }
108:
109: /**
110: * Set the if attribute.
111: * If this property is present in project,
112: * the test will be run.
113: * @param propertyName the name of the property to look for.
114: */
115: public void setIf(String propertyName) {
116: ifProperty = propertyName;
117: }
118:
119: /**
120: * Set the unless attribute.
121: * If this property is present in project,
122: * the test will *not* be run.
123: * @param propertyName the name of the property to look for.
124: */
125: public void setUnless(String propertyName) {
126: unlessProperty = propertyName;
127: }
128:
129: /**
130: * Allow a formatter nested element.
131: * @param elem a formatter nested element.
132: */
133: public void addFormatter(FormatterElement elem) {
134: formatters.addElement(elem);
135: }
136:
137: /**
138: * Sets the destination directory.
139: * @param destDir the destination directory.
140: */
141: public void setTodir(File destDir) {
142: this .destDir = destDir;
143: }
144:
145: /**
146: * Get the destination directory.
147: * @return the destination directory as an absolute path if it exists
148: * otherwise return <tt>null</tt>
149: */
150: public String getTodir() {
151: if (destDir != null) {
152: return destDir.getAbsolutePath();
153: }
154: return null;
155: }
156:
157: /**
158: * Get the failure property name.
159: * @return the name of the property to set on failure.
160: */
161: public String getFailureProperty() {
162: return failureProperty;
163: }
164:
165: /**
166: * Set the name of the failure property.
167: * @param failureProperty the name of the property to set if
168: * the test fails.
169: */
170: public void setFailureProperty(String failureProperty) {
171: this .failureProperty = failureProperty;
172: }
173:
174: /**
175: * Get the failure property name.
176: * @return the name of the property to set on failure.
177: */
178: public String getErrorProperty() {
179: return errorProperty;
180: }
181:
182: /**
183: * Set the name of the error property.
184: * @param errorProperty the name of the property to set if
185: * the test has an error.
186: */
187: public void setErrorProperty(String errorProperty) {
188: this.errorProperty = errorProperty;
189: }
190: }
|