001: /*
002: * @(#)ImmutableTestRecord.java
003: *
004: * Copyright (C) 2002-2003 Matt Albrecht
005: * groboclown@users.sourceforge.net
006: * http://groboutils.sourceforge.net
007: *
008: * Part of the GroboUtils package at:
009: * http://groboutils.sourceforge.net
010: *
011: * Permission is hereby granted, free of charge, to any person obtaining a
012: * copy of this software and associated documentation files (the "Software"),
013: * to deal in the Software without restriction, including without limitation
014: * the rights to use, copy, modify, merge, publish, distribute, sublicense,
015: * and/or sell copies of the Software, and to permit persons to whom the
016: * Software is furnished to do so, subject to the following conditions:
017: *
018: * The above copyright notice and this permission notice shall be included in
019: * all copies or substantial portions of the Software.
020: *
021: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
022: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
023: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
024: * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
025: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
026: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
027: * DEALINGS IN THE SOFTWARE.
028: */
029: package net.sourceforge.groboutils.pmti.v1.itf.impl;
030:
031: import net.sourceforge.groboutils.pmti.v1.itf.ITestRecord;
032:
033: /**
034: * Simple immutable implementation of ITestRecord.
035: *
036: * @author Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
037: * @version $Date: 2003/02/10 22:52:00 $
038: * @since July 7, 2002
039: */
040: public class ImmutableTestRecord implements ITestRecord {
041:
042: private String name;
043: private String suite;
044: private int tCount;
045: private long tRuntime;
046: private String[] failures;
047: private String[] errors;
048: private String log;
049:
050: public ImmutableTestRecord(String name, String suite, int tCount,
051: long tRuntime, String[] failures, String[] errors,
052: String log) {
053: setTestName(name);
054: setTestSuite(suite);
055: setTestCount(tCount);
056: setRuntime(tRuntime);
057: setFailures(failures);
058: setErrors(errors);
059: setLog(log);
060: }
061:
062: public ImmutableTestRecord(ITestRecord tr) {
063: if (tr == null) {
064: throw new IllegalArgumentException("no null arguments");
065: }
066:
067: setTestName(tr.getTestName());
068: setTestSuite(tr.getTestSuite());
069: setTestCount(tr.getTestCount());
070: setRuntime(tr.getRuntime());
071: setFailures(tr.getFailures());
072: setErrors(tr.getErrors());
073: setLog(tr.getLog());
074: }
075:
076: public String getTestName() {
077: return this .name;
078: }
079:
080: public String getTestSuite() {
081: return this .suite;
082: }
083:
084: public int getTestCount() {
085: return this .tCount;
086: }
087:
088: public long getRuntime() {
089: return this .tRuntime;
090: }
091:
092: public String[] getFailures() {
093: String ret[] = new String[this .failures.length];
094: System
095: .arraycopy(this .failures, 0, ret, 0,
096: this .failures.length);
097: return ret;
098: }
099:
100: public String[] getErrors() {
101: String ret[] = new String[this .errors.length];
102: System.arraycopy(this .errors, 0, ret, 0, this .errors.length);
103: return ret;
104: }
105:
106: public String getLog() {
107: return this .log;
108: }
109:
110: //-------------------------------
111: // Package protected
112:
113: ImmutableTestRecord() {
114: setErrors(null);
115: setFailures(null);
116: }
117:
118: void setTestName(String name) {
119: this .name = name;
120: }
121:
122: void setTestSuite(String suite) {
123: this .suite = suite;
124: }
125:
126: void setTestCount(int count) {
127: if (count < 0) {
128: count = 0;
129: }
130: this .tCount = count;
131: }
132:
133: void setRuntime(long time) {
134: if (time < 0L) {
135: time = 0L;
136: }
137: this .tRuntime = time;
138: }
139:
140: void setFailures(String[] f) {
141: if (f == null) {
142: f = new String[0];
143: }
144: this .failures = new String[f.length];
145: System.arraycopy(f, 0, this .failures, 0, f.length);
146: }
147:
148: void setErrors(String[] e) {
149: if (e == null) {
150: e = new String[0];
151: }
152: this .errors = new String[e.length];
153: System.arraycopy(e, 0, this .errors, 0, e.length);
154: }
155:
156: void setLog(String log) {
157: this.log = log;
158: }
159: }
|