]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/SimpleTestResult.java
Provide a generic framework for unit tests on test tree results
[gpl/argeo-slc.git] / org.argeo.slc.core / src / main / java / org / argeo / slc / core / test / SimpleTestResult.java
1 package org.argeo.slc.core.test;
2
3 import java.util.Date;
4 import java.util.List;
5 import java.util.Vector;
6
7 import org.apache.commons.logging.Log;
8 import org.apache.commons.logging.LogFactory;
9
10 import org.argeo.slc.core.SlcException;
11
12 /**
13 * Basic implementation of a test result containing only a list of result parts.
14 */
15 public class SimpleTestResult implements TestResult {
16 private static Log log = LogFactory.getLog(SimpleTestResult.class);
17
18 private Boolean throwError = true;
19
20 private TestResultId testResultId;
21 private Date closeDate;
22 private List<TestResultPart> parts = new Vector<TestResultPart>();
23
24 public void addResultPart(TestResultPart part) {
25 if (throwError && part.getStatus() == ERROR) {
26 throw new SlcException("There was an error in the underlying test",
27 part.getException());
28 }
29 parts.add(part);
30 if (log.isDebugEnabled())
31 log.debug(part);
32 }
33
34 public void close() {
35 parts.clear();
36 closeDate = new Date();
37 }
38
39 public TestResultId getTestResultId() {
40 return testResultId;
41 }
42
43 /** Sets the test result id. */
44 public void setTestResultId(TestResultId testResultId) {
45 this.testResultId = testResultId;
46 }
47
48 public List<TestResultPart> getParts() {
49 return parts;
50 }
51
52 public Date getCloseDate() {
53 return closeDate;
54 }
55
56 public void setThrowError(Boolean throwError) {
57 this.throwError = throwError;
58 }
59
60 }