Revert changes in result parts
authorMathieu Baudier <mbaudier@argeo.org>
Sun, 11 Nov 2007 19:34:31 +0000 (19:34 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Sun, 11 Nov 2007 19:34:31 +0000 (19:34 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@701 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

org.argeo.slc/src/main/java/org/argeo/slc/ant/SlcAntConfig.java
org.argeo.slc/src/main/java/org/argeo/slc/ant/taskdefs.properties
org.argeo.slc/src/main/java/org/argeo/slc/core/test/SimpleResultPart.java
org.argeo.slc/src/main/java/org/argeo/slc/core/test/TestDefinition.java
org.argeo.slc/src/main/java/org/argeo/slc/core/test/TestResultPart.java
org.argeo.slc/src/main/java/org/argeo/slc/core/test/TestStatus.java
org.argeo.slc/src/main/java/org/argeo/slc/core/test/tree/FullHtmlTreeReport.java
org.argeo.slc/src/test/java/org/argeo/slc/example/ExampleTask.java

index 93502245d080a862c27304526d68c7156461de19..e845b07197baebcbdda4a4033b4debe07e7dc47c 100644 (file)
@@ -165,6 +165,8 @@ public class SlcAntConfig {
         */\r
        protected Properties prepareAllProperties(File slcRootFile) {\r
                try {\r
+                       final String fileUrlPrefix ="";\r
+\r
                        Properties all = new Properties();\r
                        all.putAll(System.getProperties());\r
                        all.put(ROOT_FILE_PROPERTY, slcRootFile.getCanonicalPath());\r
@@ -175,14 +177,16 @@ public class SlcAntConfig {
                        final File workDir;\r
                        // Root dir\r
                        final File rootDir = slcRootFile.getParentFile();\r
-                       all.setProperty(ROOT_DIR_PROPERTY, rootDir.getCanonicalPath());\r
+                       all.setProperty(ROOT_DIR_PROPERTY, fileUrlPrefix\r
+                                       + rootDir.getCanonicalPath());\r
 \r
                        // Conf dir\r
                        if (all.getProperty(CONF_DIR_PROPERTY) == null) {\r
                                confDir = new File(rootProps.getProperty(CONF_DIR_PROPERTY,\r
                                                rootDir.getAbsolutePath() + "/../conf"))\r
                                                .getCanonicalFile();\r
-                               all.setProperty(CONF_DIR_PROPERTY, confDir.getAbsolutePath());\r
+                               all.setProperty(CONF_DIR_PROPERTY, fileUrlPrefix\r
+                                               + confDir.getAbsolutePath());\r
                        } else {\r
                                confDir = new File(all.getProperty(CONF_DIR_PROPERTY))\r
                                                .getCanonicalFile();\r
@@ -193,7 +197,8 @@ public class SlcAntConfig {
                                workDir = new File(rootProps.getProperty(WORK_DIR_PROPERTY,\r
                                                rootDir.getAbsolutePath() + "/../work"))\r
                                                .getCanonicalFile();\r
-                               all.setProperty(WORK_DIR_PROPERTY, workDir.getAbsolutePath());\r
+                               all.setProperty(WORK_DIR_PROPERTY, fileUrlPrefix\r
+                                               + workDir.getAbsolutePath());\r
                        } else {\r
                                workDir = new File(all.getProperty(WORK_DIR_PROPERTY))\r
                                                .getCanonicalFile();\r
index 4944b63a4fa2650f6905cb0ecebe5c0f0c63040b..7ae6f6839311014ca82f46ad945f3ec8a273229d 100644 (file)
@@ -1,3 +1,4 @@
+# Tasks\r
 slc.test=org.argeo.slc.ant.test.SlcTestTask\r
 slc.deploy=org.argeo.slc.ant.deploy.SlcDeployTask\r
 slc.closeResult=org.argeo.slc.ant.test.SlcCloseTestResultTask\r
index 6ea2d9dbfa197563c26b3abe8899e6463dbb48a4..97b937fa8263226d19aa4ef5e9827d6dc97d87db 100644 (file)
@@ -5,33 +5,25 @@ package org.argeo.slc.core.test;
  * Basic implementation of a result part, implementing the standard three status\r
  * approach for test results.\r
  * </p>\r
- * <p>\r
- * <ul>\r
- * <li>{@link #PASSED}: the test succeeded</li>\r
- * <li>{@link #FAILED}: the test could run, but did not reach the expected\r
- * result</li>\r
- * <li>{@link #ERROR}: an error during the test run prevented to get a\r
- * significant information on the tested system.</li>\r
- * </ul>\r
- * </p>\r
+ * @see TestStatus\r
  */\r
-public class SimpleResultPart implements TestResultPart {\r
+public class SimpleResultPart implements TestResultPart, TestStatus {\r
+\r
        /** For ORM */\r
        private Long tid;\r
 \r
-       private TestStatus status;\r
+       private Integer status;\r
        private String message;\r
        private Throwable exception;\r
 \r
-       \r
-       /** Empty constructor for ORM */\r
-       public SimpleResultPart(){\r
-               \r
+       public SimpleResultPart() {\r
        }\r
-       \r
-       public SimpleResultPart(TestStatus status, String message,\r
-                       Throwable exception) {\r
-               super();\r
+\r
+       public SimpleResultPart(Integer status, String message) {\r
+               this(status, message, null);\r
+       }\r
+\r
+       public SimpleResultPart(Integer status, String message, Throwable exception) {\r
                this.status = status;\r
                this.message = message;\r
                this.exception = exception;\r
@@ -45,11 +37,11 @@ public class SimpleResultPart implements TestResultPart {
                this.message = message;\r
        }\r
 \r
-       public void setStatus(TestStatus status) {\r
+       public void setStatus(Integer status) {\r
                this.status = status;\r
        }\r
 \r
-       public TestStatus getStatus() {\r
+       public Integer getStatus() {\r
                return status;\r
        }\r
 \r
@@ -64,7 +56,13 @@ public class SimpleResultPart implements TestResultPart {
        @Override\r
        public String toString() {\r
                StringBuffer buf = new StringBuffer("");\r
-               buf.append(status).append(" ");\r
+               if (status == PASSED) {\r
+                       buf.append("PASSED ");\r
+               } else if (status == FAILED) {\r
+                       buf.append("FAILED ");\r
+               } else if (status == ERROR) {\r
+                       buf.append("ERROR  ");\r
+               }\r
                buf.append(message);\r
                if (exception != null) {\r
                        buf.append("(").append(exception.getMessage()).append(")");\r
index 77ee482807732546dfb77534bb6c3ba8e948eca4..7c75d6a73a898140942ef74202fb9c28956fcd53 100644 (file)
@@ -4,7 +4,7 @@ package org.argeo.slc.core.test;
  * The programmatic definition of a test, which will be associated with\r
  * transient objects within a test run.\r
  */\r
-public interface TestDefinition {\r
+public interface TestDefinition extends TestStatus {\r
        /** Performs the test. */\r
        public void execute(TestRun testRun);\r
 }\r
index 844f6c419e84c10fea2124f463cd339dbdb8154b..3d56a5f11f2bba6ee86f4029af3fff1dae06acbe 100644 (file)
@@ -5,8 +5,8 @@ package org.argeo.slc.core.test;
  * \r
  * @see TestResult\r
  */\r
-public interface TestResultPart {\r
-       public TestStatus getStatus();\r
+public interface TestResultPart {      \r
+       public Integer getStatus();\r
 \r
        public String getMessage();\r
 }\r
index bda5a74ab2bc6da363e427742c2da89cd73745e2..9f7f6e82178f6249402111380934c9f41b619f3a 100644 (file)
@@ -1,14 +1,25 @@
 package org.argeo.slc.core.test;\r
 \r
-/** Simple statuses. */\r
-public enum TestStatus {\r
-       /** Test passed */\r
-       PASSED,\r
-       /** Test failed: the behavior was not the expected one */\r
-       FAILED,\r
+/**\r
+ * Simple statuses. \r
+ * <p>\r
+ * <ul>\r
+ * <li>{@link #PASSED}: the test succeeded</li>\r
+ * <li>{@link #FAILED}: the test could run, but did not reach the expected\r
+ * result</li>\r
+ * <li>{@link #ERROR}: an error during the test run prevented to get a\r
+ * significant information on the tested system.</li>\r
+ * </ul>\r
+ * </p>\r
+ */\r
+public interface TestStatus {\r
+       /** The flag for a passed test: 0 */\r
+       public final static int PASSED = 0;\r
+       /** The flag for a failed test: 1 */\r
+       public final static int FAILED = 1;\r
        /**\r
-        * Test could not run properly because of an unexpected issue: their can be\r
-        * no feedback on the behavior of the tested component\r
+        * The flag for a test which could not properly run because of an error\r
+        * (there is no feedback on the behavior of the tested component): 2\r
         */\r
-       ERROR\r
+       public final static int ERROR = 2;\r
 }\r
index 7aec7c1b3701c21116e99915db91be295effd304..1144e27935a66b2654cec014b2016118e956dd62 100644 (file)
@@ -11,6 +11,7 @@ import org.argeo.slc.core.structure.StructurePath;
 import org.argeo.slc.core.structure.StructureRegistry;\r
 import org.argeo.slc.core.structure.tree.TreeSPath;\r
 import org.argeo.slc.core.test.SimpleResultPart;\r
+import org.argeo.slc.core.test.SimpleTestResult;\r
 import org.argeo.slc.core.test.TestStatus;\r
 import org.argeo.slc.core.test.TestReport;\r
 import org.argeo.slc.core.test.TestResult;\r
@@ -109,7 +110,7 @@ public class FullHtmlTreeReport implements TestReport, StructureAware {
                        for (TestResultPart part : subList.getParts()) {\r
                                SimpleResultPart sPart = (SimpleResultPart) part;\r
                                String color = "yellow";\r
-                               if (sPart.getStatus() == TestStatus.PASSED) {\r
+                               if (sPart.getStatus().equals(SimpleResultPart.PASSED)) {\r
                                        color = "green";\r
                                } else {\r
                                        color = "red";\r
index 52e06bd59fe829dcd7b0f898422b93dffd5b2736..4feafac532c37a1e30802fa71ba39d3b77b1f6c6 100644 (file)
@@ -6,7 +6,6 @@ import org.argeo.slc.core.structure.StructurePath;
 import org.argeo.slc.core.structure.StructureRegistry;\r
 import org.argeo.slc.core.structure.tree.TreeSPath;\r
 import org.argeo.slc.core.test.SimpleResultPart;\r
-import org.argeo.slc.core.test.TestStatus;\r
 import org.argeo.slc.core.test.TestDefinition;\r
 import org.argeo.slc.core.test.TestResult;\r
 import org.argeo.slc.core.test.TestRun;\r
@@ -17,9 +16,8 @@ public class ExampleTask implements StructureAware, TestDefinition,
        private String description;\r
 \r
        public void execute(TestRun testRun) {\r
-               SimpleResultPart part = new SimpleResultPart();\r
-               part.setStatus(TestStatus.PASSED);\r
-               part.setMessage("Sub task with path " + path + " executed");\r
+               SimpleResultPart part = new SimpleResultPart(PASSED,\r
+                               "Sub task with path " + path + " executed", null);\r
 \r
                TestResult result = testRun.getTestResult();\r
                result.addResultPart(part);\r