]> git.argeo.org Git - gpl/argeo-slc.git/commitdiff
Make trees test result less strict with closed tree test results
authorMathieu Baudier <mbaudier@argeo.org>
Thu, 30 Jul 2009 12:40:01 +0000 (12:40 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Thu, 30 Jul 2009 12:40:01 +0000 (12:40 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@2836 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResult.java

index 789d468ae9940a8c41be908e7eddceb1875527c1..dc9de9a5114a3bb7adfecf3a98dd3d4955e43dd3 100644 (file)
@@ -34,7 +34,7 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
                Comparable<TreeTestResult>, AttachmentsEnabled, Serializable {\r
        private static final long serialVersionUID = 1L;\r
 \r
-       private Log log = LogFactory.getLog(TreeTestResult.class);\r
+       private final static Log log = LogFactory.getLog(TreeTestResult.class);\r
 \r
        private List<TestResultListener<TreeTestResult>> listeners = new Vector<TestResultListener<TreeTestResult>>();\r
 \r
@@ -55,6 +55,8 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
 \r
        private Map<String, String> attributes = new TreeMap<String, String>();\r
 \r
+       private Boolean strictChecks = false;\r
+\r
        /** Sets the list of listeners. */\r
        public void setListeners(List<TestResultListener<TreeTestResult>> listeners) {\r
                this.listeners = listeners;\r
@@ -62,8 +64,12 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
 \r
        public void addResultPart(TestResultPart part) {\r
                if (isClosed)\r
-                       throw new SlcException("Cannot result parts to a closed result");\r
-\r
+                       notifyIssue(\r
+                                       "Trying to add result parts to an already closed result,"\r
+                                                       + " consider changing the scope of this test result:"\r
+                                                       + " you are referencing the same stored data with each new call.",\r
+                                       null);\r
+               \r
                if (currentPath == null)\r
                        throw new SlcException("No current path set.");\r
 \r
@@ -85,6 +91,13 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
                }\r
        }\r
 \r
+       protected void notifyIssue(String msg, Exception e) {\r
+               if (strictChecks)\r
+                       throw new SlcException(msg, e);\r
+               else\r
+                       log.error(msg, e);\r
+       }\r
+\r
        public void notifyCurrentPath(StructureRegistry<TreeSPath> registry,\r
                        TreeSPath path) {\r
                if (registry != null) {\r
@@ -271,4 +284,8 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
                }\r
        }\r
 \r
+       public void setStrictChecks(Boolean strictChecks) {\r
+               this.strictChecks = strictChecks;\r
+       }\r
+\r
 }\r