]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResult.java
Introduce examples modules
[gpl/argeo-slc.git] / org.argeo.slc.core / src / main / java / org / argeo / slc / core / test / tree / TreeTestResult.java
index 781c6eee2a1cc29124f4cf4eee44d82d29133633..3e365afe0822c6f28b51f3f835d89189a6fd7328 100644 (file)
@@ -35,7 +35,9 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
 \r
        private Date closeDate;\r
 \r
-       private boolean isClosed = false;\r
+       private Boolean isClosed = false;\r
+\r
+       private Boolean warnIfAlreadyClosed = true;\r
 \r
        private String uuid;\r
 \r
@@ -50,9 +52,12 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
        }\r
 \r
        public void addResultPart(TestResultPart part) {\r
-               if (currentPath == null) {\r
+               if (isClosed)\r
+                       throw new SlcException("Cannot result parts to a closed result");\r
+\r
+               if (currentPath == null)\r
                        throw new SlcException("No current path set.");\r
-               }\r
+\r
                PartSubList subList = resultParts.get(currentPath);\r
                if (subList == null) {\r
                        subList = new PartSubList();\r
@@ -108,10 +113,20 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
        }\r
 \r
        public void close() {\r
+               if (resultParts.size() == 0) {\r
+                       if (log.isTraceEnabled())\r
+                               log.trace("Test Result #" + getUuid()\r
+                                               + " contains no results, no need to close it.");\r
+                       return;\r
+               }\r
+\r
                if (isClosed) {\r
-                       throw new SlcException("Test Result #" + getUuid()\r
-                                       + " already closed.");\r
+                       if (warnIfAlreadyClosed)\r
+                               log.warn("Test Result #" + getUuid()\r
+                                               + " already closed. Doing nothing.");\r
+                       return;\r
                }\r
+\r
                closeDate = new Date();\r
 \r
                synchronized (listeners) {\r
@@ -196,4 +211,9 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
        public void setAttributes(Map<String, String> attributes) {\r
                this.attributes = attributes;\r
        }\r
+\r
+       public void setWarnIfAlreadyClosed(Boolean warnIfAlreadyClosed) {\r
+               this.warnIfAlreadyClosed = warnIfAlreadyClosed;\r
+       }\r
+\r
 }\r