Basic reporting
authorMathieu Baudier <mbaudier@argeo.org>
Sun, 28 Oct 2007 19:35:45 +0000 (19:35 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Sun, 28 Oct 2007 19:35:45 +0000 (19:35 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@669 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

18 files changed:
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/ant/test/SlcCloseTestResultTask.java [new file with mode: 0644]
org.argeo.slc/src/main/java/org/argeo/slc/core/test/SimpleResultPart.java
org.argeo.slc/src/main/java/org/argeo/slc/core/test/TestReport.java [new file with mode: 0644]
org.argeo.slc/src/main/java/org/argeo/slc/core/test/TestResult.java
org.argeo.slc/src/main/java/org/argeo/slc/core/test/TestResultListener.java
org.argeo.slc/src/main/java/org/argeo/slc/core/test/tree/AsynchronousTreeTestResultListener.java
org.argeo.slc/src/main/java/org/argeo/slc/core/test/tree/FullHtmlTreeReport.java [new file with mode: 0644]
org.argeo.slc/src/main/java/org/argeo/slc/core/test/tree/TreeTestResult.java
org.argeo.slc/src/main/java/org/argeo/slc/core/test/tree/TreeTestResultPersister.java
org.argeo.slc/src/main/java/org/argeo/slc/hibernate/test/tree/PartSubList.hbm.xml
org.argeo.slc/src/test/java/org/argeo/slc/example/SimpleExampleTestDef.java
org.argeo.slc/src/test/java/org/argeo/slc/example/junit/TestAntBuild.java
org.argeo.slc/src/test/slc/conf/data.xml
org.argeo.slc/src/test/slc/conf/log4j.properties
org.argeo.slc/src/test/slc/root/Category1/SubCategory2/build.xml
org.argeo.slc/src/test/slc/work/data/input/nato-in.txt

index 755c063bc34ae35618df78c165d037007f3f690b..2487b20eafec7467836010ad266d817eebb0cab0 100644 (file)
@@ -45,142 +45,83 @@ public class SlcAntConfig {
                                project.setUserProperty(key, all.getProperty(key));\r
                        }\r
                }\r
-\r
-               /*\r
-               Properties rootProps = loadFile(slcRootFile.getAbsolutePath());\r
-\r
-               final File confDir;\r
-               final File workDir;\r
-               // Root dir\r
-               final File rootDir = slcRootFile.getParentFile();\r
-               project.setUserProperty(ROOT_DIR_PROPERTY, rootDir.getAbsolutePath());\r
-\r
-               // Conf dir\r
-               if (project.getUserProperty(CONF_DIR_PROPERTY) == null) {\r
-                       confDir = new File(rootProps.getProperty(CONF_DIR_PROPERTY, rootDir\r
-                                       .getAbsolutePath()\r
-                                       + "/../conf")).getAbsoluteFile();\r
-                       project.setUserProperty(CONF_DIR_PROPERTY, confDir\r
-                                       .getAbsolutePath());\r
-               } else {\r
-                       confDir = new File(project.getUserProperty(CONF_DIR_PROPERTY))\r
-                                       .getAbsoluteFile();\r
-               }\r
-\r
-               // Work dir\r
-               if (project.getUserProperty(WORK_DIR_PROPERTY) == null) {\r
-                       workDir = new File(rootProps.getProperty(WORK_DIR_PROPERTY, rootDir\r
-                                       .getAbsolutePath()\r
-                                       + "/../work")).getAbsoluteFile();\r
-                       project.setUserProperty(WORK_DIR_PROPERTY, workDir\r
-                                       .getAbsolutePath());\r
-               } else {\r
-                       workDir = new File(project.getUserProperty(WORK_DIR_PROPERTY))\r
-                                       .getAbsoluteFile();\r
-               }\r
-\r
-               // Properties from the conf dir files\r
-               Properties properties = new Properties();\r
-               StringTokenizer st = new StringTokenizer(rootProps.getProperty(\r
-                               PROPERTY_FILE_NAMES_PROPERTY, "slc.properties"), ",");\r
-               while (st.hasMoreTokens()) {\r
-                       String fileName = st.nextToken();\r
-                       properties.putAll(loadFile(confDir.getAbsolutePath() + "/"\r
-                                       + fileName));\r
-               }\r
-\r
-               for (Object o : properties.keySet()) {\r
-                       String key = o.toString();\r
-                       if (project.getUserProperty(key) == null) {// not already set\r
-                               project.setUserProperty(key, properties.getProperty(key));\r
-                       }\r
-               }\r
-\r
-               // Default application context\r
-               if (project.getUserProperty(APPLICATION_CONTEXT_PROPERTY) == null) {\r
-                       project.setUserProperty(APPLICATION_CONTEXT_PROPERTY, confDir\r
-                                       .getAbsolutePath()\r
-                                       + "/applicationContext.xml");\r
-               }\r
-               // Default test run\r
-               if (project.getUserProperty(DEFAULT_TEST_RUN_PROPERTY) == null) {\r
-                       project\r
-                                       .setUserProperty(DEFAULT_TEST_RUN_PROPERTY,\r
-                                                       "defaultTestRun");\r
-               }\r
-               */\r
        }\r
 \r
        public static Properties prepareAllProperties() {\r
-               Properties all = new Properties();\r
-               all.putAll(System.getProperties());\r
+               try {\r
+                       Properties all = new Properties();\r
+                       all.putAll(System.getProperties());\r
 \r
-               if (all.getProperty(ROOT_FILE_PROPERTY) == null) {\r
-                       throw new RuntimeException("System Property " + ROOT_FILE_PROPERTY\r
-                                       + " has to be set.");\r
-               }\r
+                       if (all.getProperty(ROOT_FILE_PROPERTY) == null) {\r
+                               throw new RuntimeException("System Property "\r
+                                               + ROOT_FILE_PROPERTY + " has to be set.");\r
+                       }\r
 \r
-               File slcRootFile = new File(all.getProperty(ROOT_FILE_PROPERTY))\r
-                               .getAbsoluteFile();\r
-               Properties rootProps = loadFile(slcRootFile.getAbsolutePath());\r
-\r
-               final File confDir;\r
-               final File workDir;\r
-               // Root dir\r
-               final File rootDir = slcRootFile.getParentFile();\r
-               all.setProperty(ROOT_DIR_PROPERTY, rootDir.getAbsolutePath());\r
-\r
-               // Conf dir\r
-               if (all.getProperty(CONF_DIR_PROPERTY) == null) {\r
-                       confDir = new File(rootProps.getProperty(CONF_DIR_PROPERTY, rootDir\r
-                                       .getAbsolutePath()\r
-                                       + "/../conf")).getAbsoluteFile();\r
-                       all.setProperty(CONF_DIR_PROPERTY, confDir.getAbsolutePath());\r
-               } else {\r
-                       confDir = new File(all.getProperty(CONF_DIR_PROPERTY))\r
+                       File slcRootFile = new File(all.getProperty(ROOT_FILE_PROPERTY))\r
                                        .getAbsoluteFile();\r
-               }\r
+                       Properties rootProps = loadFile(slcRootFile.getAbsolutePath());\r
+\r
+                       final File confDir;\r
+                       final File workDir;\r
+                       // Root dir\r
+                       final File rootDir = slcRootFile.getParentFile();\r
+                       all.setProperty(ROOT_DIR_PROPERTY, 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
+                       } else {\r
+                               confDir = new File(all.getProperty(CONF_DIR_PROPERTY))\r
+                                               .getCanonicalFile();\r
+                       }\r
 \r
-               // Work dir\r
-               if (all.getProperty(WORK_DIR_PROPERTY) == null) {\r
-                       workDir = new File(rootProps.getProperty(WORK_DIR_PROPERTY, rootDir\r
-                                       .getAbsolutePath()\r
-                                       + "/../work")).getAbsoluteFile();\r
-                       all.setProperty(WORK_DIR_PROPERTY, workDir.getAbsolutePath());\r
-               } else {\r
-                       workDir = new File(all.getProperty(WORK_DIR_PROPERTY))\r
-                                       .getAbsoluteFile();\r
-               }\r
+                       // Work dir\r
+                       if (all.getProperty(WORK_DIR_PROPERTY) == null) {\r
+                               workDir = new File(rootProps.getProperty(WORK_DIR_PROPERTY,\r
+                                               rootDir.getAbsolutePath() + "/../work"))\r
+                                               .getCanonicalFile();\r
+                               all.setProperty(WORK_DIR_PROPERTY, workDir.getAbsolutePath());\r
+                       } else {\r
+                               workDir = new File(all.getProperty(WORK_DIR_PROPERTY))\r
+                                               .getCanonicalFile();\r
+                       }\r
 \r
-               // Properties from the conf dir files\r
-               Properties properties = new Properties();\r
-               StringTokenizer st = new StringTokenizer(rootProps.getProperty(\r
-                               PROPERTY_FILE_NAMES_PROPERTY, "slc.properties"), ",");\r
-               while (st.hasMoreTokens()) {\r
-                       String fileName = st.nextToken();\r
-                       properties.putAll(loadFile(confDir.getAbsolutePath() + "/"\r
-                                       + fileName));\r
-               }\r
+                       // Properties from the conf dir files\r
+                       Properties properties = new Properties();\r
+                       StringTokenizer st = new StringTokenizer(rootProps.getProperty(\r
+                                       PROPERTY_FILE_NAMES_PROPERTY, "slc.properties"), ",");\r
+                       while (st.hasMoreTokens()) {\r
+                               String fileName = st.nextToken();\r
+                               properties.putAll(loadFile(confDir.getAbsolutePath() + "/"\r
+                                               + fileName));\r
+                       }\r
 \r
-               for (Object o : properties.keySet()) {\r
-                       String key = o.toString();\r
-                       if (all.getProperty(key) == null) {// not already set\r
-                               all.setProperty(key, properties.getProperty(key));\r
+                       for (Object o : properties.keySet()) {\r
+                               String key = o.toString();\r
+                               if (all.getProperty(key) == null) {// not already set\r
+                                       all.setProperty(key, properties.getProperty(key));\r
+                               }\r
                        }\r
-               }\r
 \r
-               // Default application context\r
-               if (all.getProperty(APPLICATION_CONTEXT_PROPERTY) == null) {\r
-                       all.setProperty(APPLICATION_CONTEXT_PROPERTY, confDir\r
-                                       .getAbsolutePath()\r
-                                       + "/applicationContext.xml");\r
-               }\r
-               // Default test run\r
-               if (all.getProperty(DEFAULT_TEST_RUN_PROPERTY) == null) {\r
-                       all.setProperty(DEFAULT_TEST_RUN_PROPERTY, "defaultTestRun");\r
-               }\r
+                       // Default application context\r
+                       if (all.getProperty(APPLICATION_CONTEXT_PROPERTY) == null) {\r
+                               all.setProperty(APPLICATION_CONTEXT_PROPERTY, confDir\r
+                                               .getAbsolutePath()\r
+                                               + "/applicationContext.xml");\r
+                       }\r
+                       // Default test run\r
+                       if (all.getProperty(DEFAULT_TEST_RUN_PROPERTY) == null) {\r
+                               all.setProperty(DEFAULT_TEST_RUN_PROPERTY, "defaultTestRun");\r
+                       }\r
 \r
-               return all;\r
+                       return all;\r
+               } catch (Exception e) {\r
+                       throw new SlcAntException("Unexpected exception while configuring",\r
+                                       e);\r
+               }\r
        }\r
 \r
        public static Properties loadFile(String path) {\r
index 4df33bd69ec3dca1a8ebcb8d007e157db4561d4a..b0d1550edfe825ba57e09dec8eadd2c1ab0f6c06 100644 (file)
@@ -1 +1,2 @@
-slc.test=org.argeo.slc.ant.test.SlcTestTask
\ No newline at end of file
+slc.test=org.argeo.slc.ant.test.SlcTestTask\r
+slc.closeResult=org.argeo.slc.ant.test.SlcCloseTestResultTask\r
diff --git a/org.argeo.slc/src/main/java/org/argeo/slc/ant/test/SlcCloseTestResultTask.java b/org.argeo.slc/src/main/java/org/argeo/slc/ant/test/SlcCloseTestResultTask.java
new file mode 100644 (file)
index 0000000..1a5bc7b
--- /dev/null
@@ -0,0 +1,30 @@
+package org.argeo.slc.ant.test;\r
+\r
+import org.argeo.slc.ant.spring.AbstractSpringTask;\r
+import org.argeo.slc.core.test.TestReport;\r
+import org.argeo.slc.core.test.TestResult;\r
+\r
+public class SlcCloseTestResultTask extends AbstractSpringTask {\r
+       private String result;\r
+       private String report;\r
+       \r
+       public void execute(){\r
+               TestResult testResult = (TestResult)getContext().getBean(result);\r
+               testResult.close();\r
+               \r
+               if(report!=null){\r
+                       TestReport testReport = (TestReport)getContext().getBean(report);\r
+                       testReport.generateTestReport(testResult);\r
+               }\r
+       }\r
+\r
+       public void setResult(String bean) {\r
+               this.result = bean;\r
+       }\r
+\r
+       public void setReport(String report) {\r
+               this.report = report;\r
+       }\r
+       \r
+       \r
+}\r
index 1c7c7e267f6ca51b08d873018f552137a7b880bb..62fd229fc112de6b9f23ce4ca7a87b15cf1e0f12 100644 (file)
@@ -2,9 +2,9 @@ package org.argeo.slc.core.test;
 \r
 public class SimpleResultPart implements TestResultPart {\r
 \r
-       public final static Integer PASSED = 1;\r
-       public final static Integer FAILED = 2;\r
-       public final static Integer ERROR = 3;\r
+       public final static int PASSED = 1;\r
+       public final static int FAILED = 2;\r
+       public final static int ERROR = 3;\r
 \r
        /** For ORM */\r
        private Long tid;\r
diff --git a/org.argeo.slc/src/main/java/org/argeo/slc/core/test/TestReport.java b/org.argeo.slc/src/main/java/org/argeo/slc/core/test/TestReport.java
new file mode 100644 (file)
index 0000000..51a97c9
--- /dev/null
@@ -0,0 +1,5 @@
+package org.argeo.slc.core.test;\r
+\r
+public interface TestReport {\r
+       public void generateTestReport(TestResult result);\r
+}\r
index f01c8fb42c4c430e4e319cb97d1fe34fc663e5b2..ec6b6babb27bbea118f74c1ada19fbcd6c5f834a 100644 (file)
@@ -4,4 +4,5 @@ package org.argeo.slc.core.test;
 public interface TestResult {\r
        public TestResultId getTestResultId();\r
        public void addResultPart(TestResultPart part);\r
+       public void close();\r
 }\r
index 15ec96d89bb525936d846448721c8381842769c7..adab823cf33a86bb99869802eea9865c3107847e 100644 (file)
@@ -3,4 +3,5 @@ package org.argeo.slc.core.test;
 public interface TestResultListener {\r
        public void resultPartAdded(TestResult testResult,\r
                        TestResultPart testResultPart);\r
+       public void close();\r
 }\r
index 13b3b25dfabe9d0fcab365df83ddbf7f9ed0b099..4a86aa2b4e657d6216963bc0822a0327d94fd062 100644 (file)
@@ -24,6 +24,21 @@ public abstract class AsynchronousTreeTestResultListener implements
                        partStructs.notifyAll();\r
                }\r
        }\r
+       \r
+       /** Finish the remaining and destroy*/\r
+       public void close(){\r
+               synchronized (partStructs) {\r
+                       // TODO: put a timeout\r
+                       while (partStructs.size() != 0) {\r
+                               try {\r
+                                       partStructs.wait();\r
+                               } catch (InterruptedException e) {\r
+                                       // silent\r
+                               }\r
+                       }\r
+                       destroy();\r
+               }\r
+       }\r
 \r
        public final void resultPartAdded(TestResult testResult,\r
                        TestResultPart testResultPart) {\r
@@ -36,6 +51,8 @@ public abstract class AsynchronousTreeTestResultListener implements
                }\r
        }\r
 \r
+       protected abstract void resultPartAdded(PartStruct partStruct);\r
+\r
        public void run() {\r
                while (thread != null) {\r
                        synchronized (partStructs) {\r
@@ -44,6 +61,7 @@ public abstract class AsynchronousTreeTestResultListener implements
                                }\r
 \r
                                partStructs.clear();\r
+                               partStructs.notifyAll();\r
                                while (partStructs.size() == 0) {\r
                                        try {\r
                                                partStructs.wait();\r
@@ -55,7 +73,6 @@ public abstract class AsynchronousTreeTestResultListener implements
                }\r
        }\r
 \r
-       protected abstract void resultPartAdded(PartStruct partStruct);\r
 \r
        protected static class PartStruct {\r
                public final TreeSPath path;\r
diff --git a/org.argeo.slc/src/main/java/org/argeo/slc/core/test/tree/FullHtmlTreeReport.java b/org.argeo.slc/src/main/java/org/argeo/slc/core/test/tree/FullHtmlTreeReport.java
new file mode 100644 (file)
index 0000000..9dd7610
--- /dev/null
@@ -0,0 +1,124 @@
+package org.argeo.slc.core.test.tree;\r
+\r
+import java.io.File;\r
+import java.io.FileWriter;\r
+import java.io.IOException;\r
+import java.util.List;\r
+\r
+import org.argeo.slc.core.structure.tree.TreeSPath;\r
+import org.argeo.slc.core.test.SimpleResultPart;\r
+import org.argeo.slc.core.test.TestReport;\r
+import org.argeo.slc.core.test.TestResult;\r
+import org.argeo.slc.core.test.TestResultPart;\r
+import org.argeo.slc.dao.test.TestResultDao;\r
+\r
+public class FullHtmlTreeReport implements TestReport {\r
+       private TestResultDao testResultDao;\r
+       private File reportDir;\r
+\r
+       public void generateTestReport(TestResult testResult) {\r
+               if (testResultDao == null) {\r
+                       TreeTestResult result = (TreeTestResult) testResult;\r
+                       generateResultPage(getResultFile(result), result);\r
+               } else {\r
+                       if (reportDir.exists()) {\r
+                               // clean\r
+                               for (File file : reportDir.listFiles()) {\r
+                                       file.delete();\r
+                               }\r
+                       }\r
+                       reportDir.mkdirs();\r
+\r
+                       StringBuffer index = new StringBuffer("");\r
+                       index\r
+                                       .append("<html><header><title>Results</title></header><body>\n<table border=1>\n");\r
+\r
+                       List<TestResult> list = testResultDao.listTestResults();\r
+                       for (TestResult testRes : list) {\r
+                               TreeTestResult res = (TreeTestResult) testRes;\r
+\r
+                               File file = getResultFile(res);\r
+                               index.append("<tr><td><a href=\"").append(file.getName())\r
+                                               .append("\">");\r
+                               index.append(res.getTestResultId()).append("</a></td></tr>\n");\r
+                               generateResultPage(file, res);\r
+                       }\r
+\r
+                       index.append("</table>\n</body></html>");\r
+\r
+                       try {\r
+                               FileWriter writer = new FileWriter(reportDir.getPath()\r
+                                               + File.separator + "index.html");\r
+                               writer.write(index.toString());\r
+                               writer.close();\r
+                       } catch (IOException e) {\r
+                               e.printStackTrace();\r
+                       }\r
+\r
+               }\r
+       }\r
+\r
+       protected void generateResultPage(File file, TreeTestResult result) {\r
+               StringBuffer buf = new StringBuffer("");\r
+               buf.append("<html>\n");\r
+               buf.append("<header><title>Result #").append(result.getTestResultId())\r
+                               .append("</title></header>\n");\r
+\r
+               buf.append("<body>\n");\r
+\r
+               buf.append("<h1>Result #").append(result.getTestResultId()).append(\r
+                               "</h1>\n");\r
+\r
+               buf.append("<table border=1>\n");\r
+               for (TreeSPath path : result.getResultParts().keySet()) {\r
+                       buf.append("<tr><td>").append(path).append("</td>\n");\r
+                       buf.append("<td>");\r
+                       PartSubList subList = (PartSubList) result.getResultParts().get(\r
+                                       path);\r
+                       buf.append("<table border=0>\n");\r
+                       for (TestResultPart part : subList.getParts()) {\r
+                               SimpleResultPart sPart = (SimpleResultPart) part;\r
+                               String color = "yellow";\r
+                               if (sPart.getStatus() == SimpleResultPart.PASSED) {\r
+                                       color = "green";\r
+                               } else {\r
+                                       color = "red";\r
+                               }\r
+                               buf.append("<tr><td style=\"color:").append(color)\r
+                                               .append("\">");\r
+\r
+                               buf.append(sPart.getMessage());\r
+                               buf.append("</td></tr>\n");\r
+                       }\r
+                       buf.append("</table>\n");\r
+\r
+                       buf.append("</td></tr>\n");\r
+               }\r
+               buf.append("</table>\n");\r
+\r
+               buf.append("</body>");\r
+               buf.append("</html>");\r
+\r
+               try {\r
+                       FileWriter writer = new FileWriter(file);\r
+                       writer.write(buf.toString());\r
+                       writer.close();\r
+               } catch (IOException e) {\r
+                       e.printStackTrace();\r
+               }\r
+       }\r
+\r
+       protected File getResultFile(TreeTestResult result) {\r
+               return new File(reportDir.getPath() + File.separator\r
+                               + result.getTestResultId() + ".html");\r
+       }\r
+\r
+       public void setTestResultDao(TestResultDao testResultDao) {\r
+               this.testResultDao = testResultDao;\r
+       }\r
+\r
+       public void setReportDir(File reportDir) {\r
+               this.reportDir = reportDir;\r
+       }\r
+\r
+}\r
index c333bf79f691baebd486faabcbd48d2a4a1b8b05..29f1c8d0616ff08407cd8b63c2a3957ed652d373 100644 (file)
@@ -26,8 +26,6 @@ public class TreeTestResult implements TestResult, StructureAware {
 \r
        private SortedMap<TreeSPath, PartSubList> resultParts = new TreeMap<TreeSPath, PartSubList>();\r
 \r
-\r
-       \r
        public TestResultId getTestResultId() {\r
                return testResultId;\r
        }\r
@@ -56,8 +54,10 @@ public class TreeTestResult implements TestResult, StructureAware {
                subList.getParts().add(part);\r
 \r
                // notify listeners\r
-               for (TestResultListener listener : listeners) {\r
-                       listener.resultPartAdded(this, part);\r
+               synchronized (listeners) {\r
+                       for (TestResultListener listener : listeners) {\r
+                               listener.resultPartAdded(this, part);\r
+                       }\r
                }\r
        }\r
 \r
@@ -77,6 +77,15 @@ public class TreeTestResult implements TestResult, StructureAware {
                this.resultParts = resultParts;\r
        }\r
 \r
+       public void close() {\r
+               synchronized (listeners) {\r
+                       for (TestResultListener listener : listeners) {\r
+                               listener.close();\r
+                       }\r
+                       listeners.clear();\r
+               }\r
+       }\r
+\r
        Long getTid() {\r
                return tid;\r
        }\r
index 16ec6facda707373ac4eb320640309b16642d658..17cf66499c463af4174eeb03ea748fec88f66b07 100644 (file)
@@ -1,32 +1,51 @@
 package org.argeo.slc.core.test.tree;\r
 \r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+\r
 import org.argeo.slc.dao.test.TestResultDao;\r
 \r
 public class TreeTestResultPersister extends AsynchronousTreeTestResultListener {\r
+       private static Log log = LogFactory.getLog(TreeTestResultPersister.class);\r
+\r
        private TestResultDao testResultDao;\r
 \r
        @Override\r
        protected void resultPartAdded(PartStruct partStruct) {\r
-               TreeTestResult persistedResult = (TreeTestResult) testResultDao\r
-                               .getTestResult(partStruct.resultId);\r
-               if (persistedResult == null) {\r
-                       persistedResult = new TreeTestResult();\r
-                       persistedResult.setNumericResultId(partStruct.resultId);\r
-                       PartSubList subList = new PartSubList();\r
-                       subList.getParts().add(partStruct.part);\r
-                       persistedResult.getResultParts().put(partStruct.path, subList);\r
-\r
-                       testResultDao.create(persistedResult);\r
-               } else {\r
-                       PartSubList subList = persistedResult.getResultParts().get(\r
-                                       partStruct.path);\r
-                       if (subList == null) {\r
-                               subList = new PartSubList();\r
+               try {\r
+                       TreeTestResult persistedResult = (TreeTestResult) testResultDao\r
+                                       .getTestResult(partStruct.resultId);\r
+                       if (persistedResult == null) {\r
+                               persistedResult = new TreeTestResult();\r
+                               persistedResult.setNumericResultId(partStruct.resultId);\r
+                               PartSubList subList = new PartSubList();\r
+                               subList.getParts().add(partStruct.part);\r
                                persistedResult.getResultParts().put(partStruct.path, subList);\r
-                       }\r
-                       subList.getParts().add(partStruct.part);\r
 \r
-                       testResultDao.update(persistedResult);\r
+                               testResultDao.create(persistedResult);\r
+                       } else {\r
+                               PartSubList subList = persistedResult.getResultParts().get(\r
+                                               partStruct.path);\r
+                               if (subList == null) {\r
+                                       subList = new PartSubList();\r
+                                       persistedResult.getResultParts().put(partStruct.path,\r
+                                                       subList);\r
+                               }\r
+                               persistedResult.getResultParts().get(partStruct.path)\r
+                                               .getParts().add(partStruct.part);\r
+\r
+                               if (log.isTraceEnabled()) {\r
+                                       log.trace("ResultId:" + persistedResult.getTestResultId());\r
+                                       log.trace("ResultParts size:"\r
+                                                       + persistedResult.getResultParts().size());\r
+                                       log.trace("Sublist size:" + subList.getParts().size());\r
+                                       log.trace("Part: " + partStruct.part);\r
+                               }\r
+                               testResultDao.update(persistedResult);\r
+                       }\r
+               } catch (Exception e) {\r
+                       log.error("Could not persist part for result #"\r
+                                       + partStruct.resultId, e);\r
                }\r
        }\r
 \r
index 158fe6d2d946807e5e275d2e9abd394492c2293a..f9740fe109d0358286a50c98332f8848f9ee9be6 100644 (file)
@@ -7,11 +7,12 @@
                <id name="tid" column="T_ID">\r
                        <generator class="native" />\r
                </id>\r
-               <list name="parts" table="SUB_LIST_PARTS"  cascade="all" lazy="false">\r
-                       <key column="PARENT_ID" unique="true" />\r
-                       <list-index column="INDEX" />\r
-                       <many-to-many\r
-                               class="org.argeo.slc.core.test.SimpleResultPart" column="PART_ID" lazy="false"/>\r
+               <list name="parts" cascade="all" lazy="false">\r
+                       <key column="PART_SUBLIST_ID" />\r
+                       <list-index column="INDX" />\r
+\r
+                       <one-to-many\r
+                               class="org.argeo.slc.core.test.SimpleResultPart" />\r
                </list>\r
        </class>\r
 </hibernate-mapping>
\ No newline at end of file
index e2e3810737f966097e69f953a3996584cbe6dffc..62eaef43c9028ecbfe6bddc264f9aeb9c030f9dc 100644 (file)
@@ -28,11 +28,25 @@ public class SimpleExampleTestDef implements TestDefinition {
                String[] args = { data.getInputFile().getAbsolutePath(),\r
                                data.getReachedFile().getAbsolutePath() };\r
 \r
-               // execute\r
-               log.info("Execute example appli...");\r
-               appli.filter(args);\r
-\r
                TestResult result = testRun.getTestResult();\r
+\r
+               SimpleResultPart executePart = new SimpleResultPart();\r
+               executePart.setMessage("Execute example appli");\r
+               try {\r
+                       // execute\r
+                       log.info("Execute example appli...");\r
+                       appli.filter(args);\r
+                       \r
+                       executePart.setStatus(SimpleResultPart.PASSED);\r
+               } catch (Exception e) {\r
+                       executePart.setStatus(SimpleResultPart.ERROR);\r
+                       executePart.setException(e);\r
+               }\r
+               result.addResultPart(executePart);\r
+               if(executePart.getStatus()==SimpleResultPart.ERROR){\r
+                       return;\r
+               }\r
+\r
                result.addResultPart(assertFiles(data));\r
        }\r
 \r
index 916d9809d1303156a3cdbab62a73fc5401fc3ee3..37440b6a0aad10dc4675821491ee4a604fb8f4c9 100644 (file)
@@ -16,10 +16,5 @@ public class TestAntBuild extends TestCase {
                                + "/root/Category1/SubCategory2/build.xml");\r
                AntRegistryUtil.runAll(antFile);\r
                \r
-               try {\r
-                       Thread.sleep(5000);\r
-               } catch (InterruptedException e) {\r
-                       e.printStackTrace();\r
-               }\r
        }\r
 }\r
index 2ea17cd205e7e57d47ece31b2fec51fed8dafe67..4287091333b0f44e9e86b83b1b402fddee04f429 100644 (file)
@@ -6,10 +6,10 @@
        <!-- Results -->\r
        <bean id="dataSourceResults"\r
                class="org.springframework.jdbc.datasource.DriverManagerDataSource"\r
-               destroy-method="close">\r
+               >\r
                <property name="driverClassName" value="org.hsqldb.jdbcDriver" />\r
                <property name="url"\r
-                       value="jdbc:hsqldb:file:${slc.workDir}/results/hsqldb/db" />\r
+                       value="jdbc:hsqldb:file:${slc.workDir}/results/hsqldb/db;shutdown=true" />\r
                <property name="username" value="sa" />\r
                <property name="password" value="" />\r
        </bean>\r
                <property name="hibernateProperties">\r
                        <value>\r
                                hibernate.dialect=org.hibernate.dialect.HSQLDialect\r
-                               c3p0.min_size=1 c3p0.timeout=1800\r
                                cache.provider_class=org.hibernate.cache.NoCacheProvider\r
-                               cache.use_query_cache=false cache.use_minimal_puts=false\r
-                               max_fetch_depth=3 show_sql=true format_sql=true\r
+                               cache.use_query_cache=false\r
+                               cache.use_minimal_puts=false\r
+                               max_fetch_depth=3\r
                                current_session_context_class=thread\r
                                hibernate.hbm2ddl.auto=update\r
                        </value>\r
                <property name="sessionFactory" ref="sessionFactoryResults" />\r
        </bean>\r
 \r
+       <bean id="report"\r
+               class="org.argeo.slc.core.test.tree.FullHtmlTreeReport">\r
+               <property name="testResultDao" ref="testResultDao" />\r
+               <property name="reportDir" value="${slc.workDir}/results/report" />\r
+       </bean>\r
 \r
+       \r
 </beans>
\ No newline at end of file
index 21da2fc410a11ed2e3682cf0bba3bf523c05166a..603ef8fdf689cc50ca8ac22084f706a422e5a1d4 100644 (file)
@@ -1,11 +1,16 @@
 # Set root logger level to DEBUG and its only appender to A1.\r
-log4j.rootLogger=DEBUG, console\r
+log4j.rootLogger=INFO, console\r
 \r
 ## Levels\r
+# Slc\r
+log4j.logger.org.argeo.slc=INFO\r
 # Spring\r
 log4j.logger.org.springframework=INFO\r
 # Hibernate\r
-log4j.logger.org.hibernate=INFO\r
+log4j.logger.org.hibernate=WARN\r
+#log4j.logger.org.hibernate.SQL=TRACE\r
+#log4j.logger.org.hibernate.tool.hbm2ddl=TRACE\r
+#log4j.logger.org.hibernate.type=TRACE\r
 \r
 \r
 ## Appenders\r
index f545420468b09534ada1799aaf7c9c9eeb024fcf..4e605f56cd1f92185336491061961c93fe07be67 100644 (file)
@@ -22,6 +22,7 @@
                        <testData bean="testData.eu-reform" />\r
                </slc.test>\r
 \r
+               <slc.closeResult result="testResult" report="report"/>\r
        </target>\r
        \r
 </project>
\ No newline at end of file
index b1384091fc63c0da10a935a47bd8740306946eb5..caa8dfeb4f54d62f4f09d8edd9535176cd697f56 100644 (file)
@@ -7,7 +7,7 @@ The Parties to this Treaty reaffirm their faith in the purposes and principles o
 They are determined to safeguard the freedom, common heritage and civilisation of their peoples, founded on the principles of democracy, individual liberty and the rule of law. They seek to promote stability and well-being in the North Atlantic area.\r
 \r
 They are resolved to unite their efforts for collective defence and for the preservation of peace and security. They therefore agree to this North Atlantic Treaty :\r
-Article 1\r
+Article 1CHANGE\r
 \r
 The Parties undertake, as set forth in the Charter of the United Nations, to settle any international dispute in which they may be involved by peaceful means in such a manner that international peace and security and justice are not endangered, and to refrain in their international relations from the threat or use of force in any manner inconsistent with the purposes of the United Nations.\r
 Article 2\r