--- /dev/null
+package org.argeo.slc.castor.test.tree;
+
+import org.argeo.slc.core.test.SimpleResultPart;
+import org.argeo.slc.core.test.SlcTestUtils;
+import org.argeo.slc.core.test.TestStatus;
+import org.exolab.castor.mapping.AbstractFieldHandler;
+
+public class StatusFieldHandler extends AbstractFieldHandler {
+
+ @Override
+ public Object getValue(Object object) throws IllegalStateException {
+ SimpleResultPart part = (SimpleResultPart) object;
+ return SlcTestUtils.statusToString(part.getStatus());
+ }
+
+ @Override
+ public Object newInstance(Object parent) throws IllegalStateException {
+ return null;
+ }
+
+ @Override
+ public Object newInstance(Object parent, Object[] args)
+ throws IllegalStateException {
+ return null;
+ }
+
+ @Override
+ public void resetValue(Object object) throws IllegalStateException,
+ IllegalArgumentException {
+ SimpleResultPart part = (SimpleResultPart) object;
+ // ERROR by default since it should be explicitely set
+ part.setStatus(TestStatus.ERROR);
+ }
+
+ @Override
+ public void setValue(Object object, Object value)
+ throws IllegalStateException, IllegalArgumentException {
+ SimpleResultPart part = (SimpleResultPart) object;
+ Integer status = SlcTestUtils.stringToStatus((String) value);
+ part.setStatus(status);
+ }
+
+}
/** For ORM */\r
private Long tid;\r
\r
- private Integer status;\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
\r
@Override\r
public String toString() {\r
StringBuffer buf = new StringBuffer("");\r
- if (status == PASSED) {\r
- buf.append("PASSED ");\r
- } else if (status == FAILED) {\r
- buf.append("FAILED ");\r
+ buf.append(SlcTestUtils.statusToString(status));\r
+ if (status == PASSED || status == FAILED) {\r
+ buf.append(' ');\r
} else if (status == ERROR) {\r
- buf.append("ERROR ");\r
+ buf.append(" ");\r
}\r
buf.append(message);\r
if (exception != null) {\r
--- /dev/null
+package org.argeo.slc.core.test;
+
+import org.argeo.slc.core.SlcException;
+
+public abstract class SlcTestUtils {
+ public static String statusToString(Integer status){
+ if(status.equals(TestStatus.PASSED)){
+ return TestStatus.STATUSSTR_PASSED;
+ }
+ else if(status.equals(TestStatus.FAILED)){
+ return TestStatus.STATUSSTR_FAILED;
+ }
+ else if(status.equals(TestStatus.ERROR)){
+ return TestStatus.STATUSSTR_ERROR;
+ }
+ else{
+ throw new SlcException("Unrecognized status "+status);
+ }
+ }
+
+ public static Integer stringToStatus(String statusStr){
+ if(statusStr.equals(TestStatus.STATUSSTR_PASSED)){
+ return TestStatus.PASSED;
+ }
+ else if(statusStr.equals(TestStatus.STATUSSTR_FAILED)){
+ return TestStatus.FAILED;
+ }
+ else if(statusStr.equals(TestStatus.STATUSSTR_ERROR)){
+ return TestStatus.ERROR;
+ }
+ else{
+ throw new SlcException("Unrecognized status string "+statusStr);
+ }
+ }
+
+ private SlcTestUtils(){
+
+ }
+
+}
* (there is no feedback on the behavior of the tested component): 2\r
*/\r
public final static Integer ERROR = 2;\r
+ public final static String STATUSSTR_PASSED = "PASSED";\r
+ public final static String STATUSSTR_FAILED = "FAILED";\r
+ public final static String STATUSSTR_ERROR = "ERROR";\r
+\r
}\r
-<?xml version="1.0"?>\r
-\r
-<mapping>\r
- <description>TreeTestResult objects XML mapping</description>\r
-\r
- <class name="org.argeo.slc.core.test.tree.TreeTestResult"\r
- auto-complete="false">\r
- <field name="numericResultId"\r
- type="org.argeo.slc.core.test.NumericTRId" />\r
- <field name="closeDate" />\r
- <field name="resultParts" collection="map">\r
- <bind-xml name="result-part" location="result-parts">\r
- <class name="org.exolab.castor.mapping.MapItem">\r
- <field name="key"\r
- type="org.argeo.slc.core.structure.tree.TreeSPath">\r
- <bind-xml name="path" node="attribute" />\r
- </field>\r
- <field name="value"\r
- type="org.argeo.slc.core.test.tree.PartSubList">\r
- <bind-xml name="part-sub-list" />\r
- </field>\r
- </class>\r
- </bind-xml>\r
- </field>\r
- <field name="elements" collection="map">\r
- <bind-xml name="element" location="elements">\r
- <class name="org.exolab.castor.mapping.MapItem">\r
- <field name="key"\r
- type="org.argeo.slc.core.structure.tree.TreeSPath">\r
- <bind-xml name="path" node="attribute" />\r
- </field>\r
- <field name="value"\r
- type="org.argeo.slc.core.structure.SimpleSElement">\r
- <bind-xml name="simpleSElement" />\r
- </field>\r
- </class>\r
- </bind-xml>\r
- </field>\r
- </class>\r
-\r
- <class name="org.argeo.slc.core.test.tree.PartSubList"\r
- auto-complete="false">\r
- <field name="slcExecutionUuid" type="string" />\r
- <field name="slcExecutionStepUuid" type="string" />\r
- <field name="parts" collection="vector"\r
- type="org.argeo.slc.core.test.SimpleResultPart">\r
- <bind-xml auto-naming="deriveByClass" location="parts" />\r
- </field>\r
- </class>\r
-\r
- <class name="org.argeo.slc.core.structure.tree.TreeSPath"\r
- auto-complete="false">\r
- <field name="asUniqueString" type="string" />\r
- </class>\r
-\r
- <class name="org.argeo.slc.core.structure.SimpleSElement"\r
- auto-complete="false">\r
- <field name="label" type="string" />\r
- <field name="tags" collection="map">\r
- <bind-xml name="tag" location="tags">\r
- <class name="org.exolab.castor.mapping.MapItem">\r
- <field name="key" type="string">\r
- <bind-xml name="name" node="attribute" />\r
- </field>\r
- <field name="value" type="string">\r
- <bind-xml name="value" />\r
- </field>\r
- </class>\r
- </bind-xml>\r
- </field>\r
- </class>\r
-\r
- <class name="java.lang.StackTraceElement" auto-complete="false"\r
- verify-constructable="false">\r
- <field name="declaringClass" type="string" set-method="%1"\r
- get-method="getClassName">\r
- <bind-xml node="attribute" />\r
- </field>\r
- <field name="methodName" type="string" set-method="%2"\r
- get-method="getMethodName">\r
- <bind-xml node="attribute" />\r
- </field>\r
- <field name="fileName" type="string" set-method="%3"\r
- get-method="getFileName">\r
- <bind-xml node="attribute" />\r
- </field>\r
- <field name="lineNumber" type="integer" set-method="%4"\r
- get-method="getLineNumber">\r
- <bind-xml node="attribute" />\r
- </field>\r
- </class>\r
+<?xml version="1.0"?>
+
+<mapping>
+ <description>TreeTestResult objects XML mapping</description>
+
+ <class name="org.argeo.slc.core.test.tree.TreeTestResult"
+ auto-complete="false">
+ <field name="numericResultId"
+ type="org.argeo.slc.core.test.NumericTRId" />
+ <field name="closeDate" />
+ <field name="resultParts" collection="map">
+ <bind-xml name="result-part" location="result-parts">
+ <class name="org.exolab.castor.mapping.MapItem">
+ <field name="key"
+ type="org.argeo.slc.core.structure.tree.TreeSPath">
+ <bind-xml name="path" node="attribute" />
+ </field>
+ <field name="value"
+ type="org.argeo.slc.core.test.tree.PartSubList">
+ <bind-xml name="part-sub-list" />
+ </field>
+ </class>
+ </bind-xml>
+ </field>
+ <field name="elements" collection="map">
+ <bind-xml name="element" location="elements">
+ <class name="org.exolab.castor.mapping.MapItem">
+ <field name="key"
+ type="org.argeo.slc.core.structure.tree.TreeSPath">
+ <bind-xml name="path" node="attribute" />
+ </field>
+ <field name="value"
+ type="org.argeo.slc.core.structure.SimpleSElement">
+ <bind-xml name="simpleSElement" />
+ </field>
+ </class>
+ </bind-xml>
+ </field>
+ </class>
+
+ <class name="org.argeo.slc.core.test.tree.PartSubList"
+ auto-complete="false">
+ <field name="slcExecutionUuid" type="string" />
+ <field name="slcExecutionStepUuid" type="string" />
+ <field name="parts" collection="vector"
+ type="org.argeo.slc.core.test.SimpleResultPart">
+ <bind-xml auto-naming="deriveByClass" location="parts" />
+ </field>
+ </class>
+
+ <class name="org.argeo.slc.core.test.SimpleResultPart"
+ auto-complete="false">
+ <field name="message" type="string" />
+ <field name="status" type="string"
+ handler="org.argeo.slc.castor.test.tree.StatusFieldHandler" />
+ <field name="exception" type="java.lang.Exception" />
+ </class>
+
+ <class name="org.argeo.slc.core.structure.tree.TreeSPath"
+ auto-complete="false">
+ <field name="asUniqueString" type="string" />
+ </class>
+
+ <class name="org.argeo.slc.core.structure.SimpleSElement"
+ auto-complete="false">
+ <field name="label" type="string" />
+ <field name="tags" collection="map">
+ <bind-xml name="tag" location="tags">
+ <class name="org.exolab.castor.mapping.MapItem">
+ <field name="key" type="string">
+ <bind-xml name="name" node="attribute" />
+ </field>
+ <field name="value" type="string">
+ <bind-xml name="value" />
+ </field>
+ </class>
+ </bind-xml>
+ </field>
+ </class>
+
+ <class name="java.lang.Exception" auto-complete="false">
+ <field name="message"></field>
+ <field name="stackTrace" collection="array"
+ type="java.lang.StackTraceElement">
+ <bind-xml auto-naming="deriveByClass"
+ location="stack-trace" />
+ </field>
+ </class>
+
+ <class name="java.lang.StackTraceElement" auto-complete="false"
+ verify-constructable="false">
+ <field name="declaringClass" type="string" set-method="%1"
+ get-method="getClassName">
+ <bind-xml node="attribute" />
+ </field>
+ <field name="methodName" type="string" set-method="%2"
+ get-method="getMethodName">
+ <bind-xml node="attribute" />
+ </field>
+ <field name="fileName" type="string" set-method="%3"
+ get-method="getFileName">
+ <bind-xml node="attribute" />
+ </field>
+ <field name="lineNumber" type="integer" set-method="%4"
+ get-method="getLineNumber">
+ <bind-xml node="attribute" />
+ </field>
+ </class>
</mapping>
\ No newline at end of file
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"\r
- xmlns:slc="http://argeo.org/projects/slc/schemas"\r
- elementFormDefault="qualified"\r
- targetNamespace="http://argeo.org/projects/slc/schemas">\r
- <!-- TREE TEST RESULT -->\r
- <xs:complexType name="TreeTestResultType">\r
- <xs:all>\r
- <xs:element name="close-date" type="xs:dateTime" />\r
- <xs:element name="result-parts" minOccurs="0"\r
- type="slc:ResultPartsType" />\r
- </xs:all>\r
- </xs:complexType>\r
- <xs:complexType name="ResultPartsType">\r
- <xs:sequence>\r
- <xs:element name="result-part" type="slc:ResultPartType"\r
- maxOccurs="unbounded">\r
- </xs:element>\r
- </xs:sequence>\r
- </xs:complexType>\r
- <xs:complexType name="ResultPartType">\r
- <xs:all>\r
- <xs:element name="part-sub-list" type="slc:PartSubListType" />\r
- </xs:all>\r
- <xs:attribute name="path" type="xs:string" use="required" />\r
- </xs:complexType>\r
- <xs:complexType name="PartSubListType">\r
- <xs:all>\r
- <xs:element name="slc-execution-uuid" type="xs:string" />\r
- <xs:element name="slc-execution-step-uuid" type="xs:string" />\r
- </xs:all>\r
- <xs:attribute name="path" type="xs:string" use="required" />\r
- </xs:complexType>\r
-\r
- <!-- SLC EXECUTION -->\r
- <xs:element name="slc-execution-request">\r
- <xs:complexType>\r
- <xs:all>\r
- <xs:element name="slc-execution"\r
- type="slc:SlcExecutionType" />\r
- </xs:all>\r
- </xs:complexType>\r
- </xs:element>\r
- <xs:element name="slc-execution-steps-request">\r
- <xs:complexType>\r
- <xs:sequence>\r
- <xs:element name="steps"\r
- type="slc:SlcExecutionStepsType" />\r
- <xs:element name="slc-execution-uuid" type="xs:string" />\r
- </xs:sequence>\r
- </xs:complexType>\r
- </xs:element>\r
- <xs:complexType name="SlcExecutionType">\r
- <xs:all>\r
- <xs:element name="status" type="xs:string" />\r
- <xs:element name="type" type="xs:string" />\r
- <xs:element name="host" type="xs:string" />\r
- <xs:element name="path" type="xs:string" />\r
- <xs:element name="steps" minOccurs="0"\r
- type="slc:SlcExecutionStepsType" />\r
- </xs:all>\r
- <xs:attribute name="uuid" type="xs:string" use="required" />\r
- </xs:complexType>\r
- <xs:complexType name="SlcExecutionStepType">\r
- <xs:all>\r
- <xs:element name="type" type="xs:string" />\r
- <xs:element name="begin" type="xs:dateTime" />\r
- <xs:element name="log-lines" minOccurs="0">\r
- <xs:complexType>\r
- <xs:sequence>\r
- <xs:element name="log-line" type="xs:string"\r
- maxOccurs="unbounded" />\r
- </xs:sequence>\r
- </xs:complexType>\r
- </xs:element>\r
- </xs:all>\r
- <xs:attribute name="uuid" type="xs:string" use="required" />\r
- </xs:complexType>\r
- <xs:complexType name="SlcExecutionStepsType">\r
- <xs:sequence>\r
- <xs:element name="slc-execution-step"\r
- type="slc:SlcExecutionStepType" maxOccurs="unbounded">\r
- </xs:element>\r
- </xs:sequence>\r
- </xs:complexType>\r
-\r
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:slc="http://argeo.org/projects/slc/schemas"
+ elementFormDefault="qualified"
+ targetNamespace="http://argeo.org/projects/slc/schemas">
+ <!-- TREE TEST RESULT -->
+ <xs:complexType name="TreeTestResultType">
+ <xs:all>
+ <xs:element name="close-date" type="xs:dateTime" />
+ <xs:element name="result-parts" minOccurs="0"
+ type="slc:ResultPartsType" />
+ <xs:element name="elements" minOccurs="0"
+ type="slc:ElementsType" />
+ </xs:all>
+ </xs:complexType>
+ <xs:complexType name="ResultPartsType">
+ <xs:sequence>
+ <xs:element name="result-part" type="slc:ResultPartType"
+ maxOccurs="unbounded">
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="ResultPartType">
+ <xs:all>
+ <xs:element name="part-sub-list" type="slc:PartSubListType" />
+ </xs:all>
+ <xs:attribute name="path" type="xs:string" use="required" />
+ </xs:complexType>
+ <xs:complexType name="PartSubListType">
+ <xs:all>
+ <xs:element name="slc-execution-uuid" type="xs:string" />
+ <xs:element name="slc-execution-step-uuid" type="xs:string" />
+ <xs:element name="parts" minOccurs="0" type="slc:PartsType" />
+ </xs:all>
+ <xs:attribute name="path" type="xs:string" use="required" />
+ </xs:complexType>
+ <xs:complexType name="PartsType">
+ <xs:sequence>
+ <xs:element name="simple-result-part"
+ type="slc:SimpleResultPartType" maxOccurs="unbounded">
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="SimpleResultPartType">
+ <xs:all>
+ <xs:element name="status">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="PASSED" />
+ <xs:enumeration value="FAILED" />
+ <xs:enumeration value="ERROR" />
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+ <xs:element name="message" type="xs:string" />
+ <xs:element name="exception" minOccurs="0"
+ type="slc:ExceptionType" />
+ </xs:all>
+ </xs:complexType>
+ <xs:complexType name="ExceptionType">
+ <xs:all>
+ <xs:element name="localized-message" type="xs:string" />
+ <xs:element name="message" type="xs:string" />
+ <xs:element name="exception" minOccurs="0"
+ type="slc:StackTraceType" />
+ </xs:all>
+ </xs:complexType>
+ <xs:complexType name="StackTraceType">
+ <xs:sequence>
+ <xs:element name="stack-trace-element"
+ type="slc:StackTraceElementType" maxOccurs="unbounded">
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="StackTraceElementType">
+ <xs:attribute name="delaring-class" type="xs:string"
+ use="required" />
+ <xs:attribute name="method-name" type="xs:string"
+ use="required" />
+ <xs:attribute name="file-name" type="xs:string" use="required" />
+ <xs:attribute name="line-number" type="xs:integer"
+ use="required" />
+ </xs:complexType>
+ <xs:complexType name="ElementsType">
+ <xs:sequence>
+ <xs:element name="element" type="slc:ElementType"
+ maxOccurs="unbounded">
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="ElementType">
+ <xs:all>
+ <xs:element name="simpleSElement" type="slc:SimpleSElementType" />
+ </xs:all>
+ <xs:attribute name="path" type="xs:string" use="required" />
+ </xs:complexType>
+ <xs:complexType name="SimpleSElementType">
+ <xs:all>
+ <xs:element name="label" type="xs:string" />
+ <xs:element name="tags" type="slc:TagsType" minOccurs="0"/>
+ </xs:all>
+ </xs:complexType>
+ <xs:complexType name="TagsType">
+ <xs:sequence>
+ <xs:element name="tag" type="slc:TagType"
+ maxOccurs="unbounded">
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="TagType">
+ <xs:all>
+ <xs:element name="value" type="xs:string" />
+ </xs:all>
+ <xs:attribute name="name" type="xs:string" use="required" />
+ </xs:complexType>
+
+ <!-- SLC EXECUTION -->
+ <xs:element name="slc-execution-request">
+ <xs:complexType>
+ <xs:all>
+ <xs:element name="slc-execution"
+ type="slc:SlcExecutionType" />
+ </xs:all>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="slc-execution-steps-request">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="steps"
+ type="slc:SlcExecutionStepsType" />
+ <xs:element name="slc-execution-uuid" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:complexType name="SlcExecutionType">
+ <xs:all>
+ <xs:element name="status" type="xs:string" />
+ <xs:element name="type" type="xs:string" />
+ <xs:element name="host" type="xs:string" />
+ <xs:element name="path" type="xs:string" />
+ <xs:element name="steps" minOccurs="0"
+ type="slc:SlcExecutionStepsType" />
+ </xs:all>
+ <xs:attribute name="uuid" type="xs:string" use="required" />
+ </xs:complexType>
+ <xs:complexType name="SlcExecutionStepType">
+ <xs:all>
+ <xs:element name="type" type="xs:string" />
+ <xs:element name="begin" type="xs:dateTime" />
+ <xs:element name="log-lines" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="log-line" type="xs:string"
+ maxOccurs="unbounded" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:all>
+ <xs:attribute name="uuid" type="xs:string" use="required" />
+ </xs:complexType>
+ <xs:complexType name="SlcExecutionStepsType">
+ <xs:sequence>
+ <xs:element name="slc-execution-step"
+ type="slc:SlcExecutionStepType" maxOccurs="unbounded">
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+
</xs:schema>
\ No newline at end of file