]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResult.java
Improve logging
[gpl/argeo-slc.git] / runtime / org.argeo.slc.core / src / main / java / org / argeo / slc / core / test / tree / TreeTestResult.java
index 40eb00f8cb262c1659c87bc25f2e99372d7445e8..16eb26c53a320e0a74de326795fc9bf858154d13 100644 (file)
@@ -20,7 +20,6 @@ import java.io.Serializable;
 import java.util.ArrayList;\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.UUID;\r
@@ -61,17 +60,19 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
        private List<SimpleAttachment> attachments = new ArrayList<SimpleAttachment>();\r
 \r
        // Headers. Used to accelerate request on a specific test result.\r
-       private Map<String, String> attributes = new TreeMap<String, String>();\r
+       private SortedMap<String, String> attributes = new TreeMap<String, String>();\r
 \r
        // Runtime Data\r
        private TreeSPath currentPath;\r
-       private TestRun currentTestRun;\r
+       private transient TestRun currentTestRun;\r
        private Boolean warnIfAlreadyClosed = true;\r
        private Boolean strictChecks = false;\r
        // TODO is it really necessary closeDate == null ?\r
        private Boolean isClosed = false;\r
 \r
-       private List<TestResultListener<TreeTestResult>> listeners = new Vector<TestResultListener<TreeTestResult>>();\r
+       private Boolean cache = true;\r
+\r
+       private transient List<TestResultListener<TreeTestResult>> listeners = new Vector<TestResultListener<TreeTestResult>>();\r
 \r
        /** Sets the list of listeners. */\r
        public void setListeners(List<TestResultListener<TreeTestResult>> listeners) {\r
@@ -89,15 +90,18 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
                if (currentPath == null)\r
                        throw new SlcException("No current path set.");\r
 \r
-               PartSubList subList = resultParts.get(currentPath);\r
-               if (subList == null) {\r
-                       subList = new PartSubList();\r
-                       resultParts.put(currentPath, subList);\r
+               if (cache) {\r
+                       PartSubList subList = resultParts.get(currentPath);\r
+                       if (subList == null) {\r
+                               subList = new PartSubList();\r
+                               resultParts.put(currentPath, subList);\r
+                       }\r
+                       subList.getParts().add(part);\r
                }\r
+\r
                if (part instanceof TestRunAware && currentTestRun != null) {\r
                        ((TestRunAware) part).notifyTestRun(currentTestRun);\r
                }\r
-               subList.getParts().add(part);\r
 \r
                // notify listeners\r
                synchronized (listeners) {\r
@@ -116,6 +120,9 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
 \r
        public void notifyCurrentPath(StructureRegistry<TreeSPath> registry,\r
                        TreeSPath path) {\r
+               if (!cache)\r
+                       return;\r
+\r
                if (registry != null) {\r
                        for (TreeSPath p : path.getHierarchyAsList()) {\r
                                if (!elements.containsKey(p)) {\r
@@ -146,8 +153,7 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
        }\r
 \r
        /**\r
-        * Used by ORM systems. \r
-        * Changed to public in order to enable jcr persistence\r
+        * Used by ORM systems. Changed to public in order to enable jcr persistence\r
         */\r
        public void setResultParts(SortedMap<TreeSPath, PartSubList> resultParts) {\r
                this.resultParts = resultParts;\r
@@ -272,11 +278,11 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
                        return super.hashCode();\r
        }\r
 \r
-       public Map<String, String> getAttributes() {\r
+       public SortedMap<String, String> getAttributes() {\r
                return attributes;\r
        }\r
 \r
-       public void setAttributes(Map<String, String> attributes) {\r
+       public void setAttributes(SortedMap<String, String> attributes) {\r
                this.attributes = attributes;\r
        }\r
 \r
@@ -307,4 +313,12 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
                this.strictChecks = strictChecks;\r
        }\r
 \r
+       /**\r
+        * Whether information should be stored in thsi object or simply forwarded\r
+        * to teh listeners.\r
+        */\r
+       public void setCache(Boolean cache) {\r
+               this.cache = cache;\r
+       }\r
+\r
 }\r