]> 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
Adapt to changes in Argeo Commons
[gpl/argeo-slc.git] / runtime / org.argeo.slc.core / src / main / java / org / argeo / slc / core / test / tree / TreeTestResult.java
index c27da2f76d13382c2859939b5eb4956275aa2b88..f102ae6ab4babaf0be961118a27c85e185afa367 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>\r
+ * Copyright (C) 2007-2012 Mathieu Baudier\r
  *\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
@@ -13,7 +13,6 @@
  * See the License for the specific language governing permissions and\r
  * limitations under the License.\r
  */\r
-\r
 package org.argeo.slc.core.test.tree;\r
 \r
 import java.io.Serializable;\r
@@ -70,6 +69,8 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
        // TODO is it really necessary closeDate == null ?\r
        private Boolean isClosed = false;\r
 \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
@@ -88,15 +89,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
@@ -115,6 +119,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
@@ -305,4 +312,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