Source Code Cross Referenced for ReporterList.java in  » Testing » sqlunit » net » sourceforge » sqlunit » reporters » 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 » Testing » sqlunit » net.sourceforge.sqlunit.reporters 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: ReporterList.java,v 1.2 2006/04/05 02:51:59 spal Exp $
003:         * $Source: /cvsroot/sqlunit/sqlunit/src/net/sourceforge/sqlunit/reporters/ReporterList.java,v $
004:         * SQLUnit - a test harness for unit testing database stored procedures.
005:         * Copyright (C) 2003  The SQLUnit Team
006:         * 
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License
009:         * as published by the Free Software Foundation; either version 2
010:         * of the License, or (at your option) any later version.
011:         * 
012:         * This program is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015:         * GNU General Public License for more details.
016:         * 
017:         * You should have received a copy of the GNU General Public License
018:         * along with this program; if not, write to the Free Software
019:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
020:         */
021:        package net.sourceforge.sqlunit.reporters;
022:
023:        import java.util.Iterator;
024:        import java.util.List;
025:        import java.util.Map;
026:        import java.util.Vector;
027:
028:        import net.sourceforge.sqlunit.IReporter;
029:
030:        /**
031:         * A IReporter that contains a list of other IReporters.
032:         * Used to provide reporting to multiple places.
033:         * @author Ivan Ivanov
034:         * @version $Revision: 1.2 $
035:         */
036:        public class ReporterList implements  IReporter {
037:
038:            /**
039:             * The name of the reporter.
040:             */
041:            public static final String NAME = "ReporterList";
042:
043:            private List reporters;
044:
045:            /**
046:             * Always throws IllegalStateException since it is not real
047:             * reporter; it is just a holder of other regular reporters.
048:             * @param outputFile not used
049:             */
050:            public ReporterList(String outputFile) {
051:                throw new IllegalStateException("IReporterList is a container"
052:                        + "for other repporters and cannot be constructed as "
053:                        + "ordinary reporter");
054:            }
055:
056:            /**
057:             * Constructs a new IReporterList.
058:             * @param initialCapacity the initial capacity of the
059:             * reporter list.
060:             */
061:            public ReporterList(int initialCapacity) {
062:                reporters = new Vector(initialCapacity);
063:            }
064:
065:            /**
066:             * Returns true if the reporter is run in another context
067:             * (container). If the method returns <code>false</code>
068:             * SQLUnit engine will print to the reporter's logfile
069:             * the output from the Ant process.
070:             * @return <code>true</code>
071:             */
072:            public boolean hasContainer() {
073:                return true;
074:            }
075:
076:            /**
077:             * Returns the name of the reporter that will be used in
078:             * Ant task.
079:             * @return the name of the reporter
080:             */
081:            public String getName() {
082:                return NAME;
083:            }
084:
085:            /**
086:             * Adds a new reporter to the reporter list.
087:             * @param r the new reporter
088:             */
089:            public void add(IReporter r) {
090:                if (r instanceof  ReporterList) {
091:                    throw new IllegalStateException(
092:                            "ReporterList is a container for"
093:                                    + "other reporters and cannot be added");
094:                }
095:                reporters.add(r);
096:            }
097:
098:            /**
099:             * Called when a new test file is entered.
100:             * The delegation is passed to the reporters in the list.
101:             * @param testName the type of the test
102:             * @param testFile the location of the rest file
103:             */
104:            public void newTestFile(String testName, String testFile) {
105:                for (Iterator i = reporters.iterator(); i.hasNext();) {
106:                    IReporter r = (IReporter) i.next();
107:                    r.newTestFile(testName, testFile);
108:                }
109:            }
110:
111:            /**
112:             * Called before a new connection to a database is
113:             * established. The delegation is passed to the reporters
114:             * in the list.
115:             * @param elConnection the XML node describing the
116:             * connection as taken from the test file
117:             */
118:            public void settingUpConnection(String connectionId) {
119:                for (Iterator i = reporters.iterator(); i.hasNext();) {
120:                    IReporter r = (IReporter) i.next();
121:                    r.settingUpConnection(connectionId);
122:                }
123:            }
124:
125:            /**
126:             * Called after the connection to the database is made.
127:             * The delegation is passed to the reporters in the list.
128:             * @param configMap contains configuration key-value pairs.
129:             */
130:            public void setConfig(Map configMap) {
131:                for (Iterator i = reporters.iterator(); i.hasNext();) {
132:                    IReporter r = (IReporter) i.next();
133:                    r.setConfig(configMap);
134:                }
135:            }
136:
137:            /**
138:             * Called before the setup section of the test file.
139:             * The delegation is passed to the reporters in the list.
140:             */
141:            public void setUp() {
142:                for (Iterator i = reporters.iterator(); i.hasNext();) {
143:                    IReporter r = (IReporter) i.next();
144:                    r.setUp();
145:                }
146:            }
147:
148:            /**
149:             * Called after the test is executed.
150:             * The delegation is passed to the reporters in the list.
151:             * @param elTest the XML node describing the test
152:             * as taken from the test file.
153:             * @param testIndex the index of the test
154:             */
155:            public void runningTest(String name, int testIndex, String desc) {
156:                for (Iterator i = reporters.iterator(); i.hasNext();) {
157:                    IReporter r = (IReporter) i.next();
158:                    r.runningTest(name, testIndex, desc);
159:                }
160:            }
161:
162:            /**
163:             * Called when a test is finished.
164:             * The delegation is passed to the reporters in the list.
165:             * @param elTest the XML node describing the test
166:             * as taken from the test file
167:             * @param elapsed the time taken for the test to execute
168:             * @param success <code>true</code> if the test succeed;
169:             * <code>false</code> otherwise.
170:             */
171:            public void finishedTest(long elapsed, boolean success) {
172:                for (Iterator i = reporters.iterator(); i.hasNext();) {
173:                    IReporter r = (IReporter) i.next();
174:                    r.finishedTest(elapsed, success);
175:                }
176:            }
177:
178:            /**
179:             * Called when the test is skipped.
180:             * The delegation is passed to the reporters in the list.
181:             * @param elTest the XML node describing the test
182:             * as taken from the test file
183:             * @param testIndex the index of the test
184:             * @param reason the reason why the test is skipped
185:             */
186:            public void skippedTest(String name, int testIndex, String desc) {
187:                for (Iterator i = reporters.iterator(); i.hasNext();) {
188:                    IReporter r = (IReporter) i.next();
189:                    r.skippedTest(name, testIndex, desc);
190:                }
191:            }
192:
193:            /**
194:             * Called when an exception is raised during test execution.
195:             * The delegation is passed to the reporters in the list.
196:             * @param t the exception that is thrown
197:             * @param isError if <code>true</code> it is a test error
198:             * (cause not by the very test, but by an external factor);
199:             * if <code>false</code> it is a test failure (like a failed
200:             * assertion)
201:             */
202:            public void addFailure(Throwable t, boolean isError) {
203:                for (Iterator i = reporters.iterator(); i.hasNext();) {
204:                    IReporter r = (IReporter) i.next();
205:                    r.addFailure(t, isError);
206:                }
207:            }
208:
209:            /**
210:             * Called before tearDown is executed.
211:             * The delegation is passed to the reporters in the list.
212:             */
213:            public void tearDown() {
214:                for (Iterator i = reporters.iterator(); i.hasNext();) {
215:                    IReporter r = (IReporter) i.next();
216:                    r.tearDown();
217:                }
218:            }
219:
220:            /**
221:             * Called when a test has failed and a temporary file is left
222:             * containing data. The delegation is passed to the reporters
223:             * in the list.
224:             * @param testId the index of the test
225:             * @param result the result of the test
226:             * @param file the temporary file
227:             */
228:            public void tempFile(int testId, String result, String file) {
229:                for (Iterator i = reporters.iterator(); i.hasNext();) {
230:                    IReporter r = (IReporter) i.next();
231:                    r.tempFile(testId, result, file);
232:                }
233:            }
234:
235:            /**
236:             * Called when a test file is completed (when all tests
237:             * in it are executed(. The delegation is passed to the
238:             * reporters in the list.
239:             * @param success if <code>true</code> the test is successful;
240:             * if <code>false</code> it failed
241:             */
242:            public void testFileComplete(boolean success) {
243:                for (Iterator i = reporters.iterator(); i.hasNext();) {
244:                    IReporter r = (IReporter) i.next();
245:                    r.testFileComplete(success);
246:                }
247:            }
248:
249:            /**
250:             * Prints the given the message to the reporter's
251:             * output destination. The delegation is passed to the
252:             * reporters in the list.
253:             * @param message the message to be printed
254:             */
255:            public void echo(String message) {
256:                for (Iterator i = reporters.iterator(); i.hasNext();) {
257:                    IReporter r = (IReporter) i.next();
258:                    r.echo(message);
259:                }
260:            }
261:
262:            /**
263:             * Returns the number of the reporters.
264:             * @return the number of the reporters
265:             */
266:            public int size() {
267:                return reporters.size();
268:            }
269:
270:            /**
271:             * Returns an iterator over all reporters.
272:             * @return an iterator.
273:             */
274:            public Iterator iterator() {
275:                return reporters.iterator();
276:            }
277:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.