1 package org
.argeo
.slc
.core
.test
.tree
;
4 import java
.util
.Vector
;
6 import org
.apache
.commons
.logging
.Log
;
7 import org
.apache
.commons
.logging
.LogFactory
;
8 import org
.argeo
.slc
.core
.structure
.SimpleSElement
;
9 import org
.argeo
.slc
.core
.structure
.StructureAware
;
10 import org
.argeo
.slc
.core
.structure
.StructureElement
;
11 import org
.argeo
.slc
.core
.structure
.StructureElementProvider
;
12 import org
.argeo
.slc
.core
.structure
.StructureRegistry
;
13 import org
.argeo
.slc
.core
.structure
.tree
.TreeSPath
;
14 import org
.argeo
.slc
.core
.test
.TestDefinition
;
15 import org
.argeo
.slc
.core
.test
.TestResult
;
16 import org
.argeo
.slc
.core
.test
.TestRun
;
19 * Collection of test definitions propagating tree structure information to its
22 public class CompositeTreeTestDefinition
implements TestDefinition
,
23 StructureAware
<TreeSPath
> {
24 private Log log
= LogFactory
.getLog(CompositeTreeTestDefinition
.class);
26 private List
<TestDefinition
> tasks
= null;
27 private List
<TreeSPath
> taskPaths
= null;
28 private TreeSPath path
;
29 private StructureRegistry
<TreeSPath
> registry
;
31 public void execute(TestRun testRun
) {
32 log
.info("Execute sequence of test definitions...");
35 for (TestDefinition task
: tasks
) {
36 TestResult result
= testRun
.getTestResult();
37 if (result
instanceof StructureAware
) {
38 ((StructureAware
) result
).notifyCurrentPath(registry
, taskPaths
42 task
.execute(testRun
);
44 // Reset current path in case it has been changed
45 if (result
instanceof StructureAware
) {
46 ((StructureAware
) result
).notifyCurrentPath(registry
, path
);
52 /** Sets the list of children test definitions */
53 public void setTasks(List
<TestDefinition
> tasks
) {
56 taskPaths
= new Vector
<TreeSPath
>();
60 public void notifyCurrentPath(StructureRegistry
<TreeSPath
> registry
,
63 this.registry
= registry
;
69 for (TestDefinition task
: tasks
) {
70 final StructureElement element
;
71 if (task
instanceof StructureElementProvider
) {
72 element
= ((StructureElementProvider
) task
)
73 .createStructureElement();
75 element
= new SimpleSElement("[no desc]");
77 TreeSPath taskPath
= this.path
.createChild(count
.toString());
78 registry
.register(taskPath
, element
);
79 taskPaths
.add(taskPath
);
80 if (task
instanceof StructureAware
) {
81 ((StructureAware
<TreeSPath
>) task
).notifyCurrentPath(registry
,