KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > junit > output > Report


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.junit.output;
21
22 import java.awt.EventQueue JavaDoc;
23 import java.io.File JavaDoc;
24 import java.util.ArrayList JavaDoc;
25 import java.util.Collection JavaDoc;
26 import java.util.Collections JavaDoc;
27 import org.netbeans.api.java.classpath.ClassPath;
28 import org.openide.ErrorManager;
29 import org.openide.filesystems.FileObject;
30
31 /**
32  * Data structure (model) of results of JUnit task results.
33  * The data are built by the {@link JUnitOutputReader}.
34  *
35  * @see JUnitOutputReader
36  * @author Marian Petras
37  */

38 final class Report {
39
40     File JavaDoc antScript;
41     File JavaDoc resultsDir;
42     String JavaDoc suiteClassName;
43     String JavaDoc classpath;
44     ClassPath platformSources;
45     Collection JavaDoc<FileObject> classpathSourceRoots;
46     String JavaDoc[] outputStd;
47     String JavaDoc[] outputErr;
48     int totalTests;
49     int failures;
50     int errors;
51     int elapsedTimeMillis;
52     /**
53      * number of recognized (by the parser) passed test reports
54      */

55     int detectedPassedTests;
56     private Collection JavaDoc<Testcase> tests;
57     private boolean closed = false;
58     
59     /**
60      */

61     Report(String JavaDoc suiteClassName) {
62         this.suiteClassName = suiteClassName;
63         this.antScript = antScript;
64         this.tests = new ArrayList JavaDoc<Testcase>(10);
65     }
66     
67     /**
68      */

69     void reportTest(Testcase test) {
70         
71         /* Called from the AntLogger thread */
72         
73         //PENDING - should be synchronized
74
tests.add(test);
75         
76         if (test.trouble == null) {
77             detectedPassedTests++;
78         }
79     }
80     
81     /**
82      */

83     void update(Report report) {
84         
85         /* Called from the AntLogger thread */
86         
87         //PENDING - should be synchronized
88

89         //this.antScript = report.antScript; - KEEP DISABLED!!!
90
this.resultsDir = report.resultsDir;
91         this.suiteClassName = report.suiteClassName;
92         this.outputStd = report.outputStd;
93         this.outputErr = report.outputErr;
94         this.totalTests = report.totalTests;
95         this.failures = report.failures;
96         this.errors = report.errors;
97         this.elapsedTimeMillis = report.elapsedTimeMillis;
98         this.detectedPassedTests = report.detectedPassedTests;
99         this.tests = report.tests;
100     }
101     
102     /**
103      */

104     Collection JavaDoc<Testcase> getTests() {
105         
106         /*
107          * May be called both from the EventDispatch thread and
108          * from other threads!
109          *
110          * TestSuiteNodeChildren.setFiltered() ... EventDispatch thread
111          * TestSuiteNodeChildren.addNotify() ... EventDispatch thread or else
112          */

113         
114         //PENDING - should be synchronized
115
if (tests.isEmpty()) {
116             final Collection JavaDoc<Testcase> emptyList = Collections.emptyList();
117             return emptyList;
118         } else {
119             return new ArrayList JavaDoc<Testcase>(tests);
120         }
121     }
122     
123     /**
124      */

125     boolean containsFailed() {
126         assert EventQueue.isDispatchThread();
127         
128         /* Called from the EventDispatch thread */
129         
130         return (failures + errors) != 0;
131     }
132     
133     /**
134      */

135     static final class Testcase {
136         String JavaDoc className;
137         String JavaDoc name;
138         int timeMillis;
139         Trouble trouble;
140     }
141     
142     /**
143      */

144     static final class Trouble {
145         
146         private final boolean error;
147         String JavaDoc message;
148         String JavaDoc exceptionClsName;
149         String JavaDoc[] stackTrace;
150         Trouble nestedTrouble;
151         
152         /**
153          */

154         Trouble(boolean error) {
155             this.error = error;
156         }
157         
158         /** */
159         boolean isError() {
160             return error;
161         }
162         
163     }
164     
165 }
166
Popular Tags