<classpathentry kind="lib" path="lib/jta.jar"/>\r
<classpathentry kind="lib" path="lib/dbunit-2.2.jar" sourcepath="lib-src/dbunit-2.2-sources.jar"/>\r
<classpathentry kind="lib" path="lib/junit-3.8.2.jar" sourcepath="lib-src/junit-3.8.2-sources.jar"/>\r
+ <classpathentry kind="lib" path="lib/commons-io-1.3.2.jar" sourcepath="lib-src/commons-io-1.3.2-sources.jar"/>\r
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>\r
<classpathentry kind="output" path="target/classes"/>\r
</classpath>\r
-#Sun Nov 11 11:22:17 CET 2007\r
+#Sun Nov 18 09:33:59 CET 2007\r
eclipse.preferences.version=1\r
+org.eclipse.jdt.core.builder.cleanOutputFolder=clean\r
+org.eclipse.jdt.core.builder.duplicateResourceTask=warning\r
+org.eclipse.jdt.core.builder.invalidClasspath=abort\r
+org.eclipse.jdt.core.builder.recreateModifiedClassFileInOutputFolder=ignore\r
+org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch,*.testsuite,*.deploy,*.location,*.execution,*.datapool,*.artifact,package.html,*.svg\r
+org.eclipse.jdt.core.circularClasspath=error\r
+org.eclipse.jdt.core.classpath.exclusionPatterns=enabled\r
+org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled\r
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5\r
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve\r
org.eclipse.jdt.core.compiler.debug.lineNumber=generate\r
org.eclipse.jdt.core.compiler.debug.localVariable=generate\r
org.eclipse.jdt.core.compiler.debug.sourceFile=generate\r
+org.eclipse.jdt.core.compiler.maxProblemPerUnit=100\r
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
org.eclipse.jdt.core.compiler.source=1.5\r
+org.eclipse.jdt.core.incompatibleJDKLevel=ignore\r
+org.eclipse.jdt.core.incompleteClasspath=error\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
+slc.report=org.argeo.slc.ant.test.SlcReportTask\r
import org.argeo.slc.core.test.TestReport;\r
import org.argeo.slc.core.test.TestResult;\r
\r
-/** Ant tasks closing a given result, and optionally generating a report. */\r
+/** Ant tasks closing a given result. */\r
public class SlcCloseTestResultTask extends SAwareTask {\r
private String result;\r
- private String report;\r
\r
@Override\r
public void executeActions(String mode) {\r
if (!mode.equals(StructureRegistry.READ)) {\r
TestResult testResult = (TestResult) getContext().getBean(result);\r
testResult.close();\r
-\r
- if (report != null) {\r
- TestReport testReport = (TestReport) getContext().getBean(\r
- report);\r
- if (testReport instanceof StructureAware) {\r
- ((StructureAware) testReport).notifyCurrentPath(\r
- getRegistry(), null);\r
- }\r
- testReport.generateTestReport(testResult);\r
- }\r
}\r
}\r
\r
this.result = bean;\r
}\r
\r
- /** Sets the bean name of the report to generate. */\r
- public void setReport(String report) {\r
- this.report = report;\r
- }\r
-\r
}\r
--- /dev/null
+package org.argeo.slc.ant.test;\r
+\r
+import org.argeo.slc.ant.structure.SAwareTask;\r
+import org.argeo.slc.core.structure.StructureAware;\r
+import org.argeo.slc.core.structure.StructureRegistry;\r
+import org.argeo.slc.core.test.TestReport;\r
+import org.argeo.slc.core.test.TestResult;\r
+\r
+/** Ant tasks generating a report. */\r
+public class SlcReportTask extends SAwareTask {\r
+ private String result;\r
+ private String report;\r
+\r
+ @Override\r
+ public void executeActions(String mode) {\r
+ if (!mode.equals(StructureRegistry.READ)) {\r
+ TestResult testResult = null;\r
+ if (result != null) {\r
+ testResult = (TestResult) getContext().getBean(result);\r
+ }\r
+ TestReport testReport = (TestReport) getContext().getBean(report);\r
+ if (testReport instanceof StructureAware) {\r
+ ((StructureAware) testReport).notifyCurrentPath(getRegistry(),\r
+ null);\r
+ }\r
+ testReport.generateTestReport(testResult);\r
+ }\r
+ }\r
+\r
+ /** Sets the bean name of the result to close. */\r
+ public void setResult(String bean) {\r
+ this.result = bean;\r
+ }\r
+\r
+ /** Sets the bean name of the report to generate. */\r
+ public void setReport(String report) {\r
+ this.report = report;\r
+ }\r
+\r
+}\r
package org.argeo.slc.core.test;\r
\r
+import java.util.Date;\r
import java.util.List;\r
import java.util.Vector;\r
\r
import org.apache.commons.logging.Log;\r
import org.apache.commons.logging.LogFactory;\r
\r
+/**\r
+ * Basic implementation of a test result containing only a list of result\r
+ * parts.\r
+ */\r
public class SimpleTestResult implements TestResult {\r
private static Log log = LogFactory.getLog(SimpleTestResult.class);\r
\r
private TestResultId testResultId;\r
+ private Date closeDate;\r
private List<TestResultPart> parts = new Vector<TestResultPart>();\r
\r
public void addResultPart(TestResultPart part) {\r
\r
public void close() {\r
parts.clear();\r
+ closeDate = new Date();\r
}\r
\r
public TestResultId getTestResultId() {\r
return testResultId;\r
}\r
\r
+ /** Sets the test result id. */\r
public void setTestResultId(TestResultId testResultId) {\r
this.testResultId = testResultId;\r
}\r
return parts;\r
}\r
\r
+ public Date getCloseDate() {\r
+ return closeDate;\r
+ }\r
+\r
}\r
package org.argeo.slc.core.test;\r
\r
+import java.util.Date;\r
+\r
/** The result of a test */\r
public interface TestResult {\r
/** Gets the id of the related test result. */\r
* related resources (also closing listeners).\r
*/\r
public void close();\r
+\r
+ /**\r
+ * The date when this test result was closed. Can be null, which means the\r
+ * result is not closed.\r
+ */\r
+ public Date getCloseDate();\r
}\r
TestResultPart testResultPart);\r
\r
/** Stops listening and release the related resources. */\r
- public void close();\r
+ public void close(TestResult testResult);\r
}\r
}\r
\r
/** Finish the remaining and destroy */\r
- public void close() {\r
+ public void close(TestResult testResult) {\r
synchronized (partStructs) {\r
// TODO: put a timeout\r
while (partStructs.size() != 0) {\r
thread = null;\r
partStructs.notifyAll();\r
}\r
+ postClose((TreeTestResult)testResult);\r
}\r
\r
public final void resultPartAdded(TestResult testResult,\r
/** Called when a result part has been added. */\r
protected abstract void resultPartAdded(PartStruct partStruct);\r
\r
+ /**\r
+ * Called at the end of close. Default implementation is empty. To be\r
+ * overridden.\r
+ */\r
+ protected void postClose(TreeTestResult testResult) {\r
+\r
+ }\r
+\r
public void run() {\r
while (thread != null) {\r
synchronized (partStructs) {\r
+++ /dev/null
-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.SlcException;\r
-import org.argeo.slc.core.structure.StructureAware;\r
-import org.argeo.slc.core.structure.StructureElement;\r
-import org.argeo.slc.core.structure.StructurePath;\r
-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.TestReport;\r
-import org.argeo.slc.core.test.TestResult;\r
-import org.argeo.slc.core.test.TestResultPart;\r
-import org.argeo.slc.dao.structure.tree.TreeSRegistryDao;\r
-import org.argeo.slc.dao.test.TestResultDao;\r
-\r
-/**\r
- * Basic implementation of TestReport generating static HTML pages. If a\r
- * <code>TestResultDao</code> is passed, all the datas are dumped, otherwise\r
- * only the passed <code>TestResult</code>.\r
- */\r
-public class FullHtmlTreeReport implements TestReport, StructureAware {\r
- private TestResultDao testResultDao;\r
- private TreeSRegistryDao treeSRegistryDao;\r
- private File reportDir;\r
-\r
- private StructureRegistry registry;\r
-\r
- public void generateTestReport(TestResult testResult) {\r
- \r
- if (testResultDao == null) {\r
- TreeTestResult result = (TreeTestResult) testResult;\r
- initRegistry(result.getResultParts().firstKey());\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 result = (TreeTestResult) testRes;\r
- initRegistry(result.getResultParts().firstKey());\r
-\r
- File file = getResultFile(result);\r
- index.append("<tr><td><a href=\"").append(file.getName())\r
- .append("\">");\r
- index.append(result.getTestResultId()).append("</a></td></tr>\n");\r
- generateResultPage(file, result);\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
- /**\r
- * Generates a result page for one test result\r
- * \r
- * @param file\r
- * file to which generate the HTML\r
- * @param result\r
- * the result to dump\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>");\r
- buf.append(path);\r
- StructureElement element = registry.getElement(path);\r
- if (registry != null) {\r
- if (element != null) {\r
- buf.append("<br/><b>");\r
- buf.append(element.getDescription());\r
- buf.append("</b>");\r
- }\r
- }\r
- buf.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().equals(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
- /**\r
- * Generates a result file location based on the report dir and the id of\r
- * the test result.\r
- */\r
- protected File getResultFile(TreeTestResult result) {\r
- return new File(reportDir.getPath() + File.separator\r
- + result.getTestResultId() + ".html");\r
- }\r
-\r
- /** Sets the DAO to use to extract all data. */\r
- public void setTestResultDao(TestResultDao testResultDao) {\r
- this.testResultDao = testResultDao;\r
- }\r
-\r
- /** Sets the tree structure registry DAO.*/\r
- public void setTreeSRegistryDao(TreeSRegistryDao treeSRegistryDao) {\r
- this.treeSRegistryDao = treeSRegistryDao;\r
- }\r
-\r
- /** Sets the directory where to generate all the data. */\r
- public void setReportDir(File reportDir) {\r
- this.reportDir = reportDir;\r
- }\r
-\r
- private void initRegistry(TreeSPath path){\r
- if(treeSRegistryDao != null){\r
- registry = treeSRegistryDao.getTreeSRegistry(path);\r
- }\r
- if(registry==null){\r
- throw new SlcException("No structure registry available");\r
- }\r
- }\r
- \r
- public void notifyCurrentPath(StructureRegistry registry, StructurePath path) {\r
- this.registry = registry;\r
- }\r
-\r
-}\r
package org.argeo.slc.core.test.tree;\r
\r
+import java.util.Date;\r
import java.util.List;\r
import java.util.SortedMap;\r
import java.util.TreeMap;\r
private List<TestResultListener> listeners = new Vector<TestResultListener>();\r
\r
private TreeSPath currentPath;\r
+ \r
+ private Date closeDate;\r
\r
private boolean isClosed = false;\r
\r
throw new SlcException("Test Result #" + getTestResultId()\r
+ " alredy closed.");\r
}\r
+ closeDate = new Date();\r
\r
synchronized (listeners) {\r
for (TestResultListener listener : listeners) {\r
- listener.close();\r
+ listener.close(this);\r
}\r
listeners.clear();\r
}\r
isClosed = true;\r
+ \r
log.info("Test Result #" + getTestResultId() + " closed.");\r
}\r
\r
this.registry = registry;\r
}\r
\r
+ public Date getCloseDate() {\r
+ return closeDate;\r
+ }\r
+\r
+ /** Sets the close date (for ORM)*/\r
+ public void setCloseDate(Date closeDate) {\r
+ this.closeDate = closeDate;\r
+ }\r
+\r
}\r
}\r
}\r
\r
+ @Override\r
+ protected void postClose(TreeTestResult testResult) {\r
+ TreeTestResult persistedResult = (TreeTestResult) testResultDao\r
+ .getTestResult(testResult.getTestResultId());\r
+\r
+ if (persistedResult != null) {\r
+ persistedResult.setCloseDate(testResult.getCloseDate());\r
+ testResultDao.update(persistedResult);\r
+ }\r
+ if (log.isDebugEnabled())\r
+ log.debug("Closed result persister for result "\r
+ + testResult.getNumericResultId());\r
+ }\r
+\r
private TreeSRegistry getOrCreateTreeSRegistry(TreeSPath path) {\r
TreeSRegistry registry = treeSRegistryDao.getTreeSRegistry(path);\r
if (registry == null) {\r
--- /dev/null
+package org.argeo.slc.core.test.tree.htmlreport;\r
+\r
+import java.io.File;\r
+import java.io.FileOutputStream;\r
+import java.io.InputStream;\r
+import java.text.SimpleDateFormat;\r
+import java.util.List;\r
+\r
+import org.dbunit.dataset.IDataSet;\r
+import org.dbunit.dataset.xml.FlatXmlDataSet;\r
+import org.hsqldb.lib.FileUtil;\r
+\r
+import org.apache.commons.io.FileUtils;\r
+import org.apache.commons.io.IOUtils;\r
+\r
+import org.argeo.slc.core.SlcException;\r
+import org.argeo.slc.core.structure.StructureAware;\r
+import org.argeo.slc.core.structure.StructurePath;\r
+import org.argeo.slc.core.structure.StructureRegistry;\r
+import org.argeo.slc.core.structure.tree.TreeSPath;\r
+import org.argeo.slc.core.test.TestReport;\r
+import org.argeo.slc.core.test.TestResult;\r
+import org.argeo.slc.core.test.tree.TreeTestResult;\r
+import org.argeo.slc.dao.structure.tree.TreeSRegistryDao;\r
+import org.argeo.slc.dao.test.TestResultDao;\r
+\r
+/**\r
+ * Basic implementation of TestReport generating static HTML pages. If a\r
+ * <code>TestResultDao</code> is passed, all the data is dumped, otherwise\r
+ * only the passed <code>TestResult</code>.\r
+ */\r
+public class FullHtmlTreeReport implements TestReport, StructureAware {\r
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");\r
+\r
+ private TestResultDao testResultDao;\r
+ private TreeSRegistryDao treeSRegistryDao;\r
+ private File reportDir;\r
+\r
+ private StructureRegistry localRegistry;\r
+\r
+ public void generateTestReport(TestResult testResult) {\r
+\r
+ if (testResultDao == null) {\r
+ if (testResult == null)\r
+ throw new SlcException(\r
+ "Cannot generate report without DAO or result instance.");\r
+\r
+ TreeTestResult result = (TreeTestResult) testResult;\r
+ ResultPage page = new ResultPage(this, result);\r
+ page.generate(getRegistry(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
+ resourceToFile("index.html");\r
+ resourceToFile("style.css");\r
+\r
+ ResultsList index = new ResultsList(this);\r
+ List<TestResult> list = testResultDao.listTestResults();\r
+ for (TestResult testRes : list) {\r
+ TreeTestResult result = (TreeTestResult) testRes;\r
+\r
+ index.addTestResult(result);\r
+ ResultPage page = new ResultPage(this, result);\r
+ page.generate(getRegistry(result));\r
+ }\r
+ index.close();\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Generates a result file location based on the report dir and the id of\r
+ * the test result.\r
+ */\r
+ protected File getResultFile(TreeTestResult result) {\r
+ return new File(reportDir.getPath() + File.separator + "slc-result-"\r
+ + result.getTestResultId() + ".html");\r
+ }\r
+\r
+ /** Sets the DAO to use to extract all data. */\r
+ public void setTestResultDao(TestResultDao testResultDao) {\r
+ this.testResultDao = testResultDao;\r
+ }\r
+\r
+ /** Sets the tree structure registry DAO. */\r
+ public void setTreeSRegistryDao(TreeSRegistryDao treeSRegistryDao) {\r
+ this.treeSRegistryDao = treeSRegistryDao;\r
+ }\r
+\r
+ /** Sets the directory where to generate all the data. */\r
+ public void setReportDir(File reportDir) {\r
+ this.reportDir = reportDir;\r
+ }\r
+\r
+ private StructureRegistry getRegistry(TreeTestResult result) {\r
+ StructureRegistry registry = null;\r
+ if (treeSRegistryDao != null) {\r
+ TreeSPath path = result.getResultParts().firstKey();\r
+ registry = treeSRegistryDao.getTreeSRegistry(path);\r
+ }\r
+ if (registry == null) {\r
+ registry = localRegistry;\r
+ }\r
+ if (registry == null) {\r
+ throw new SlcException("No structure registry available");\r
+ }\r
+ return registry;\r
+ }\r
+\r
+ public void notifyCurrentPath(StructureRegistry registry, StructurePath path) {\r
+ this.localRegistry = registry;\r
+ }\r
+\r
+ File getReportDir() {\r
+ return reportDir;\r
+ }\r
+\r
+ private void resourceToFile(String resourceName) {\r
+ try {\r
+ File file = new File(getReportDir() + File.separator + resourceName);\r
+ InputStream in = FullHtmlTreeReport.class\r
+ .getResourceAsStream(resourceName);\r
+ FileOutputStream out = new FileOutputStream(file);\r
+ IOUtils.copy(in, out);\r
+ IOUtils.closeQuietly(in);\r
+ IOUtils.closeQuietly(out);\r
+ } catch (Exception e) {\r
+ throw new SlcException("Cannot load resource", e);\r
+ }\r
+\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.argeo.slc.core.test.tree.htmlreport;\r
+\r
+import java.io.FileWriter;\r
+import java.io.IOException;\r
+\r
+import org.argeo.slc.core.structure.StructureElement;\r
+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.TestResultPart;\r
+import org.argeo.slc.core.test.tree.PartSubList;\r
+import org.argeo.slc.core.test.tree.TreeTestResult;\r
+\r
+class ResultPage {\r
+ private final FullHtmlTreeReport report;\r
+ private final TreeTestResult result;\r
+\r
+ ResultPage(FullHtmlTreeReport report, TreeTestResult result) {\r
+ this.report = report;\r
+ this.result = result;\r
+ }\r
+\r
+ /**\r
+ * Generates a result page for one test result\r
+ * \r
+ * @param file\r
+ * file to which generate the HTML\r
+ * @param result\r
+ * the result to dump\r
+ */\r
+ protected void generate(StructureRegistry registry) {\r
+ StringBuffer buf = new StringBuffer("");\r
+ buf.append("<html>\n");\r
+ buf.append("<header>");\r
+ buf.append("<title>Result #").append(result.getTestResultId()).append(\r
+ "</title>\n");\r
+ buf\r
+ .append("<link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\"/>");\r
+ buf.append("</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>");\r
+ buf.append(path);\r
+ if (registry != null) {\r
+ StructureElement element = registry.getElement(path);\r
+ if (element != null) {\r
+ buf.append("<br/><b>");\r
+ buf.append(element.getDescription());\r
+ buf.append("</b>");\r
+ }\r
+ }\r
+ buf.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().equals(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(report.getResultFile(result));\r
+ writer.write(buf.toString());\r
+ writer.close();\r
+ } catch (IOException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.argeo.slc.core.test.tree.htmlreport;\r
+\r
+import java.io.File;\r
+import java.io.FileWriter;\r
+import java.io.IOException;\r
+import java.util.Date;\r
+\r
+import org.argeo.slc.core.SlcException;\r
+import org.argeo.slc.core.test.tree.TreeTestResult;\r
+\r
+class ResultsList {\r
+ private final FullHtmlTreeReport report;\r
+ private final StringBuffer buf = new StringBuffer("");\r
+\r
+ ResultsList(FullHtmlTreeReport report) {\r
+ this.report = report;\r
+\r
+ buf.append("<html><header><title>Results</title></header><body>");\r
+ buf.append("<header>");\r
+ buf.append("<title>Results</title>\n");\r
+ buf\r
+ .append("<link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\"/>");\r
+ buf.append("</header>\n");\r
+ buf.append("<body>\n");\r
+\r
+ buf.append("<h1>Results</h1>\n");\r
+ buf.append("<table border=\"1\" cellspacing=\"0\">\n");\r
+ }\r
+\r
+ void addTestResult(TreeTestResult result) {\r
+ buf.append("<tr>\n");\r
+ // Date\r
+ buf.append("<td>");\r
+ Date closeDate = result.getCloseDate();\r
+ if(closeDate == null){\r
+ throw new SlcException("No close date");\r
+ }\r
+ buf.append(report.sdf.format(closeDate));\r
+ buf.append("</td>\n");\r
+ // Id and link\r
+ buf.append("<td><a href=\"");\r
+ buf.append(report.getResultFile(result).getName());\r
+ buf.append("\" target=\"main\">");\r
+ buf.append(result.getTestResultId()).append("</a></td>\n");\r
+ \r
+ buf.append("</tr>\n");\r
+ }\r
+\r
+ void close() {\r
+ buf.append("</table>\n</body></html>");\r
+\r
+ try {\r
+ FileWriter writer = new FileWriter(report.getReportDir().getPath()\r
+ + File.separator + "slc-resultsList.html");\r
+ writer.write(buf.toString());\r
+ writer.close();\r
+ } catch (IOException e) {\r
+ e.printStackTrace();\r
+ }\r
+\r
+ }\r
+\r
+}\r
--- /dev/null
+<html>\r
+<head>\r
+<META http-equiv="Content-Type" content="text/html; charset=US-ASCII">\r
+<title>SLC test results</title>\r
+<link href="style.css" rel="stylesheet" type="text/css"/>\r
+</head>\r
+<frameset cols="20%,80%">\r
+ <frame src="slc-resultsList.html" name="navigation">\r
+ <frame src="about:blank" name="main">\r
+ <noframes>\r
+ <h2>Frame Alert</h2>\r
+ <p>This document is designed to be viewed using the frames feature.\r
+ If you see this message, you are using a non-frame-capable web client.\r
+ </p>\r
+ </noframes>\r
+</frameset>\r
+</html>\r
--- /dev/null
+/* Generic Selectors */\r
+body {\r
+ font-family: sans-serif;\r
+ font-size: 12px;\r
+ color: black;\r
+ background-color: white;\r
+}\r
+\r
+li {\r
+ list-style-type: none;\r
+}\r
+\r
+h1 {\r
+ font-family: sans-serif;\r
+ font-size: 16px;\r
+ font-weight: bold;\r
+ color: #000000;\r
+ padding: 0px 0px 5px 0px;\r
+ margin: 0px;\r
+}\r
+\r
+h2 {\r
+ font-family: sans-serif;\r
+ font-size: 14px;\r
+ font-weight: bold;\r
+ color: #000000;\r
+ padding: 5px 0px 5px 0px;\r
+ margin: 0px;\r
+ margin-top: 5px;\r
+}\r
+\r
+table,form {\r
+ margin: 0px;\r
+}\r
+\r
+img {\r
+ border: none;\r
+}\r
+\r
+div {\r
+ font-size: 100%;\r
+}\r
+\r
+tr.list:hover {\r
+ background-color: lightgrey;\r
+}\r
+\r
+td.list {\r
+ border-top: 1px solid lighgrey;\r
+ padding: 2px 20px 2px 2px;\r
+ padding-right: 15px;\r
+}\r
+\r
+th {\r
+ font-size: 12px;\r
+ padding: 2px 20px 2px 2px;\r
+ vertical-align: top;\r
+ text-align: left;\r
+}\r
+\r
+td {\r
+ font-size: 12px;\r
+ padding: 1px;\r
+ vertical-align: middle;\r
+ text-align: left;\r
+}\r
+\r
+/**************** Navigation ****************/\r
+td.nav1 {\r
+ padding: 5px 0px 0px 0px;\r
+ font-size: 12px;\r
+ font-weight: bold;\r
+}\r
+\r
+td.nav2 {\r
+ padding: 0px 0px 0px 5px;\r
+ font-size: 12px;\r
+}\r
+\r
+/**************** Forms ****************/\r
+input.submit {\r
+ border: solid 1px grey;\r
+ background-color: lightgrey;\r
+ align: right;\r
+}\r
+\r
+input.submit:hover {\r
+ border: solid 1px #3399FF;\r
+ background-color: white;\r
+ color: #3399FF;\r
+}\r
+\r
+input.std {\r
+ border: solid 1px lightgrey;\r
+ padding: 1px;\r
+ margin: 2px;\r
+}\r
+\r
+.formError {\r
+ color: red;\r
+ padding: 1px;\r
+ margin: 2px;\r
+ font-weight: bold;\r
+}\r
+\r
+/**************** Pseudo classes ****************/\r
+a:link {\r
+ color: #0066CC;\r
+ text-decoration: none;\r
+}\r
+\r
+a:visited {\r
+ color: #0066CC;\r
+ text-decoration: none;\r
+}\r
+\r
+a:hover {\r
+ color: #3399FF;\r
+ text-decoration: none;\r
+}\r
+\r
+/************************* ID's *************************/\r
+#main {\r
+ position: absolute;\r
+ margin-left: 180px;\r
+ padding-top: 65px;\r
+}\r
+\r
+#navigation {\r
+ position: absolute;\r
+ width: 150px;\r
+ height: 800px;\r
+ border-right: 1px solid #0066CC;\r
+ font-weight: normal;\r
+ margin-top: 60px;\r
+ margin-left: 10px;\r
+}\r
+\r
+#banner {\r
+ position: absolute;\r
+ width: 400px;\r
+ height: 50px;\r
+}\r
+\r
+#upperRight {\r
+ position: absolute;\r
+ top: 0;\r
+ right: 0;\r
+ margin-top: 20px;\r
+ margin-right: 10px;\r
+}
\ No newline at end of file
<generator class="native" />\r
</id>\r
\r
+ <property name="closeDate" column="CLOSE_DATE" type="timestamp"\r
+ not-null="false" />\r
+\r
<many-to-one name="numericResultId" unique="true"\r
not-null="true" column="TEST_RESULT_ID" cascade="all" lazy="false" />\r
\r
TestStatus.FAILED,\r
"Compare eu-reform-expected.txt with eu-reform-reached.txt");\r
\r
- assertTrue(new File("src/test/slc/work/results/report/index.html")\r
- .exists());\r
- assertTrue(new File("src/test/slc/work/results/report/1.html").exists());\r
- assertTrue(new File("src/test/slc/work/results/report/2.html").exists());\r
+ String reportDirPath = "src/test/slc/work/results/report/";\r
+ assertTrue(new File(reportDirPath + "index.html").exists());\r
+ assertTrue(new File(reportDirPath + "slc-resultsList.html").exists());\r
+ assertTrue(new File(reportDirPath + "slc-result-1.html").exists());\r
+ assertTrue(new File(reportDirPath + "slc-result-2.html").exists());\r
}\r
\r
private void assertPart(TreeTestResult testResult, String pathStr,\r
package org.argeo.slc.hibernate.test.tree;\r
\r
+import java.util.Date;\r
+\r
import org.argeo.slc.core.structure.tree.TreeSPath;\r
import org.argeo.slc.core.test.NumericTRId;\r
import org.argeo.slc.core.test.SimpleResultPart;\r
treeTestResult.notifyCurrentPath(null, path);\r
treeTestResult.addResultPart(partPassed);\r
treeTestResult.addResultPart(partFailed);\r
+ \r
+ Date closeDate = new Date();\r
+ treeTestResult.setCloseDate(closeDate);\r
\r
testResultDao.create(treeTestResult);\r
\r
assertEquals(TestStatus.FAILED, (int)part1.getStatus());\r
assertEquals(msgFailed,part1.getMessage());\r
\r
- \r
+ assertEquals(closeDate, treeTestResult2.getCloseDate());\r
}\r
\r
@Override\r
\r
## Levels\r
# Slc\r
-log4j.logger.org.argeo.slc=INFO\r
+log4j.logger.org.argeo.slc=DEBUG\r
# Spring\r
log4j.logger.org.springframework=INFO\r
# Hibernate\r
</list>\r
</property>\r
</bean>\r
-<!-- \r
- <bean id="testResultId" class="org.argeo.slc.core.test.NumericTRId"\r
- init-method="init" scope="prototype">\r
- </bean>\r
--->\r
+\r
<bean\r
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" />\r
\r
<bean id="resultLogger"\r
class="org.argeo.slc.core.test.tree.TreeTestResultLogger"\r
- init-method="init">\r
+ init-method="init" scope="prototype">\r
</bean>\r
\r
<bean id="resultPersister"\r
class="org.argeo.slc.core.test.tree.TreeTestResultPersister"\r
- init-method="init">\r
+ init-method="init" scope="prototype">\r
<property name="testResultDao" ref="testResultDao" />\r
<property name="treeSPathDao" ref="treeSPathDao" />\r
<property name="treeSRegistryDao" ref="treeSRegistryDao" />\r
</bean>\r
\r
<bean id="report"\r
- class="org.argeo.slc.core.test.tree.FullHtmlTreeReport">\r
+ class="org.argeo.slc.core.test.tree.htmlreport.FullHtmlTreeReport">\r
<property name="testResultDao" ref="testResultDao" />\r
<property name="treeSRegistryDao" ref="treeSRegistryDao" />\r
<property name="reportDir"\r
<description>A Test project</description>\r
\r
<target name="test" depends="testSimple,testComplex">\r
- <slc.closeResult result="testResult" report="report" />\r
- <slc.closeResult result="testResult2" report="report" />\r
+ <slc.closeResult result="testResult" />\r
+ <slc.closeResult result="testResult2" />\r
+ <slc.report report="report" />\r
</target>\r
\r
<target name="testSimple" description="Simple tests">\r