]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc/src/main/java/org/argeo/slc/core/test/SimpleResultPart.java
Introduce unit tests framework
[gpl/argeo-slc.git] / org.argeo.slc / src / main / java / org / argeo / slc / core / test / SimpleResultPart.java
1 package org.argeo.slc.core.test;
2
3 /**
4 * <p>
5 * Basic implementation of a result part, implementing the standard three status
6 * approach for test results.
7 * </p>
8 * <p>
9 * <ul>
10 * <li>{@link #PASSED}: the test succeeded</li>
11 * <li>{@link #FAILED}: the test could run, but did not reach the expected
12 * result</li>
13 * <li>{@link #ERROR}: an error during the test run prevented to get a
14 * significant information on the tested system.</li>
15 * </ul>
16 * </p>
17 */
18 public class SimpleResultPart implements TestResultPart {
19
20 /** The flag for a passed test: 1 */
21 public final static int PASSED = 1;
22 /** The flag for a failed test: 2 */
23 public final static int FAILED = 2;
24 /** The flag for a test which could not properly run because of an error: 3 */
25 public final static int ERROR = 3;
26
27 /** For ORM */
28 private Long tid;
29
30 private Integer status;
31 private String message;
32 private Throwable exception;
33
34 public String getMessage() {
35 return message;
36 }
37
38 public void setMessage(String message) {
39 this.message = message;
40 }
41
42 public void setStatus(Integer status) {
43 this.status = status;
44 }
45
46 public Integer getStatus() {
47 return status;
48 }
49
50 public Throwable getException() {
51 return exception;
52 }
53
54 public void setException(Throwable exception) {
55 this.exception = exception;
56 }
57
58 @Override
59 public String toString() {
60 StringBuffer buf = new StringBuffer("");
61 if (status == PASSED) {
62 buf.append("PASSED ");
63 } else if (status == FAILED) {
64 buf.append("FAILED ");
65 } else if (status == ERROR) {
66 buf.append("ERROR ");
67 }
68 buf.append(message);
69 if (exception != null) {
70 buf.append("(").append(exception.getMessage()).append(")");
71 }
72 return buf.toString();
73 }
74
75 Long getTid() {
76 return tid;
77 }
78
79 void setTid(Long tid) {
80 this.tid = tid;
81 }
82
83 }