--- /dev/null
+package org.argeo.slc.core.test.tree;\r
+\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
+import org.argeo.slc.core.structure.SimpleSElement;\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.TestDefinition;\r
+import org.argeo.slc.core.test.TestResult;\r
+import org.argeo.slc.core.test.TestRun;\r
+\r
+public class CompositeTreeTestDefinition implements TestDefinition,\r
+ StructureAware {\r
+ private Log log = LogFactory.getLog(CompositeTreeTestDefinition.class);\r
+\r
+ private List<TestDefinition> tasks = null;\r
+ private List<TreeSPath> taskPaths = null;\r
+ private TreeSPath path;\r
+\r
+ public void execute(TestRun testRun) {\r
+ log.info("Execute sequence of test definitions...");\r
+\r
+ int i = 0;\r
+ for (TestDefinition task : tasks) {\r
+ TestResult result = testRun.getTestResult();\r
+ if (result instanceof StructureAware) {\r
+ ((StructureAware) result).notifyCurrentPath(null, taskPaths\r
+ .get(i));\r
+ }\r
+\r
+ task.execute(testRun);\r
+\r
+ // Reset current path in case it has been changed\r
+ if (result instanceof StructureAware) {\r
+ ((StructureAware) result).notifyCurrentPath(null, path);\r
+ }\r
+ i++;\r
+ }\r
+ }\r
+\r
+ public void setTasks(List<TestDefinition> tasks) {\r
+ this.tasks = tasks;\r
+ if (tasks != null) {\r
+ taskPaths = new Vector<TreeSPath>();\r
+ }\r
+ }\r
+\r
+ public void notifyCurrentPath(StructureRegistry registry, StructurePath path) {\r
+ this.path = (TreeSPath) path;\r
+\r
+ // clear task paths\r
+ taskPaths.clear();\r
+\r
+ Integer count = 0;\r
+ for (TestDefinition task : tasks) {\r
+ final StructureElement element;\r
+ if (task instanceof StructureElement) {\r
+ element = (StructureElement) task;\r
+ } else {\r
+ element = new SimpleSElement("<no desc>");\r
+ }\r
+ TreeSPath taskPath = this.path.createChild(count.toString());\r
+ registry.register(taskPath, element);\r
+ taskPaths.add(taskPath);\r
+ if (task instanceof StructureAware) {\r
+ ((StructureAware) task).notifyCurrentPath(registry, taskPath);\r
+ }\r
+ count++;\r
+ }\r
+ }\r
+\r
+}\r
+++ /dev/null
-package org.argeo.slc.example;\r
-\r
-import java.util.List;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-import org.argeo.slc.core.structure.SimpleSElement;\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.TestDefinition;\r
-import org.argeo.slc.core.test.TestResult;\r
-import org.argeo.slc.core.test.TestRun;\r
-\r
-public class ComplexExampleTestDef implements TestDefinition, StructureAware {\r
- private Log log = LogFactory.getLog(ComplexExampleTestDef.class);\r
-\r
- private List<TestDefinition> tasks;\r
- private TreeSPath path;\r
-\r
- public void execute(TestRun testRun) {\r
- log.info("Execute sequence of test definitions...");\r
-\r
- for (TestDefinition task : tasks) {\r
- task.execute(testRun);\r
-\r
- // Reset current path in case it has been changed\r
- TestResult result = testRun.getTestResult();\r
- if (result instanceof StructureAware) {\r
- ((StructureAware) result).notifyCurrentPath(null, path);\r
- }\r
-\r
- }\r
- }\r
-\r
- public void setTasks(List<TestDefinition> tasks) {\r
- this.tasks = tasks;\r
- }\r
-\r
- public void notifyCurrentPath(StructureRegistry registry, StructurePath path) {\r
- this.path = (TreeSPath) path;\r
-\r
- Integer count = 0;\r
- for (TestDefinition task : tasks) {\r
- String description = "";\r
- if (task instanceof ExampleTask) {\r
- description = ((ExampleTask) task).getDescription();\r
- }\r
- SimpleSElement element = new SimpleSElement(description);\r
- TreeSPath taskPath = this.path.createChild(count.toString());\r
- registry.register(taskPath, element);\r
- if (task instanceof StructureAware) {\r
- ((StructureAware) task).notifyCurrentPath(registry, taskPath);\r
- }\r
- count++;\r
- }\r
- }\r
-\r
-}\r
package org.argeo.slc.example;\r
\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.TestResult;\r
import org.argeo.slc.core.test.TestRun;\r
\r
-public class ExampleTask implements StructureAware,TestDefinition{\r
+public class ExampleTask implements StructureAware, TestDefinition,\r
+ StructureElement {\r
private TreeSPath path;\r
private String description;\r
\r
- public void execute(TestRun testRun){\r
+ public void execute(TestRun testRun) {\r
SimpleResultPart part = new SimpleResultPart();\r
part.setStatus(SimpleResultPart.PASSED);\r
- part.setMessage("Sub task executed");\r
- \r
+ part.setMessage("Sub task with path " + path + " executed");\r
+\r
TestResult result = testRun.getTestResult();\r
- if(result instanceof StructureAware){\r
- ((StructureAware)result).notifyCurrentPath(null, path);\r
- }\r
result.addResultPart(part);\r
}\r
\r
public void notifyCurrentPath(StructureRegistry registry, StructurePath path) {\r
- this.path = (TreeSPath)path; \r
+ this.path = (TreeSPath) path;\r
}\r
\r
public String getDescription() {\r
public void setDescription(String description) {\r
this.description = description;\r
}\r
- \r
- \r
+\r
}\r
class="org.argeo.slc.hibernate.test.tree.TestResultDaoHibernate">\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
<property name="deployedSystem" ref="exampleDeployedSystem" />\r
</bean>\r
\r
- <bean id="testResultId"\r
- class="org.argeo.slc.core.test.NumericTRId" init-method="init">\r
+ <bean id="testResultId" class="org.argeo.slc.core.test.NumericTRId"\r
+ init-method="init">\r
</bean>\r
\r
<bean id="testResult"\r
</bean>\r
\r
<bean id="resultPersister"\r
- class="org.argeo.slc.core.test.tree.TreeTestResultPersister" init-method="init" destroy-method="destroy">\r
- <property name="testResultDao" ref="testResultDao"/>\r
+ class="org.argeo.slc.core.test.tree.TreeTestResultPersister"\r
+ init-method="init" destroy-method="destroy">\r
+ <property name="testResultDao" ref="testResultDao" />\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"\r
+ value="${slc.workDir}/results/report" />\r
</bean>\r
\r
<bean id="exampleDeployedSystem"\r
</bean>\r
\r
<bean id="complexExampleTestDef"\r
- class="org.argeo.slc.example.ComplexExampleTestDef"\r
+ class="org.argeo.slc.core.test.tree.CompositeTreeTestDefinition "\r
scope="prototype">\r
<property name="tasks">\r
<list>\r