KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > groboutils > pmti > v1 > itf > impl > ImmutableTestRecord


1 /*
2  * @(#)ImmutableTestRecord.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.itf.impl;
30
31 import net.sourceforge.groboutils.pmti.v1.itf.ITestRecord;
32
33
34
35 /**
36  * Simple immutable implementation of ITestRecord.
37  *
38  * @author Matt Albrecht <a HREF="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
39  * @version $Date: 2003/02/10 22:52:00 $
40  * @since July 7, 2002
41  */

42 public class ImmutableTestRecord implements ITestRecord
43 {
44     
45     private String JavaDoc name;
46     private String JavaDoc suite;
47     private int tCount;
48     private long tRuntime;
49     private String JavaDoc[] failures;
50     private String JavaDoc[] errors;
51     private String JavaDoc log;
52     
53     
54     public ImmutableTestRecord( String JavaDoc name, String JavaDoc suite, int tCount,
55             long tRuntime, String JavaDoc[] failures, String JavaDoc[] errors, String JavaDoc log )
56     {
57         setTestName( name );
58         setTestSuite( suite );
59         setTestCount( tCount );
60         setRuntime( tRuntime );
61         setFailures( failures );
62         setErrors( errors );
63         setLog( log );
64     }
65     
66     
67     public ImmutableTestRecord( ITestRecord tr )
68     {
69         if (tr == null)
70         {
71             throw new IllegalArgumentException JavaDoc("no null arguments");
72         }
73         
74         setTestName( tr.getTestName() );
75         setTestSuite( tr.getTestSuite() );
76         setTestCount( tr.getTestCount() );
77         setRuntime( tr.getRuntime() );
78         setFailures( tr.getFailures() );
79         setErrors( tr.getErrors() );
80         setLog( tr.getLog() );
81     }
82     
83     
84     public String JavaDoc getTestName()
85     {
86         return this.name;
87     }
88     
89     public String JavaDoc getTestSuite()
90     {
91         return this.suite;
92     }
93     
94     public int getTestCount()
95     {
96         return this.tCount;
97     }
98     
99     public long getRuntime()
100     {
101         return this.tRuntime;
102     }
103     
104     public String JavaDoc[] getFailures()
105     {
106         String JavaDoc ret[] = new String JavaDoc[ this.failures.length ];
107         System.arraycopy( this.failures, 0, ret, 0, this.failures.length );
108         return ret;
109     }
110     
111     public String JavaDoc[] getErrors()
112     {
113         String JavaDoc ret[] = new String JavaDoc[ this.errors.length ];
114         System.arraycopy( this.errors, 0, ret, 0, this.errors.length );
115         return ret;
116     }
117     
118     public String JavaDoc getLog()
119     {
120         return this.log;
121     }
122     
123     
124     
125     //-------------------------------
126
// Package protected
127

128     ImmutableTestRecord()
129     {
130         setErrors( null );
131         setFailures( null );
132     }
133     
134     
135     void setTestName( String JavaDoc name )
136     {
137         this.name = name;
138     }
139     
140     
141     void setTestSuite( String JavaDoc suite )
142     {
143         this.suite = suite;
144     }
145     
146     
147     void setTestCount( int count )
148     {
149         if (count < 0)
150         {
151             count = 0;
152         }
153         this.tCount = count;
154     }
155     
156     
157     void setRuntime( long time )
158     {
159         if (time < 0L)
160         {
161             time = 0L;
162         }
163         this.tRuntime = time;
164     }
165     
166     
167     void setFailures( String JavaDoc[] f )
168     {
169         if (f == null)
170         {
171             f = new String JavaDoc[0];
172         }
173         this.failures = new String JavaDoc[ f.length ];
174         System.arraycopy( f, 0, this.failures, 0, f.length );
175     }
176     
177     
178     void setErrors( String JavaDoc[] e )
179     {
180         if (e == null)
181         {
182             e = new String JavaDoc[0];
183         }
184         this.errors = new String JavaDoc[ e.length ];
185         System.arraycopy( e, 0, this.errors, 0, e.length );
186     }
187     
188     
189     void setLog( String JavaDoc log )
190     {
191         this.log = log;
192     }
193 }
194
195
Popular Tags