]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResult.java
Improve logging
[gpl/argeo-slc.git] / org.argeo.slc.core / src / main / java / org / argeo / slc / core / test / tree / TreeTestResult.java
index 96d0db046509e4ab5e356e85e309c7097ddf0545..781c6eee2a1cc29124f4cf4eee44d82d29133633 100644 (file)
@@ -2,13 +2,13 @@ package org.argeo.slc.core.test.tree;
 \r
 import java.util.Date;\r
 import java.util.List;\r
+import java.util.Map;\r
 import java.util.SortedMap;\r
 import java.util.TreeMap;\r
 import java.util.Vector;\r
 \r
 import org.apache.commons.logging.Log;\r
 import org.apache.commons.logging.LogFactory;\r
-\r
 import org.argeo.slc.core.SlcException;\r
 import org.argeo.slc.core.structure.StructureAware;\r
 import org.argeo.slc.core.structure.StructureElement;\r
@@ -42,6 +42,8 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
        private SortedMap<TreeSPath, PartSubList> resultParts = new TreeMap<TreeSPath, PartSubList>();\r
        private SortedMap<TreeSPath, StructureElement> elements = new TreeMap<TreeSPath, StructureElement>();\r
 \r
+       private Map<String, String> attributes = new TreeMap<String, String>();\r
+\r
        /** Sets the list of listeners. */\r
        public void setListeners(List<TestResultListener<TreeTestResult>> listeners) {\r
                this.listeners = listeners;\r
@@ -87,7 +89,7 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
                        }\r
                }\r
 \r
-               currentPath = (TreeSPath) path;\r
+               currentPath = path;\r
        }\r
 \r
        /** Gets the current path. */\r
@@ -108,7 +110,7 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
        public void close() {\r
                if (isClosed) {\r
                        throw new SlcException("Test Result #" + getUuid()\r
-                                       + " alredy closed.");\r
+                                       + " already closed.");\r
                }\r
                closeDate = new Date();\r
 \r
@@ -120,7 +122,8 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
                }\r
                isClosed = true;\r
 \r
-               log.info("Test Result #" + getUuid() + " closed.");\r
+               if (log.isTraceEnabled())\r
+                       log.trace("Test Result " + getUuid() + " closed.");\r
        }\r
 \r
        public Date getCloseDate() {\r
@@ -154,6 +157,11 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
 \r
        public SortedMap<TreeSPath, StructureElement> getRelatedElements(\r
                        TreeSPath path) {\r
+               if (path == null)\r
+                       throw new SlcException(\r
+                                       "Cannot retrieve element for a null path in result #"\r
+                                                       + uuid);\r
+\r
                SortedMap<TreeSPath, StructureElement> relatedElements = new TreeMap<TreeSPath, StructureElement>();\r
                List<TreeSPath> hierarchy = path.getHierarchyAsList();\r
                for (TreeSPath currPath : elements.keySet()) {\r
@@ -181,4 +189,11 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
                }\r
        }\r
 \r
+       public Map<String, String> getAttributes() {\r
+               return attributes;\r
+       }\r
+\r
+       public void setAttributes(Map<String, String> attributes) {\r
+               this.attributes = attributes;\r
+       }\r
 }\r