Source Code Cross Referenced for NiceUnit.java in  » Scripting » Nice » nice » tools » ant » 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 » Scripting » Nice » nice.tools.ant 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**************************************************************************/
002:        /*                                N I C E                                 */
003:        /*             A high-level object-oriented research language             */
004:        /*                        (c) Daniel Bonniot 2004                         */
005:        /*                                                                        */
006:        /*  This program is free software; you can redistribute it and/or modify  */
007:        /*  it under the terms of the GNU General Public License as published by  */
008:        /*  the Free Software Foundation; either version 2 of the License, or     */
009:        /*  (at your option) any later version.                                   */
010:        /*                                                                        */
011:        /**************************************************************************/package nice.tools.ant;
012:
013:        import org.apache.tools.ant.*;
014:        import org.apache.tools.ant.types.*;
015:        import java.io.File;
016:        import java.util.Vector;
017:        import bossa.modules.Compilation;
018:
019:        /**
020:         <h2><a name="java">NiceUnit</a></h2>
021:         <h3>Description</h3>
022:         <p>Runs unit tests for a Nice package.</p>
023:         All arguments to the NiceUnit task have to be placed as attributes in the niceunit xml-element.
024:         <h3>Parameters</h3>
025:         <table border="1" cellpadding="2" cellspacing="0">
026:         <tr>
027:         <td valign="top"><b>Attribute</b></td>
028:         <td valign="top"><b>Description</b></td>
029:         <td align="center" valign="top"><b>Required</b></td>
030:         </tr>
031:         <tr>
032:         <td valign="top">package</td>
033:         <td valign="top">The Nice package to test.</td>
034:         <td align="center" valign="top">Yes</td>
035:         </tr>
036:         <tr>
037:         <td valign="top">classpath</td>
038:         <td valign="top">Search path for compiled packages and libraries.</td>
039:         <td align="center" valign="top">No</td>
040:         </tr>
041:         </table>
042:
043:         <h4>classpath</h4>
044:         <p><code>NiceUnit</code>'s <i>classpath</i> attribute is a PATH like structure and can also be set via a nested
045:         <i>classpath</i> element. This is very reasonable if you want to make your build script's pathes platform
046:         independent. </p>
047:         <h5>Example</h5>
048:         <pre>
049:         &lt;niceunit package=&quot;test&quot; &gt;
050:         &lt;classpath&gt;
051:         &lt;pathelement location=&quot;\test.jar&quot;/&gt;
052:         &lt;pathelement path=&quot;${java.class.path}&quot;/&gt;
053:         &lt;/classpath&gt;
054:         &lt;/niceunit&gt;
055:         </pre>
056:         <p>It is possible to use the <i>classpath</i> attribute together with the
057:         <i>classpath<i> nested tag. In this case the result is a concatenated path.</p>
058:         <p>It is highly recommended to use the nested version!<p>
059:
060:
061:         <h3>Examples</h3>
062:         <pre>
063:         &lt;taskdef name=&quot;niceunit&quot; classname=&quot;nice.tools.ant.NiceUnit&quot;/&gt;
064:         &lt;target name=&quot;nice-tests&quot;&gt;
065:         &lt;niceunit package=&quot;test&quot; /&gt;
066:         &lt;/target&gt;
067:         </pre>
068:
069:
070:         * @author Daniel Bonniot
071:         */
072:
073:        public class NiceUnit extends Task {
074:
075:            /**	Search path for compiled packages and libraries.
076:             */
077:            private String classpath = "";
078:
079:            public void setClasspath(String classpath) {
080:                this .classpath = classpath;
081:            }
082:
083:            /**	Location of nice.jar
084:             */
085:            private String runtime = null;
086:
087:            public void setRuntime(String runtime) {
088:                this .runtime = runtime;
089:            }
090:
091:            /**	The package to test.
092:             */
093:            private String pack;
094:
095:            public void setPackage(String pack) {
096:                this .pack = pack;
097:            }
098:
099:            private Path nestedClasspath = null;
100:
101:            /**
102:             * Creates a nested classpath element
103:             */
104:            public Path createClasspath() {
105:                nestedClasspath = new Path(project);
106:                return nestedClasspath.createPath();
107:            }
108:
109:            /**	Executes niceunit.
110:             */
111:            public void execute() throws BuildException {
112:
113:                String oldUserDir = System.getProperty("user.dir");
114:                try {
115:                    System.setProperty("user.dir", project.getBaseDir()
116:                            .getAbsolutePath());
117:
118:                    TestListener listener = new TestListener(this );
119:
120:                    String classpath = this .classpath
121:                            + (nestedClasspath != null ? File.pathSeparator
122:                                    + nestedClasspath : "");
123:
124:                    if (!nice.tools.unit.fun.runTests(pack, listener,
125:                            classpath, null))
126:                        throw new BuildException("Package " + pack
127:                                + " was not found");
128:
129:                    listener.printSummary();
130:                } finally {
131:                    System.setProperty("user.dir", oldUserDir);
132:                }
133:            }
134:
135:        }
136:
137:        // Setting for Emacs
138:        // Local variables:
139:        // tab-width:2
140:        // indent-tabs-mode:t
141:        // End:
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.