Source Code Cross Referenced for JUnitTest.java in  » Build » ANT » org » apache » tools » ant » taskdefs » optional » junit » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Build » ANT » org.apache.tools.ant.taskdefs.optional.junit 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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.util.Enumeration;
022:        import java.util.Hashtable;
023:        import java.util.Properties;
024:        import java.util.Vector;
025:        import org.apache.tools.ant.Project;
026:
027:        /**
028:         * <p> Run a single JUnit test.
029:         *
030:         * <p> The JUnit test is actually run by {@link JUnitTestRunner}.
031:         * So read the doc comments for that class :)
032:         *
033:         * @since Ant 1.2
034:         *
035:         * @see JUnitTask
036:         * @see JUnitTestRunner
037:         */
038:        public class JUnitTest extends BaseTest implements  Cloneable {
039:
040:            /** the name of the test case */
041:            private String name = null;
042:
043:            /** the name of the result file */
044:            private String outfile = null;
045:
046:            // @todo this is duplicating TestResult information. Only the time is not
047:            // part of the result. So we'd better derive a new class from TestResult
048:            // and deal with it. (SB)
049:            private long runs, failures, errors;
050:            private long runTime;
051:
052:            // Snapshot of the system properties
053:            private Properties props = null;
054:
055:            /** No arg constructor. */
056:            public JUnitTest() {
057:            }
058:
059:            /**
060:             * Constructor with name.
061:             * @param name the name of the test.
062:             */
063:            public JUnitTest(String name) {
064:                this .name = name;
065:            }
066:
067:            /**
068:             * Constructor with options.
069:             * @param name the name of the test.
070:             * @param haltOnError if true halt the tests if there is an error.
071:             * @param haltOnFailure if true halt the tests if there is a failure.
072:             * @param filtertrace if true filter stack traces.
073:             */
074:            public JUnitTest(String name, boolean haltOnError,
075:                    boolean haltOnFailure, boolean filtertrace) {
076:                this .name = name;
077:                this .haltOnError = haltOnError;
078:                this .haltOnFail = haltOnFailure;
079:                this .filtertrace = filtertrace;
080:            }
081:
082:            /**
083:             * Set the name of the test class.
084:             * @param value the name to use.
085:             */
086:            public void setName(String value) {
087:                name = value;
088:            }
089:
090:            /**
091:             * Set the name of the output file.
092:             * @param value the name of the output file to use.
093:             */
094:            public void setOutfile(String value) {
095:                outfile = value;
096:            }
097:
098:            /**
099:             * Get the name of the test class.
100:             * @return the name of the test.
101:             */
102:            public String getName() {
103:                return name;
104:            }
105:
106:            /**
107:             * Get the name of the output file
108:             *
109:             * @return the name of the output file.
110:             */
111:            public String getOutfile() {
112:                return outfile;
113:            }
114:
115:            /**
116:             * Set the number of runs, failures and errors.
117:             * @param runs     the number of runs.
118:             * @param failures the number of failures.
119:             * @param errors   the number of errors.
120:             */
121:            public void setCounts(long runs, long failures, long errors) {
122:                this .runs = runs;
123:                this .failures = failures;
124:                this .errors = errors;
125:            }
126:
127:            /**
128:             * Set the runtime.
129:             * @param runTime the time in milliseconds.
130:             */
131:            public void setRunTime(long runTime) {
132:                this .runTime = runTime;
133:            }
134:
135:            /**
136:             * Get the number of runs.
137:             * @return the number of runs.
138:             */
139:            public long runCount() {
140:                return runs;
141:            }
142:
143:            /**
144:             * Get the number of failures.
145:             * @return the number of failures.
146:             */
147:            public long failureCount() {
148:                return failures;
149:            }
150:
151:            /**
152:             * Get the number of errors.
153:             * @return the number of errors.
154:             */
155:            public long errorCount() {
156:                return errors;
157:            }
158:
159:            /**
160:             * Get the run time.
161:             * @return the run time in milliseconds.
162:             */
163:            public long getRunTime() {
164:                return runTime;
165:            }
166:
167:            /**
168:             * Get the properties used in the test.
169:             * @return the properties.
170:             */
171:            public Properties getProperties() {
172:                return props;
173:            }
174:
175:            /**
176:             * Set the properties to be used in the test.
177:             * @param p the properties.
178:             *          This is a copy of the projects ant properties.
179:             */
180:            public void setProperties(Hashtable p) {
181:                props = new Properties();
182:                for (Enumeration e = p.keys(); e.hasMoreElements();) {
183:                    Object key = e.nextElement();
184:                    props.put(key, p.get(key));
185:                }
186:            }
187:
188:            /**
189:             * Check if this test should run based on the if and unless
190:             * attributes.
191:             * @param p the project to use to check if the if and unless
192:             *          properties exist in.
193:             * @return true if this test or testsuite should be run.
194:             */
195:            public boolean shouldRun(Project p) {
196:                if (ifProperty != null && p.getProperty(ifProperty) == null) {
197:                    return false;
198:                } else if (unlessProperty != null
199:                        && p.getProperty(unlessProperty) != null) {
200:                    return false;
201:                }
202:
203:                return true;
204:            }
205:
206:            /**
207:             * Get the formatters set for this test.
208:             * @return the formatters as an array.
209:             */
210:            public FormatterElement[] getFormatters() {
211:                FormatterElement[] fes = new FormatterElement[formatters.size()];
212:                formatters.copyInto(fes);
213:                return fes;
214:            }
215:
216:            /**
217:             * Convenient method to add formatters to a vector
218:             */
219:            void addFormattersTo(Vector v) {
220:                final int count = formatters.size();
221:                for (int i = 0; i < count; i++) {
222:                    v.addElement(formatters.elementAt(i));
223:                }
224:            }
225:
226:            /**
227:             * @since Ant 1.5
228:             * @return a clone of this test.
229:             */
230:            public Object clone() {
231:                try {
232:                    JUnitTest t = (JUnitTest) super .clone();
233:                    t.props = props == null ? null : (Properties) props.clone();
234:                    t.formatters = (Vector) formatters.clone();
235:                    return t;
236:                } catch (CloneNotSupportedException e) {
237:                    // plain impossible
238:                    return this;
239:                }
240:            }
241:        }
w__ww___.___ja_v_a_2_s__.___co_m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.