KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > groboutils > pmti > v1 > autodoc > v1 > ITFTestData


1 /*
2  * @(#)ITFTestData.java
3  *
4  * Copyright (C) 2002-2003 Matt Albrecht
5  * groboclown@users.sourceforge.net
6  * http://groboutils.sourceforge.net
7  *
8  * Part of the GroboUtils package at:
9  * http://groboutils.sourceforge.net
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining a
12  * copy of this software and associated documentation files (the "Software"),
13  * to deal in the Software without restriction, including without limitation
14  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15  * and/or sell copies of the Software, and to permit persons to whom the
16  * Software is furnished to do so, subject to the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be included in
19  * all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27  * DEALINGS IN THE SOFTWARE.
28  */

29 package net.sourceforge.groboutils.pmti.v1.autodoc.v1;
30
31
32 import net.sourceforge.groboutils.autodoc.v1.testserver.TestDataFactory;
33 import net.sourceforge.groboutils.autodoc.v1.testserver.DefaultTestData;
34 import net.sourceforge.groboutils.autodoc.v1.testserver.TestInfo;
35
36 import junit.framework.AssertionFailedError;
37
38 import java.util.Vector JavaDoc;
39
40 /**
41  * An interface used to briefly describe a test and the gathered data associated
42  * for the test in a particular framework. These should be created for
43  * a framework through the {@link TestDataFactory} class.
44  *
45  * @author Matt Albrecht <a HREF="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
46  * @version $Date: 2003/02/10 22:51:56 $
47  * @since March 30, 2002
48  */

49 public class ITFTestData extends DefaultTestData
50 {
51     private Vector JavaDoc issueIDs = new Vector JavaDoc();
52     private Vector JavaDoc errors = new Vector JavaDoc();
53     private Vector JavaDoc failures = new Vector JavaDoc();
54     private int testCount = 0;
55     private long startTime = -1;
56     private long endTime = -1;
57     
58     
59     public ITFTestData( TestInfo info )
60     {
61         super( info );
62     }
63     
64     
65     /**
66      * This may be called multiple times. Each time will add a new issue for
67      * the corresponding test info. If <tt>id</tt> is <tt>null</tt>, then it
68      * will be ignored. Likewise, any duplicate IDs passed in will be ignored.
69      *
70      * @param id the issue id to associate with this test.
71      */

72     public void addIssueID( String JavaDoc id )
73     {
74         if (id != null && !this.issueIDs.contains( id ))
75         {
76             this.issueIDs.addElement( id );
77         }
78     }
79     
80     
81     /**
82      *
83      */

84     public void addError( Throwable JavaDoc error )
85     {
86         if (error != null)
87         {
88             this.errors.addElement( error );
89         }
90     }
91     
92     
93     /**
94      *
95      */

96     public void addFailure( AssertionFailedError failure )
97     {
98         if (failure != null)
99         {
100             this.failures.addElement( failure );
101         }
102     }
103     
104     
105     /**
106      *
107      */

108     public void addTest()
109     {
110         ++this.testCount;
111     }
112     
113     
114     /**
115      *
116      */

117     public void setStartTime( long startTime )
118     {
119         this.startTime = startTime;
120     }
121     
122     
123     /**
124      *
125      */

126     public void setEndTime( long endTime )
127     {
128         this.endTime = endTime;
129     }
130     
131     
132     /**
133      * Retrieves all issue IDs for this TestInfo object. This will never return
134      * <tt>null</tt>, but may return an empty array.
135      */

136     public String JavaDoc[] getIssues()
137     {
138         String JavaDoc[] issues = new String JavaDoc[ this.issueIDs.size() ];
139         this.issueIDs.copyInto( issues );
140         return issues;
141     }
142     
143     
144     /**
145      *
146      */

147     public Throwable JavaDoc[] getErrors()
148     {
149         Throwable JavaDoc t[] = new Throwable JavaDoc[ this.errors.size() ];
150         this.errors.copyInto( t );
151         return t;
152     }
153     
154     
155     /**
156      *
157      */

158     public AssertionFailedError[] getFailures()
159     {
160         AssertionFailedError s[] = new AssertionFailedError[
161             this.failures.size() ];
162         this.failures.copyInto( s );
163         return s;
164     }
165     
166     
167     /**
168      *
169      */

170     public int getSuccessCount()
171     {
172         int c = this.testCount - this.errors.size() - this.failures.size();
173         if (c < 0)
174         {
175             c = 0;
176         }
177         return c;
178     }
179     
180     
181     /**
182      *
183      */

184     public int getTestCount()
185     {
186         return this.testCount;
187     }
188     
189     
190     /**
191      *
192      */

193     public long getRunTime()
194     {
195         if (this.startTime < 0 || this.endTime < 0)
196         {
197             return -1L;
198         }
199         return this.endTime - this.startTime;
200     }
201 }
202
203
Popular Tags