1 package org
.argeo
.slc
.ant
.test
;
3 import org
.apache
.commons
.logging
.Log
;
4 import org
.apache
.commons
.logging
.LogFactory
;
5 import org
.apache
.tools
.ant
.BuildException
;
7 import org
.argeo
.slc
.ant
.SlcAntConfig
;
8 import org
.argeo
.slc
.ant
.spring
.AbstractSpringArg
;
9 import org
.argeo
.slc
.ant
.structure
.SAwareTask
;
10 import org
.argeo
.slc
.core
.deploy
.DeployedSystem
;
11 import org
.argeo
.slc
.core
.structure
.StructureAware
;
12 import org
.argeo
.slc
.core
.test
.ExecutableTestRun
;
13 import org
.argeo
.slc
.core
.test
.TestData
;
14 import org
.argeo
.slc
.core
.test
.TestDefinition
;
15 import org
.argeo
.slc
.core
.test
.TestResult
;
16 import org
.argeo
.slc
.core
.test
.WritableTestRun
;
18 /** Ant task wrapping a test run. */
19 public class SlcTestTask
extends SAwareTask
{
20 private Log log
= LogFactory
.getLog(SlcTestTask
.class);
22 private String testRunBean
= null;
24 private TestDefinitionArg testDefinitionArg
;
25 private TestDataArg testDataArg
;
26 private DeployedSystemArg deployedSystemArg
;
27 private TestResultArg testResultArg
;
30 public void executeActions(String mode
) throws BuildException
{
31 final String testRunBeanT
;
32 if (testRunBean
!= null) {
33 testRunBeanT
= testRunBean
;
35 testRunBeanT
= getProject().getUserProperty(
36 SlcAntConfig
.DEFAULT_TEST_RUN_PROPERTY
);
38 WritableTestRun testRun
= (WritableTestRun
) getContext().getBean(
41 // set overridden references
42 if (testDataArg
!= null) {
43 testRun
.setTestData(testDataArg
.getTestData());
44 log
.trace("Overrides test data");
47 if (testDefinitionArg
!= null) {
48 testRun
.setTestDefinition(testDefinitionArg
.getTestDefinition());
49 log
.trace("Overrides test definition");
52 if (deployedSystemArg
!= null) {
53 testRun
.setDeployedSystem(deployedSystemArg
.getDeployedSystem());
54 log
.trace("Overrides deployed system");
57 if (testResultArg
!= null) {
58 testRun
.setTestResult(testResultArg
.getTestResult());
59 log
.trace("Overrides test result");
62 // notify path to test result
63 TestResult result
= testRun
.getTestResult();
64 if (result
!= null && result
instanceof StructureAware
) {
65 ((StructureAware
) result
).notifyCurrentPath(getRegistry(),
69 ((ExecutableTestRun
)testRun
).execute();
73 * The bean name of the test run to use. If not set the default is used.
77 public void setTestRun(String testRunBean
) {
78 this.testRunBean
= testRunBean
;
81 public TestDefinitionArg
createTestDefinition() {
82 testDefinitionArg
= new TestDefinitionArg();
83 // only test definitions can add to path
84 addSAwareArg(testDefinitionArg
);
85 return testDefinitionArg
;
88 public TestDataArg
createTestData() {
89 testDataArg
= new TestDataArg();
93 public DeployedSystemArg
createDeployedSystem() {
94 deployedSystemArg
= new DeployedSystemArg();
95 return deployedSystemArg
;
98 public TestResultArg
createTestResult() {
99 testResultArg
= new TestResultArg();
100 return testResultArg
;
105 class TestDefinitionArg
extends AbstractSpringArg
{
106 public TestDefinition
getTestDefinition() {
107 return (TestDefinition
) getBeanInstance();
111 class TestDataArg
extends AbstractSpringArg
{
112 public TestData
getTestData() {
113 return (TestData
) getBeanInstance();
118 class DeployedSystemArg
extends AbstractSpringArg
{
119 public DeployedSystem
getDeployedSystem() {
120 return (DeployedSystem
) getBeanInstance();
125 class TestResultArg
extends AbstractSpringArg
{
126 public TestResult
getTestResult() {
127 return (TestResult
) getBeanInstance();