KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > test > DefaultTestReport


1 /*
2
3    Copyright 2001 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.test;
19
20 /**
21  * Simple, default implementation for the <tt>TestReport</tt>
22  * interface.
23  *
24  * @author <a HREF="mailto:vhardy@apache.org">Vincent Hardy</a>
25  * @version $Id: DefaultTestReport.java,v 1.4 2004/08/18 07:16:56 vhardy Exp $
26  */

27 public class DefaultTestReport implements TestReport {
28     private boolean passed = true;
29
30     protected Entry[] description = null;
31
32     protected Test test;
33
34     private String JavaDoc errorCode;
35     
36     /**
37      * Parent report, in case this report is part of a
38      * <tt>TestSuiteReport</tt>
39      */

40     protected TestSuiteReport parent;
41
42     public DefaultTestReport(Test test){
43         if(test == null){
44             throw new IllegalArgumentException JavaDoc();
45         }
46
47         this.test = test;
48     }
49
50     public TestSuiteReport getParentReport(){
51         return parent;
52     }
53
54     public void setParentReport(TestSuiteReport parent){
55         this.parent = parent;
56     }
57
58     public Test getTest(){
59         return test;
60     }
61
62     public String JavaDoc getErrorCode(){
63         return errorCode;
64     }
65
66     public void setErrorCode(String JavaDoc errorCode){
67         if( !passed && errorCode == null ){
68             /**
69              * Error code should be set first
70              */

71             throw new IllegalArgumentException JavaDoc();
72         }
73
74         this.errorCode = errorCode;
75     }
76
77     public boolean hasPassed(){
78         return passed;
79     }
80     
81     public void setPassed(boolean passed){
82         if( !passed && (errorCode == null) ){
83             /**
84              * Error Code should be set first
85              */

86             throw new IllegalArgumentException JavaDoc();
87         }
88         this.passed = passed;
89     }
90     
91     public Entry[] getDescription(){
92         return description;
93     }
94     
95     public void setDescription(Entry[] description){
96         this.description = description;
97     }
98
99     public void addDescriptionEntry(String JavaDoc key,
100                                     Object JavaDoc value){
101         addDescriptionEntry(new Entry(key, value));
102     }
103
104     protected void addDescriptionEntry(Entry entry){
105         if(description == null){
106             description = new Entry[1];
107             description[0] = entry;
108         }
109         else{
110             Entry[] oldDescription = description;
111             description = new Entry[description.length + 1];
112             System.arraycopy(oldDescription, 0, description, 0,
113                              oldDescription.length);
114             description[oldDescription.length] = entry;
115         }
116     }
117
118 }
119
120
Popular Tags