X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.core%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fcore%2Ftest%2Ftree%2FTreeTestResult.java;h=eadfbef58a128ecc1f374d71744634c871b0cd9e;hb=2916f0d4e65111ecf97e16517f490be25c878ed9;hp=7a90133d6418a01434be38fe3ef7a3cafcd128d2;hpb=ee6c3543a0ff9403420ce6a9c647723269f14331;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResult.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResult.java index 7a90133d6..eadfbef58 100644 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResult.java +++ b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResult.java @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2010 Mathieu Baudier + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.argeo.slc.core.test.tree; import java.io.Serializable; @@ -7,6 +23,7 @@ import java.util.List; import java.util.Map; import java.util.SortedMap; import java.util.TreeMap; +import java.util.UUID; import java.util.Vector; import org.apache.commons.logging.Log; @@ -31,29 +48,31 @@ import org.argeo.slc.test.TestRunAware; */ public class TreeTestResult implements TestResult, StructureAware, Comparable, AttachmentsEnabled, Serializable { - private static final long serialVersionUID = 1L; - private Log log = LogFactory.getLog(TreeTestResult.class); - - private List> listeners = new Vector>(); - - private TreeSPath currentPath; - private TestRun currentTestRun; + private static final long serialVersionUID = 1L; + private final static Log log = LogFactory.getLog(TreeTestResult.class); + // Persistence data + private String uuid = UUID.randomUUID().toString(); private Date closeDate; - private Boolean isClosed = false; - - private Boolean warnIfAlreadyClosed = true; - - private String uuid; - private SortedMap resultParts = new TreeMap(); private SortedMap elements = new TreeMap(); private List attachments = new ArrayList(); + // Headers. Used to accelerate request on a specific test result. private Map attributes = new TreeMap(); + // Runtime Data + private TreeSPath currentPath; + private transient TestRun currentTestRun; + private Boolean warnIfAlreadyClosed = true; + private Boolean strictChecks = false; + // TODO is it really necessary closeDate == null ? + private Boolean isClosed = false; + + private transient List> listeners = new Vector>(); + /** Sets the list of listeners. */ public void setListeners(List> listeners) { this.listeners = listeners; @@ -61,7 +80,11 @@ public class TreeTestResult implements TestResult, StructureAware, public void addResultPart(TestResultPart part) { if (isClosed) - throw new SlcException("Cannot result parts to a closed result"); + notifyIssue( + "Trying to add result parts to an already closed result," + + " consider changing the scope of this test result:" + + " you are referencing the same stored data with each new call.", + null); if (currentPath == null) throw new SlcException("No current path set."); @@ -84,6 +107,13 @@ public class TreeTestResult implements TestResult, StructureAware, } } + protected void notifyIssue(String msg, Exception e) { + if (strictChecks) + throw new SlcException(msg, e); + else + log.error(msg, e); + } + public void notifyCurrentPath(StructureRegistry registry, TreeSPath path) { if (registry != null) { @@ -115,8 +145,10 @@ public class TreeTestResult implements TestResult, StructureAware, return resultParts; } - /** Used by ORM systems. */ - void setResultParts(SortedMap resultParts) { + /** + * Used by ORM systems. Changed to public in order to enable jcr persistence + */ + public void setResultParts(SortedMap resultParts) { this.resultParts = resultParts; } @@ -270,4 +302,8 @@ public class TreeTestResult implements TestResult, StructureAware, } } + public void setStrictChecks(Boolean strictChecks) { + this.strictChecks = strictChecks; + } + }