001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.pluto.testsuite;
018:
019: import java.io.Serializable;
020:
021: /**
022: * The test result represents the result of one test method.
023: *
024: */
025: public class TestResult implements Serializable {
026:
027: /** The undefined return code. */
028: public static final int UNDEFINED = -1;
029:
030: /** The warning return code. */
031: public static final int WARNING = 0;
032:
033: /** The failed return code. */
034: public static final int FAILED = 1;
035:
036: /** The passed return code. */
037: public static final int PASSED = 2;
038:
039: // Private Member Variables ------------------------------------------------
040:
041: /** The name of the test. */
042: private String name = null;
043:
044: /** The description of the test. */
045: private String description = "[unknown]";
046:
047: /** The PLT number in the spec that is tested. */
048: private String specPLT = "[unknown]";
049:
050: /** The return code of the test result: PASSED, WARNING, FAILED. */
051: private int returnCode = UNDEFINED;
052:
053: /** The message of the test result. */
054: private String resultMessage = "[unknown]";
055:
056: // Public Methods ----------------------------------------------------------
057:
058: public String getName() {
059: return name;
060: }
061:
062: public void setName(String name) {
063: this .name = name;
064: }
065:
066: public String getDescription() {
067: return description;
068: }
069:
070: public void setDescription(String description) {
071: this .description = description;
072: }
073:
074: public String getSpecPLT() {
075: return specPLT;
076: }
077:
078: public void setSpecPLT(String specPLT) {
079: this .specPLT = specPLT;
080: }
081:
082: public int getReturnCode() {
083: return returnCode;
084: }
085:
086: public String getReturnCodeAsString() {
087: if (returnCode == WARNING) {
088: return "WARNING";
089: } else if (returnCode == FAILED) {
090: return "FAILED";
091: } else if (returnCode == PASSED) {
092: return "PASSED";
093: } else {
094: return "UNKNOWN RETURN CODE";
095: }
096: }
097:
098: public void setReturnCode(int returnCode) {
099: this .returnCode = returnCode;
100: }
101:
102: public String getResultMessage() {
103: return resultMessage;
104: }
105:
106: public void setResultMessage(String resultMessage) {
107: this .resultMessage = resultMessage;
108: }
109:
110: // Object Methods ----------------------------------------------------------
111:
112: /**
113: * Override of toString() that prints out name and results values.
114: * @see java.lang.Object#toString()
115: */
116: public String toString() {
117: StringBuffer buffer = new StringBuffer();
118: buffer.append(getClass().getName());
119: buffer.append("[name=").append(name);
120: buffer.append(";returnCode=").append(returnCode);
121: buffer.append(";resultMessage=").append(resultMessage).append(
122: "]");
123: return buffer.toString();
124: }
125:
126: }
|