package org.argeo.slc.core.test;\r
\r
+import java.io.IOException;\r
+import java.io.PrintWriter;\r
+import java.io.StringReader;\r
+import java.io.StringWriter;\r
+import java.util.List;\r
+import java.util.Vector;\r
+\r
+import org.apache.commons.io.IOUtils;\r
+\r
/**\r
* <p>\r
* Basic implementation of a result part, implementing the standard three status\r
* \r
* @see TestStatus\r
*/\r
-public class SimpleResultPart implements TestResultPart, TestStatus {\r
+public class SimpleResultPart implements TestResultPart, TestStatus,\r
+ TestRunAware {\r
\r
- /** For ORM */\r
+ /** @deprecated */\r
private Long tid;\r
\r
+ private String testRunUuid;\r
+\r
/** The status. Default to ERROR since it should always be explicitely set. */\r
private Integer status = ERROR;\r
private String message;\r
- private Exception exception;\r
+ private String exceptionMessage;\r
+ private List<String> exceptionStackLines = new Vector<String>();\r
\r
public SimpleResultPart() {\r
}\r
public SimpleResultPart(Integer status, String message, Exception exception) {\r
this.status = status;\r
this.message = message;\r
- this.exception = exception;\r
+ setException(exception);\r
}\r
\r
public String getMessage() {\r
return status;\r
}\r
\r
- public Exception getException() {\r
- return exception;\r
+ public String getExceptionMessage() {\r
+ return exceptionMessage;\r
}\r
\r
public void setException(Exception exception) {\r
- this.exception = exception;\r
+ if (exception == null)\r
+ return;\r
+\r
+ this.exceptionMessage = exception.getMessage();\r
+\r
+ StringWriter writer = null;\r
+ StringReader reader = null;\r
+ try {\r
+ writer = new StringWriter();\r
+ exception.printStackTrace(new PrintWriter(writer));\r
+ reader = new StringReader(writer.toString());\r
+ exceptionStackLines = new Vector<String>(IOUtils.readLines(reader));\r
+ } catch (IOException e) {\r
+ // silent\r
+ } finally {\r
+ IOUtils.closeQuietly(writer);\r
+ IOUtils.closeQuietly(reader);\r
+ }\r
}\r
\r
@Override\r
buf.append(" ");\r
}\r
buf.append(message);\r
- if (exception != null) {\r
- buf.append("(").append(exception.getMessage()).append(")");\r
- }\r
return buf.toString();\r
}\r
\r
+ /** @deprecated */\r
Long getTid() {\r
return tid;\r
}\r
\r
+ /** @deprecated */\r
void setTid(Long tid) {\r
this.tid = tid;\r
}\r
\r
+ public String getTestRunUuid() {\r
+ return testRunUuid;\r
+ }\r
+\r
+ /** For ORM */\r
+ public void setTestRunUuid(String testRunUuid) {\r
+ this.testRunUuid = testRunUuid;\r
+ }\r
+\r
+ public void notifyTestRun(TestRun testRun) {\r
+ testRunUuid = testRun.getUuid();\r
+ }\r
+\r
+ public List<String> getExceptionStackLines() {\r
+ return exceptionStackLines;\r
+ }\r
+\r
+ public void setExceptionStackLines(List<String> exceptionStackLines) {\r
+ this.exceptionStackLines = exceptionStackLines;\r
+ }\r
+\r
+ public void setExceptionMessage(String exceptionMessage) {\r
+ this.exceptionMessage = exceptionMessage;\r
+ }\r
+\r
}\r