KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > tools > testrecorder > shared > TestResults


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

18
19 package org.apache.beehive.netui.tools.testrecorder.shared;
20
21 import java.util.List JavaDoc;
22 import java.util.ArrayList JavaDoc;
23 import java.util.Collections JavaDoc;
24
25
26 public class TestResults {
27
28     private String JavaDoc uri;
29     private int testNumber;
30     // if true indicates an error has occured playing back the test
31
private boolean error;
32     // if no error has occured and the the test passed
33
private boolean testPassed = true;
34     // List of entrues
35
private List JavaDoc diffResults;
36
37     public TestResults( int testNumber, final String JavaDoc uri ) {
38         this( testNumber, uri, false, true );
39     }
40
41     public TestResults( int testNumber, String JavaDoc uri, boolean error, boolean testPassed ) {
42         this.uri = uri;
43         this.testNumber = testNumber;
44         this.error = error;
45         this.testPassed = testPassed;
46     }
47
48     public String JavaDoc getUri() {
49         return uri;
50     }
51
52     public int getTestNumber() {
53         return testNumber;
54     }
55
56     public String JavaDoc getStatus() {
57         if ( error ) {
58             return Constants.ERROR;
59         }
60         if ( testPassed ) {
61             return Constants.PASS;
62         }
63         return Constants.FAIL;
64     }
65
66     public boolean isError() {
67         return error;
68     }
69
70     public boolean isTestPassed() {
71         if ( isError() ) {
72             return false;
73         }
74         return testPassed;
75     }
76
77     public void addDiffResult( String JavaDoc result ) {
78         addDiffResult( result, false );
79     }
80
81     public void addDiffResult( String JavaDoc result, final boolean error ) {
82         if ( error ) {
83             this.error = true;
84         }
85         testPassed = false;
86         if ( diffResults == null ) {
87             diffResults = new ArrayList JavaDoc();
88         }
89         diffResults.add( result );
90     }
91
92     // may return null.
93
public List JavaDoc getDiffResults() {
94         if ( diffResults == null ) {
95             return null;
96         }
97         return Collections.unmodifiableList( diffResults );
98     }
99
100     public String JavaDoc toString() {
101         StringBuffer JavaDoc sb = new StringBuffer JavaDoc( 16 );
102         sb.append( "[ " );
103         sb.append( ", status( " + getStatus() + " )" );
104         sb.append( ", diffResults( " +
105                 ( ( diffResults == null ) ? "null" :
106                 Util.toString( diffResults.iterator(), diffResults.size() ) ) + " )" );
107         sb.append( " ]" );
108         return sb.toString();
109     }
110
111 }
112
Popular Tags