01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: package org.apache.pluto.testsuite;
18:
19: import java.io.Serializable;
20: import java.util.ArrayList;
21: import java.util.Collection;
22: import java.util.Collections;
23:
24: /**
25: * This class contains one or more test results.
26: */
27: public class TestResults implements Serializable {
28:
29: private String name;
30:
31: private final ArrayList list = new ArrayList();
32:
33: private boolean failed = false;
34: private boolean inQuestion = false;
35:
36: public TestResults(String name) {
37: this .name = name;
38: }
39:
40: public String getName() {
41: return name;
42: }
43:
44: public void setName(String name) {
45: this .name = name;
46: }
47:
48: public void add(TestResult result) {
49: if (result.getReturnCode() == TestResult.FAILED) {
50: failed = true;
51: } else if (result.getReturnCode() == TestResult.WARNING) {
52: inQuestion = true;
53: }
54: list.add(result);
55: }
56:
57: public boolean isFailed() {
58: return failed;
59: }
60:
61: public boolean isInQuestion() {
62: return inQuestion;
63: }
64:
65: public Collection getCollection() {
66: return Collections.unmodifiableCollection(list);
67: }
68:
69: /**
70: * Override of toString() that prints out variable
71: * names and values.
72: *
73: * @see java.lang.Object#toString()
74: */
75: public String toString() {
76: StringBuffer buffer = new StringBuffer();
77: buffer.append(getClass().getName());
78: buffer.append("[name=").append(name);
79: buffer.append(";failed=").append(failed);
80: buffer.append(";inQuestion=").append(inQuestion);
81: buffer.append(";results={").append(list).append("}]");
82: return buffer.toString();
83: }
84: }
|