1 /*
2 * Copyright (c) 2004, RV Test Team
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * Redistributions of source code must retain the above copyright notice, this
9 * list of conditions and the following disclaimer.
10 *
11 * Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * Neither the name of the "RV Test Team" nor the names of its contributors may
16 * be used to endorse or promote products derived from this software without
17 * specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
29 * THE POSSIBILITY OF SUCH DAMAGE.
30 *
31 */
32 //Created on Oct 4, 2004
33 package com.reuters.msgtest.load;
34
35 import com.tibco.tibrv.TibrvMsg;
36
37
38 /***
39 * @author <a href="mailto:Kurman.Karabukaev@thoughtworks.com">Kurman</a>
40 *
41 */
42 public class LoadTestResult {
43 public static final Object EMPTY_KEY = new Object();
44 public static final LoadTestResult NONE = new LoadTestResult();
45 private long sentTime = -1;
46 private long receiveTime = -1;
47 private TibrvMsg responseMessage;
48 private Throwable error;
49 private Object key;
50
51 public LoadTestResult() {
52 this(-1);
53 }
54
55 public LoadTestResult(long sentTime) {
56 this(sentTime, -1, null);
57 }
58
59 public LoadTestResult(long sentTime, long receiveTime) {
60 this(sentTime, receiveTime, null);
61 }
62
63 public LoadTestResult(long sentTime, long receiveTime,
64 TibrvMsg responseMessage) {
65 this(sentTime, receiveTime, responseMessage, null);
66 }
67
68 public LoadTestResult(long sentTime, long receiveTime,
69 TibrvMsg responseMessage, Throwable error) {
70 setSentTime(sentTime);
71 setReceiveTime(receiveTime);
72 setResponseMessage(responseMessage);
73 setError(error);
74 }
75
76 public long getReceiveTime() {
77 return receiveTime;
78 }
79
80 public void setReceiveTime(long receiveTime) {
81 this.receiveTime = receiveTime;
82 }
83
84 public long getSentTime() {
85 return sentTime;
86 }
87
88 public void setSentTime(long sentTime) {
89 this.sentTime = sentTime;
90 }
91
92 public Throwable getError() {
93 return error;
94 }
95
96 public void setError(Throwable error) {
97 this.error = error;
98 }
99
100 public TibrvMsg getResponseMessage() {
101 return responseMessage;
102 }
103
104 public void setResponseMessage(TibrvMsg responseMessage) {
105 this.responseMessage = responseMessage;
106 }
107
108 public Object getKey() {
109 if (key == null) {
110 return EMPTY_KEY;
111 }
112
113 return key;
114 }
115
116 public void setKey(Object key) {
117 this.key = key;
118 }
119
120 // it would be good to provide hashCode method as well.
121 // public boolean equals(Object obj) {
122 // if (obj == null) return false;
123 // if (getKey() == null) return false; //???
124 // return getKey().equals(obj);
125 // }
126 //
127 public String toString() {
128 return "Send time: " + getSentTime() + ". Receive time: " +
129 getReceiveTime();
130 }
131
132 public boolean isError() {
133 return (getError() == null) ? false : true;
134 }
135 }