X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.slc.core%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fcore%2Ftest%2Ftree%2FTreeTestResult.java;h=3e365afe0822c6f28b51f3f835d89189a6fd7328;hb=7a8f034133c1112e187e2a2bfd2c56a8d2452345;hp=781c6eee2a1cc29124f4cf4eee44d82d29133633;hpb=3e9377296723ae3d8bb8a6efcdaf9828ff2e4139;p=gpl%2Fargeo-slc.git diff --git a/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResult.java b/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResult.java index 781c6eee2..3e365afe0 100644 --- a/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResult.java +++ b/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResult.java @@ -35,7 +35,9 @@ public class TreeTestResult implements TestResult, StructureAware, private Date closeDate; - private boolean isClosed = false; + private Boolean isClosed = false; + + private Boolean warnIfAlreadyClosed = true; private String uuid; @@ -50,9 +52,12 @@ public class TreeTestResult implements TestResult, StructureAware, } public void addResultPart(TestResultPart part) { - if (currentPath == null) { + if (isClosed) + throw new SlcException("Cannot result parts to a closed result"); + + if (currentPath == null) throw new SlcException("No current path set."); - } + PartSubList subList = resultParts.get(currentPath); if (subList == null) { subList = new PartSubList(); @@ -108,10 +113,20 @@ public class TreeTestResult implements TestResult, StructureAware, } public void close() { + if (resultParts.size() == 0) { + if (log.isTraceEnabled()) + log.trace("Test Result #" + getUuid() + + " contains no results, no need to close it."); + return; + } + if (isClosed) { - throw new SlcException("Test Result #" + getUuid() - + " already closed."); + if (warnIfAlreadyClosed) + log.warn("Test Result #" + getUuid() + + " already closed. Doing nothing."); + return; } + closeDate = new Date(); synchronized (listeners) { @@ -196,4 +211,9 @@ public class TreeTestResult implements TestResult, StructureAware, public void setAttributes(Map attributes) { this.attributes = attributes; } + + public void setWarnIfAlreadyClosed(Boolean warnIfAlreadyClosed) { + this.warnIfAlreadyClosed = warnIfAlreadyClosed; + } + }