]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/test/tree/TreeTestResult.java
Attachments management
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.simple / src / main / java / org / argeo / slc / core / test / tree / TreeTestResult.java
index b5d78a7da1663c088d019ae795c00f91e2fa273d..c7fa530ace9a8a6b4ff9856cf74cf84fd1ee8c55 100644 (file)
@@ -1,5 +1,6 @@
 package org.argeo.slc.core.test.tree;\r
 \r
+import java.util.ArrayList;\r
 import java.util.Date;\r
 import java.util.List;\r
 import java.util.Map;\r
@@ -10,6 +11,8 @@ import java.util.Vector;
 import org.apache.commons.logging.Log;\r
 import org.apache.commons.logging.LogFactory;\r
 import org.argeo.slc.SlcException;\r
+import org.argeo.slc.core.attachment.Attachment;\r
+import org.argeo.slc.core.attachment.AttachmentsEnabled;\r
 import org.argeo.slc.core.structure.tree.TreeSPath;\r
 import org.argeo.slc.structure.StructureAware;\r
 import org.argeo.slc.structure.StructureElement;\r
@@ -25,7 +28,7 @@ import org.argeo.slc.test.TestRunAware;
  * structure.\r
  */\r
 public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,\r
-               Comparable<TreeTestResult> {\r
+               Comparable<TreeTestResult>, AttachmentsEnabled {\r
        private Log log = LogFactory.getLog(TreeTestResult.class);\r
 \r
        private List<TestResultListener<TreeTestResult>> listeners = new Vector<TestResultListener<TreeTestResult>>();\r
@@ -43,6 +46,7 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
 \r
        private SortedMap<TreeSPath, PartSubList> resultParts = new TreeMap<TreeSPath, PartSubList>();\r
        private SortedMap<TreeSPath, StructureElement> elements = new TreeMap<TreeSPath, StructureElement>();\r
+       private List<Attachment> attachments = new ArrayList<Attachment>();\r
 \r
        private Map<String, String> attributes = new TreeMap<String, String>();\r
 \r
@@ -133,7 +137,6 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
                        for (TestResultListener<TreeTestResult> listener : listeners) {\r
                                listener.close(this);\r
                        }\r
-                       listeners.clear();\r
                }\r
                isClosed = true;\r
 \r
@@ -216,4 +219,23 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
                this.warnIfAlreadyClosed = warnIfAlreadyClosed;\r
        }\r
 \r
+       public List<Attachment> getAttachments() {\r
+               return attachments;\r
+       }\r
+\r
+       public void setAttachments(List<Attachment> attachments) {\r
+               this.attachments = attachments;\r
+       }\r
+\r
+       public void addAttachment(Attachment attachment) {\r
+               attachments.add(attachment);\r
+               synchronized (listeners) {\r
+                       for (TestResultListener<TreeTestResult> listener : listeners) {\r
+                               if (listener instanceof TreeTestResultListener)\r
+                                       ((TreeTestResultListener) listener).addAttachment(this,\r
+                                                       attachment);\r
+                       }\r
+               }\r
+       }\r
+\r
 }\r