KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > taskdefs > optional > Test


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

17 package org.apache.tools.ant.taskdefs.optional;
18
19 import java.util.Vector JavaDoc;
20 import org.apache.tools.ant.BuildException;
21 import org.apache.tools.ant.taskdefs.Java;
22
23 /**
24  * This is a primitive task to execute a unit test in the
25  * org.apache.testlet framework.
26  *
27  * @deprecated testlet has been abandoned in favor of JUnit by the
28  * Avalon community
29  *
30  * @ant.task ignore="true"
31  */

32 public class Test extends Java {
33
34     protected Vector JavaDoc m_tests = new Vector JavaDoc();
35
36
37     /**
38      * testlet to run
39      */

40     protected static final class TestletEntry {
41
42         protected String JavaDoc m_testname = "";
43
44
45         /** name of test. No property expansion takes place here */
46         public void addText(final String JavaDoc testname) {
47             m_testname += testname;
48         }
49
50
51         public String JavaDoc toString() {
52             return m_testname;
53         }
54     }
55
56
57     public Test() {
58         setClassname("org.apache.testlet.engine.TextTestEngine");
59     }
60
61
62     /**
63      * add a declaration of a testlet to run
64      */

65     public TestletEntry createTestlet() {
66         final TestletEntry entry = new TestletEntry();
67
68         m_tests.addElement(entry);
69         return entry;
70     }
71
72
73     /**
74      * a boolean value indicating whether tests should display a
75      * message on success; optional
76      */

77
78     public void setShowSuccess(final boolean showSuccess) {
79         createArg().setValue("-s=" + showSuccess);
80     }
81
82
83     /**
84      * a boolean value indicating whether a banner should be displayed
85      * when starting testlet engine; optional.
86      */

87     public void setShowBanner(final String JavaDoc showBanner) {
88         createArg().setValue("-b=" + showBanner);
89     }
90
91
92     /**
93      * a boolean indicating that a stack trace is displayed on
94      * error (but not normal failure); optional.
95      */

96     public void setShowTrace(final boolean showTrace) {
97         createArg().setValue("-t=" + showTrace);
98     }
99
100
101     public void setForceShowTrace(final boolean forceShowTrace) {
102         createArg().setValue("-f=" + forceShowTrace);
103     }
104
105
106     public void execute()
107          throws BuildException {
108
109         final int size = m_tests.size();
110
111         for (int i = 0; i < size; i++) {
112             createArg().setValue(m_tests.elementAt(i).toString());
113         }
114
115         super.execute();
116     }
117 }
118
119
120
Popular Tags